diff --git a/build.mjs b/build.mjs index 174a4b1948..59ddcc4374 100644 --- a/build.mjs +++ b/build.mjs @@ -2,6 +2,22 @@ import { overrideGQLOperations } from '@dropins/build-tools/gql-extend.js'; overrideGQLOperations([ + { + npm: '@dropins/storefront-order', + operations: [ + ` + fragment ADDRESS_FRAGMENT on OrderAddress { + city + company + country_code + fax + firstname + lastname + middlename + } + `, + ], + }, // { // npm: '@dropins/storefront-cart', // operations: [], diff --git a/scripts/__dropins__/storefront-account/api.js b/scripts/__dropins__/storefront-account/api.js index 39c0e85ccb..80d1dacbc0 100644 --- a/scripts/__dropins__/storefront-account/api.js +++ b/scripts/__dropins__/storefront-account/api.js @@ -1,3 +1 @@ -/*! Copyright 2024 Adobe -All Rights Reserved. */ -import{Initializer as r}from"@dropins/tools/lib.js";import{d as m,f as u,c as f,g as p,h as C,e as c,i as h,j as l,r as x,s as A,a as H,b as F,u as G}from"./chunks/removeCustomerAddress.js";import{g as b,b as z,a as v,u as w}from"./chunks/updateCustomer.js";import{g as E}from"./chunks/getOrderHistoryList.js";import{g as j}from"./chunks/getStoreConfig.js";import"@dropins/tools/event-bus.js";import"@dropins/tools/fetch-graphql.js";const e=new r({init:async t=>{const s={authHeaderConfig:{header:"Authorization",tokenPrefix:"Bearer"}};e.config.setConfig({...s,...t})},listeners:()=>[]}),n=e.config;export{n as config,m as createCustomerAddress,u as fetchGraphQl,f as getAttributesForm,p as getConfig,C as getCountries,b as getCustomer,c as getCustomerAddress,E as getOrderHistoryList,h as getRegions,j as getStoreConfig,e as initialize,l as removeCustomerAddress,x as removeFetchGraphQlHeader,A as setEndpoint,H as setFetchGraphQlHeader,F as setFetchGraphQlHeaders,z as updateCustomer,G as updateCustomerAddress,v as updateCustomerEmail,w as updateCustomerPassword}; +import{Initializer as r}from"@dropins/tools/lib.js";import{d as m,f as u,c as f,g as p,h as c,e as C,i as h,j as l,r as A,s as x,a as H,b as F,u as G}from"./chunks/removeCustomerAddress.js";import{g as b,a as z,c as v,b as w,u as y}from"./chunks/updateCustomer.js";import{g as P}from"./chunks/getOrderHistoryList.js";import"@dropins/tools/event-bus.js";import"@dropins/tools/fetch-graphql.js";const e=new r({init:async t=>{const s={authHeaderConfig:{header:"Authorization",tokenPrefix:"Bearer"}};e.config.setConfig({...s,...t})},listeners:()=>[]}),n=e.config;export{n as config,m as createCustomerAddress,u as fetchGraphQl,f as getAttributesForm,p as getConfig,c as getCountries,b as getCustomer,C as getCustomerAddress,P as getOrderHistoryList,h as getRegions,z as getStoreConfig,e as initialize,l as removeCustomerAddress,A as removeFetchGraphQlHeader,x as setEndpoint,H as setFetchGraphQlHeader,F as setFetchGraphQlHeaders,v as updateCustomer,G as updateCustomerAddress,w as updateCustomerEmail,y as updateCustomerPassword}; diff --git a/scripts/__dropins__/storefront-account/api/fragments/CustomerFragment.graphql.d.ts b/scripts/__dropins__/storefront-account/api/fragments/CustomerFragment.graphql.d.ts index 8d074db6fe..bd2d4a00d0 100644 --- a/scripts/__dropins__/storefront-account/api/fragments/CustomerFragment.graphql.d.ts +++ b/scripts/__dropins__/storefront-account/api/fragments/CustomerFragment.graphql.d.ts @@ -1,2 +1,2 @@ -export declare const BASIC_CUSTOMER_INFO_FRAGMENT = "\n fragment BasicCustomerInfo on Customer {\n date_of_birth\n email\n firstname\n gender\n lastname\n middlename\n prefix\n suffix\n created_at\n }\n"; +export declare const BASIC_CUSTOMER_INFO_FRAGMENT = "\n fragment BasicCustomerInfo on Customer {\n date_of_birth\n dob\n email\n firstname\n gender\n lastname\n middlename\n prefix\n suffix\n created_at\n }\n"; //# sourceMappingURL=CustomerFragment.graphql.d.ts.map \ No newline at end of file diff --git a/scripts/__dropins__/storefront-account/api/getCustomerAddress/graphql/getCustomerAddress.graphql.d.ts b/scripts/__dropins__/storefront-account/api/getCustomerAddress/graphql/getCustomerAddress.graphql.d.ts index 1a32153512..0386fdb80d 100644 --- a/scripts/__dropins__/storefront-account/api/getCustomerAddress/graphql/getCustomerAddress.graphql.d.ts +++ b/scripts/__dropins__/storefront-account/api/getCustomerAddress/graphql/getCustomerAddress.graphql.d.ts @@ -1,2 +1,2 @@ -export declare const GET_CUSTOMER_ADDRESS = "\n query GET_CUSTOMER_ADDRESS {\n customer {\n addresses {\n firstname\n lastname\n middlename\n fax\n prefix\n suffix\n city\n company\n country_code\n region {\n region\n region_code\n region_id\n }\n custom_attributesV2 {\n ... on AttributeValue {\n code\n value\n }\n }\n telephone\n id\n vat_id\n postcode\n street\n default_shipping\n default_billing\n }\n }\n }\n"; +export declare const GET_CUSTOMER_ADDRESS = "\n query GET_CUSTOMER_ADDRESS {\n customer {\n addresses {\n firstname\n lastname\n city\n company\n country_code\n region {\n region\n region_code\n region_id\n }\n custom_attributesV2 {\n ... on AttributeValue {\n code\n value\n }\n }\n telephone\n id\n vat_id\n postcode\n street\n default_shipping\n default_billing\n }\n }\n }\n"; //# sourceMappingURL=getCustomerAddress.graphql.d.ts.map \ No newline at end of file diff --git a/scripts/__dropins__/storefront-account/api/getStoreConfig/graphql/getStoreConfig.graphql.d.ts b/scripts/__dropins__/storefront-account/api/getStoreConfig/graphql/getStoreConfig.graphql.d.ts index 129d8e7a5e..6af98bcb32 100644 --- a/scripts/__dropins__/storefront-account/api/getStoreConfig/graphql/getStoreConfig.graphql.d.ts +++ b/scripts/__dropins__/storefront-account/api/getStoreConfig/graphql/getStoreConfig.graphql.d.ts @@ -1,2 +1,2 @@ -export declare const GET_STORE_CONFIG = "\n query GET_STORE_CONFIG {\n storeConfig {\n base_media_url\n autocomplete_on_storefront\n minimum_password_length\n required_character_classes_number\n }\n }\n"; +export declare const GET_STORE_CONFIG = "\n query GET_STORE_CONFIG {\n storeConfig {\n autocomplete_on_storefront\n minimum_password_length\n required_character_classes_number\n }\n }\n"; //# sourceMappingURL=getStoreConfig.graphql.d.ts.map \ No newline at end of file diff --git a/scripts/__dropins__/storefront-account/chunks/CustomerInformationCard.js b/scripts/__dropins__/storefront-account/chunks/CustomerInformationCard.js index 505e565eb2..95e03fa5ac 100644 --- a/scripts/__dropins__/storefront-account/chunks/CustomerInformationCard.js +++ b/scripts/__dropins__/storefront-account/chunks/CustomerInformationCard.js @@ -1,3 +1 @@ -/*! Copyright 2024 Adobe -All Rights Reserved. */ -import{jsx as a,Fragment as Q,jsxs as j}from"@dropins/tools/preact-jsx-runtime.js";import{classes as X,Slot as Ae}from"@dropins/tools/lib.js";import{Field as le,Picker as Pe,Input as je,InputDate as We,Checkbox as xe,TextArea as De,Card as he,Skeleton as we,SkeletonRow as D,Button as de,Tag as pe,Icon as Se,Modal as Ge,ProgressSpinner as Ke,IllustratedMessage as Je,Header as Xe,InLineAlert as Ye}from"@dropins/tools/components.js";import{useRef as Qe,useState as _,useEffect as ee,useCallback as k,useMemo as et}from"@dropins/tools/preact-hooks.js";import{m as Re,o as Ve,u as Ce,c as He,e as tt,n as rt,j as st,h as nt,i as at,d as dt}from"./removeCustomerAddress.js";import{useText as ne}from"@dropins/tools/i18n.js";import*as G from"@dropins/tools/preact-compat.js";import{memo as Ee,forwardRef as ot,useImperativeHandle as lt,useMemo as be,useCallback as Ne}from"@dropins/tools/preact-compat.js";import{Fragment as _e}from"@dropins/tools/preact.js";import"@dropins/tools/event-bus.js";const fe=({hideActionFormButtons:e,formName:s,showFormLoader:n,showSaveCheckBox:r,saveCheckBoxValue:d,forwardFormRef:o,slots:i,addressesFormTitle:l,className:c,addressFormId:u,inputsDefaultValueSet:p,billingCheckBoxValue:y,shippingCheckBoxValue:g,showBillingCheckBox:O,showShippingCheckBox:L,isOpen:x,onSubmit:t,onCloseBtnClick:h,onSuccess:f,onError:N,onChange:T})=>a("div",{className:X(["account-address-form"]),children:a(Wt,{hideActionFormButtons:e,formName:s,showFormLoader:n,slots:i,addressesFormTitle:l,className:c,addressFormId:u,inputsDefaultValueSet:p,shippingCheckBoxValue:g,billingCheckBoxValue:y,showShippingCheckBox:L,showBillingCheckBox:O,isOpen:x,onSubmit:t,onCloseBtnClick:h,onSuccess:f,onError:N,onChange:T,forwardFormRef:o,showSaveCheckBox:r,saveCheckBoxValue:d})}),it=e=>e.reduce((s,n)=>({...s,[n.name]:n.value}),{}),ct=e=>/^\d+$/.test(e),ut=e=>/^[a-zA-Z0-9\s]+$/.test(e),pt=e=>/^[a-zA-Z0-9]+$/.test(e),ft=e=>/^[a-zA-Z]+$/.test(e),mt=e=>/^[a-z0-9,!\#\$%&'\*\+\/=\?\^_`\{\|\}~-]+(\.[a-z0-9,!\#\$%&'\*\+\/=\?\^_`\{\|\}~-]+)*@([a-z0-9-]+\.)+[a-z]{2,}$/i.test(e),ht=e=>/^\d{4}-\d{2}-\d{2}$/.test(e)&&!isNaN(Date.parse(e)),At=(e,s,n)=>{const r=new Date(e).getTime()/1e3;return isNaN(r)||r<0?!1:r>=s&&r<=n},Te=e=>new Date(parseInt(e,10)*1e3).toISOString().split("T")[0],Lt=e=>/^(https?|ftp):\/\/(([A-Z0-9]([A-Z0-9_-]*[A-Z0-9]|))(\.[A-Z0-9]([A-Z0-9_-]*[A-Z0-9]|))*)(:(\d+))?(\/[A-Z0-9~](([A-Z0-9_~-]|\.)*[A-Z0-9~]|))*\/?(.*)?$/i.test(e),gt=(e,s,n)=>{const r=e.length;return r>=s&&r<=n},ye=(e,s,n,r)=>{var w,V;const{requiredFieldError:d,lengthTextError:o,numericError:i,alphaNumWithSpacesError:l,alphaNumericError:c,alphaError:u,emailError:p,dateError:y,urlError:g,dateLengthError:O}=n,L=s==null?void 0:s.customUpperCode,x={[L]:""};if(r[L]&&delete r[L],s!=null&&s.required&&!e)return{[L]:d};if(!(s!=null&&s.required)&&!e||!((w=s==null?void 0:s.validateRules)!=null&&w.length))return x;const t=it(s==null?void 0:s.validateRules),h=t.MIN_TEXT_LENGTH??1,f=t.MAX_TEXT_LENGTH??255,N=t.DATE_RANGE_MIN,T=t.DATE_RANGE_MAX;if(!gt(e,+h,+f)&&!(N||T))return{[L]:o.replace("{min}",h).replace("{max}",f)};if(!At(e,+N,+T)&&(N||T))return{[L]:O.replace("{min}",Te(N)).replace("{max}",Te(T))};const z={numeric:{validate:ct,error:i},"alphanum-with-spaces":{validate:ut,error:l},alphanumeric:{validate:pt,error:c},alpha:{validate:ft,error:u},email:{validate:mt,error:p},date:{validate:ht,error:y},url:{validate:Lt,error:g}}[t.INPUT_VALIDATION];return z&&!z.validate(e)&&!((V=r[L])!=null&&V.length)?{[L]:z.error}:x},Be=e=>{switch(e){case"on":case"true":case 1:case"1":return!0;case"0":case"off":case"false":case 0:return!1;default:return!1}},yt=["true","false","yes","on","off"],Ct={firstName:"",lastName:"",city:"",company:"",countryCode:"",region:"",regionCode:"",regionId:"",id:"",telephone:"",vatId:"",postcode:"",defaultShipping:"",defaultBilling:"",street:"",saveAddressBook:"",prefix:"",middleName:"",fax:"",suffix:""},bt=e=>{const s={},n={};for(const r in e)if(Object.prototype.hasOwnProperty.call(e,r)){const d=e[r],o=r.match(/^(.*)Multiline_(\d+)$/);if(o){const i=o[1],l=parseInt(o[2],10);n[i]||(n[i]=[]),n[i].push({index:l,value:d})}else Object.keys(e).filter(l=>l.startsWith(`${r}Multiline_`)).length>0?n[r]=[{index:1,value:d}]:s[r]=d}for(const r in n)if(Object.prototype.hasOwnProperty.call(n,r)){const d=n[r];d.sort((o,i)=>o.index-i.index),s[r]=d.map(o=>o.value)}return s},Mt=e=>{const s={},n=[];for(const r in e){const d=yt.includes(e[r])?Be(e[r]):e[r];Object.prototype.hasOwnProperty.call(e,r)&&(Object.prototype.hasOwnProperty.call(Ct,r)?s[r]=d:n.push({code:Ve(r),value:d}))}return{...s,customAttributes:n}},ae=(e,s=!1)=>{const n=Re(e,"camelCase",{firstname:"firstName",lastname:"lastName",middlename:"middleName"}),r=Mt(bt(n));if(!s)return r;const[d,o]=r.region?r.region.split(","):[];return{...r,region:{regionCode:d,...o&&{regionId:+o}}}},me=e=>{if(!e.current)return{};const s=e.current.elements;return Array.from(s).reduce((r,d)=>(d.name&&(r[d.name]=d.type==="checkbox"?d.checked:d.value),r),{})},Ze=(e,s)=>Object.keys(e).length?Object.keys(e).every(r=>r in s&&s[r]!==""):!1,ze=e=>typeof e=="function",vt=e=>e.reduce((s,{customUpperCode:n,required:r,defaultValue:d})=>(r&&n&&(s.initialData[n]=d||"",s.errorList[n]=""),s),{initialData:{},errorList:{}}),$e=e=>Object.keys(e).length>0,Et=({fieldsConfig:e,onSubmit:s,onChange:n,setInputChange:r,formName:d,isWaitingForResponse:o})=>{const i=ne({requiredFieldError:"Account.FormText.requiredFieldError",lengthTextError:"Account.FormText.lengthTextError",numericError:"Account.FormText.numericError",alphaNumWithSpacesError:"Account.FormText.alphaNumWithSpacesError",alphaNumericError:"Account.FormText.alphaNumericError",alphaError:"Account.FormText.alphaError",emailError:"Account.FormText.emailError",dateError:"Account.FormText.dateError",dateLengthError:"Account.FormText.dateLengthError",urlError:"Account.FormText.urlError"}),l=Qe(null),[c,u]=_({}),[p,y]=_({}),[g,O]=_({}),[L,x]=_(!0),[t,h]=_(!1),[f,N]=_(!1),[T,Z]=_(!0),[z,w]=_(!1);ee(()=>{const m=()=>{if(l.current){const b=window.getComputedStyle(l.current).getPropertyValue("grid-template-rows").split(" ").length,M=l.current.querySelector(".account-address-form--saveAddressBook");M&&(M.style.gridRow=String(b-1))}};return m(),window.addEventListener("resize",m),()=>{window.removeEventListener("resize",m)}},[e==null?void 0:e.length]);const V=k((m=!1)=>{let v=!0;const b={...p};let M=null;for(const[I,A]of Object.entries(c)){const $=e==null?void 0:e.find(S=>S.customUpperCode.includes(I)),U=ye(A.toString(),$,i,b);U[I]&&(Object.assign(b,U),v=!1),M||(M=Object.keys(b).find(S=>b[S])||null)}if(m||y(b),M&&l.current&&!m){const I=l.current.elements.namedItem(M);I==null||I.focus()}return v},[p,e,c,i]),C=k((m,v,b,M)=>{const I={...me(l),[v]:m,...v.includes("countryCode")?{region:""}:{}},A={data:ae(I,!0),isDataValid:Ze(b,I)};w(A.isDataValid),V(!0),["selectedShippingAddress","selectedBillingAddress"].includes(d)&&sessionStorage.setItem(`${d}_addressData`,JSON.stringify(A)),n==null||n(A,{},M)},[V,d,n]);ee(()=>{if(e!=null&&e.length){const{initialData:m,errorList:v}=vt(e);u(b=>({...m,...b})),y(v),O(v)}},[JSON.stringify(e)]),ee(()=>{if(f)return;const m=me(l),v=sessionStorage.getItem(`${d}_addressData`);if($e(c)&&$e(g)){let b={};const M=Ze(g,c);v?b=JSON.parse(v).data:b=ae(m,!0)??{},n==null||n({data:b,isDataValid:M},{},null),w(M),N(!0)}},[c,g]),ee(()=>{var I;if(!T)return;const m=me(l),v=!!(m!=null&&m.countryCode),b=!!((I=m==null?void 0:m.region)!=null&&I.length);m&&v&&!b&&ze(n)&&!o&&C(m==null?void 0:m.region,"region",g,null)},[T,L,e,l,n,C,g,t,o]);const H=k((m,v)=>{const{name:b,value:M,type:I,checked:A}=m==null?void 0:m.target,$=I==="checkbox"?A:M;u(B=>{const te={...B,[b]:$};return b==="countryCode"&&(te.region="",x(!0),h(!1)),te}),r==null||r({[b]:$}),N(!0);const U=e==null?void 0:e.find(B=>B.customUpperCode.includes(b));let S=v?{...v}:{...p};if(U){const B=ye($.toString(),U,i,S);B&&Object.assign(S,B),y(S)}C($,b,g,m)},[r,e,p,i,C,g,L]),q=k(m=>{const{name:v}=m==null?void 0:m.target,b=e==null?void 0:e.find(M=>M.customUpperCode===v);v==="region"&&(b!=null&&b.options.length)&&Z(!1),Z(v==="countryCode")},[]),P=k((m,v)=>{const{name:b,value:M,type:I,checked:A}=m==null?void 0:m.target,$=I==="checkbox"?A:M,U=e==null?void 0:e.find(S=>S.customUpperCode===b);if(U){const S=v?{...v}:{...p},B=ye($.toString(),U,i,S);B&&Object.assign(S,B),y(S)}},[p,e,i]),K=k(m=>{m.preventDefault();const v=V();s==null||s(m,v)},[V,s]);return{isDataValid:z,formData:c,errors:p,formRef:l,handleInputChange:H,onFocus:q,handleBlur:P,handleSubmit:K,handleValidationSubmit:V}};var se=(e=>(e.BOOLEAN="BOOLEAN",e.DATE="DATE",e.DATETIME="DATETIME",e.DROPDOWN="DROPDOWN",e.FILE="FILE",e.GALLERY="GALLERY",e.HIDDEN="HIDDEN",e.IMAGE="IMAGE",e.MEDIA_IMAGE="MEDIA_IMAGE",e.MULTILINE="MULTILINE",e.MULTISELECT="MULTISELECT",e.PRICE="PRICE",e.SELECT="SELECT",e.TEXT="TEXT",e.TEXTAREA="TEXTAREA",e.UNDEFINED="UNDEFINED",e.VISUAL="VISUAL",e.WEIGHT="WEIGHT",e.EMPTY="",e))(se||{});const Nt=Ee(({loading:e,values:s,fields:n=[],errors:r,className:d="",onChange:o,onBlur:i,onFocus:l,slots:c})=>{const u=`${d}__field`,p=(t,h)=>{if(!(c!=null&&c[`AddressFormInput_${t.code}`]))return;const f={inputName:t.customUpperCode,handleOnChange:o,handleOnBlur:i,handleOnFocus:l,errorMessage:h,errors:r,config:t};return a(Ae,{"data-testid":`addressFormInput_${t.code}`,name:`AddressFormInput_${t.code}`,slot:c[`AddressFormInput_${t.code}`],context:f},t.id)},y=(t,h,f)=>{var T;const N=((T=t.options.find(Z=>Z.isDefault))==null?void 0:T.value)??h??t.defaultValue;return a(Q,{children:p(t,f)??a(le,{error:f,className:X([u,`${u}--${t.id}`,[`${u}--${t.id}-hidden`,t.isHidden],t.className]),"data-testid":`${d}--${t.id}`,disabled:e||t.disabled,children:a(Pe,{id:t.code,required:t.required,name:t.customUpperCode,floatingLabel:`${t.label} ${t.required?"*":""}`,placeholder:t.label,"aria-label":t.label,options:t.options,onBlur:i,onFocus:l,handleSelect:o,defaultValue:N,value:N})},t.id)})},g=(t,h,f)=>a(Q,{children:p(t,f)??a(le,{error:f,className:X([u,`${u}--${t.id}`,[`${u}--${t.id}-hidden`,t.isHidden],t.className]),"data-testid":`${d}--${t.id}`,disabled:e,children:a(je,{id:t.code,type:"text",name:t.customUpperCode,value:h??t.defaultValue,placeholder:t.label,floatingLabel:`${t.label} ${t.required?"*":""}`,onBlur:i,onFocus:l,onChange:o})},t.id)}),O=(t,h,f)=>a(Q,{children:p(t,f)??a(le,{error:f,className:X([u,`${u}--${t.id}`,[`${u}--${t.id}-hidden`,t.isHidden],t.className]),"data-testid":`${d}--${t.id}`,disabled:e||t.disabled,children:a(We,{id:t.code,type:"text",name:t.customUpperCode,value:h||t.defaultValue,placeholder:t.label,floatingLabel:`${t.label} ${t.required?"*":""}`,onBlur:i,onChange:o,disabled:e||t.disabled})},t.id)}),L=(t,h,f)=>a(Q,{children:p(t,f)??a(le,{error:f,className:X([u,`${u}--${t.id}`,[`${u}--${t.id}-hidden`,t.isHidden],t.className]),"data-testid":`${d}--${t.id}`,disabled:e,children:a(xe,{id:t.code,name:t.customUpperCode,checked:h||t.defaultValue,placeholder:t.label,label:`${t.label} ${t.required?"*":""}`,onBlur:i,onChange:o})},t.id)}),x=(t,h,f)=>a(Q,{children:p(t,f)??a(le,{error:f,className:X([u,`${u}--${t.id}`,[`${u}--${t.id}-hidden`,t.isHidden],t.className]),"data-testid":`${d}--${t.id}`,disabled:e,children:a(De,{id:t.code,type:"text",name:t.customUpperCode,value:h??t.defaultValue,label:`${t.label} ${t.required?"*":""}`,onBlur:i,onChange:o})},t.id)});return n.length?a(Q,{children:n.map(t=>{const h=r==null?void 0:r[t.customUpperCode],f=s==null?void 0:s[t.customUpperCode];switch(t.fieldType){case se.TEXT:return t.options.length?y(t,f,h):g(t,f,h);case se.MULTILINE:return g(t,f,h);case se.SELECT:return y(t,f,h);case se.DATE:return O(t,f,h);case se.BOOLEAN:return L(t,f,h);case se.TEXTAREA:return x(t,f,h);default:return null}})}):null}),Ue=({testId:e,withCard:s=!0})=>{const n=j(we,{"data-testid":e||"skeletonLoader",children:[a(D,{variant:"heading",size:"xlarge",fullWidth:!1,lines:1}),a(D,{variant:"heading",size:"xlarge",fullWidth:!0,lines:1}),a(D,{variant:"heading",size:"xlarge",fullWidth:!0,lines:1})]});return s?n:a(he,{variant:"secondary",className:X(["account-account-loaders","account-account-loaders--card-loader"]),children:n})},_t=()=>j(we,{"data-testid":"addressFormLoader",children:[a(D,{variant:"heading",size:"medium"}),a(D,{variant:"empty",size:"medium"}),a(D,{size:"large"}),a(D,{size:"large"}),a(D,{size:"large",fullWidth:!0}),a(D,{size:"large",fullWidth:!0,lines:3}),a(D,{size:"large"}),a(D,{size:"large"}),a(D,{size:"large"}),a(D,{size:"large"}),a(D,{size:"large"}),a(D,{size:"large"}),a(D,{size:"large",fullWidth:!0})]}),Tt=Ee(ot(({isWaitingForResponse:e,setInputChange:s,showFormLoader:n,slots:r,name:d,loading:o,children:i,className:l="defaultForm",fieldsConfig:c,onSubmit:u,onChange:p,forwardFormRef:y,regionOptions:g,showSaveCheckBox:O,handleSaveCheckBoxAddress:L,saveCheckBoxAddress:x})=>{const t=ne({saveAddressBook:"Account.AddressForm.formText.saveAddressBook"}),{isDataValid:h,formData:f,errors:N,formRef:T,handleInputChange:Z,handleBlur:z,handleSubmit:w,handleValidationSubmit:V,onFocus:C}=Et({fieldsConfig:c,onSubmit:u,onChange:p,setInputChange:s,regionOptions:g,formName:d,isWaitingForResponse:e});return lt(y,()=>{const H=me(T);return{handleValidationSubmit:V,formData:ae(H,!0),isDataValid:h}}),n||!(c!=null&&c.length)?a(_t,{}):j("form",{className:X(["account-form",l]),onSubmit:w,name:d,ref:T,children:[a(Nt,{className:l,loading:o,fields:c,onChange:Z,onBlur:z,errors:N,values:f,onFocus:C,slots:r}),r!=null&&r.AddressFormInputs?a(Ae,{"data-testid":"addressFormInputs",name:"AddressFormInputs",slot:r.AddressFormInputs,context:{formActions:{handleChange:Z}}}):null,O?a("div",{className:"account-address-form--saveAddressBook",children:a(xe,{"data-testid":"testSaveAddressBook",name:"saveAddressBook",label:t.saveAddressBook,checked:x,onChange:H=>{Z(H),L==null||L(H)}})}):null,i]})})),Me=({slots:e,selectable:s,selectShipping:n,selectBilling:r,variant:d="secondary",minifiedView:o,keysSortOrder:i,addressData:l,loading:c,setAddressId:u,handleRenderModal:p,handleRenderForm:y})=>{const g=o?"minifiedView":"fullSizeView",O=ne({actionRemove:`Account.${g}.Addresses.addressCard.actionRemove`,actionEdit:`Account.${g}.Addresses.addressCard.actionEdit`,cardLabelShipping:`Account.${g}.Addresses.addressCard.cardLabelShipping`,cardLabelBilling:`Account.${g}.Addresses.addressCard.cardLabelBilling`,defaultLabelText:`Account.${g}.Addresses.addressCard.defaultLabelText`}),L=O.cardLabelBilling.toLocaleUpperCase(),x=O.cardLabelShipping.toLocaleUpperCase(),t=O.defaultLabelText.toLocaleUpperCase(),h=be(()=>{const C={shippingLabel:x,billingLabel:L,hideShipping:!1,hideBilling:!1};return s?n&&!r?{shippingLabel:t,billingLabel:t,hideShipping:!1,hideBilling:!0}:r&&!n?{shippingLabel:t,billingLabel:t,hideShipping:!0,hideBilling:!1}:C:C},[L,t,x,r,n,s]),f=Ne(()=>{u==null||u(l==null?void 0:l.id),p==null||p()},[p,l==null?void 0:l.id,u]),N=Ne(()=>{u==null||u(l==null?void 0:l.id),y==null||y()},[y,l==null?void 0:l.id,u]),T=be(()=>{if(!i)return[];const{region:C,...H}=l,q={...H,...C};return i.filter(({name:P})=>q[P]).map(P=>({name:P.name,orderNumber:P.orderNumber,value:q[P.name],label:P.label}))},[l,i]),{shippingLabel:Z,billingLabel:z,hideShipping:w,hideBilling:V}=h;return a(he,{variant:d,className:"account-address-card","data-testid":"addressCard",children:c?a(Ue,{}):j(Q,{children:[j("div",{className:"account-address-card__action",children:[p?a(de,{type:"button",variant:"tertiary",onClick:f,"data-testid":"removeButton",children:O.actionRemove}):null,y?a(de,{type:"button",variant:"tertiary",onClick:N,className:"account-address-card__action--editbutton","data-testid":"editButton",children:O.actionEdit}):null]}),a("div",{className:"account-address-card__description",children:e!=null&&e.AddressCard?a(Ae,{name:"AddressCard",slot:e==null?void 0:e.AddressCard,context:{addressData:T}}):a(Q,{children:T.map((C,H)=>{const q=C.label?`${C.label}: ${C==null?void 0:C.value}`:C==null?void 0:C.value;return a("p",{"data-testid":`${C.name}_${H}`,children:q},H)})})}),(l!=null&&l.defaultShipping||l!=null&&l.defaultBilling)&&!s?j("div",{className:"account-address-card__labels",children:[l!=null&&l.defaultShipping?a(pe,{label:x}):null,l!=null&&l.defaultBilling?a(pe,{label:L}):null]}):null,s?j("div",{className:"account-address-card__labels",children:[!w&&(l!=null&&l.defaultShipping)?a(pe,{label:Z}):null,!V&&(l!=null&&l.defaultBilling)?a(pe,{label:z}):null]}):null]})})},Zt=e=>G.createElement("svg",{id:"Icon_Add_Base","data-name":"Icon \\u2013 Add \\u2013 Base",xmlns:"http://www.w3.org/2000/svg",width:24,height:24,viewBox:"0 0 24 24",...e},G.createElement("g",{id:"Large"},G.createElement("rect",{id:"Placement_area","data-name":"Placement area",width:24,height:24,fill:"#fff",opacity:0}),G.createElement("g",{id:"Add_icon","data-name":"Add icon",transform:"translate(9.734 9.737)"},G.createElement("line",{vectorEffect:"non-scaling-stroke",id:"Line_579","data-name":"Line 579",y2:12.7,transform:"translate(2.216 -4.087)",fill:"none",stroke:"currentColor"}),G.createElement("line",{vectorEffect:"non-scaling-stroke",id:"Line_580","data-name":"Line 580",x2:12.7,transform:"translate(-4.079 2.263)",fill:"none",stroke:"currentColor"})))),$t=e=>G.createElement("svg",{id:"Icon_Chevron_right_Base","data-name":"Icon \\u2013 Chevron right \\u2013 Base",xmlns:"http://www.w3.org/2000/svg",width:24,height:24,viewBox:"0 0 24 24",...e},G.createElement("g",{id:"Large"},G.createElement("rect",{id:"Placement_area","data-name":"Placement area",width:24,height:24,fill:"#fff",opacity:0}),G.createElement("g",{id:"Chevron_right_icon","data-name":"Chevron right icon"},G.createElement("path",{vectorEffect:"non-scaling-stroke",id:"chevron",d:"M199.75,367.5l4.255,-4.255-4.255,-4.255",transform:"translate(-189.25 -351.0)",fill:"none",stroke:"currentColor"})))),Ft=e=>G.createElement("svg",{width:24,height:24,viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",...e},G.createElement("path",{d:"M3.375 7.38672C3.09886 7.38672 2.875 7.61058 2.875 7.88672C2.875 8.16286 3.09886 8.38672 3.375 8.38672V7.38672ZM5.88409 8.38672C6.16023 8.38672 6.38409 8.16286 6.38409 7.88672C6.38409 7.61058 6.16023 7.38672 5.88409 7.38672V8.38672ZM3.375 11.1836C3.09886 11.1836 2.875 11.4075 2.875 11.6836C2.875 11.9597 3.09886 12.1836 3.375 12.1836V11.1836ZM5.88409 12.1836C6.16023 12.1836 6.38409 11.9597 6.38409 11.6836C6.38409 11.4075 6.16023 11.1836 5.88409 11.1836V12.1836ZM3.375 15.6133C3.09886 15.6133 2.875 15.8371 2.875 16.1133C2.875 16.3894 3.09886 16.6133 3.375 16.6133V15.6133ZM5.88409 16.6133C6.16023 16.6133 6.38409 16.3894 6.38409 16.1133C6.38409 15.8371 6.16023 15.6133 5.88409 15.6133V16.6133ZM8.52059 16.4182C8.51422 16.6942 8.73286 16.9232 9.00893 16.9296C9.285 16.9359 9.51396 16.7173 9.52032 16.4412L8.52059 16.4182ZM9.19302 14.8261L8.70612 14.7124C8.70434 14.72 8.70274 14.7277 8.70132 14.7354L9.19302 14.8261ZM11.2762 13.3887L11.4404 13.8611L11.4499 13.8576L11.2762 13.3887ZM12.3195 13.1013C12.4035 12.8382 12.2583 12.5569 11.9953 12.4729C11.7322 12.3889 11.4509 12.5341 11.3669 12.7971L12.3195 13.1013ZM15.7342 16.4412C15.7406 16.7173 15.9695 16.9359 16.2456 16.9296C16.5217 16.9232 16.7403 16.6942 16.734 16.4182L15.7342 16.4412ZM16.0615 14.8261L16.5532 14.7354C16.5518 14.7277 16.5502 14.72 16.5484 14.7124L16.0615 14.8261ZM13.9784 13.3887L13.8046 13.8577L13.8142 13.861L13.9784 13.3887ZM13.8877 12.7971C13.8037 12.5341 13.5223 12.3889 13.2593 12.4729C12.9962 12.5569 12.8511 12.8382 12.9351 13.1013L13.8877 12.7971ZM10.9023 10.418L11.4023 10.418V10.418H10.9023ZM11.2309 8.60993L11.6861 8.81678L11.6861 8.81678L11.2309 8.60993ZM12.0518 12.7684L11.7218 13.1441L11.7682 13.1848L11.823 13.213L12.0518 12.7684ZM13.202 12.7684L13.4308 13.213L13.4787 13.1884L13.5203 13.1541L13.202 12.7684ZM3.375 8.38672H5.88409V7.38672H3.375V8.38672ZM3.375 12.1836H5.88409V11.1836H3.375V12.1836ZM3.375 16.6133H5.88409V15.6133H3.375V16.6133ZM6.41058 2.375H18.844V1.375H6.41058V2.375ZM18.844 2.375C19.4866 2.375 20.125 2.99614 20.125 3.9225H21.125C21.125 2.57636 20.1627 1.375 18.844 1.375V2.375ZM20.125 3.9225V20.0775H21.125V3.9225H20.125ZM20.125 20.0775C20.125 20.9945 19.485 21.625 18.844 21.625V22.625C20.1643 22.625 21.125 21.4105 21.125 20.0775H20.125ZM18.844 21.625H6.41058V22.625H18.844V21.625ZM6.41058 21.625C5.76792 21.625 5.12955 21.0039 5.12955 20.0775H4.12955C4.12955 21.4236 5.09185 22.625 6.41058 22.625V21.625ZM5.12955 20.0775V3.9225H4.12955V20.0775H5.12955ZM5.12955 3.9225C5.12955 3.0055 5.76956 2.375 6.41058 2.375V1.375C5.0902 1.375 4.12955 2.5895 4.12955 3.9225H5.12955ZM9.52032 16.4412C9.53194 15.9373 9.59014 15.4295 9.68473 14.9168L8.70132 14.7354C8.59869 15.2917 8.53362 15.853 8.52059 16.4182L9.52032 16.4412ZM9.67993 14.9397C9.69157 14.8899 9.78099 14.7261 10.1128 14.496C10.4223 14.2813 10.8711 14.0589 11.4404 13.861L11.112 12.9165C10.4856 13.1343 9.94827 13.3931 9.54284 13.6743C9.15974 13.94 8.80542 14.2871 8.70612 14.7124L9.67993 14.9397ZM11.4499 13.8576C11.5852 13.8074 11.7547 13.7102 11.8933 13.6105C11.9656 13.5584 12.0441 13.4954 12.1133 13.4247C12.1723 13.3646 12.2709 13.2534 12.3195 13.1013L11.3669 12.7971C11.3809 12.7532 11.3985 12.7277 11.4022 12.7225C11.407 12.7157 11.4073 12.7164 11.3993 12.7246C11.3827 12.7416 11.3525 12.7676 11.3092 12.7988C11.2674 12.8288 11.222 12.8575 11.1805 12.8808C11.1363 12.9057 11.1089 12.9175 11.1024 12.9199L11.4499 13.8576ZM16.734 16.4182C16.7209 15.853 16.6559 15.2917 16.5532 14.7354L15.5698 14.9168C15.6644 15.4295 15.7226 15.9373 15.7342 16.4412L16.734 16.4182ZM16.5484 14.7124C16.4491 14.2871 16.0948 13.94 15.7117 13.6743C15.3063 13.3931 14.769 13.1343 14.1426 12.9165L13.8142 13.861C14.3834 14.0589 14.8322 14.2813 15.1417 14.496C15.4736 14.7261 15.563 14.8899 15.5746 14.9397L16.5484 14.7124ZM14.1521 12.9199C14.1456 12.9175 14.1183 12.9057 14.074 12.8808C14.0325 12.8575 13.9871 12.8288 13.9453 12.7988C13.9021 12.7676 13.8719 12.7416 13.8552 12.7246C13.8472 12.7164 13.8476 12.7157 13.8524 12.7225C13.856 12.7277 13.8736 12.7532 13.8877 12.7971L12.9351 13.1013C12.9836 13.2534 13.0823 13.3646 13.1412 13.4247C13.2105 13.4954 13.2889 13.5584 13.3612 13.6105C13.4999 13.7102 13.6694 13.8074 13.8046 13.8576L14.1521 12.9199ZM11.4023 10.418C11.4023 9.83385 11.4811 9.26803 11.6861 8.81678L10.7757 8.40309C10.4878 9.03666 10.4023 9.76284 10.4023 10.418H11.4023ZM11.6861 8.81678C11.8053 8.55448 12.0796 8.38672 12.5813 8.38672V7.38672C11.8704 7.38672 11.1213 7.6426 10.7757 8.40309L11.6861 8.81678ZM12.5813 8.38672C13.087 8.38672 13.4614 8.60522 13.5777 8.83539L14.4703 8.38448C14.1169 7.685 13.2884 7.38672 12.5813 7.38672V8.38672ZM13.5777 8.83539C13.7606 9.19738 13.8523 9.72518 13.8523 10.418H14.8523C14.8523 9.66433 14.757 8.95213 14.4703 8.38448L13.5777 8.83539ZM12.5813 12.4492C12.5364 12.4492 12.5158 12.4464 12.5087 12.4451C12.5046 12.4444 12.5042 12.4442 12.5008 12.4428C12.4922 12.4391 12.4782 12.4321 12.438 12.4096C12.4018 12.3893 12.3471 12.358 12.2805 12.3238L11.823 13.213C11.8698 13.2371 11.9055 13.2576 11.9494 13.2821C11.9893 13.3045 12.0449 13.3354 12.1079 13.3623C12.2569 13.426 12.403 13.4492 12.5813 13.4492V12.4492ZM12.3817 12.3927C11.8273 11.9058 11.4022 11.3083 11.4023 10.418L10.4023 10.4179C10.4022 11.6973 11.0412 12.5462 11.7218 13.1441L12.3817 12.3927ZM13.8523 10.418C13.8523 11.3319 13.4575 11.9093 12.8838 12.3828L13.5203 13.1541C14.2611 12.5427 14.8523 11.7035 14.8523 10.418H13.8523ZM12.9733 12.3238C12.7638 12.4316 12.717 12.4492 12.5813 12.4492V13.4492C12.9639 13.4492 13.1869 13.3385 13.4308 13.213L12.9733 12.3238Z",fill:"#3D3D3D"})),Ot=e=>G.createElement("svg",{width:24,height:24,viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",...e},G.createElement("path",{d:"M12.002 21L11.8275 21.4686C11.981 21.5257 12.1528 21.5041 12.2873 21.4106C12.4218 21.3172 12.502 21.1638 12.502 21H12.002ZM3.89502 17.9823H3.39502C3.39502 18.1912 3.52485 18.378 3.72059 18.4509L3.89502 17.9823ZM3.89502 8.06421L4.07193 7.59655C3.91831 7.53844 3.74595 7.55948 3.61082 7.65284C3.47568 7.74619 3.39502 7.89997 3.39502 8.06421H3.89502ZM12.0007 21H11.5007C11.5007 21.1638 11.5809 21.3172 11.7154 21.4106C11.8499 21.5041 12.0216 21.5257 12.1751 21.4686L12.0007 21ZM20.1076 17.9823L20.282 18.4509C20.4778 18.378 20.6076 18.1912 20.6076 17.9823H20.1076ZM20.1076 8.06421H20.6076C20.6076 7.89997 20.527 7.74619 20.3918 7.65284C20.2567 7.55948 20.0843 7.53844 19.9307 7.59655L20.1076 8.06421ZM12.0007 11.1311L11.8238 10.6634C11.6293 10.737 11.5007 10.9232 11.5007 11.1311H12.0007ZM20.2858 8.53191C20.5441 8.43421 20.6743 8.14562 20.5766 7.88734C20.4789 7.62906 20.1903 7.49889 19.932 7.5966L20.2858 8.53191ZM12.002 4.94826L12.1775 4.48008C12.0605 4.43623 11.9314 4.43775 11.8154 4.48436L12.002 4.94826ZM5.87955 6.87106C5.62334 6.97407 5.49915 7.26528 5.60217 7.52149C5.70518 7.77769 5.99639 7.90188 6.2526 7.79887L5.87955 6.87106ZM18.1932 7.80315C18.4518 7.90008 18.74 7.76904 18.8369 7.51047C18.9338 7.2519 18.8028 6.96371 18.5442 6.86678L18.1932 7.80315ZM12 4.94827L11.5879 5.23148C11.6812 5.36719 11.8353 5.44827 12 5.44827C12.1647 5.44827 12.3188 5.36719 12.4121 5.23148L12 4.94827ZM14.0263 2L14.2028 1.53218C13.9875 1.45097 13.7446 1.52717 13.6143 1.71679L14.0263 2ZM21.8421 4.94827L22.2673 5.2113C22.3459 5.08422 22.3636 4.92863 22.3154 4.78717C22.2673 4.64571 22.1584 4.53319 22.0186 4.48045L21.8421 4.94827ZM9.97368 2L10.3857 1.71679C10.2554 1.52717 10.0125 1.45097 9.79721 1.53218L9.97368 2ZM2.15789 4.94827L1.98142 4.48045C1.84161 4.53319 1.73271 4.64571 1.68456 4.78717C1.63641 4.92863 1.65406 5.08422 1.73267 5.2113L2.15789 4.94827ZM12 11.1256L11.6702 11.5014C11.8589 11.667 12.1411 11.667 12.3298 11.5014L12 11.1256ZM15.0395 8.45812L14.8732 7.98659C14.8131 8.00779 14.7576 8.04028 14.7097 8.08232L15.0395 8.45812ZM23 5.65024L23.3288 6.0269C23.5095 5.86916 23.5527 5.60532 23.4318 5.39817C23.3109 5.19102 23.0599 5.09893 22.8337 5.17871L23 5.65024ZM8.96053 8.45812L9.29034 8.08232C9.24244 8.04028 9.18695 8.00779 9.12685 7.98659L8.96053 8.45812ZM1 5.65024L1.16632 5.17871C0.940115 5.09893 0.689119 5.19102 0.568192 5.39817C0.447264 5.60532 0.49048 5.86916 0.671176 6.0269L1 5.65024ZM12.1764 20.5314L4.06945 17.5137L3.72059 18.4509L11.8275 21.4686L12.1764 20.5314ZM4.39502 17.9823V8.06421H3.39502V17.9823H4.39502ZM3.71811 8.53187L11.8251 11.5987L12.1789 10.6634L4.07193 7.59655L3.71811 8.53187ZM11.502 11.1311V21H12.502V11.1311H11.502ZM12.1751 21.4686L20.282 18.4509L19.9332 17.5137L11.8262 20.5314L12.1751 21.4686ZM20.6076 17.9823V8.06421H19.6076V17.9823H20.6076ZM19.9307 7.59655L11.8238 10.6634L12.1776 11.5987L20.2845 8.53187L19.9307 7.59655ZM11.5007 11.1311V21H12.5007V11.1311H11.5007ZM19.932 7.5966L11.8251 10.6634L12.1789 11.5987L20.2858 8.53191L19.932 7.5966ZM11.8154 4.48436L5.87955 6.87106L6.2526 7.79887L12.1885 5.41217L11.8154 4.48436ZM11.8265 5.41645L18.1932 7.80315L18.5442 6.86678L12.1775 4.48008L11.8265 5.41645ZM11.502 4.94826V11.1311H12.502V4.94826H11.502ZM12.4121 5.23148L14.4384 2.28321L13.6143 1.71679L11.5879 4.66507L12.4121 5.23148ZM13.8498 2.46782L21.6656 5.4161L22.0186 4.48045L14.2028 1.53218L13.8498 2.46782ZM21.4169 4.68525L20.5485 6.08919L21.3989 6.61524L22.2673 5.2113L21.4169 4.68525ZM12.4121 4.66507L10.3857 1.71679L9.56162 2.28321L11.5879 5.23148L12.4121 4.66507ZM9.79721 1.53218L1.98142 4.48045L2.33437 5.4161L10.1502 2.46782L9.79721 1.53218ZM1.73267 5.2113L2.60109 6.61524L3.45154 6.08919L2.58312 4.68525L1.73267 5.2113ZM12.3298 11.5014L15.3693 8.83392L14.7097 8.08232L11.6702 10.7498L12.3298 11.5014ZM15.2058 8.92965L23.1663 6.12177L22.8337 5.17871L14.8732 7.98659L15.2058 8.92965ZM22.6712 5.27358L19.7764 7.80067L20.4341 8.554L23.3288 6.0269L22.6712 5.27358ZM12.3298 10.7498L9.29034 8.08232L8.63072 8.83392L11.6702 11.5014L12.3298 10.7498ZM9.12685 7.98659L1.16632 5.17871L0.83368 6.12177L8.79421 8.92965L9.12685 7.98659ZM0.671176 6.0269L3.56591 8.554L4.22356 7.80067L1.32882 5.27358L0.671176 6.0269Z",fill:"#D6D6D6"})),Fe=({selectable:e,className:s,addNewAddress:n,minifiedView:r,routeAddressesPage:d})=>{const o=r?"minifiedView":"fullSizeView",i=ne({viewAllAddressesButton:`Account.${o}.Addresses.viewAllAddressesButton`,addNewAddressButton:`Account.${o}.Addresses.addNewAddressButton`,differentAddressButton:`Account.${o}.Addresses.differentAddressButton`}),l=e?"span":"button",c=e?{}:{AriaRole:"button",type:"button"},u=r&&!n?i.viewAllAddressesButton:i.addNewAddressButton,p=e?i.differentAddressButton:u;return j(l,{...c,className:X(["account-actions-address",["account-actions-address--viewall",r],["account-actions-address--address",!r],["account-actions-address--selectable",e],s]),"data-testid":"showRouteFullAddress",onClick:d,children:[a("span",{className:"account-actions-address__title","data-testid":"addressActionsText",children:p}),a(Se,{source:r&&!n?$t:Zt,size:"32"})]})},It=({minifiedView:e,keysSortOrder:s,addressData:n,open:r,submitLoading:d,onRemoveAddress:o,closeModal:i})=>{const l=e?"minifiedView":"fullSizeView",c=ne({title:`Account.${l}.Addresses.removeAddressModal.title`,description:`Account.${l}.Addresses.removeAddressModal.description`,actionCancel:`Account.${l}.Addresses.removeAddressModal.actionCancel`,actionConfirm:`Account.${l}.Addresses.removeAddressModal.actionConfirm`});return r?j(Ge,{title:a("h3",{children:c.title}),className:"account-address-modal",size:"full","data-testid":"addressModal",showCloseButton:!0,onClose:i,children:[d?a("div",{className:"account-address-modal__spinner","data-testid":"progressSpinner",children:a(Ke,{stroke:"4",size:"large"})}):null,a("p",{children:c.description}),a(Me,{minifiedView:e,addressData:n,keysSortOrder:s}),j("div",{className:"account-address-modal__buttons",children:[a(de,{type:"button",onClick:i,variant:"secondary",disabled:d,children:c.actionCancel}),a(de,{disabled:d,onClick:o,children:c.actionConfirm})]})]}):null},xt=({typeList:e,isEmpty:s,minifiedView:n,className:r})=>{const d=n?"minifiedView":"fullSizeView",o=ne({addressesMessage:`Account.${d}.EmptyList.Addresses.message`,ordersListMessage:`Account.${d}.EmptyList.OrdersList.message`}),i=be(()=>{switch(e){case"address":return{icon:Ft,text:a("p",{children:o.addressesMessage})};case"orders":return{icon:Ot,text:a("p",{children:o.ordersListMessage})};default:return{icon:"",text:""}}},[e,o]);return!s||!e||!i.text?null:a(Je,{className:X(["account-empty-list",n?"account-empty-list--minified":"",r]),message:i.text,icon:a(Se,{source:i.icon}),"data-testid":"emptyList"})},wt=async(e,s)=>{if(s.length===1){const i=s[0],c=Object.values(i.region).every(p=>!!p)?{}:{region:{...i.region,regionId:0}};return!!await Ce({addressId:Number(i==null?void 0:i.id),defaultShipping:!1,defaultBilling:!1,...c})}const n=s.filter(i=>i.id!==e&&(i.defaultBilling||i.defaultShipping)||i.id!==e),r=s[s.length-1],d=n[0]||((r==null?void 0:r.id)!==e?r:null);return!d||!d.id?!1:!!await Ce({addressId:+d.id,defaultShipping:!0,defaultBilling:!0})},St=["firstname","lastname","city","company","country_code","region","region_code","region_id","telephone","id","vat_id","postcode","street","street_multiline_2","default_shipping","default_billing","fax","prefix","suffix","middlename"],r1=["email","firstname","lastname","middlename","gender","date_of_birth","prefix","suffix","fax"],ke=(e,s,n)=>{if(s&&n||!s&&!n)return e;const r=e.slice();return s?r.sort((d,o)=>Number(o.defaultShipping)-Number(d.defaultShipping)):n?r.sort((d,o)=>Number(o.defaultBilling)-Number(d.defaultBilling)):e},ve=e=>e==null?!0:typeof e!="object"?!1:Object.keys(e).length===0||Object.values(e).every(ve),Rt=({selectShipping:e,selectBilling:s,defaultSelectAddressId:n,onAddressData:r,minifiedView:d,routeAddressesPage:o,onSuccess:i})=>{const[l,c]=_(""),[u,p]=_(!1),[y,g]=_(!1),[O,L]=_(!1),[x,t]=_(!1),[h,f]=_(!1),[N,T]=_(""),[Z,z]=_([]),[w,V]=_([]),C=k(async()=>{L(!0),Promise.all([He("shortRequest"),tt()]).then(A=>{const[$,U]=A;if($){const S=$.map(({name:B,orderNumber:te,label:re})=>({name:rt(B),orderNumber:te,label:St.includes(B)?null:re}));V(S)}if(U)if(d){const S=U.filter(B=>!!B.defaultShipping||!!B.defaultBilling);z(S)}else z(U)}).finally(()=>{L(!1)})},[d]);ee(()=>{C()},[C]),ee(()=>{var A;if(Z.length)if(n===0)f(!0),c("0");else{const $=Z.find(S=>+S.id===n)||ke(Z,e,s)[0],U={data:ae($),isDataValid:!ve($)};c(n.toString()||((A=$==null?void 0:$.id)==null?void 0:A.toString())),r==null||r(U)}},[Z,n,r,s,e]);const H=k(A=>{T(A),f(!1)},[]),q=k((A,$)=>{const U=(A==null?void 0:A.target).value;c(U);const S={data:ae($),isDataValid:!ve(ae($))};r==null||r(S),U!=="0"&&f(!1)},[r]),P=k(()=>{g(!0)},[]),K=k(()=>{T(""),g(!1),p(!1)},[]),m=k(()=>{p(!0)},[]),v=k(async()=>{t(!0),await wt(N,Z),st(+N).then(()=>{C(),K()}).finally(()=>{t(!1)})},[Z,N,K,C]),b=k(()=>{f(!1)},[]),M=k(()=>{ze(o)&&d&&!h?window.location.href=o():(f(!0),T(""))},[h,o,d]),I=k(async()=>{await C(),await(i==null?void 0:i())},[C,i]);return{keysSortOrder:w,submitLoading:x,isModalRendered:u,isFormRendered:y,loading:O,addNewAddress:h,addressesList:Z,addressId:N,handleRenderForm:P,handleRenderModal:m,removeAddress:v,onCloseBtnClick:K,setEditingAddressId:H,closeNewAddressForm:b,redirectToAddressesRoute:M,handleOnSuccess:I,handleSelectAddressOption:q,selectedAddressOption:l}},s1=Ee(({hideActionFormButtons:e=!1,formName:s,slots:n,title:r="",addressFormTitle:d="",defaultSelectAddressId:o="",showFormLoader:i=!1,onAddressData:l,forwardFormRef:c,className:u,showSaveCheckBox:p=!1,saveCheckBoxValue:y=!1,selectShipping:g=!1,selectBilling:O=!1,selectable:L=!1,withHeader:x=!0,minifiedView:t=!1,withActionsInMinifiedView:h=!1,withActionsInFullSizeView:f=!0,inputsDefaultValueSet:N,showShippingCheckBox:T=!0,showBillingCheckBox:Z=!0,shippingCheckBoxValue:z=!0,billingCheckBoxValue:w=!0,routeAddressesPage:V,onSuccess:C,onError:H})=>{var J;const q=t?"minifiedView":"fullSizeView",P=ne({containerTitle:`Account.${q}.Addresses.containerTitle`,differentAddressFormTitle:`Account.${q}.Addresses.differentAddressFormTitle`,editAddressFormTitle:`Account.${q}.Addresses.editAddressFormTitle`,viewAllAddressesButton:`Account.${q}.Addresses.viewAllAddressesButton`,newAddressFormTitle:`Account.${q}.Addresses.newAddressFormTitle`}),{keysSortOrder:K,submitLoading:m,isModalRendered:v,isFormRendered:b,loading:M,addNewAddress:I,addressesList:A,addressId:$,handleRenderForm:U,handleRenderModal:S,removeAddress:B,onCloseBtnClick:te,handleOnSuccess:re,setEditingAddressId:Le,closeNewAddressForm:oe,redirectToAddressesRoute:ie,handleSelectAddressOption:ce,selectedAddressOption:ue}=Rt({defaultSelectAddressId:o,minifiedView:t,routeAddressesPage:V,onSuccess:C,onAddressData:l,selectShipping:g,selectBilling:O}),R=s??(g&&O?"selectedAddress":g?"selectedShippingAddress":O?"selectedBillingAddress":"default"),W=L?j("div",{className:"account-addresses-wrapper--select-view",children:[(J=ke(A,g,O))==null?void 0:J.map((E,Y)=>j(_e,{children:[a("input",{"data-testid":`radio-${Y+1}`,type:"radio",name:R,id:`${R}_${E.id}`,value:E.id,checked:ue===(E==null?void 0:E.id.toString()),onChange:ge=>ce(ge,E)}),a("label",{htmlFor:`${R}_${E.id}`,className:"account-addresses-wrapper__label",children:a(Me,{slots:n,selectable:L,selectShipping:g,selectBilling:O,minifiedView:t,addressData:E,keysSortOrder:K,loading:M})})]},E.id)),a("input",{"data-testid":"radio-0",type:"radio",name:R,id:`${R}_addressActions`,value:"0",checked:ue==="0",onChange:E=>ce(E,{})}),a("label",{htmlFor:`${R}_addressActions`,className:"account-addresses-wrapper__label",children:I?a("div",{className:X(["account-addresses-form__footer__wrapper",["account-addresses-form__footer__wrapper-show",I]]),children:a(fe,{slots:n,hideActionFormButtons:e,formName:R,showFormLoader:i,isOpen:I,forwardFormRef:c,showSaveCheckBox:p,saveCheckBoxValue:y,shippingCheckBoxValue:z,billingCheckBoxValue:w,addressesFormTitle:d||P.differentAddressFormTitle,inputsDefaultValueSet:N,showShippingCheckBox:T,showBillingCheckBox:Z,onCloseBtnClick:oe,onSuccess:re,onError:H,onChange:l})}):A!=null&&A.length?a(Fe,{selectable:L,minifiedView:t,addNewAddress:I,routeAddressesPage:ie}):null})]}):j(Q,{children:[A.map(E=>a(_e,{children:$===E.id&&b?a(he,{variant:"secondary",style:{marginBottom:20},children:a(fe,{slots:n,isOpen:$===E.id&&b,addressFormId:$,inputsDefaultValueSet:E,addressesFormTitle:P.editAddressFormTitle,showShippingCheckBox:T,showBillingCheckBox:Z,shippingCheckBoxValue:z,billingCheckBoxValue:w,onCloseBtnClick:te,onSuccess:re,onError:H})}):a(Me,{slots:n,minifiedView:t,addressData:E,keysSortOrder:K,loading:M,setAddressId:Le,handleRenderModal:t&&h||!t&&f?S:void 0,handleRenderForm:t&&h||!t&&f?U:void 0},E.id)},E.id)),a("div",{className:"account-addresses__footer",children:I?a(he,{variant:"secondary",children:a(fe,{slots:n,isOpen:I,addressesFormTitle:P.newAddressFormTitle,inputsDefaultValueSet:N,showShippingCheckBox:!!(A!=null&&A.length),showBillingCheckBox:!!(A!=null&&A.length),shippingCheckBoxValue:z,billingCheckBoxValue:w,onCloseBtnClick:oe,onSuccess:re,onError:H})}):a(Fe,{minifiedView:t,addNewAddress:I,routeAddressesPage:ie})})]});return j("div",{children:[a("div",{children:x?a(Xe,{title:r||P.containerTitle,divider:!t,className:t?"account-addresses-header":""}):null}),j("div",{className:X(["account-addresses-wrapper",u]),"data-testid":"addressesIdWrapper",children:[a(It,{minifiedView:t,addressData:A==null?void 0:A.find(E=>E.id===$),keysSortOrder:K,submitLoading:m,open:v,closeModal:te,onRemoveAddress:B}),M?a(Ue,{testId:"addressSkeletonLoader",withCard:!1}):L?a(fe,{slots:n,hideActionFormButtons:e,formName:R,isOpen:!(A!=null&&A.length),forwardFormRef:c,showSaveCheckBox:p,saveCheckBoxValue:y,shippingCheckBoxValue:z,billingCheckBoxValue:w,inputsDefaultValueSet:N,showShippingCheckBox:T,showBillingCheckBox:Z,onCloseBtnClick:oe,onSuccess:re,onError:H,onChange:l}):a(xt,{isEmpty:!(A!=null&&A.length),typeList:"address",minifiedView:t}),W]})]})}),qe={entityType:"CUSTOMER_ADDRESS",isUnique:!1,options:[],multilineCount:0,validateRules:[],defaultValue:!1,fieldType:se.BOOLEAN,className:"",required:!1,orderNumber:90,isHidden:!1},Vt={...qe,label:"Set as default shipping address",name:"default_shipping",id:"default_shipping",code:"default_shipping",customUpperCode:"defaultShipping"},Ht={...qe,label:"Set as default billing address",name:"default_billing",id:"default_billing",code:"default_billing",customUpperCode:"defaultBilling"},Bt=(e,s)=>s==null?void 0:s.map(n=>{const r={...e,firstName:e.firstname??e.firstName,lastName:e.lastname??e.lastName,middleName:e.middlename??e.middleName},d=JSON.parse(JSON.stringify(n));if(Object.hasOwn(r,n.customUpperCode)){const o=r[n.customUpperCode];n.customUpperCode==="region"&&typeof o=="object"?d.defaultValue=o.regionCode&&o.regionId?`${o.regionCode},${o.regionId}`:o.region??o.regionCode:d.defaultValue=o}return d}),Oe=e=>{if(!e)return null;const s=new FormData(e);if(e.querySelectorAll('input[type="checkbox"]').forEach(r=>{s.has(r.name)||s.set(r.name,"false"),r.checked&&s.set(r.name,"true")}),s&&typeof s.entries=="function"){const r=s.entries();if(r&&typeof r[Symbol.iterator]=="function")return JSON.parse(JSON.stringify(Object.fromEntries(r)))||{}}return{}},zt=({fields:e,addressId:s,countryOptions:n,disableField:r,regionOptions:d,isRequiredRegion:o,isRequiredPostCode:i})=>e.filter(c=>!(s&&(c.customUpperCode==="defaultShipping"||c.customUpperCode==="defaultBilling")&&c.defaultValue)).map(c=>c.customUpperCode==="countryCode"?{...c,options:n,disabled:r}:c.customUpperCode==="postcode"?{...c,required:i}:c.customUpperCode==="region"?{...c,options:d,required:o,disabled:r}:c),Ut=(e,s="address")=>{const n=s==="address"?["region","city","company","countryCode","countryId","defaultBilling","defaultShipping","fax","firstName","lastName","middleName","postcode","prefix","street","suffix","telephone","vatId","addressId"]:["email","firstName","lastName","middleName","gender","dateOfBirth","prefix","suffix"],r={},d=[];return Object.keys(e).forEach(o=>{n.includes(o)?r[o]=e[o]:d.push({attribute_code:Ve(o),value:e[o]})}),d.length>0&&(r.custom_attributesV2=d),r},Ie=e=>{const s=["street","streetMultiline_1","streetMultiline_2"],n=["on","off","true","false"],r=[],d={};for(const L in e){const x=e[L];n.includes(x)&&(d[L]=Be(x)),s.includes(L)&&r.push(x)}const{street:o,streetMultiline_2:i,streetMultiline_1:l,region:c,...u}=e,[p,y]=c?c.split(","):[void 0,void 0],g=y&&p?{regionId:+y,regionCode:p}:{region:p};return Ut({...u,...d,region:{...g},street:r})},kt=(e,s)=>{const n={};for(const r in e)if(Object.prototype.hasOwnProperty.call(e,r)){const d=e[r];if(r==="region"&&d.regionId){const o=s.find(i=>(i==null?void 0:i.id)===d.regionId);o?n[r]={...d,text:o.text}:n[r]=d}else Array.isArray(d)?(n[r]=d[0]||"",d.slice(1).forEach((o,i)=>{n[`${r}Multiline_${i+2}`]=o})):n[r]=d}return n},qt=(e,s)=>e&&Object.keys(e).length>0?e:s&&Object.keys(s).length>0?s:{},Pt=({showFormLoader:e,showSaveCheckBox:s,saveCheckBoxValue:n,addressFormId:r,billingCheckBoxValue:d,shippingCheckBoxValue:o,showShippingCheckBox:i,showBillingCheckBox:l,inputsDefaultValueSet:c,onCloseBtnClick:u,onSuccess:p,onError:y,formName:g})=>{const[O,L]=_({text:"",type:"success"}),[x,t]=_(e??!1),[h,f]=_(r||""),[N,T]=_([]),[Z,z]=_([]),[w,V]=_([]),[C,H]=_([]),[q,P]=_([]),[K,m]=_(!1),[v,b]=_(!1),[M,I]=_(()=>{var R,W;const F=sessionStorage.getItem(`${g}_addressData`);return F?{countryCode:(W=(R=JSON.parse(F))==null?void 0:R.data)==null?void 0:W.countryCode}:c}),[A,$]=_(!1),[U,S]=_(!1),[B,te]=_(()=>{var W,J;const F=sessionStorage.getItem(`${g}_addressData`);return F?(J=(W=JSON.parse(F))==null?void 0:W.data)==null?void 0:J.saveAddressBook:n}),re=k(F=>{te(F.target.checked)},[]);ee(()=>{typeof e>"u"||t(e)},[e]),ee(()=>{He(h?"customer_address_edit":"customer_register_address").then(F=>{T(F)})},[h]),ee(()=>{$(!0),nt().then(({availableCountries:F,countriesWithRequiredRegion:R,optionalZipCountries:W})=>{z(F),H(R),P(W),$(!1)})},[]),ee(()=>{if(M!=null&&M.countryCode){$(!0),S(!0);const F=M==null?void 0:M.countryCode;at(F).then(R=>{V(R);const W=C.find(E=>E===F),J=q.find(E=>E===F);m(!!W),b(!J),$(!1),S(!1)})}},[M==null?void 0:M.countryCode,C,q]);const Le=k(()=>{L({text:"",type:"success"}),u==null||u()},[u]),oe=k(async(F,R)=>{if(!R)return null;t(!0);const W=Oe(F.target),J=Ie(W);await Ce(J).then(()=>{var E;p==null||p(),u==null||u(),(E=F==null?void 0:F.target)==null||E.reset()}).catch(E=>{L(Y=>({...Y,text:E.message,type:"error"})),y==null||y(E)}).finally(()=>{f(""),t(!1)})},[u,y,p]),ie=k(async(F,R)=>{if(!R)return;t(!0);const{saveAddressBook:W,...J}=Oe(F.target),E=Ie(J);await dt(E).then(()=>{var Y;p==null||p(),u==null||u(),(Y=F==null?void 0:F.target)==null||Y.reset()}).catch(Y=>{L(ge=>({...ge,text:Y.message,type:"error"})),y==null||y(Y)}).finally(()=>{f(""),t(!1)})},[u,y,p]),ce=et(()=>{if(!N.length)return[];const F={...Vt,defaultValue:o,isHidden:s&&!B?!0:!i},R={...Ht,defaultValue:d,isHidden:s&&!B?!0:!l},W=[...N,F,R],J=sessionStorage.getItem(`${g}_addressData`),E=J?kt(JSON.parse(J).data,w):{},Y=Bt(qt(E,c),W);return zt({fields:Y,addressId:h,countryOptions:Z,disableField:A,regionOptions:w,isRequiredRegion:K,isRequiredPostCode:v})},[N,o,s,B,i,d,l,g,w,c,h,Z,A,K,v]),ue=k(F=>{I(R=>({...R,...F}))},[]);return{isWaitingForResponse:U,regionOptions:w,saveCheckBoxAddress:B,inLineAlert:O,addressId:h,submitLoading:x,normalizeFieldsConfig:ce,handleSaveCheckBoxAddress:re,handleUpdateAddress:oe,handleCreateAddress:ie,handleOnCloseForm:Le,handleInputChange:ue}},jt=e=>{var d;if(!e||!Array.isArray(e.customAttributes))return e??{};const s={};(d=e==null?void 0:e.customAttributes)==null||d.forEach(o=>{o.code&&Object.hasOwn(o,"value")&&(s[o.code]=o.value)});const{customAttributes:n,...r}=e;return{...r,...Re(s,"camelCase",{})}},Wt=({hideActionFormButtons:e,formName:s="",showFormLoader:n=!1,showSaveCheckBox:r=!1,saveCheckBoxValue:d=!1,forwardFormRef:o,slots:i,addressesFormTitle:l,className:c,addressFormId:u,inputsDefaultValueSet:p,showShippingCheckBox:y=!0,showBillingCheckBox:g=!0,shippingCheckBoxValue:O=!0,billingCheckBoxValue:L=!0,isOpen:x,onSubmit:t,onCloseBtnClick:h,onSuccess:f,onError:N,onChange:T})=>{const Z=ne({secondaryButton:"Account.AddressForm.formText.secondaryButton",primaryButton:"Account.AddressForm.formText.primaryButton",saveAddressBook:"Account.AddressForm.formText.saveAddressBook"}),{isWaitingForResponse:z,inLineAlert:w,addressId:V,submitLoading:C,normalizeFieldsConfig:H,handleUpdateAddress:q,handleCreateAddress:P,handleOnCloseForm:K,handleSaveCheckBoxAddress:m,saveCheckBoxAddress:v,handleInputChange:b,regionOptions:M}=Pt({showFormLoader:n,addressFormId:u,inputsDefaultValueSet:jt(p),shippingCheckBoxValue:O,billingCheckBoxValue:L,showShippingCheckBox:y,showBillingCheckBox:g,saveCheckBoxValue:d,showSaveCheckBox:r,onSuccess:f,onError:N,onCloseBtnClick:h,formName:s});return x?j("div",{className:X(["account-address-form-wrapper",c]),children:[l?a("div",{className:"account-address-form-wrapper__title","data-testid":"addressesFormTitle",children:l}):null,w.text?a(Ye,{"data-testid":"inLineAlert",className:"account-address-form-wrapper__notification",type:w.type,variant:"secondary",heading:w.text,icon:w.icon}):null,j(Tt,{regionOptions:M,forwardFormRef:o,slots:i,className:"account-address-form",name:s||"addressesForm",fieldsConfig:H,onSubmit:t||(V?q:P),setInputChange:b,loading:C,showFormLoader:n,showSaveCheckBox:r,handleSaveCheckBoxAddress:m,saveCheckBoxAddress:v,onChange:T,isWaitingForResponse:z,children:[V?a("input",{type:"hidden",name:"addressId",value:V,"data-testid":"hidden_test_id"}):null,e?null:a("div",{className:X(["dropin-field account-address-form-wrapper__buttons",["account-address-form-wrapper__buttons--empty",r]]),children:i!=null&&i.AddressFormActions?a(Ae,{"data-testid":"addressFormActions",name:"AddressFormActions",slot:i.AddressFormActions,context:{handleUpdateAddress:q,handleCreateAddress:P,addressId:V}}):a(Q,{children:r?null:j(Q,{children:[a(de,{type:"button",onClick:K,variant:"secondary",disabled:C,children:Z.secondaryButton}),a(de,{disabled:C,children:Z.primaryButton})]})})})]})]}):null};export{fe as A,Ue as C,xt as E,Tt as F,$t as S,s1 as a,ze as c,r1 as d,Oe as g,Ut as n}; +import{jsx as a,Fragment as Q,jsxs as W}from"@dropins/tools/preact-jsx-runtime.js";import{classes as X,Slot as Ae}from"@dropins/tools/lib.js";import{Field as le,Picker as qe,Input as Pe,InputDate as We,Checkbox as xe,TextArea as je,Card as he,Skeleton as we,SkeletonRow as G,Button as de,Tag as pe,Icon as Se,Modal as Ge,ProgressSpinner as Ke,IllustratedMessage as De,Header as Je,InLineAlert as Xe}from"@dropins/tools/components.js";import{useRef as Ye,useState as N,useEffect as ee,useCallback as k,useMemo as Qe}from"@dropins/tools/preact-hooks.js";import{k as et,o as Re,u as Ce,c as Ve,e as tt,n as rt,j as st,h as nt,i as at,d as dt}from"./removeCustomerAddress.js";import{useText as ne}from"@dropins/tools/i18n.js";import*as K from"@dropins/tools/preact-compat.js";import{memo as Ee,forwardRef as ot,useImperativeHandle as lt,useMemo as be,useCallback as _e}from"@dropins/tools/preact-compat.js";import{Fragment as Ne}from"@dropins/tools/preact.js";import"@dropins/tools/event-bus.js";const fe=({hideActionFormButtons:e,formName:s,showFormLoader:n,showSaveCheckBox:r,saveCheckBoxValue:d,forwardFormRef:l,slots:i,addressesFormTitle:o,className:c,addressFormId:u,inputsDefaultValueSet:p,billingCheckBoxValue:y,shippingCheckBoxValue:g,showBillingCheckBox:I,showShippingCheckBox:L,isOpen:x,onSubmit:t,onCloseBtnClick:h,onSuccess:f,onError:_,onChange:T})=>a("div",{className:X(["account-address-form"]),children:a(Wt,{hideActionFormButtons:e,formName:s,showFormLoader:n,slots:i,addressesFormTitle:o,className:c,addressFormId:u,inputsDefaultValueSet:p,shippingCheckBoxValue:g,billingCheckBoxValue:y,showShippingCheckBox:L,showBillingCheckBox:I,isOpen:x,onSubmit:t,onCloseBtnClick:h,onSuccess:f,onError:_,onChange:T,forwardFormRef:l,showSaveCheckBox:r,saveCheckBoxValue:d})}),it=e=>e.reduce((s,n)=>({...s,[n.name]:n.value}),{}),ct=e=>/^\d+$/.test(e),ut=e=>/^[a-zA-Z0-9\s]+$/.test(e),pt=e=>/^[a-zA-Z0-9]+$/.test(e),ft=e=>/^[a-zA-Z]+$/.test(e),mt=e=>/^[a-z0-9,!\#\$%&'\*\+\/=\?\^_`\{\|\}~-]+(\.[a-z0-9,!\#\$%&'\*\+\/=\?\^_`\{\|\}~-]+)*@([a-z0-9-]+\.)+[a-z]{2,}$/i.test(e),ht=e=>/^\d{4}-\d{2}-\d{2}$/.test(e)&&!isNaN(Date.parse(e)),At=(e,s,n)=>{const r=new Date(e).getTime()/1e3;return isNaN(r)||r<0?!1:r>=s&&r<=n},Te=e=>new Date(parseInt(e,10)*1e3).toISOString().split("T")[0],Lt=e=>/^(https?|ftp):\/\/(([A-Z0-9]([A-Z0-9_-]*[A-Z0-9]|))(\.[A-Z0-9]([A-Z0-9_-]*[A-Z0-9]|))*)(:(\d+))?(\/[A-Z0-9~](([A-Z0-9_~-]|\.)*[A-Z0-9~]|))*\/?(.*)?$/i.test(e),gt=(e,s,n)=>{const r=e.length;return r>=s&&r<=n},ye=(e,s,n,r)=>{var w,V;const{requiredFieldError:d,lengthTextError:l,numericError:i,alphaNumWithSpacesError:o,alphaNumericError:c,alphaError:u,emailError:p,dateError:y,urlError:g,dateLengthError:I}=n,L=s==null?void 0:s.customUpperCode,x={[L]:""};if(r[L]&&delete r[L],s!=null&&s.required&&!e)return{[L]:d};if(!(s!=null&&s.required)&&!e||!((w=s==null?void 0:s.validateRules)!=null&&w.length))return x;const t=it(s==null?void 0:s.validateRules),h=t.MIN_TEXT_LENGTH??1,f=t.MAX_TEXT_LENGTH??255,_=t.DATE_RANGE_MIN,T=t.DATE_RANGE_MAX;if(!gt(e,+h,+f)&&!(_||T))return{[L]:l.replace("{min}",h).replace("{max}",f)};if(!At(e,+_,+T)&&(_||T))return{[L]:I.replace("{min}",Te(_)).replace("{max}",Te(T))};const z={numeric:{validate:ct,error:i},"alphanum-with-spaces":{validate:ut,error:o},alphanumeric:{validate:pt,error:c},alpha:{validate:ft,error:u},email:{validate:mt,error:p},date:{validate:ht,error:y},url:{validate:Lt,error:g}}[t.INPUT_VALIDATION];return z&&!z.validate(e)&&!((V=r[L])!=null&&V.length)?{[L]:z.error}:x},He=e=>{switch(e){case"on":case"true":case 1:case"1":return!0;case"0":case"off":case"false":case 0:return!1;default:return!1}},yt=["true","false","yes","on","off"],Ct={firstName:"",lastName:"",city:"",company:"",countryCode:"",region:"",regionCode:"",regionId:"",id:"",telephone:"",vatId:"",postcode:"",defaultShipping:"",defaultBilling:"",street:"",saveAddressBook:""},bt=e=>{const s={},n={};for(const r in e)if(Object.prototype.hasOwnProperty.call(e,r)){const d=e[r],l=r.match(/^(.*)Multiline_(\d+)$/);if(l){const i=l[1],o=parseInt(l[2],10);n[i]||(n[i]=[]),n[i].push({index:o,value:d})}else Object.keys(e).filter(o=>o.startsWith(`${r}Multiline_`)).length>0?n[r]=[{index:1,value:d}]:s[r]=d}for(const r in n)if(Object.prototype.hasOwnProperty.call(n,r)){const d=n[r];d.sort((l,i)=>l.index-i.index),s[r]=d.map(l=>l.value)}return s},Mt=e=>{const s={},n=[];for(const r in e){const d=yt.includes(e[r])?He(e[r]):e[r];Object.prototype.hasOwnProperty.call(e,r)&&(Object.prototype.hasOwnProperty.call(Ct,r)?s[r]=d:n.push({code:Re(r),value:d}))}return{...s,customAttributes:n}},ae=(e,s=!1)=>{const n=et(e,"camelCase",{firstname:"firstName",lastname:"lastName"}),r=Mt(bt(n));if(!s)return r;const[d,l]=r.region?r.region.split(","):[];return{...r,region:{regionCode:d,...l&&{regionId:+l}}}},me=e=>{if(!e.current)return{};const s=e.current.elements;return Array.from(s).reduce((r,d)=>(d.name&&(r[d.name]=d.type==="checkbox"?d.checked:d.value),r),{})},Ze=(e,s)=>Object.keys(e).every(r=>r in s&&s[r]!==""),Be=e=>typeof e=="function",vt=e=>e.reduce((s,{customUpperCode:n,required:r,defaultValue:d})=>(r&&n&&(s.initialData[n]=d||"",s.errorList[n]=""),s),{initialData:{},errorList:{}}),$e=e=>Object.keys(e).length>0,Et=({fieldsConfig:e,onSubmit:s,onChange:n,setInputChange:r,formName:d,isWaitingForResponse:l})=>{const i=ne({requiredFieldError:"Account.FormText.requiredFieldError",lengthTextError:"Account.FormText.lengthTextError",numericError:"Account.FormText.numericError",alphaNumWithSpacesError:"Account.FormText.alphaNumWithSpacesError",alphaNumericError:"Account.FormText.alphaNumericError",alphaError:"Account.FormText.alphaError",emailError:"Account.FormText.emailError",dateError:"Account.FormText.dateError",dateLengthError:"Account.FormText.dateLengthError",urlError:"Account.FormText.urlError"}),o=Ye(null),[c,u]=N({}),[p,y]=N({}),[g,I]=N({}),[L,x]=N(!0),[t,h]=N(!1),[f,_]=N(!1),[T,Z]=N(!0),[z,w]=N(!1);ee(()=>{const m=()=>{if(o.current){const b=window.getComputedStyle(o.current).getPropertyValue("grid-template-rows").split(" ").length,M=o.current.querySelector(".account-address-form--saveAddressBook");M&&(M.style.gridRow=String(b-1))}};return m(),window.addEventListener("resize",m),()=>{window.removeEventListener("resize",m)}},[e==null?void 0:e.length]);const V=k((m=!1)=>{let v=!0;const b={...p};let M=null;for(const[O,A]of Object.entries(c)){const $=e==null?void 0:e.find(S=>S.customUpperCode.includes(O)),U=ye(A.toString(),$,i,b);U[O]&&(Object.assign(b,U),v=!1),M||(M=Object.keys(b).find(S=>b[S])||null)}if(m||y(b),M&&o.current&&!m){const O=o.current.elements.namedItem(M);O==null||O.focus()}return v},[p,e,c,i]),C=k((m,v,b,M)=>{const O={...me(o),[v]:m,...v.includes("countryCode")?{region:""}:{}},A={data:ae(O,!0),isDataValid:Ze(b,O)};w(A.isDataValid),V(!0),["selectedShippingAddress","selectedBillingAddress"].includes(d)&&sessionStorage.setItem(`${d}_addressData`,JSON.stringify(A)),n==null||n(A,{},M)},[V,d,n]);ee(()=>{if(e!=null&&e.length){const{initialData:m,errorList:v}=vt(e);u(b=>({...m,...b})),y(v),I(v)}},[JSON.stringify(e)]),ee(()=>{if(f)return;const m=me(o),v=sessionStorage.getItem(`${d}_addressData`);if($e(c)&&$e(g)){let b={};const M=Ze(g,c);v?b=JSON.parse(v).data:b=ae(m,!0)??{},n==null||n({data:b,isDataValid:M},{},null),w(M),_(!0)}},[c,g]),ee(()=>{var O;if(!T)return;const m=me(o),v=!!(m!=null&&m.countryCode),b=!!((O=m==null?void 0:m.region)!=null&&O.length);m&&v&&!b&&Be(n)&&!l&&C(m==null?void 0:m.region,"region",g,null)},[T,L,e,o,n,C,g,t,l]);const H=k((m,v)=>{const{name:b,value:M,type:O,checked:A}=m==null?void 0:m.target,$=O==="checkbox"?A:M;u(B=>{const te={...B,[b]:$};return b==="countryCode"&&(te.region="",x(!0),h(!1)),te}),r==null||r({[b]:$}),_(!0);const U=e==null?void 0:e.find(B=>B.customUpperCode.includes(b));let S=v?{...v}:{...p};if(U){const B=ye($.toString(),U,i,S);B&&Object.assign(S,B),y(S)}C($,b,g,m)},[r,e,p,i,C,g,L]),q=k(m=>{const{name:v}=m==null?void 0:m.target,b=e==null?void 0:e.find(M=>M.customUpperCode===v);v==="region"&&(b!=null&&b.options.length)&&Z(!1),Z(v==="countryCode")},[]),P=k((m,v)=>{const{name:b,value:M,type:O,checked:A}=m==null?void 0:m.target,$=O==="checkbox"?A:M,U=e==null?void 0:e.find(S=>S.customUpperCode===b);if(U){const S=v?{...v}:{...p},B=ye($.toString(),U,i,S);B&&Object.assign(S,B),y(S)}},[p,e,i]),D=k(m=>{m.preventDefault();const v=V();s==null||s(m,v)},[V,s]);return{isDataValid:z,formData:c,errors:p,formRef:o,handleInputChange:H,onFocus:q,handleBlur:P,handleSubmit:D,handleValidationSubmit:V}};var se=(e=>(e.BOOLEAN="BOOLEAN",e.DATE="DATE",e.DATETIME="DATETIME",e.DROPDOWN="DROPDOWN",e.FILE="FILE",e.GALLERY="GALLERY",e.HIDDEN="HIDDEN",e.IMAGE="IMAGE",e.MEDIA_IMAGE="MEDIA_IMAGE",e.MULTILINE="MULTILINE",e.MULTISELECT="MULTISELECT",e.PRICE="PRICE",e.SELECT="SELECT",e.TEXT="TEXT",e.TEXTAREA="TEXTAREA",e.UNDEFINED="UNDEFINED",e.VISUAL="VISUAL",e.WEIGHT="WEIGHT",e.EMPTY="",e))(se||{});const _t=Ee(({loading:e,values:s,fields:n=[],errors:r,className:d="",onChange:l,onBlur:i,onFocus:o,slots:c})=>{const u=`${d}__field`,p=(t,h)=>{if(!(c!=null&&c[`AddressFormInput_${t.code}`]))return;const f={inputName:t.customUpperCode,handleOnChange:l,handleOnBlur:i,handleOnFocus:o,errorMessage:h,errors:r,config:t};return a(Ae,{"data-testid":`addressFormInput_${t.code}`,name:`AddressFormInput_${t.code}`,slot:c[`AddressFormInput_${t.code}`],context:f},t.id)},y=(t,h,f)=>{var T;const _=((T=t.options.find(Z=>Z.isDefault))==null?void 0:T.value)??h??t.defaultValue;return a(Q,{children:p(t,f)??a(le,{error:f,className:X([u,`${u}--${t.id}`,[`${u}--${t.id}-hidden`,t.isHidden],t.className]),"data-testid":`${d}--${t.id}`,disabled:e||t.disabled,children:a(qe,{id:t.code,required:t.required,name:t.customUpperCode,floatingLabel:`${t.label} ${t.required?"*":""}`,placeholder:t.label,"aria-label":t.label,options:t.options,onBlur:i,onFocus:o,handleSelect:l,defaultValue:_,value:_})},t.id)})},g=(t,h,f)=>a(Q,{children:p(t,f)??a(le,{error:f,className:X([u,`${u}--${t.id}`,[`${u}--${t.id}-hidden`,t.isHidden],t.className]),"data-testid":`${d}--${t.id}`,disabled:e,children:a(Pe,{id:t.code,type:"text",name:t.customUpperCode,value:h??t.defaultValue,placeholder:t.label,floatingLabel:`${t.label} ${t.required?"*":""}`,onBlur:i,onFocus:o,onChange:l})},t.id)}),I=(t,h,f)=>a(Q,{children:p(t,f)??a(le,{error:f,className:X([u,`${u}--${t.id}`,[`${u}--${t.id}-hidden`,t.isHidden],t.className]),"data-testid":`${d}--${t.id}`,disabled:e||t.disabled,children:a(We,{id:t.code,type:"text",name:t.customUpperCode,value:h||t.defaultValue,placeholder:t.label,floatingLabel:`${t.label} ${t.required?"*":""}`,onBlur:i,onChange:l,disabled:e||t.disabled})},t.id)}),L=(t,h,f)=>a(Q,{children:p(t,f)??a(le,{error:f,className:X([u,`${u}--${t.id}`,[`${u}--${t.id}-hidden`,t.isHidden],t.className]),"data-testid":`${d}--${t.id}`,disabled:e,children:a(xe,{id:t.code,name:t.customUpperCode,checked:h||t.defaultValue,placeholder:t.label,label:`${t.label} ${t.required?"*":""}`,onBlur:i,onChange:l})},t.id)}),x=(t,h,f)=>a(Q,{children:p(t,f)??a(le,{error:f,className:X([u,`${u}--${t.id}`,[`${u}--${t.id}-hidden`,t.isHidden],t.className]),"data-testid":`${d}--${t.id}`,disabled:e,children:a(je,{id:t.code,type:"text",name:t.customUpperCode,value:h??t.defaultValue,label:`${t.label} ${t.required?"*":""}`,onBlur:i,onChange:l})},t.id)});return n.length?a(Q,{children:n.map(t=>{const h=r==null?void 0:r[t.customUpperCode],f=s==null?void 0:s[t.customUpperCode];switch(t.fieldType){case se.TEXT:return t.options.length?y(t,f,h):g(t,f,h);case se.MULTILINE:return g(t,f,h);case se.SELECT:return y(t,f,h);case se.DATE:return I(t,f,h);case se.BOOLEAN:return L(t,f,h);case se.TEXTAREA:return x(t,f,h);default:return null}})}):null}),ze=({testId:e,withCard:s=!0})=>{const n=W(we,{"data-testid":e||"skeletonLoader",children:[a(G,{variant:"heading",size:"xlarge",fullWidth:!1,lines:1}),a(G,{variant:"heading",size:"xlarge",fullWidth:!0,lines:1}),a(G,{variant:"heading",size:"xlarge",fullWidth:!0,lines:1})]});return s?n:a(he,{variant:"secondary",className:X(["account-account-loaders","account-account-loaders--card-loader"]),children:n})},Nt=()=>W(we,{"data-testid":"addressFormLoader",children:[a(G,{variant:"heading",size:"medium"}),a(G,{variant:"empty",size:"medium"}),a(G,{size:"large"}),a(G,{size:"large"}),a(G,{size:"large",fullWidth:!0}),a(G,{size:"large",fullWidth:!0,lines:3}),a(G,{size:"large"}),a(G,{size:"large"}),a(G,{size:"large"}),a(G,{size:"large"}),a(G,{size:"large"}),a(G,{size:"large"}),a(G,{size:"large",fullWidth:!0})]}),Tt=Ee(ot(({isWaitingForResponse:e,setInputChange:s,showFormLoader:n,slots:r,name:d,loading:l,children:i,className:o="defaultForm",fieldsConfig:c,onSubmit:u,onChange:p,forwardFormRef:y,regionOptions:g,showSaveCheckBox:I,handleSaveCheckBoxAddress:L,saveCheckBoxAddress:x})=>{const t=ne({saveAddressBook:"Account.AddressForm.formText.saveAddressBook"}),{isDataValid:h,formData:f,errors:_,formRef:T,handleInputChange:Z,handleBlur:z,handleSubmit:w,handleValidationSubmit:V,onFocus:C}=Et({fieldsConfig:c,onSubmit:u,onChange:p,setInputChange:s,regionOptions:g,formName:d,isWaitingForResponse:e});return lt(y,()=>{const H=me(T);return{handleValidationSubmit:V,formData:ae(H,!0),isDataValid:h}}),n||!(c!=null&&c.length)?a(Nt,{}):W("form",{className:X(["account-form",o]),onSubmit:w,name:d,ref:T,children:[a(_t,{className:o,loading:l,fields:c,onChange:Z,onBlur:z,errors:_,values:f,onFocus:C,slots:r}),r!=null&&r.AddressFormInputs?a(Ae,{"data-testid":"addressFormInputs",name:"AddressFormInputs",slot:r.AddressFormInputs,context:{formActions:{handleChange:Z}}}):null,I?a("div",{className:"account-address-form--saveAddressBook",children:a(xe,{"data-testid":"testSaveAddressBook",name:"saveAddressBook",label:t.saveAddressBook,checked:x,onChange:H=>{Z(H),L==null||L(H)}})}):null,i]})})),Me=({slots:e,selectable:s,selectShipping:n,selectBilling:r,variant:d="secondary",minifiedView:l,keysSortOrder:i,addressData:o,loading:c,setAddressId:u,handleRenderModal:p,handleRenderForm:y})=>{const g=l?"minifiedView":"fullSizeView",I=ne({actionRemove:`Account.${g}.Addresses.addressCard.actionRemove`,actionEdit:`Account.${g}.Addresses.addressCard.actionEdit`,cardLabelShipping:`Account.${g}.Addresses.addressCard.cardLabelShipping`,cardLabelBilling:`Account.${g}.Addresses.addressCard.cardLabelBilling`,defaultLabelText:`Account.${g}.Addresses.addressCard.defaultLabelText`}),L=I.cardLabelBilling.toLocaleUpperCase(),x=I.cardLabelShipping.toLocaleUpperCase(),t=I.defaultLabelText.toLocaleUpperCase(),h=be(()=>{const C={shippingLabel:x,billingLabel:L,hideShipping:!1,hideBilling:!1};return s?n&&!r?{shippingLabel:t,billingLabel:t,hideShipping:!1,hideBilling:!0}:r&&!n?{shippingLabel:t,billingLabel:t,hideShipping:!0,hideBilling:!1}:C:C},[L,t,x,r,n,s]),f=_e(()=>{u==null||u(o==null?void 0:o.id),p==null||p()},[p,o==null?void 0:o.id,u]),_=_e(()=>{u==null||u(o==null?void 0:o.id),y==null||y()},[y,o==null?void 0:o.id,u]),T=be(()=>{if(!i)return[];const{region:C,...H}=o,q={...H,...C};return i.filter(({name:P})=>q[P]).map(P=>({name:P.name,orderNumber:P.orderNumber,value:q[P.name],label:P.label}))},[o,i]),{shippingLabel:Z,billingLabel:z,hideShipping:w,hideBilling:V}=h;return a(he,{variant:d,className:"account-address-card","data-testid":"addressCard",children:c?a(ze,{}):W(Q,{children:[W("div",{className:"account-address-card__action",children:[p?a(de,{type:"button",variant:"tertiary",onClick:f,"data-testid":"removeButton",children:I.actionRemove}):null,y?a(de,{type:"button",variant:"tertiary",onClick:_,className:"account-address-card__action--editbutton","data-testid":"editButton",children:I.actionEdit}):null]}),a("div",{className:"account-address-card__description",children:e!=null&&e.AddressCard?a(Ae,{name:"AddressCard",slot:e==null?void 0:e.AddressCard,context:{addressData:T}}):a(Q,{children:T.map((C,H)=>{const q=C.label?`${C.label}: ${C==null?void 0:C.value}`:C==null?void 0:C.value;return a("p",{"data-testid":`${C.name}_${H}`,children:q},H)})})}),(o!=null&&o.defaultShipping||o!=null&&o.defaultBilling)&&!s?W("div",{className:"account-address-card__labels",children:[o!=null&&o.defaultShipping?a(pe,{label:x}):null,o!=null&&o.defaultBilling?a(pe,{label:L}):null]}):null,s?W("div",{className:"account-address-card__labels",children:[!w&&(o!=null&&o.defaultShipping)?a(pe,{label:Z}):null,!V&&(o!=null&&o.defaultBilling)?a(pe,{label:z}):null]}):null]})})},Zt=e=>K.createElement("svg",{id:"Icon_Add_Base","data-name":"Icon \\u2013 Add \\u2013 Base",xmlns:"http://www.w3.org/2000/svg",width:24,height:24,viewBox:"0 0 24 24",...e},K.createElement("g",{id:"Large"},K.createElement("rect",{id:"Placement_area","data-name":"Placement area",width:24,height:24,fill:"#fff",opacity:0}),K.createElement("g",{id:"Add_icon","data-name":"Add icon",transform:"translate(9.734 9.737)"},K.createElement("line",{vectorEffect:"non-scaling-stroke",id:"Line_579","data-name":"Line 579",y2:12.7,transform:"translate(2.216 -4.087)",fill:"none",stroke:"currentColor"}),K.createElement("line",{vectorEffect:"non-scaling-stroke",id:"Line_580","data-name":"Line 580",x2:12.7,transform:"translate(-4.079 2.263)",fill:"none",stroke:"currentColor"})))),$t=e=>K.createElement("svg",{id:"Icon_Chevron_right_Base","data-name":"Icon \\u2013 Chevron right \\u2013 Base",xmlns:"http://www.w3.org/2000/svg",width:24,height:24,viewBox:"0 0 24 24",...e},K.createElement("g",{id:"Large"},K.createElement("rect",{id:"Placement_area","data-name":"Placement area",width:24,height:24,fill:"#fff",opacity:0}),K.createElement("g",{id:"Chevron_right_icon","data-name":"Chevron right icon"},K.createElement("path",{vectorEffect:"non-scaling-stroke",id:"chevron",d:"M199.75,367.5l4.255,-4.255-4.255,-4.255",transform:"translate(-189.25 -351.0)",fill:"none",stroke:"currentColor"})))),Ft=e=>K.createElement("svg",{width:24,height:24,viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",...e},K.createElement("path",{d:"M3.375 7.38672C3.09886 7.38672 2.875 7.61058 2.875 7.88672C2.875 8.16286 3.09886 8.38672 3.375 8.38672V7.38672ZM5.88409 8.38672C6.16023 8.38672 6.38409 8.16286 6.38409 7.88672C6.38409 7.61058 6.16023 7.38672 5.88409 7.38672V8.38672ZM3.375 11.1836C3.09886 11.1836 2.875 11.4075 2.875 11.6836C2.875 11.9597 3.09886 12.1836 3.375 12.1836V11.1836ZM5.88409 12.1836C6.16023 12.1836 6.38409 11.9597 6.38409 11.6836C6.38409 11.4075 6.16023 11.1836 5.88409 11.1836V12.1836ZM3.375 15.6133C3.09886 15.6133 2.875 15.8371 2.875 16.1133C2.875 16.3894 3.09886 16.6133 3.375 16.6133V15.6133ZM5.88409 16.6133C6.16023 16.6133 6.38409 16.3894 6.38409 16.1133C6.38409 15.8371 6.16023 15.6133 5.88409 15.6133V16.6133ZM8.52059 16.4182C8.51422 16.6942 8.73286 16.9232 9.00893 16.9296C9.285 16.9359 9.51396 16.7173 9.52032 16.4412L8.52059 16.4182ZM9.19302 14.8261L8.70612 14.7124C8.70434 14.72 8.70274 14.7277 8.70132 14.7354L9.19302 14.8261ZM11.2762 13.3887L11.4404 13.8611L11.4499 13.8576L11.2762 13.3887ZM12.3195 13.1013C12.4035 12.8382 12.2583 12.5569 11.9953 12.4729C11.7322 12.3889 11.4509 12.5341 11.3669 12.7971L12.3195 13.1013ZM15.7342 16.4412C15.7406 16.7173 15.9695 16.9359 16.2456 16.9296C16.5217 16.9232 16.7403 16.6942 16.734 16.4182L15.7342 16.4412ZM16.0615 14.8261L16.5532 14.7354C16.5518 14.7277 16.5502 14.72 16.5484 14.7124L16.0615 14.8261ZM13.9784 13.3887L13.8046 13.8577L13.8142 13.861L13.9784 13.3887ZM13.8877 12.7971C13.8037 12.5341 13.5223 12.3889 13.2593 12.4729C12.9962 12.5569 12.8511 12.8382 12.9351 13.1013L13.8877 12.7971ZM10.9023 10.418L11.4023 10.418V10.418H10.9023ZM11.2309 8.60993L11.6861 8.81678L11.6861 8.81678L11.2309 8.60993ZM12.0518 12.7684L11.7218 13.1441L11.7682 13.1848L11.823 13.213L12.0518 12.7684ZM13.202 12.7684L13.4308 13.213L13.4787 13.1884L13.5203 13.1541L13.202 12.7684ZM3.375 8.38672H5.88409V7.38672H3.375V8.38672ZM3.375 12.1836H5.88409V11.1836H3.375V12.1836ZM3.375 16.6133H5.88409V15.6133H3.375V16.6133ZM6.41058 2.375H18.844V1.375H6.41058V2.375ZM18.844 2.375C19.4866 2.375 20.125 2.99614 20.125 3.9225H21.125C21.125 2.57636 20.1627 1.375 18.844 1.375V2.375ZM20.125 3.9225V20.0775H21.125V3.9225H20.125ZM20.125 20.0775C20.125 20.9945 19.485 21.625 18.844 21.625V22.625C20.1643 22.625 21.125 21.4105 21.125 20.0775H20.125ZM18.844 21.625H6.41058V22.625H18.844V21.625ZM6.41058 21.625C5.76792 21.625 5.12955 21.0039 5.12955 20.0775H4.12955C4.12955 21.4236 5.09185 22.625 6.41058 22.625V21.625ZM5.12955 20.0775V3.9225H4.12955V20.0775H5.12955ZM5.12955 3.9225C5.12955 3.0055 5.76956 2.375 6.41058 2.375V1.375C5.0902 1.375 4.12955 2.5895 4.12955 3.9225H5.12955ZM9.52032 16.4412C9.53194 15.9373 9.59014 15.4295 9.68473 14.9168L8.70132 14.7354C8.59869 15.2917 8.53362 15.853 8.52059 16.4182L9.52032 16.4412ZM9.67993 14.9397C9.69157 14.8899 9.78099 14.7261 10.1128 14.496C10.4223 14.2813 10.8711 14.0589 11.4404 13.861L11.112 12.9165C10.4856 13.1343 9.94827 13.3931 9.54284 13.6743C9.15974 13.94 8.80542 14.2871 8.70612 14.7124L9.67993 14.9397ZM11.4499 13.8576C11.5852 13.8074 11.7547 13.7102 11.8933 13.6105C11.9656 13.5584 12.0441 13.4954 12.1133 13.4247C12.1723 13.3646 12.2709 13.2534 12.3195 13.1013L11.3669 12.7971C11.3809 12.7532 11.3985 12.7277 11.4022 12.7225C11.407 12.7157 11.4073 12.7164 11.3993 12.7246C11.3827 12.7416 11.3525 12.7676 11.3092 12.7988C11.2674 12.8288 11.222 12.8575 11.1805 12.8808C11.1363 12.9057 11.1089 12.9175 11.1024 12.9199L11.4499 13.8576ZM16.734 16.4182C16.7209 15.853 16.6559 15.2917 16.5532 14.7354L15.5698 14.9168C15.6644 15.4295 15.7226 15.9373 15.7342 16.4412L16.734 16.4182ZM16.5484 14.7124C16.4491 14.2871 16.0948 13.94 15.7117 13.6743C15.3063 13.3931 14.769 13.1343 14.1426 12.9165L13.8142 13.861C14.3834 14.0589 14.8322 14.2813 15.1417 14.496C15.4736 14.7261 15.563 14.8899 15.5746 14.9397L16.5484 14.7124ZM14.1521 12.9199C14.1456 12.9175 14.1183 12.9057 14.074 12.8808C14.0325 12.8575 13.9871 12.8288 13.9453 12.7988C13.9021 12.7676 13.8719 12.7416 13.8552 12.7246C13.8472 12.7164 13.8476 12.7157 13.8524 12.7225C13.856 12.7277 13.8736 12.7532 13.8877 12.7971L12.9351 13.1013C12.9836 13.2534 13.0823 13.3646 13.1412 13.4247C13.2105 13.4954 13.2889 13.5584 13.3612 13.6105C13.4999 13.7102 13.6694 13.8074 13.8046 13.8576L14.1521 12.9199ZM11.4023 10.418C11.4023 9.83385 11.4811 9.26803 11.6861 8.81678L10.7757 8.40309C10.4878 9.03666 10.4023 9.76284 10.4023 10.418H11.4023ZM11.6861 8.81678C11.8053 8.55448 12.0796 8.38672 12.5813 8.38672V7.38672C11.8704 7.38672 11.1213 7.6426 10.7757 8.40309L11.6861 8.81678ZM12.5813 8.38672C13.087 8.38672 13.4614 8.60522 13.5777 8.83539L14.4703 8.38448C14.1169 7.685 13.2884 7.38672 12.5813 7.38672V8.38672ZM13.5777 8.83539C13.7606 9.19738 13.8523 9.72518 13.8523 10.418H14.8523C14.8523 9.66433 14.757 8.95213 14.4703 8.38448L13.5777 8.83539ZM12.5813 12.4492C12.5364 12.4492 12.5158 12.4464 12.5087 12.4451C12.5046 12.4444 12.5042 12.4442 12.5008 12.4428C12.4922 12.4391 12.4782 12.4321 12.438 12.4096C12.4018 12.3893 12.3471 12.358 12.2805 12.3238L11.823 13.213C11.8698 13.2371 11.9055 13.2576 11.9494 13.2821C11.9893 13.3045 12.0449 13.3354 12.1079 13.3623C12.2569 13.426 12.403 13.4492 12.5813 13.4492V12.4492ZM12.3817 12.3927C11.8273 11.9058 11.4022 11.3083 11.4023 10.418L10.4023 10.4179C10.4022 11.6973 11.0412 12.5462 11.7218 13.1441L12.3817 12.3927ZM13.8523 10.418C13.8523 11.3319 13.4575 11.9093 12.8838 12.3828L13.5203 13.1541C14.2611 12.5427 14.8523 11.7035 14.8523 10.418H13.8523ZM12.9733 12.3238C12.7638 12.4316 12.717 12.4492 12.5813 12.4492V13.4492C12.9639 13.4492 13.1869 13.3385 13.4308 13.213L12.9733 12.3238Z",fill:"#3D3D3D"})),It=e=>K.createElement("svg",{width:24,height:24,viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",...e},K.createElement("path",{d:"M12.002 21L11.8275 21.4686C11.981 21.5257 12.1528 21.5041 12.2873 21.4106C12.4218 21.3172 12.502 21.1638 12.502 21H12.002ZM3.89502 17.9823H3.39502C3.39502 18.1912 3.52485 18.378 3.72059 18.4509L3.89502 17.9823ZM3.89502 8.06421L4.07193 7.59655C3.91831 7.53844 3.74595 7.55948 3.61082 7.65284C3.47568 7.74619 3.39502 7.89997 3.39502 8.06421H3.89502ZM12.0007 21H11.5007C11.5007 21.1638 11.5809 21.3172 11.7154 21.4106C11.8499 21.5041 12.0216 21.5257 12.1751 21.4686L12.0007 21ZM20.1076 17.9823L20.282 18.4509C20.4778 18.378 20.6076 18.1912 20.6076 17.9823H20.1076ZM20.1076 8.06421H20.6076C20.6076 7.89997 20.527 7.74619 20.3918 7.65284C20.2567 7.55948 20.0843 7.53844 19.9307 7.59655L20.1076 8.06421ZM12.0007 11.1311L11.8238 10.6634C11.6293 10.737 11.5007 10.9232 11.5007 11.1311H12.0007ZM20.2858 8.53191C20.5441 8.43421 20.6743 8.14562 20.5766 7.88734C20.4789 7.62906 20.1903 7.49889 19.932 7.5966L20.2858 8.53191ZM12.002 4.94826L12.1775 4.48008C12.0605 4.43623 11.9314 4.43775 11.8154 4.48436L12.002 4.94826ZM5.87955 6.87106C5.62334 6.97407 5.49915 7.26528 5.60217 7.52149C5.70518 7.77769 5.99639 7.90188 6.2526 7.79887L5.87955 6.87106ZM18.1932 7.80315C18.4518 7.90008 18.74 7.76904 18.8369 7.51047C18.9338 7.2519 18.8028 6.96371 18.5442 6.86678L18.1932 7.80315ZM12 4.94827L11.5879 5.23148C11.6812 5.36719 11.8353 5.44827 12 5.44827C12.1647 5.44827 12.3188 5.36719 12.4121 5.23148L12 4.94827ZM14.0263 2L14.2028 1.53218C13.9875 1.45097 13.7446 1.52717 13.6143 1.71679L14.0263 2ZM21.8421 4.94827L22.2673 5.2113C22.3459 5.08422 22.3636 4.92863 22.3154 4.78717C22.2673 4.64571 22.1584 4.53319 22.0186 4.48045L21.8421 4.94827ZM9.97368 2L10.3857 1.71679C10.2554 1.52717 10.0125 1.45097 9.79721 1.53218L9.97368 2ZM2.15789 4.94827L1.98142 4.48045C1.84161 4.53319 1.73271 4.64571 1.68456 4.78717C1.63641 4.92863 1.65406 5.08422 1.73267 5.2113L2.15789 4.94827ZM12 11.1256L11.6702 11.5014C11.8589 11.667 12.1411 11.667 12.3298 11.5014L12 11.1256ZM15.0395 8.45812L14.8732 7.98659C14.8131 8.00779 14.7576 8.04028 14.7097 8.08232L15.0395 8.45812ZM23 5.65024L23.3288 6.0269C23.5095 5.86916 23.5527 5.60532 23.4318 5.39817C23.3109 5.19102 23.0599 5.09893 22.8337 5.17871L23 5.65024ZM8.96053 8.45812L9.29034 8.08232C9.24244 8.04028 9.18695 8.00779 9.12685 7.98659L8.96053 8.45812ZM1 5.65024L1.16632 5.17871C0.940115 5.09893 0.689119 5.19102 0.568192 5.39817C0.447264 5.60532 0.49048 5.86916 0.671176 6.0269L1 5.65024ZM12.1764 20.5314L4.06945 17.5137L3.72059 18.4509L11.8275 21.4686L12.1764 20.5314ZM4.39502 17.9823V8.06421H3.39502V17.9823H4.39502ZM3.71811 8.53187L11.8251 11.5987L12.1789 10.6634L4.07193 7.59655L3.71811 8.53187ZM11.502 11.1311V21H12.502V11.1311H11.502ZM12.1751 21.4686L20.282 18.4509L19.9332 17.5137L11.8262 20.5314L12.1751 21.4686ZM20.6076 17.9823V8.06421H19.6076V17.9823H20.6076ZM19.9307 7.59655L11.8238 10.6634L12.1776 11.5987L20.2845 8.53187L19.9307 7.59655ZM11.5007 11.1311V21H12.5007V11.1311H11.5007ZM19.932 7.5966L11.8251 10.6634L12.1789 11.5987L20.2858 8.53191L19.932 7.5966ZM11.8154 4.48436L5.87955 6.87106L6.2526 7.79887L12.1885 5.41217L11.8154 4.48436ZM11.8265 5.41645L18.1932 7.80315L18.5442 6.86678L12.1775 4.48008L11.8265 5.41645ZM11.502 4.94826V11.1311H12.502V4.94826H11.502ZM12.4121 5.23148L14.4384 2.28321L13.6143 1.71679L11.5879 4.66507L12.4121 5.23148ZM13.8498 2.46782L21.6656 5.4161L22.0186 4.48045L14.2028 1.53218L13.8498 2.46782ZM21.4169 4.68525L20.5485 6.08919L21.3989 6.61524L22.2673 5.2113L21.4169 4.68525ZM12.4121 4.66507L10.3857 1.71679L9.56162 2.28321L11.5879 5.23148L12.4121 4.66507ZM9.79721 1.53218L1.98142 4.48045L2.33437 5.4161L10.1502 2.46782L9.79721 1.53218ZM1.73267 5.2113L2.60109 6.61524L3.45154 6.08919L2.58312 4.68525L1.73267 5.2113ZM12.3298 11.5014L15.3693 8.83392L14.7097 8.08232L11.6702 10.7498L12.3298 11.5014ZM15.2058 8.92965L23.1663 6.12177L22.8337 5.17871L14.8732 7.98659L15.2058 8.92965ZM22.6712 5.27358L19.7764 7.80067L20.4341 8.554L23.3288 6.0269L22.6712 5.27358ZM12.3298 10.7498L9.29034 8.08232L8.63072 8.83392L11.6702 11.5014L12.3298 10.7498ZM9.12685 7.98659L1.16632 5.17871L0.83368 6.12177L8.79421 8.92965L9.12685 7.98659ZM0.671176 6.0269L3.56591 8.554L4.22356 7.80067L1.32882 5.27358L0.671176 6.0269Z",fill:"#D6D6D6"})),Fe=({selectable:e,className:s,addNewAddress:n,minifiedView:r,routeAddressesPage:d})=>{const l=r?"minifiedView":"fullSizeView",i=ne({viewAllAddressesButton:`Account.${l}.Addresses.viewAllAddressesButton`,addNewAddressButton:`Account.${l}.Addresses.addNewAddressButton`,differentAddressButton:`Account.${l}.Addresses.differentAddressButton`}),o=e?"span":"button",c=e?{}:{AriaRole:"button",type:"button"},u=r&&!n?i.viewAllAddressesButton:i.addNewAddressButton,p=e?i.differentAddressButton:u;return W(o,{...c,className:X(["account-actions-address",["account-actions-address--viewall",r],["account-actions-address--address",!r],["account-actions-address--selectable",e],s]),"data-testid":"showRouteFullAddress",onClick:d,children:[a("span",{className:"account-actions-address__title","data-testid":"addressActionsText",children:p}),a(Se,{source:r&&!n?$t:Zt,size:"32"})]})},Ot=({minifiedView:e,keysSortOrder:s,addressData:n,open:r,submitLoading:d,onRemoveAddress:l,closeModal:i})=>{const o=e?"minifiedView":"fullSizeView",c=ne({title:`Account.${o}.Addresses.removeAddressModal.title`,description:`Account.${o}.Addresses.removeAddressModal.description`,actionCancel:`Account.${o}.Addresses.removeAddressModal.actionCancel`,actionConfirm:`Account.${o}.Addresses.removeAddressModal.actionConfirm`});return r?W(Ge,{title:a("h3",{children:c.title}),className:"account-address-modal",size:"full","data-testid":"addressModal",showCloseButton:!0,onClose:i,children:[d?a("div",{className:"account-address-modal__spinner","data-testid":"progressSpinner",children:a(Ke,{stroke:"4",size:"large"})}):null,a("p",{children:c.description}),a(Me,{minifiedView:e,addressData:n,keysSortOrder:s}),W("div",{className:"account-address-modal__buttons",children:[a(de,{type:"button",onClick:i,variant:"secondary",disabled:d,children:c.actionCancel}),a(de,{disabled:d,onClick:l,children:c.actionConfirm})]})]}):null},xt=({typeList:e,isEmpty:s,minifiedView:n,className:r})=>{const d=n?"minifiedView":"fullSizeView",l=ne({addressesMessage:`Account.${d}.EmptyList.Addresses.message`,ordersListMessage:`Account.${d}.EmptyList.OrdersList.message`}),i=be(()=>{switch(e){case"address":return{icon:Ft,text:a("p",{children:l.addressesMessage})};case"orders":return{icon:It,text:a("p",{children:l.ordersListMessage})};default:return{icon:"",text:""}}},[e,l]);return!s||!e||!i.text?null:a(De,{className:X(["account-empty-list",n?"account-empty-list--minified":"",r]),message:i.text,icon:a(Se,{source:i.icon}),"data-testid":"emptyList"})},wt=async(e,s)=>{if(s.length===1){const i=s[0],c=Object.values(i.region).every(p=>!!p)?{}:{region:{...i.region,regionId:0}};return!!await Ce({addressId:Number(i==null?void 0:i.id),defaultShipping:!1,defaultBilling:!1,...c})}const n=s.filter(i=>i.id!==e&&(i.defaultBilling||i.defaultShipping)||i.id!==e),r=s[s.length-1],d=n[0]||((r==null?void 0:r.id)!==e?r:null);return!d||!d.id?!1:!!await Ce({addressId:+d.id,defaultShipping:!0,defaultBilling:!0})},St=["firstname","lastname","city","company","country_code","region","region_code","region_id","telephone","id","vat_id","postcode","street","street_multiline_2","default_shipping","default_billing"],t1=["email","firstname","lastname","middlename","gender","dob","date_of_birth","prefix","suffix"],Ue=(e,s,n)=>{if(s&&n||!s&&!n)return e;const r=e.slice();return s?r.sort((d,l)=>Number(l.defaultShipping)-Number(d.defaultShipping)):n?r.sort((d,l)=>Number(l.defaultBilling)-Number(d.defaultBilling)):e},ve=e=>e==null?!0:typeof e!="object"?!1:Object.keys(e).length===0||Object.values(e).every(ve),Rt=({selectShipping:e,selectBilling:s,defaultSelectAddressId:n,onAddressData:r,minifiedView:d,routeAddressesPage:l,onSuccess:i})=>{const[o,c]=N(""),[u,p]=N(!1),[y,g]=N(!1),[I,L]=N(!1),[x,t]=N(!1),[h,f]=N(!1),[_,T]=N(""),[Z,z]=N([]),[w,V]=N([]),C=k(async()=>{L(!0),Promise.all([Ve("shortRequest"),tt()]).then(A=>{const[$,U]=A;if($){const S=$.map(({name:B,orderNumber:te,label:re})=>({name:rt(B),orderNumber:te,label:St.includes(B)?null:re}));V(S)}if(U)if(d){const S=U.filter(B=>!!B.defaultShipping||!!B.defaultBilling);z(S)}else z(U)}).finally(()=>{L(!1)})},[d]);ee(()=>{C()},[C]),ee(()=>{var A;if(Z.length)if(n===0)f(!0),c("0");else{const $=Z.find(S=>+S.id===n)||Ue(Z,e,s)[0],U={data:ae($),isDataValid:!ve($)};c(n.toString()||((A=$==null?void 0:$.id)==null?void 0:A.toString())),r==null||r(U)}},[Z,n,r,s,e]);const H=k(A=>{T(A),f(!1)},[]),q=k((A,$)=>{const U=(A==null?void 0:A.target).value;c(U);const S={data:ae($),isDataValid:!ve(ae($))};r==null||r(S),U!=="0"&&f(!1)},[r]),P=k(()=>{g(!0)},[]),D=k(()=>{T(""),g(!1),p(!1)},[]),m=k(()=>{p(!0)},[]),v=k(async()=>{t(!0),await wt(_,Z),st(+_).then(()=>{C(),D()}).finally(()=>{t(!1)})},[Z,_,D,C]),b=k(()=>{f(!1)},[]),M=k(()=>{Be(l)&&d&&!h?window.location.href=l():(f(!0),T(""))},[h,l,d]),O=k(async()=>{await C(),await(i==null?void 0:i())},[C,i]);return{keysSortOrder:w,submitLoading:x,isModalRendered:u,isFormRendered:y,loading:I,addNewAddress:h,addressesList:Z,addressId:_,handleRenderForm:P,handleRenderModal:m,removeAddress:v,onCloseBtnClick:D,setEditingAddressId:H,closeNewAddressForm:b,redirectToAddressesRoute:M,handleOnSuccess:O,handleSelectAddressOption:q,selectedAddressOption:o}},r1=Ee(({hideActionFormButtons:e=!1,formName:s,slots:n,title:r="",addressFormTitle:d="",defaultSelectAddressId:l="",showFormLoader:i=!1,onAddressData:o,forwardFormRef:c,className:u,showSaveCheckBox:p=!1,saveCheckBoxValue:y=!1,selectShipping:g=!1,selectBilling:I=!1,selectable:L=!1,withHeader:x=!0,minifiedView:t=!1,withActionsInMinifiedView:h=!1,withActionsInFullSizeView:f=!0,inputsDefaultValueSet:_,showShippingCheckBox:T=!0,showBillingCheckBox:Z=!0,shippingCheckBoxValue:z=!0,billingCheckBoxValue:w=!0,routeAddressesPage:V,onSuccess:C,onError:H})=>{var J;const q=t?"minifiedView":"fullSizeView",P=ne({containerTitle:`Account.${q}.Addresses.containerTitle`,differentAddressFormTitle:`Account.${q}.Addresses.differentAddressFormTitle`,editAddressFormTitle:`Account.${q}.Addresses.editAddressFormTitle`,viewAllAddressesButton:`Account.${q}.Addresses.viewAllAddressesButton`,newAddressFormTitle:`Account.${q}.Addresses.newAddressFormTitle`}),{keysSortOrder:D,submitLoading:m,isModalRendered:v,isFormRendered:b,loading:M,addNewAddress:O,addressesList:A,addressId:$,handleRenderForm:U,handleRenderModal:S,removeAddress:B,onCloseBtnClick:te,handleOnSuccess:re,setEditingAddressId:Le,closeNewAddressForm:oe,redirectToAddressesRoute:ie,handleSelectAddressOption:ce,selectedAddressOption:ue}=Rt({defaultSelectAddressId:l,minifiedView:t,routeAddressesPage:V,onSuccess:C,onAddressData:o,selectShipping:g,selectBilling:I}),R=s??(g&&I?"selectedAddress":g?"selectedShippingAddress":I?"selectedBillingAddress":"default"),j=L?W("div",{className:"account-addresses-wrapper--select-view",children:[(J=Ue(A,g,I))==null?void 0:J.map((E,Y)=>W(Ne,{children:[a("input",{"data-testid":`radio-${Y+1}`,type:"radio",name:R,id:`${R}_${E.id}`,value:E.id,checked:ue===(E==null?void 0:E.id.toString()),onChange:ge=>ce(ge,E)}),a("label",{htmlFor:`${R}_${E.id}`,className:"account-addresses-wrapper__label",children:a(Me,{slots:n,selectable:L,selectShipping:g,selectBilling:I,minifiedView:t,addressData:E,keysSortOrder:D,loading:M})})]},E.id)),a("input",{"data-testid":"radio-0",type:"radio",name:R,id:`${R}_addressActions`,value:"0",checked:ue==="0",onChange:E=>ce(E,{})}),a("label",{htmlFor:`${R}_addressActions`,className:"account-addresses-wrapper__label",children:O?a("div",{className:X(["account-addresses-form__footer__wrapper",["account-addresses-form__footer__wrapper-show",O]]),children:a(fe,{slots:n,hideActionFormButtons:e,formName:R,showFormLoader:i,isOpen:O,forwardFormRef:c,showSaveCheckBox:p,saveCheckBoxValue:y,shippingCheckBoxValue:z,billingCheckBoxValue:w,addressesFormTitle:d||P.differentAddressFormTitle,inputsDefaultValueSet:_,showShippingCheckBox:T,showBillingCheckBox:Z,onCloseBtnClick:oe,onSuccess:re,onError:H,onChange:o})}):A!=null&&A.length?a(Fe,{selectable:L,minifiedView:t,addNewAddress:O,routeAddressesPage:ie}):null})]}):W(Q,{children:[A.map(E=>a(Ne,{children:$===E.id&&b?a(he,{variant:"secondary",style:{marginBottom:20},children:a(fe,{slots:n,isOpen:$===E.id&&b,addressFormId:$,inputsDefaultValueSet:E,addressesFormTitle:P.editAddressFormTitle,showShippingCheckBox:T,showBillingCheckBox:Z,shippingCheckBoxValue:z,billingCheckBoxValue:w,onCloseBtnClick:te,onSuccess:re,onError:H})}):a(Me,{slots:n,minifiedView:t,addressData:E,keysSortOrder:D,loading:M,setAddressId:Le,handleRenderModal:t&&h||!t&&f?S:void 0,handleRenderForm:t&&h||!t&&f?U:void 0},E.id)},E.id)),a("div",{className:"account-addresses__footer",children:O?a(he,{variant:"secondary",children:a(fe,{slots:n,isOpen:O,addressesFormTitle:P.newAddressFormTitle,inputsDefaultValueSet:_,showShippingCheckBox:!!(A!=null&&A.length),showBillingCheckBox:!!(A!=null&&A.length),shippingCheckBoxValue:z,billingCheckBoxValue:w,onCloseBtnClick:oe,onSuccess:re,onError:H})}):a(Fe,{minifiedView:t,addNewAddress:O,routeAddressesPage:ie})})]});return W("div",{children:[a("div",{children:x?a(Je,{title:r||P.containerTitle,divider:!t,className:t?"account-addresses-header":""}):null}),W("div",{className:X(["account-addresses-wrapper",u]),"data-testid":"addressesIdWrapper",children:[a(Ot,{minifiedView:t,addressData:A==null?void 0:A.find(E=>E.id===$),keysSortOrder:D,submitLoading:m,open:v,closeModal:te,onRemoveAddress:B}),M?a(ze,{testId:"addressSkeletonLoader",withCard:!1}):L?a(fe,{slots:n,hideActionFormButtons:e,formName:R,isOpen:!(A!=null&&A.length),forwardFormRef:c,showSaveCheckBox:p,saveCheckBoxValue:y,shippingCheckBoxValue:z,billingCheckBoxValue:w,inputsDefaultValueSet:_,showShippingCheckBox:T,showBillingCheckBox:Z,onCloseBtnClick:oe,onSuccess:re,onError:H,onChange:o}):a(xt,{isEmpty:!(A!=null&&A.length),typeList:"address",minifiedView:t}),j]})]})}),ke={entityType:"CUSTOMER_ADDRESS",isUnique:!1,options:[],multilineCount:0,validateRules:[],defaultValue:!1,fieldType:se.BOOLEAN,className:"",required:!1,orderNumber:90,isHidden:!1},Vt={...ke,label:"Set as default shipping address",name:"default_shipping",id:"default_shipping",code:"default_shipping",customUpperCode:"defaultShipping"},Ht={...ke,label:"Set as default billing address",name:"default_billing",id:"default_billing",code:"default_billing",customUpperCode:"defaultBilling"},Bt=(e,s)=>s==null?void 0:s.map(n=>{const r={...e,firstName:e.firstname??e.firstName,lastName:e.lastname??e.lastName},d=JSON.parse(JSON.stringify(n));if(Object.hasOwn(r,n.customUpperCode)){const l=r[n.customUpperCode];n.customUpperCode==="region"&&typeof l=="object"?d.defaultValue=l.regionCode&&l.regionId?`${l.regionCode},${l.regionId}`:l.region??l.regionCode:d.defaultValue=l}return d}),Ie=e=>{if(!e)return null;const s=new FormData(e);if(e.querySelectorAll('input[type="checkbox"]').forEach(r=>{s.has(r.name)||s.set(r.name,"false"),r.checked&&s.set(r.name,"true")}),s&&typeof s.entries=="function"){const r=s.entries();if(r&&typeof r[Symbol.iterator]=="function")return JSON.parse(JSON.stringify(Object.fromEntries(r)))||{}}return{}},zt=({fields:e,addressId:s,countryOptions:n,disableField:r,regionOptions:d,isRequiredRegion:l,isRequiredPostCode:i})=>e.filter(c=>!(s&&(c.customUpperCode==="defaultShipping"||c.customUpperCode==="defaultBilling")&&c.defaultValue)).map(c=>c.customUpperCode==="countryCode"?{...c,options:n,disabled:r}:c.customUpperCode==="postcode"?{...c,required:i}:c.customUpperCode==="region"?{...c,options:d,required:l,disabled:r}:c),Ut=(e,s="address")=>{const n=s==="address"?["region","city","company","countryCode","countryId","defaultBilling","defaultShipping","fax","firstName","lastName","middleName","postcode","prefix","street","suffix","telephone","vatId","addressId"]:["email","firstName","lastName","middleName","gender","dob","dateOfBirth","prefix","suffix"],r={},d=[];return Object.keys(e).forEach(l=>{n.includes(l)?r[l]=e[l]:d.push({attribute_code:Re(l),value:e[l]})}),d.length>0&&(r.custom_attributesV2=d),r},Oe=e=>{const s=["street","streetMultiline_1","streetMultiline_2"],n=["on","off","true","false"],r=[],d={};for(const L in e){const x=e[L];n.includes(x)&&(d[L]=He(x)),s.includes(L)&&r.push(x)}const{street:l,streetMultiline_2:i,streetMultiline_1:o,region:c,...u}=e,[p,y]=c?c.split(","):[void 0,void 0],g=y&&p?{regionId:+y,regionCode:p}:{region:p};return Ut({...u,...d,region:{...g},street:r})},kt=(e,s)=>{const n={};for(const r in e)if(Object.prototype.hasOwnProperty.call(e,r)){const d=e[r];if(r==="region"&&d.regionId){const l=s.find(i=>(i==null?void 0:i.id)===d.regionId);l?n[r]={...d,text:l.text}:n[r]=d}else Array.isArray(d)?(n[r]=d[0]||"",d.slice(1).forEach((l,i)=>{n[`${r}Multiline_${i+2}`]=l})):n[r]=d}return n},qt=(e,s)=>e&&Object.keys(e).length>0?e:s&&Object.keys(s).length>0?s:{},Pt=({showFormLoader:e,showSaveCheckBox:s,saveCheckBoxValue:n,addressFormId:r,billingCheckBoxValue:d,shippingCheckBoxValue:l,showShippingCheckBox:i,showBillingCheckBox:o,inputsDefaultValueSet:c,onCloseBtnClick:u,onSuccess:p,onError:y,formName:g})=>{const[I,L]=N({text:"",type:"success"}),[x,t]=N(e??!1),[h,f]=N(r||""),[_,T]=N([]),[Z,z]=N([]),[w,V]=N([]),[C,H]=N([]),[q,P]=N([]),[D,m]=N(!1),[v,b]=N(!1),[M,O]=N(()=>{var R,j;const F=sessionStorage.getItem(`${g}_addressData`);return F?{countryCode:(j=(R=JSON.parse(F))==null?void 0:R.data)==null?void 0:j.countryCode}:c}),[A,$]=N(!1),[U,S]=N(!1),[B,te]=N(()=>{var j,J;const F=sessionStorage.getItem(`${g}_addressData`);return F?(J=(j=JSON.parse(F))==null?void 0:j.data)==null?void 0:J.saveAddressBook:n}),re=k(F=>{te(F.target.checked)},[]);ee(()=>{typeof e>"u"||t(e)},[e]),ee(()=>{Ve(h?"customer_address_edit":"customer_register_address").then(F=>{T(F)})},[h]),ee(()=>{$(!0),nt().then(({availableCountries:F,countriesWithRequiredRegion:R,optionalZipCountries:j})=>{z(F),H(R),P(j),$(!1)})},[]),ee(()=>{if(M!=null&&M.countryCode){$(!0),S(!0);const F=M==null?void 0:M.countryCode;at(F).then(R=>{V(R);const j=C.find(E=>E===F),J=q.find(E=>E===F);m(!!j),b(!J),$(!1),S(!1)})}},[M==null?void 0:M.countryCode,C,q]);const Le=k(()=>{L({text:"",type:"success"}),u==null||u()},[u]),oe=k(async(F,R)=>{if(!R)return null;t(!0);const j=Ie(F.target),J=Oe(j);await Ce(J).then(()=>{var E;p==null||p(),u==null||u(),(E=F==null?void 0:F.target)==null||E.reset()}).catch(E=>{L(Y=>({...Y,text:E.message,type:"error"})),y==null||y(E)}).finally(()=>{f(""),t(!1)})},[u,y,p]),ie=k(async(F,R)=>{if(!R)return;t(!0);const{saveAddressBook:j,...J}=Ie(F.target),E=Oe(J);await dt(E).then(()=>{var Y;p==null||p(),u==null||u(),(Y=F==null?void 0:F.target)==null||Y.reset()}).catch(Y=>{L(ge=>({...ge,text:Y.message,type:"error"})),y==null||y(Y)}).finally(()=>{f(""),t(!1)})},[u,y,p]),ce=Qe(()=>{if(!_.length)return[];const F={...Vt,defaultValue:l,isHidden:s&&!B?!0:!i},R={...Ht,defaultValue:d,isHidden:s&&!B?!0:!o},j=[..._,F,R],J=sessionStorage.getItem(`${g}_addressData`),E=J?kt(JSON.parse(J).data,w):{},Y=Bt(qt(E,c),j);return zt({fields:Y,addressId:h,countryOptions:Z,disableField:A,regionOptions:w,isRequiredRegion:D,isRequiredPostCode:v})},[_,l,s,B,i,d,o,g,w,c,h,Z,A,D,v]),ue=k(F=>{O(R=>({...R,...F}))},[]);return{isWaitingForResponse:U,regionOptions:w,saveCheckBoxAddress:B,inLineAlert:I,addressId:h,submitLoading:x,normalizeFieldsConfig:ce,handleSaveCheckBoxAddress:re,handleUpdateAddress:oe,handleCreateAddress:ie,handleOnCloseForm:Le,handleInputChange:ue}},Wt=({hideActionFormButtons:e,formName:s="",showFormLoader:n=!1,showSaveCheckBox:r=!1,saveCheckBoxValue:d=!1,forwardFormRef:l,slots:i,addressesFormTitle:o,className:c,addressFormId:u,inputsDefaultValueSet:p,showShippingCheckBox:y=!0,showBillingCheckBox:g=!0,shippingCheckBoxValue:I=!0,billingCheckBoxValue:L=!0,isOpen:x,onSubmit:t,onCloseBtnClick:h,onSuccess:f,onError:_,onChange:T})=>{const Z=ne({secondaryButton:"Account.AddressForm.formText.secondaryButton",primaryButton:"Account.AddressForm.formText.primaryButton",saveAddressBook:"Account.AddressForm.formText.saveAddressBook"}),{isWaitingForResponse:z,inLineAlert:w,addressId:V,submitLoading:C,normalizeFieldsConfig:H,handleUpdateAddress:q,handleCreateAddress:P,handleOnCloseForm:D,handleSaveCheckBoxAddress:m,saveCheckBoxAddress:v,handleInputChange:b,regionOptions:M}=Pt({showFormLoader:n,addressFormId:u,inputsDefaultValueSet:p,shippingCheckBoxValue:I,billingCheckBoxValue:L,showShippingCheckBox:y,showBillingCheckBox:g,saveCheckBoxValue:d,showSaveCheckBox:r,onSuccess:f,onError:_,onCloseBtnClick:h,formName:s});return x?W("div",{className:X(["account-address-form-wrapper",c]),children:[o?a("div",{className:"account-address-form-wrapper__title","data-testid":"addressesFormTitle",children:o}):null,w.text?a(Xe,{"data-testid":"inLineAlert",className:"account-address-form-wrapper__notification",type:w.type,variant:"secondary",heading:w.text,icon:w.icon}):null,W(Tt,{regionOptions:M,forwardFormRef:l,slots:i,className:"account-address-form",name:s||"addressesForm",fieldsConfig:H,onSubmit:t||(V?q:P),setInputChange:b,loading:C,showFormLoader:n,showSaveCheckBox:r,handleSaveCheckBoxAddress:m,saveCheckBoxAddress:v,onChange:T,isWaitingForResponse:z,children:[V?a("input",{type:"hidden",name:"addressId",value:V,"data-testid":"hidden_test_id"}):null,e?null:a("div",{className:X(["dropin-field account-address-form-wrapper__buttons",["account-address-form-wrapper__buttons--empty",r]]),children:i!=null&&i.AddressFormActions?a(Ae,{"data-testid":"addressFormActions",name:"AddressFormActions",slot:i.AddressFormActions,context:{handleUpdateAddress:q,handleCreateAddress:P,addressId:V}}):a(Q,{children:r?null:W(Q,{children:[a(de,{type:"button",onClick:D,variant:"secondary",disabled:C,children:Z.secondaryButton}),a(de,{disabled:C,children:Z.primaryButton})]})})})]})]}):null};export{fe as A,ze as C,xt as E,Tt as F,$t as S,r1 as a,Be as c,t1 as d,Ie as g,Ut as n}; diff --git a/scripts/__dropins__/storefront-account/chunks/getOrderHistoryList.js b/scripts/__dropins__/storefront-account/chunks/getOrderHistoryList.js index 319a9a0f4d..84ca43ae12 100644 --- a/scripts/__dropins__/storefront-account/chunks/getOrderHistoryList.js +++ b/scripts/__dropins__/storefront-account/chunks/getOrderHistoryList.js @@ -1,6 +1,4 @@ -/*! Copyright 2024 Adobe -All Rights Reserved. */ -import{t as u,m as i,f as _,l as p}from"./removeCustomerAddress.js";const f=(e,t="en-US",a={})=>{const s={...{day:"2-digit",month:"2-digit",year:"numeric"},...a},r=new Date(e);return isNaN(r.getTime())?"Invalid Date":new Intl.DateTimeFormat(t,s).format(r)},g=e=>{var d,c;if(!((c=(d=e.data)==null?void 0:d.customer)!=null&&c.orders))return null;const{items:t,page_info:a,total_count:o,date_of_first_order:s}=e.data.customer.orders,{returns:r}=e.data.customer;return{items:t.map(n=>{const l={...n,returns:r==null?void 0:r.items.filter(m=>m.order.id===n.id),order_date:f(n.order_date),shipping_address:u(n.shipping_address),billing_address:u(n.billing_address)};return i(l,"camelCase",{})}),pageInfo:i(a,"camelCase",{}),totalCount:i(o,"camelCase",{}),dateOfFirstOrder:i(s,"camelCase",{})}},y=` +import{t as u,k as i,f as _,l as f,m as p}from"./removeCustomerAddress.js";const g=(r,a="en-US",s={})=>{const t={...{day:"2-digit",month:"2-digit",year:"numeric"},...s},e=new Date(r);return isNaN(e.getTime())?"Invalid Date":new Intl.DateTimeFormat(a,t).format(e)},y=r=>{var d,c;if(!((c=(d=r.data)==null?void 0:d.customer)!=null&&c.orders))return null;const{items:a,page_info:s,total_count:o,date_of_first_order:t}=r.data.customer.orders,{returns:e}=r.data.customer;return{items:a.map(n=>{const l={...n,returns:e==null?void 0:e.items.filter(m=>m.order.id===n.id),order_date:g(n.order_date),shipping_address:u(n.shipping_address),billing_address:u(n.billing_address)};return i(l,"camelCase",{})}),pageInfo:i(s,"camelCase",{}),totalCount:i(o,"camelCase",{}),dateOfFirstOrder:i(t,"camelCase",{})}},h=` fragment AddressesList on OrderAddress { city company @@ -121,6 +119,6 @@ fragment OrderSummary on OrderTotal { } } } -${y} +${h} ${O} -`,h={sort_direction:"DESC",sort_field:"CREATED_AT"},E=async(e,t,a)=>{const o=t.includes("viewAll")?{}:{order_date:JSON.parse(t)};return await _(S,{method:"GET",cache:"no-cache",variables:{pageSize:e,currentPage:a,filter:o,sort:h}}).then(s=>g(s)).catch(p)};export{E as g}; +`,E={sort_direction:"DESC",sort_field:"CREATED_AT"},C=async(r,a,s)=>{const o=a.includes("viewAll")?{}:{order_date:JSON.parse(a)};return await _(S,{method:"GET",cache:"no-cache",variables:{pageSize:r,currentPage:s,filter:o,sort:E}}).then(t=>{var e;return(e=t.errors)!=null&&e.length?f(t.errors):y(t)}).catch(p)};export{C as g}; diff --git a/scripts/__dropins__/storefront-account/chunks/getStoreConfig.js b/scripts/__dropins__/storefront-account/chunks/getStoreConfig.js deleted file mode 100644 index 06859e5b26..0000000000 --- a/scripts/__dropins__/storefront-account/chunks/getStoreConfig.js +++ /dev/null @@ -1,12 +0,0 @@ -/*! Copyright 2024 Adobe -All Rights Reserved. */ -import{f as h,k as o,l as m}from"./removeCustomerAddress.js";const u=r=>{var a,t,c,e,i,_;return{baseMediaUrl:(t=(a=r==null?void 0:r.data)==null?void 0:a.storeConfig)==null?void 0:t.base_media_url,minLength:+((e=(c=r==null?void 0:r.data)==null?void 0:c.storeConfig)==null?void 0:e.minimum_password_length)||3,requiredCharacterClasses:+((_=(i=r==null?void 0:r.data)==null?void 0:i.storeConfig)==null?void 0:_.required_character_classes_number)||0}},d=` - query GET_STORE_CONFIG { - storeConfig { - base_media_url - autocomplete_on_storefront - minimum_password_length - required_character_classes_number - } - } -`,f=async()=>await h(d,{method:"GET",cache:"force-cache"}).then(r=>{var a;return(a=r.errors)!=null&&a.length?o(r.errors):u(r)}).catch(m);export{f as g}; diff --git a/scripts/__dropins__/storefront-account/chunks/removeCustomerAddress.js b/scripts/__dropins__/storefront-account/chunks/removeCustomerAddress.js index a8cfb8df87..9a1dcf7657 100644 --- a/scripts/__dropins__/storefront-account/chunks/removeCustomerAddress.js +++ b/scripts/__dropins__/storefront-account/chunks/removeCustomerAddress.js @@ -1,6 +1,4 @@ -/*! Copyright 2024 Adobe -All Rights Reserved. */ -import{events as b}from"@dropins/tools/event-bus.js";import{FetchGraphQL as C}from"@dropins/tools/fetch-graphql.js";const S=t=>t.replace(/_([a-z])/g,(n,e)=>e.toUpperCase()),p=t=>t.replace(/([A-Z])/g,n=>`_${n.toLowerCase()}`),g=(t,n,e)=>{const r=["string","boolean","number"],o=n==="camelCase"?S:p;return Array.isArray(t)?t.map(i=>r.includes(typeof i)||i===null?i:typeof i=="object"?g(i,n,e):i):t!==null&&typeof t=="object"?Object.entries(t).reduce((i,[c,a])=>{const u=e&&e[c]?e[c]:o(c);return i[u]=r.includes(typeof a)||a===null?a:g(a,n,e),i},{}):t},{setEndpoint:k,setFetchGraphQlHeader:H,removeFetchGraphQlHeader:J,setFetchGraphQlHeaders:K,fetchGraphQl:s,getConfig:L}=new C().getMethods(),T=` +import{events as C}from"@dropins/tools/event-bus.js";import{FetchGraphQL as T}from"@dropins/tools/fetch-graphql.js";const b=t=>t.replace(/_([a-z])/g,(e,r)=>r.toUpperCase()),A=t=>t.replace(/([A-Z])/g,e=>`_${e.toLowerCase()}`),a=(t,e,r)=>{const n=["string","boolean","number"],o=e==="camelCase"?b:A;return Array.isArray(t)?t.map(i=>n.includes(typeof i)||i===null?i:typeof i=="object"?a(i,e,r):i):t!==null&&typeof t=="object"?Object.entries(t).reduce((i,[c,_])=>{const u=r&&r[c]?r[c]:o(c);return i[u]=n.includes(typeof _)||_===null?_:a(_,e,r),i},{}):t},{setEndpoint:x,setFetchGraphQlHeader:B,removeFetchGraphQlHeader:Q,setFetchGraphQlHeaders:j,fetchGraphQl:s,getConfig:k}=new T().getMethods(),p=` query GET_ATTRIBUTES_FORM($formCode: String!) { attributesForm(formCode: $formCode) { items { @@ -32,7 +30,7 @@ import{events as b}from"@dropins/tools/event-bus.js";import{FetchGraphQL as C}fr } } } -`,A=` +`,R=` query GET_ATTRIBUTES_FORM_SHORT { attributesForm(formCode: "customer_register_address") { items { @@ -46,22 +44,18 @@ import{events as b}from"@dropins/tools/event-bus.js";import{FetchGraphQL as C}fr } } } -`,_=t=>{throw t instanceof DOMException&&t.name==="AbortError"||b.emit("error",{source:"auth",type:"network",error:t}),t},f=t=>{const n=t.map(e=>e.message).join(" ");throw Error(n)},y=t=>{let n=[];for(const e of t)if(!(e.frontend_input!=="MULTILINE"||e.multiline_count<2))for(let r=2;r<=e.multiline_count;r++){const o={...e,is_required:!1,name:`${e.code}_multiline_${r}`,code:`${e.code}_multiline_${r}`,id:`${e.code}_multiline_${r}`};n.push(o)}return n},R=t=>{var i,c,a;const n=((c=(i=t==null?void 0:t.data)==null?void 0:i.attributesForm)==null?void 0:c.items)||[];if(!n.length)return[];const e=(a=n.filter(u=>{var l;return!((l=u.frontend_input)!=null&&l.includes("HIDDEN"))}))==null?void 0:a.map(({code:u,...l})=>{const m=u!=="country_id"?u:"country_code";return{...l,name:m,id:m,code:m}}),r=y(e);return e.concat(r).map(u=>{var E;const l=u.code==="middlename"?"middleName":u.code==="firstname"?"firstName":u.code==="lastname"?"lastName":S(u.code),m=(E=u.options)==null?void 0:E.map(h=>({isDefault:h.is_default,text:h.label,value:h.value}));return g({...u,options:m,customUpperCode:l},"camelCase",{frontend_input:"fieldType",frontend_class:"className",is_required:"required",sort_order:"orderNumber"})}).sort((u,l)=>u.orderNumber-l.orderNumber)},v=t=>{const n={};for(const e in t){const r=t[e];!Array.isArray(r)||r.length===0||(e==="custom_attributesV2"?r.forEach(o=>{typeof o=="object"&&"value"in o&&(n[o==null?void 0:o.code]=o==null?void 0:o.value)}):r.length>1?r.forEach((o,i)=>{i===0?n[e]=o:n[`${e}_multiline_${i+1}`]=o}):n[e]=r[0])}return n},N=t=>({prefix:(t==null?void 0:t.prefix)??"",suffix:(t==null?void 0:t.suffix)??"",firstname:(t==null?void 0:t.firstname)??"",lastname:(t==null?void 0:t.lastname)??"",middlename:(t==null?void 0:t.middlename)??""}),O=t=>({id:(t==null?void 0:t.id)??"",vat_id:(t==null?void 0:t.vat_id)??"",postcode:(t==null?void 0:t.postcode)??"",country_code:(t==null?void 0:t.country_code)??""}),I=t=>({company:(t==null?void 0:t.company)??"",telephone:(t==null?void 0:t.telephone)??"",fax:(t==null?void 0:t.fax)??""}),$=t=>{var e,r,o;return g({...N(t),...O(t),...I(t),city:(t==null?void 0:t.city)??"",region:{region:((e=t==null?void 0:t.region)==null?void 0:e.region)??"",region_code:((r=t==null?void 0:t.region)==null?void 0:r.region_code)??"",region_id:((o=t==null?void 0:t.region)==null?void 0:o.region_id)??""},default_shipping:(t==null?void 0:t.default_shipping)||!1,default_billing:(t==null?void 0:t.default_billing)||!1,...v(t)},"camelCase",{})},G=t=>{var r,o;const n=((o=(r=t==null?void 0:t.data)==null?void 0:r.customer)==null?void 0:o.addresses)||[];return n.length?n.map($).sort((i,c)=>(Number(c.defaultBilling)||Number(c.defaultShipping))-(Number(i.defaultBilling)||Number(i.defaultShipping))):[]},M=t=>{var c,a;if(!((a=(c=t==null?void 0:t.data)==null?void 0:c.countries)!=null&&a.length))return{availableCountries:[],countriesWithRequiredRegion:[],optionalZipCountries:[]};const{countries:n,storeConfig:e}=t.data,r=e==null?void 0:e.countries_with_required_region.split(","),o=e==null?void 0:e.optional_zip_countries.split(",");return{availableCountries:n.filter(({two_letter_abbreviation:u,full_name_locale:l})=>!!(u&&l)).map(u=>{const{two_letter_abbreviation:l,full_name_locale:m}=u;return{value:l,text:m}}).sort((u,l)=>u.text.localeCompare(l.text)),countriesWithRequiredRegion:r,optionalZipCountries:o}},U=t=>{var e,r;return(r=(e=t==null?void 0:t.data)==null?void 0:e.country)!=null&&r.available_regions?t.data.country.available_regions.filter(o=>{if(!o)return!1;const{id:i,code:c,name:a}=o;return!!(i&&c&&a)}).map(o=>{const{id:i}=o;return{id:i,text:o.name,value:`${o.code},${o.id}`}}):[]},P=async t=>{const n=`_account_attributesForm_${t}`,e=sessionStorage.getItem(n);return e?JSON.parse(e):await s(t!=="shortRequest"?T:A,{method:"GET",cache:"force-cache",variables:{formCode:t}}).then(r=>{var i;if((i=r.errors)!=null&&i.length)return f(r.errors);const o=R(r);return sessionStorage.setItem(n,JSON.stringify(o)),o}).catch(_)},w=` +`,f=t=>{throw t instanceof DOMException&&t.name==="AbortError"||C.emit("error",{source:"auth",type:"network",error:t}),t},h=t=>{const e=t.map(r=>r.message).join(" ");throw Error(e)},S=t=>{let e=[];for(const r of t)if(!(r.frontend_input!=="MULTILINE"||r.multiline_count<2))for(let n=2;n<=r.multiline_count;n++){const o={...r,is_required:!1,name:`${r.code}_multiline_${n}`,code:`${r.code}_multiline_${n}`,id:`${r.code}_multiline_${n}`};e.push(o)}return e},y=t=>{var i,c,_;const e=((c=(i=t==null?void 0:t.data)==null?void 0:i.attributesForm)==null?void 0:c.items)||[];if(!e.length)return[];const r=(_=e.filter(u=>{var l;return!((l=u.frontend_input)!=null&&l.includes("HIDDEN"))}))==null?void 0:_.map(({code:u,...l})=>{const m=u!=="country_id"?u:"country_code";return{...l,name:m,id:m,code:m}}),n=S(r);return r.concat(n).map(u=>{var g;const l=u.code==="middlename"?"middleName":u.code==="firstname"?"firstName":u.code==="lastname"?"lastName":b(u.code),m=(g=u.options)==null?void 0:g.map(E=>({isDefault:E.is_default,text:E.label,value:E.value}));return a({...u,options:m,customUpperCode:l},"camelCase",{frontend_input:"fieldType",frontend_class:"className",is_required:"required",sort_order:"orderNumber"})}).sort((u,l)=>u.orderNumber-l.orderNumber)},v=t=>{const e={};for(const r in t){const n=t[r];!Array.isArray(n)||n.length===0||(r==="custom_attributesV2"?n.forEach(o=>{typeof o=="object"&&"value"in o&&(e[o==null?void 0:o.code]=o==null?void 0:o.value)}):n.length>1?n.forEach((o,i)=>{i===0?e[r]=o:e[`${r}_multiline_${i+1}`]=o}):e[r]=n[0])}return e},d=t=>{var e,r,n;return a({firstname:(t==null?void 0:t.firstname)||"",lastname:(t==null?void 0:t.lastname)||"",city:(t==null?void 0:t.city)||"",company:(t==null?void 0:t.company)||"",country_code:(t==null?void 0:t.country_code)||"",region:{region:((e=t==null?void 0:t.region)==null?void 0:e.region)||"",region_code:((r=t==null?void 0:t.region)==null?void 0:r.region_code)||"",region_id:((n=t==null?void 0:t.region)==null?void 0:n.region_id)||""},telephone:(t==null?void 0:t.telephone)||"",id:(t==null?void 0:t.id)||"",vat_id:(t==null?void 0:t.vat_id)||"",postcode:(t==null?void 0:t.postcode)||"",default_shipping:(t==null?void 0:t.default_shipping)||!1,default_billing:(t==null?void 0:t.default_billing)||!1,...v(t)},"camelCase",{})},O=t=>{var r,n;const e=((n=(r=t==null?void 0:t.data)==null?void 0:r.customer)==null?void 0:n.addresses)||[];return e.length?e.map(d).sort((o,i)=>(Number(i.defaultBilling)||Number(i.defaultShipping))-(Number(o.defaultBilling)||Number(o.defaultShipping))):[]},$=t=>{var c,_;if(!((_=(c=t==null?void 0:t.data)==null?void 0:c.countries)!=null&&_.length))return{availableCountries:[],countriesWithRequiredRegion:[],optionalZipCountries:[]};const{countries:e,storeConfig:r}=t.data,n=r==null?void 0:r.countries_with_required_region.split(","),o=r==null?void 0:r.optional_zip_countries.split(",");return{availableCountries:e.filter(({two_letter_abbreviation:u,full_name_locale:l})=>!!(u&&l)).map(u=>{const{two_letter_abbreviation:l,full_name_locale:m}=u;return{value:l,text:m}}).sort((u,l)=>u.text.localeCompare(l.text)),countriesWithRequiredRegion:n,optionalZipCountries:o}},N=t=>{var r,n;return(n=(r=t==null?void 0:t.data)==null?void 0:r.country)!=null&&n.available_regions?t.data.country.available_regions.filter(o=>{if(!o)return!1;const{id:i,code:c,name:_}=o;return!!(i&&c&&_)}).map(o=>{const{id:i}=o;return{id:i,text:o.name,value:`${o.code},${o.id}`}}):[]},H=async t=>await s(t!=="shortRequest"?p:R,{method:"GET",cache:"force-cache",variables:{formCode:t}}).then(e=>{var r;return(r=e.errors)!=null&&r.length?h(e.errors):y(e)}).catch(f),G=` mutation CREATE_CUSTOMER_ADDRESS($input: CustomerAddressInput!) { createCustomerAddress(input:$input) { firstname } } -`,d=async t=>await s(w,{method:"POST",variables:{input:g(t,"snakeCase",{custom_attributesV2:"custom_attributesV2",firstName:"firstname",lastName:"lastname",middleName:"middlename"})}}).then(n=>{var e,r,o;return(e=n.errors)!=null&&e.length?f(n.errors):((o=(r=n==null?void 0:n.data)==null?void 0:r.createCustomerAddress)==null?void 0:o.firstname)||""}).catch(_),x=` +`,L=async t=>await s(G,{method:"POST",variables:{input:a(t,"snakeCase",{custom_attributesV2:"custom_attributesV2",firstName:"firstname",lastName:"lastname"})}}).then(e=>{var r,n,o;return(r=e.errors)!=null&&r.length?h(e.errors):((o=(n=e==null?void 0:e.data)==null?void 0:n.createCustomerAddress)==null?void 0:o.firstname)||""}).catch(f),I=` query GET_CUSTOMER_ADDRESS { customer { addresses { firstname lastname - middlename - fax - prefix - suffix city company country_code @@ -86,7 +80,7 @@ import{events as b}from"@dropins/tools/event-bus.js";import{FetchGraphQL as C}fr } } } -`,z=async()=>await s(x,{method:"GET",cache:"no-cache"}).then(t=>{var n;return(n=t.errors)!=null&&n.length?f(t.errors):G(t)}).catch(_),F=` +`,P=async()=>await s(I,{method:"GET",cache:"no-cache"}).then(t=>{var e;return(e=t.errors)!=null&&e.length?h(t.errors):O(t)}).catch(f),M=` query GET_COUNTRIES_QUERY { countries { two_letter_abbreviation @@ -97,7 +91,7 @@ import{events as b}from"@dropins/tools/event-bus.js";import{FetchGraphQL as C}fr optional_zip_countries } } -`,Z=async()=>{const t="_account_countries",n=sessionStorage.getItem(t);return n?JSON.parse(n):await s(F,{method:"GET",cache:"no-cache"}).then(e=>{var o;if((o=e.errors)!=null&&o.length)return f(e.errors);const r=M(e);return sessionStorage.setItem(t,JSON.stringify(r)),r}).catch(_)},q=` +`,z=async()=>await s(M,{method:"GET",cache:"no-cache"}).then(t=>{var e;return(e=t.errors)!=null&&e.length?h(t.errors):$(t)}).catch(f),U=` query GET_REGIONS($countryCode: String!) { country(id: $countryCode) { id @@ -108,15 +102,15 @@ import{events as b}from"@dropins/tools/event-bus.js";import{FetchGraphQL as C}fr } } } -`,W=async t=>{const n=`_account_regions_${t}`,e=sessionStorage.getItem(n);return e?JSON.parse(e):await s(q,{method:"GET",cache:"no-cache",variables:{countryCode:t}}).then(r=>{var i;if((i=r.errors)!=null&&i.length)return f(r.errors);const o=U(r);return sessionStorage.setItem(n,JSON.stringify(o)),o}).catch(_)},V=` +`,Z=async t=>await s(U,{method:"GET",cache:"no-cache",variables:{countryCode:t}}).then(e=>{var r;return(r=e.errors)!=null&&r.length?h(e.errors):N(e)}).catch(f),w=` mutation UPDATE_CUSTOMER_ADDRESS($id: Int!, $input: CustomerAddressInput) { updateCustomerAddress(id:$id, input:$input) { firstname } } -`,Y=async t=>{const{addressId:n,...e}=t;return n?await s(V,{method:"POST",variables:{id:n,input:g(e,"snakeCase",{custom_attributesV2:"custom_attributesV2",firstName:"firstname",lastName:"lastname",middleName:"middlename"})}}).then(r=>{var o,i,c;return(o=r.errors)!=null&&o.length?f(r.errors):((c=(i=r==null?void 0:r.data)==null?void 0:i.updateCustomerAddress)==null?void 0:c.firstname)||""}).catch(_):""},B=` +`,K=async t=>{const{addressId:e,...r}=t;return e?await s(w,{method:"POST",variables:{id:e,input:a(r,"snakeCase",{custom_attributesV2:"custom_attributesV2",firstName:"firstname",lastName:"lastname"})}}).then(n=>{var o,i,c;return(o=n.errors)!=null&&o.length?h(n.errors):((c=(i=n==null?void 0:n.data)==null?void 0:i.updateCustomerAddress)==null?void 0:c.firstname)||""}).catch(f):""},q=` mutation REMOVE_CUSTOMER_ADDRESS($id: Int!) { deleteCustomerAddress(id:$id) } -`,X=async t=>await s(B,{method:"POST",variables:{id:t}}).then(n=>{var e;return(e=n.errors)!=null&&e.length?f(n.errors):n.data.deleteCustomerAddress}).catch(_);export{H as a,K as b,P as c,d,z as e,s as f,L as g,Z as h,W as i,X as j,f as k,_ as l,g as m,S as n,p as o,J as r,k as s,$ as t,Y as u}; +`,W=async t=>await s(q,{method:"POST",variables:{id:t}}).then(e=>{var r;return(r=e.errors)!=null&&r.length?h(e.errors):e.data.deleteCustomerAddress}).catch(f);export{B as a,j as b,H as c,L as d,P as e,s as f,k as g,z as h,Z as i,W as j,a as k,h as l,f as m,b as n,A as o,Q as r,x as s,d as t,K as u}; diff --git a/scripts/__dropins__/storefront-account/chunks/updateCustomer.js b/scripts/__dropins__/storefront-account/chunks/updateCustomer.js index 92e71674e2..bf2d67bd23 100644 --- a/scripts/__dropins__/storefront-account/chunks/updateCustomer.js +++ b/scripts/__dropins__/storefront-account/chunks/updateCustomer.js @@ -1,8 +1,7 @@ -/*! Copyright 2024 Adobe -All Rights Reserved. */ -import{n as N,f as c,k as l,l as C,m as $}from"./removeCustomerAddress.js";const v=t=>{var a,u,r,i,d,f,h,_,e,E,o,S,T,w,P,g,O,A,U,b,n;const m=(r=(u=(a=t==null?void 0:t.data)==null?void 0:a.customer)==null?void 0:u.custom_attributes)==null?void 0:r.reduce((M,R)=>(M[N(R.code)]=R.value??"",M),{});return{email:((d=(i=t==null?void 0:t.data)==null?void 0:i.customer)==null?void 0:d.email)||"",firstName:((h=(f=t==null?void 0:t.data)==null?void 0:f.customer)==null?void 0:h.firstname)||"",lastName:((e=(_=t==null?void 0:t.data)==null?void 0:_.customer)==null?void 0:e.lastname)||"",middleName:((o=(E=t==null?void 0:t.data)==null?void 0:E.customer)==null?void 0:o.middlename)||"",gender:((T=(S=t==null?void 0:t.data)==null?void 0:S.customer)==null?void 0:T.gender)||"1",dateOfBirth:((P=(w=t==null?void 0:t.data)==null?void 0:w.customer)==null?void 0:P.date_of_birth)||"",prefix:((O=(g=t==null?void 0:t.data)==null?void 0:g.customer)==null?void 0:O.prefix)||"",suffix:((U=(A=t==null?void 0:t.data)==null?void 0:A.customer)==null?void 0:U.suffix)||"",createdAt:((n=(b=t==null?void 0:t.data)==null?void 0:b.customer)==null?void 0:n.created_at)||"",...m}},x=` +import{n as $,f as d,l,m as _,k as I}from"./removeCustomerAddress.js";const y=t=>{var r,m,u,c,i,h,C,f,o,e,E,g,T,S,w,n,O,P,b,A,R,U,N;const a=(u=(m=(r=t==null?void 0:t.data)==null?void 0:r.customer)==null?void 0:m.custom_attributes)==null?void 0:u.reduce((G,M)=>(G[$(M.code)]=M.value??"",G),{});return{email:((i=(c=t==null?void 0:t.data)==null?void 0:c.customer)==null?void 0:i.email)||"",firstName:((C=(h=t==null?void 0:t.data)==null?void 0:h.customer)==null?void 0:C.firstname)||"",lastName:((o=(f=t==null?void 0:t.data)==null?void 0:f.customer)==null?void 0:o.lastname)||"",middleName:((E=(e=t==null?void 0:t.data)==null?void 0:e.customer)==null?void 0:E.middlename)||"",gender:(T=(g=t==null?void 0:t.data)==null?void 0:g.customer)==null?void 0:T.gender,dob:((w=(S=t==null?void 0:t.data)==null?void 0:S.customer)==null?void 0:w.dob)||"",dateOfBirth:((O=(n=t==null?void 0:t.data)==null?void 0:n.customer)==null?void 0:O.date_of_birth)||"",prefix:((b=(P=t==null?void 0:t.data)==null?void 0:P.customer)==null?void 0:b.prefix)||"",suffix:((R=(A=t==null?void 0:t.data)==null?void 0:A.customer)==null?void 0:R.suffix)||"",createdAt:((N=(U=t==null?void 0:t.data)==null?void 0:U.customer)==null?void 0:N.created_at)||"",...a}},v=t=>{var a,r,m,u;return{minLength:+((r=(a=t==null?void 0:t.data)==null?void 0:a.storeConfig)==null?void 0:r.minimum_password_length)||3,requiredCharacterClasses:+((u=(m=t==null?void 0:t.data)==null?void 0:m.storeConfig)==null?void 0:u.required_character_classes_number)||0}},x=` fragment BasicCustomerInfo on Customer { date_of_birth + dob email firstname gender @@ -12,7 +11,7 @@ import{n as N,f as c,k as l,l as C,m as $}from"./removeCustomerAddress.js";const suffix created_at } -`,G=` +`,D=` query GET_CUSTOMER { customer { ...BasicCustomerInfo @@ -25,13 +24,21 @@ import{n as N,f as c,k as l,l as C,m as $}from"./removeCustomerAddress.js";const } } } -${x}`,B=async()=>await c(G,{method:"GET",cache:"no-cache"}).then(t=>{var m;return(m=t.errors)!=null&&m.length?l(t.errors):v(t)}).catch(C),I=` +${x}`,k=async()=>await d(D,{method:"GET",cache:"no-cache"}).then(t=>{var a;return(a=t.errors)!=null&&a.length?l(t.errors):y(t)}).catch(_),q=` mutation CHANGE_CUSTOMER_PASSWORD($currentPassword: String!, $newPassword: String!) { changeCustomerPassword(currentPassword: $currentPassword, newPassword: $newPassword) { email } } -`,k=async({currentPassword:t,newPassword:m})=>await c(I,{method:"POST",variables:{currentPassword:t,newPassword:m}}).then(a=>{var u,r,i;return(u=a.errors)!=null&&u.length?l(a.errors):((i=(r=a==null?void 0:a.data)==null?void 0:r.changeCustomerPassword)==null?void 0:i.email)||""}).catch(C),y=` +`,H=async({currentPassword:t,newPassword:a})=>await d(q,{method:"POST",variables:{currentPassword:t,newPassword:a}}).then(r=>{var m,u,c;return(m=r.errors)!=null&&m.length?l(r.errors):((c=(u=r==null?void 0:r.data)==null?void 0:u.changeCustomerPassword)==null?void 0:c.email)||""}).catch(_),F=` + query GET_STORE_CONFIG { + storeConfig { + autocomplete_on_storefront + minimum_password_length + required_character_classes_number + } + } +`,W=async()=>await d(F,{method:"GET",cache:"force-cache"}).then(t=>{var a;return(a=t.errors)!=null&&a.length?l(t.errors):v(t)}).catch(_),V=` mutation UPDATE_CUSTOMER_EMAIL($email: String! $password: String!) { updateCustomerEmail(email:$email password:$password) { customer { @@ -39,7 +46,7 @@ ${x}`,B=async()=>await c(G,{method:"GET",cache:"no-cache"}).then(t=>{var m;retur } } } -`,F=async({email:t,password:m})=>await c(y,{method:"POST",variables:{email:t,password:m}}).then(a=>{var u,r,i,d;return(u=a.errors)!=null&&u.length?l(a.errors):((d=(i=(r=a==null?void 0:a.data)==null?void 0:r.updateCustomerEmail)==null?void 0:i.customer)==null?void 0:d.email)||""}).catch(C),D=` +`,K=async({email:t,password:a})=>await d(V,{method:"POST",variables:{email:t,password:a}}).then(r=>{var m,u,c,i;return(m=r.errors)!=null&&m.length?l(r.errors):((i=(c=(u=r==null?void 0:r.data)==null?void 0:u.updateCustomerEmail)==null?void 0:c.customer)==null?void 0:i.email)||""}).catch(_),B=` mutation UPDATE_CUSTOMER_V2($input: CustomerUpdateInput!) { updateCustomerV2(input:$input) { customer { @@ -47,4 +54,4 @@ ${x}`,B=async()=>await c(G,{method:"GET",cache:"no-cache"}).then(t=>{var m;retur } } } -`,L=async t=>await c(D,{method:"POST",variables:{input:$(t,"snakeCase",{firstName:"firstname",lastName:"lastname",middleName:"middlename",custom_attributesV2:"custom_attributes"})}}).then(m=>{var a,u,r,i;return(a=m.errors)!=null&&a.length?l(m.errors):((i=(r=(u=m==null?void 0:m.data)==null?void 0:u.updateCustomerV2)==null?void 0:r.customer)==null?void 0:i.email)||""}).catch(C);export{F as a,L as b,B as g,k as u}; +`,Q=async t=>await d(B,{method:"POST",variables:{input:I(t,"snakeCase",{firstName:"firstname",lastName:"lastname",middleName:"middlename",custom_attributesV2:"custom_attributes"})}}).then(a=>{var r,m,u,c;return(r=a.errors)!=null&&r.length?l(a.errors):((c=(u=(m=a==null?void 0:a.data)==null?void 0:m.updateCustomerV2)==null?void 0:u.customer)==null?void 0:c.email)||""}).catch(_);export{W as a,K as b,Q as c,k as g,H as u}; diff --git a/scripts/__dropins__/storefront-account/configs/mockDefaultAddress.config.d.ts b/scripts/__dropins__/storefront-account/configs/mockDefaultAddress.config.d.ts index e1e41541a6..c985d9cdcf 100644 --- a/scripts/__dropins__/storefront-account/configs/mockDefaultAddress.config.d.ts +++ b/scripts/__dropins__/storefront-account/configs/mockDefaultAddress.config.d.ts @@ -94,10 +94,6 @@ export declare const mockDefaultAddress: { streetMultiline_2: string; defaultShipping: boolean; defaultBilling: boolean; - fax: string; - middlename: string; - prefix: string; - suffix: string; }; export declare const mockResponseAddressWithText: { firstname: string; @@ -118,10 +114,45 @@ export declare const mockResponseAddressWithText: { default_shipping: boolean; default_billing: boolean; custom_attributesV2: never[]; - fax: string; - middlename: string; - prefix: string; - suffix: string; +}; +export declare const mockResponseAddressEmpty: { + firstname: string; + lastname: string; + city: string; + company: string; + country_code: string; + region: { + region: string; + region_code: string; + region_id: string; + }; + telephone: string; + id: string; + vat_id: string; + postcode: string; + street: string[]; + default_shipping: boolean; + default_billing: boolean; + custom_attributesV2: never[]; +}; +export declare const mockDefaultAddressEmpty: { + firstname: string; + lastname: string; + city: string; + company: string; + countryCode: string; + region: { + region: string; + regionCode: string; + regionId: string; + }; + telephone: string; + id: string; + vatId: string; + postcode: string; + street: string; + defaultShipping: boolean; + defaultBilling: boolean; }; export declare const mockResponseCountries: { two_letter_abbreviation: string; diff --git a/scripts/__dropins__/storefront-account/containers/AddressForm.js b/scripts/__dropins__/storefront-account/containers/AddressForm.js index 9284ac8a3d..154dd81c21 100644 --- a/scripts/__dropins__/storefront-account/containers/AddressForm.js +++ b/scripts/__dropins__/storefront-account/containers/AddressForm.js @@ -1,3 +1 @@ -/*! Copyright 2024 Adobe -All Rights Reserved. */ import{A as l,A as u}from"../chunks/CustomerInformationCard.js";import"@dropins/tools/preact-jsx-runtime.js";import"@dropins/tools/lib.js";import"@dropins/tools/components.js";import"@dropins/tools/preact-hooks.js";import"../chunks/removeCustomerAddress.js";import"@dropins/tools/event-bus.js";import"@dropins/tools/fetch-graphql.js";import"@dropins/tools/i18n.js";import"@dropins/tools/preact-compat.js";import"@dropins/tools/preact.js";export{l as AddressForm,u as default}; diff --git a/scripts/__dropins__/storefront-account/containers/Addresses.js b/scripts/__dropins__/storefront-account/containers/Addresses.js index 836ce978cc..79553d3545 100644 --- a/scripts/__dropins__/storefront-account/containers/Addresses.js +++ b/scripts/__dropins__/storefront-account/containers/Addresses.js @@ -1,3 +1 @@ -/*! Copyright 2024 Adobe -All Rights Reserved. */ import{jsx as s}from"@dropins/tools/preact-jsx-runtime.js";import{classes as B}from"@dropins/tools/lib.js";import{a as C}from"../chunks/CustomerInformationCard.js";import"@dropins/tools/preact-compat.js";import"@dropins/tools/components.js";import"@dropins/tools/preact-hooks.js";import"@dropins/tools/event-bus.js";import"../chunks/removeCustomerAddress.js";import"@dropins/tools/fetch-graphql.js";import"@dropins/tools/i18n.js";import"@dropins/tools/preact.js";const O=({hideActionFormButtons:t,formName:o,slots:e,title:i,addressFormTitle:d,defaultSelectAddressId:m,showFormLoader:p,forwardFormRef:a,showSaveCheckBox:c,saveCheckBoxValue:f,selectShipping:n,selectBilling:l,selectable:u,className:r,withHeader:x,minifiedView:A,withActionsInMinifiedView:h,withActionsInFullSizeView:j,inputsDefaultValueSet:v,showShippingCheckBox:W,showBillingCheckBox:b,shippingCheckBoxValue:g,billingCheckBoxValue:k,onAddressData:q,routeAddressesPage:w,onSuccess:y,onError:z})=>s("div",{className:B(["account-addresses",r]),"data-testid":"addressesid",children:s(C,{hideActionFormButtons:t,formName:o,slots:e,title:i,addressFormTitle:d,defaultSelectAddressId:m,showFormLoader:p,onAddressData:q,forwardFormRef:a,selectShipping:n,selectBilling:l,showSaveCheckBox:c,saveCheckBoxValue:f,selectable:u,className:r,withHeader:x,minifiedView:A,withActionsInMinifiedView:h,withActionsInFullSizeView:j,inputsDefaultValueSet:v,billingCheckBoxValue:k,shippingCheckBoxValue:g,showBillingCheckBox:b,showShippingCheckBox:W,routeAddressesPage:w,onSuccess:y,onError:z})});export{O as Addresses,O as default}; diff --git a/scripts/__dropins__/storefront-account/containers/CustomerInformation.js b/scripts/__dropins__/storefront-account/containers/CustomerInformation.js index f1c2c438af..6e7d20a894 100644 --- a/scripts/__dropins__/storefront-account/containers/CustomerInformation.js +++ b/scripts/__dropins__/storefront-account/containers/CustomerInformation.js @@ -1,3 +1 @@ -/*! Copyright 2024 Adobe -All Rights Reserved. */ -import{jsxs as F,jsx as d,Fragment as ue}from"@dropins/tools/preact-jsx-runtime.js";import{classes as re,Slot as me}from"@dropins/tools/lib.js";import{F as fe,d as he,g as ge,n as D,C as we}from"../chunks/CustomerInformationCard.js";import*as E from"@dropins/tools/preact-compat.js";import{Card as Q,Header as X,InLineAlert as te,InputPassword as R,Button as H}from"@dropins/tools/components.js";import{useState as m,useEffect as B,useCallback as C,useMemo as G}from"@dropins/tools/preact-hooks.js";import"@dropins/tools/event-bus.js";import{g as Ce}from"../chunks/getStoreConfig.js";import{u as Pe,g as pe,b as ee,a as be}from"../chunks/updateCustomer.js";import{useText as x}from"@dropins/tools/i18n.js";import{c as Ve}from"../chunks/removeCustomerAddress.js";import"@dropins/tools/preact.js";import"@dropins/tools/fetch-graphql.js";const Ee=e=>E.createElement("svg",{id:"Icon_Warning_Base",width:24,height:24,viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",...e},E.createElement("g",{clipPath:"url(#clip0_841_1324)"},E.createElement("path",{vectorEffect:"non-scaling-stroke",d:"M11.9949 2.30237L0.802734 21.6977H23.1977L11.9949 2.30237Z",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round"}),E.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"})),E.createElement("defs",null,E.createElement("clipPath",{id:"clip0_841_1324"},E.createElement("rect",{width:24,height:21,fill:"white",transform:"translate(0 1.5)"})))),ye=e=>E.createElement("svg",{width:24,height:24,viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",...e},E.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"}),E.createElement("path",{vectorEffect:"non-scaling-stroke",d:"M6.75 12.762L10.2385 15.75L17.25 9",stroke:"currentColor"})),Ie=e=>E.createElement("svg",{width:24,height:24,viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",...e},E.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"}),E.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"})),Le=()=>{const[e,t]=m(null);return B(()=>{const a=sessionStorage.getItem("accountStoreConfig"),r=a?JSON.parse(a):null;if(r){const{minLength:n,requiredCharacterClasses:s}=r;t({minLength:n,requiredCharacterClasses:s})}else Ce().then(n=>{if(n){const{minLength:s,requiredCharacterClasses:P}=n;sessionStorage.setItem("accountStoreConfig",JSON.stringify(n)),t({minLength:s,requiredCharacterClasses:P})}})},[]),{passwordConfigs:e}},ve=({currentPassword:e,newPassword:t,confirmPassword:a,translations:r})=>{let n={...K};const s=!e.length&&!t.length&&!a.length,P=e.length&&t!==a;return s?(n={...n,currentPassword:r.requiredFieldError,newPassword:r.requiredFieldError,confirmPassword:r.requiredFieldError},{isValid:!1,errors:n}):e.length?t.length?a.length?P?(n={...n,currentPassword:"",newPassword:"",confirmPassword:r.passwordMismatch},{isValid:!1,errors:n}):{isValid:!0,errors:n}:(n={...n,confirmPassword:r.requiredFieldError},{isValid:!1,errors:n}):(n={...n,newPassword:r.requiredFieldError},{isValid:!1,errors:n}):(n={...n,currentPassword:r.requiredFieldError},{isValid:!1,errors:n})},ne=(e,t)=>{if(t<=1)return!0;const a=/[0-9]/.test(e)?1:0,r=/[a-z]/.test(e)?1:0,n=/[A-Z]/.test(e)?1:0,s=/[^a-zA-Z0-9\s]/.test(e)?1:0;return a+r+n+s>=t},K={currentPassword:"",newPassword:"",confirmPassword:""},Fe=({passwordConfigs:e,handleSetInLineAlert:t,handleHideChangePassword:a})=>{const r=x({requiredFieldError:"Account.FormText.requiredFieldError",passwordMismatch:"Account.minifiedView.CustomerInformation.changePassword.passwordValidationMessage.passwordMismatch",incorrectCurrentPassword:"Account.minifiedView.CustomerInformation.changePassword.passwordValidationMessage.incorrectCurrentPassword",passwordUpdateMessage:"Account.minifiedView.CustomerInformation.changePassword.passwordValidationMessage.passwordUpdateMessage"}),[n,s]=m(!1),[P,l]=m(!1),[c,p]=m(""),[h,u]=m(""),[A,y]=m(""),[I,b]=m({currentPassword:"",newPassword:"",confirmPassword:""}),i=C(()=>{a(()=>{t({}),b(K)})},[a,t]),_=C(f=>{p(f),b(V=>({...V,currentPassword:f?"":r.requiredFieldError}))},[r]),w=C(f=>{u(f),b(V=>({...V,newPassword:f?"":r.requiredFieldError}))},[r]),U=C(f=>{y(f),b(V=>({...V,confirmPassword:f?"":r.requiredFieldError}))},[r]),M=C(f=>{const{name:V,value:Z}=f==null?void 0:f.target;b(L=>({...L,[V]:Z?"":r.requiredFieldError}))},[r]),T=C(()=>{const{isValid:f,errors:V}=ve({currentPassword:c,newPassword:h,confirmPassword:A,translations:r});return b(V),f},[c,h,A,r]),O=C(f=>{f.preventDefault(),l(!0);const V=(e==null?void 0:e.requiredCharacterClasses)??0,Z=(e==null?void 0:e.minLength)??1;if(!T()){s(!0),l(!1);return}if(!ne(h,V)||Z>(h==null?void 0:h.length)){s(!0),l(!1);return}Pe({currentPassword:c,newPassword:h}).then(L=>{if(!(L!=null&&L.length)){l(!1);return}p(""),u(""),y(""),b(K),s(!1),t({type:"success",text:r.passwordUpdateMessage})}).catch(L=>{L.message==="Invalid login or password."&&t({type:"error",text:r.incorrectCurrentPassword}),L.message==="The account is locked."&&t({type:"error",text:L.message})}),l(!1)},[e,T,h,c,t,r]);return{hideChangePassword:i,handleOnBlurPassword:M,handleConfirmPasswordChange:U,handleNewPasswordChange:w,handleCurrentPasswordChange:_,mutationChangePassword:O,currentPassword:c,newPassword:h,confirmPassword:A,passwordErrors:I,submitLoading:P,isClickSubmit:n}},_e=({passwordConfigs:e,isClickSubmit:t,password:a})=>{const r=x({messageLengthPassword:"Account.minifiedView.CustomerInformation.changePassword.passwordValidationMessage.messageLengthPassword"}),[n,s]=m("pending");B(()=>{if(!e)return;const l=ne(a,e.requiredCharacterClasses);t&&a.length>0?s(l?"success":"error"):t&&a.length===0?s("pending"):s(l?"success":"pending")},[t,e,a]);const P=G(()=>{var c;if(!e)return;const l={status:"pending",icon:"pending",message:(c=r.messageLengthPassword)==null?void 0:c.replace("{minLength}",`${e.minLength}`)};return a.length&&a.length>=e.minLength?{...l,icon:"success",status:"success"}:a.length&&a.length{const{passwordConfigs:r}=Le(),{hideChangePassword:n,handleOnBlurPassword:s,handleConfirmPasswordChange:P,handleNewPasswordChange:l,handleCurrentPasswordChange:c,mutationChangePassword:p,currentPassword:h,newPassword:u,confirmPassword:A,passwordErrors:y,submitLoading:I,isClickSubmit:b}=Fe({passwordConfigs:r,handleSetInLineAlert:t,handleHideChangePassword:e}),{isValidUniqueSymbols:i,defaultLengthMessage:_}=_e({password:u,isClickSubmit:b,passwordConfigs:r}),w=x({containerTitle:"Account.minifiedView.CustomerInformation.changePassword.containerTitle",currentPasswordPlaceholder:"Account.minifiedView.CustomerInformation.changePassword.currentPassword.placeholder",currentPasswordFloatingLabel:"Account.minifiedView.CustomerInformation.changePassword.currentPassword.floatingLabel",newPasswordPlaceholder:"Account.minifiedView.CustomerInformation.changePassword.newPassword.placeholder",newPasswordFloatingLabel:"Account.minifiedView.CustomerInformation.changePassword.newPassword.floatingLabel",confirmPasswordPlaceholder:"Account.minifiedView.CustomerInformation.changePassword.confirmPassword.placeholder",confirmPasswordFloatingLabel:"Account.minifiedView.CustomerInformation.changePassword.confirmPassword.floatingLabel",buttonSecondary:"Account.minifiedView.CustomerInformation.changePassword.buttonSecondary",buttonPrimary:"Account.minifiedView.CustomerInformation.changePassword.buttonPrimary"});return F(Q,{className:"account-change-password",variant:"secondary",children:[d(X,{title:w.containerTitle,divider:!1,className:"account-change-password__title"}),a.text?d(te,{className:"account-change-password__notification",type:a.type,variant:"secondary",heading:a.text,icon:a.icon,"data-testid":"changePasswordInLineAlert"}):null,F("div",{className:"account-change-password__fields",children:[d(R,{className:"account-change-password__fields-item",autoComplete:"currentPassword",name:"currentPassword",placeholder:w.currentPasswordPlaceholder,floatingLabel:w.currentPasswordFloatingLabel,errorMessage:y.currentPassword,defaultValue:h,onValue:c,onBlur:s}),d(R,{className:"account-change-password__fields-item",autoComplete:"newPassword",name:"newPassword",placeholder:w.newPasswordPlaceholder,floatingLabel:w.newPasswordFloatingLabel,minLength:r==null?void 0:r.minLength,validateLengthConfig:_,uniqueSymbolsStatus:i,requiredCharacterClasses:r==null?void 0:r.requiredCharacterClasses,errorMessage:i==="error"||(_==null?void 0:_.status)==="error"||b&&u.length<=0?y.newPassword:void 0,defaultValue:u,onValue:l,onBlur:s}),d(R,{className:"account-change-password__fields-item",autoComplete:"confirmPassword",name:"confirmPassword",placeholder:w.confirmPasswordPlaceholder,floatingLabel:w.confirmPasswordFloatingLabel,errorMessage:y.confirmPassword,defaultValue:A,onValue:P,onBlur:s})]}),F("div",{className:"account-change-password__actions",children:[d(H,{type:"button",disabled:I,onClick:n,variant:"secondary",children:w.buttonSecondary}),d(H,{variant:"primary",type:"button",disabled:I,onClick:p,children:w.buttonPrimary})]})]})},Me=({inLineAlertProps:e,errorPasswordEmpty:t,passwordValue:a,showPasswordOnEmailChange:r,submitLoading:n,formFieldsList:s,handleHideEditForm:P,handleUpdateCustomerInformation:l,handleInputChange:c,handleSetPassword:p,handleOnBlurPassword:h})=>{const u=x({buttonSecondary:"Account.minifiedView.CustomerInformation.editCustomerInformation.buttonSecondary",buttonPrimary:"Account.minifiedView.CustomerInformation.editCustomerInformation.buttonPrimary",placeholder:"Account.minifiedView.CustomerInformation.editCustomerInformation.passwordField.placeholder",floatingLabel:"Account.minifiedView.CustomerInformation.editCustomerInformation.passwordField.floatingLabel",containerTitle:"Account.minifiedView.CustomerInformation.editCustomerInformation.containerTitle",requiredFieldError:"Account.FormText.requiredFieldError"});return F(Q,{variant:"secondary",className:"account-edit-customer-information",children:[d(X,{title:u.containerTitle,divider:!1,className:"account-edit-customer-information__title"}),e.text?d(te,{className:"account-edit-customer-information__notification",type:e.type,variant:"secondary",heading:e.text,icon:e.icon,"data-testid":"editCustomerInLineAlert"}):null,F(fe,{loading:n,fieldsConfig:s||[],name:"editCustomerInformation",className:"account-edit-customer-information-form",onSubmit:l,setInputChange:c,children:[r?d("div",{className:"account-edit-customer-information__password",children:d(R,{autoComplete:"password",name:"password",placeholder:u.placeholder,floatingLabel:u.floatingLabel,errorMessage:t?u.requiredFieldError:void 0,defaultValue:a,onValue:p,onBlur:h})}):null,F("div",{className:"account-edit-customer-information__actions",children:[d(H,{disabled:n,type:"button",variant:"secondary",onClick:()=>P(),children:u.buttonSecondary}),d(H,{disabled:n,type:"submit",variant:"primary",children:u.buttonPrimary})]})]})]})},Se=({createdAt:e,slots:t,orderedCustomerData:a,showEditForm:r,showChangePassword:n,handleShowChangePassword:s,handleShowEditForm:P})=>{const l=x({buttonSecondary:"Account.minifiedView.CustomerInformation.customerInformationCard.buttonSecondary",buttonPrimary:"Account.minifiedView.CustomerInformation.customerInformationCard.buttonPrimary",accountCreation:"Account.minifiedView.CustomerInformation.customerInformationCard.accountCreation"});return d(Q,{variant:"secondary",className:re(["account-customer-information-card",["account-customer-information-card-short",n||r]]),children:F("div",{className:"account-customer-information-card__wrapper",children:[d("div",{className:"account-customer-information-card__content",children:t!=null&&t.CustomerData?d(me,{name:"CustomerData",slot:t==null?void 0:t.CustomerData,context:{customerData:a}}):F(ue,{children:[a==null?void 0:a.map((c,p)=>{const h=c!=null&&c.label?`${c.label}: ${c==null?void 0:c.value}`:c==null?void 0:c.value;return d("p",{"data-testid":`${c.name}_${p}`,children:h},`${c.name}_${p}`)}),F("p",{children:[l.accountCreation,": ",e]})]})}),F("div",{className:"account-customer-information-card__actions",children:[d(H,{type:"button",variant:"tertiary",onClick:s,children:l.buttonSecondary}),d(H,{type:"button",variant:"tertiary",onClick:P,children:l.buttonPrimary})]})]})})},Ne=({handleSetInLineAlert:e})=>{const t=x({accountSuccess:"Account.minifiedView.CustomerInformation.editCustomerInformation.accountSuccess",accountError:"Account.minifiedView.CustomerInformation.editCustomerInformation.accountError",genderMale:"Account.minifiedView.CustomerInformation.genderMale",genderFemale:"Account.minifiedView.CustomerInformation.genderFemale"}),[a,r]=m(!0),[n,s]=m(!1),[P,l]=m(!1),[c,p]=m(!1),[h,u]=m(!1),[A,y]=m(!1),[I,b]=m([]),[i,_]=m(null),[w,U]=m([]),[M,T]=m({}),[O,f]=m(""),[V,Z]=m(""),L=C(o=>{const{value:g}=o==null?void 0:o.target;g.length&&u(!1),g.length||u(!0)},[]),S=C(o=>{f(o)},[]),oe=C(o=>{T(o)},[]),ae=C(()=>{l(!0),p(!1),e(),S("")},[e,S]),se=C(o=>{o==null||o(),l(!1)},[]),ie=C(()=>{p(!0),l(!1),e(),S("")},[e,S]),ce=C(o=>{o==null||o(),p(!1)},[]),N=C((o,g)=>{o==="success"?e({type:"success",text:g??t.accountSuccess}):o==="error"?e({type:"error",text:g??t.accountError}):e(),s(!1)},[e,t]),W=C(()=>{pe().then(o=>{var v;const g=(v=o==null?void 0:o.createdAt)==null?void 0:v.split(" ")[0],z={...o,gender:o.gender===1?t.genderMale:t.genderFemale};_(z),Z(g)})},[t.genderFemale,t.genderMale]);B(()=>{W()},[]),B(()=>{Ve("customer_account_edit").then(o=>{U(o);const g=o.map(({name:z,customUpperCode:v,orderNumber:q,label:j})=>({name:v,orderNumber:q,label:he.includes(z)?null:j}));b(g)})},[]),B(()=>{M.email&&M.email!==(i==null?void 0:i.email)?y(!0):M.email&&M.email===(i==null?void 0:i.email)&&y(!1)},[i==null?void 0:i.email,M]);const $=G(()=>!I||!i?[]:I.filter(({name:g})=>g!==void 0&&i[g]).map(g=>({name:g.name,orderNumber:g.orderNumber,value:i[g.name],label:g.label})),[i,I]);B(()=>{$!=null&&$.length&&r(!1)},[$]);const de=G(()=>w==null?void 0:w.map(o=>({...o,defaultValue:o!=null&&o.customUpperCode&&i?i[o==null?void 0:o.customUpperCode]??"":""})).map(o=>o.customUpperCode==="gender"?{...o,defaultValue:o.defaultValue==="Male"?1:2}:o),[w,i]),le=C(async(o,g)=>{const z=ge(o.target),{email:v,password:q,...j}=z,Y=v!==(i==null?void 0:i.email)&&q.length===0;if(!g){Y&&u(!0);return}if(u(!1),s(!0),v===(i==null?void 0:i.email)){S(""),ee(D(j,"account")).then(k=>{k&&(W(),N("success"))}).catch(k=>{N("error",k.message)});return}if(Y){u(!0),s(!1);return}v!=null&&v.length&&(q!=null&&q.length)&&be({email:v,password:q}).then(k=>{k&&ee(D(j,"account")).then(J=>{J&&(W(),N("success"))}).catch(J=>{N("error",J.message)})}).catch(k=>{N("error",k.message)})},[i==null?void 0:i.email,S,W,N]);return{createdAt:V,errorPasswordEmpty:h,passwordValue:O,showPasswordOnEmailChange:A,orderedCustomerData:$,loading:a,normalizeFieldsConfig:de,submitLoading:n,showEditForm:c,showChangePassword:P,handleShowChangePassword:ae,handleHideChangePassword:se,handleShowEditForm:ie,handleHideEditForm:ce,handleUpdateCustomerInformation:le,handleInputChange:oe,handleSetPassword:S,handleOnBlurPassword:L,renderAlertMessage:N}},qe={success:d(ye,{}),warning:d(Ee,{}),error:d(Ie,{})},ke=()=>{const[e,t]=m({}),a=C(r=>{if(!(r!=null&&r.type)){t({});return}const n=qe[r.type];t({...r,icon:n})},[]);return{inLineAlertProps:e,handleSetInLineAlert:a}},Je=({className:e,withHeader:t=!0,slots:a})=>{const r=x({containerTitle:"Account.minifiedView.CustomerInformation.containerTitle"}),{inLineAlertProps:n,handleSetInLineAlert:s}=ke(),{createdAt:P,errorPasswordEmpty:l,passwordValue:c,showPasswordOnEmailChange:p,orderedCustomerData:h,loading:u,normalizeFieldsConfig:A,submitLoading:y,showEditForm:I,showChangePassword:b,handleShowChangePassword:i,handleHideChangePassword:_,handleShowEditForm:w,handleHideEditForm:U,handleUpdateCustomerInformation:M,handleInputChange:T,handleSetPassword:O,handleOnBlurPassword:f}=Ne({handleSetInLineAlert:s});return u?d("div",{"data-testid":"customerInformationLoader",children:d(we,{withCard:!0})}):F("div",{className:re(["account-customer-information",e]),children:[t?d(X,{title:r.containerTitle,divider:!1,className:"customer-information__title"}):null,d(Se,{createdAt:P,slots:a,orderedCustomerData:h,showEditForm:I,showChangePassword:b,handleShowChangePassword:i,handleShowEditForm:w}),b?d(Ae,{inLineAlertProps:n,handleSetInLineAlert:s,handleHideChangePassword:_}):null,I?d(Me,{inLineAlertProps:n,submitLoading:y,formFieldsList:A,errorPasswordEmpty:l,passwordValue:c,showPasswordOnEmailChange:p,handleSetPassword:O,handleOnBlurPassword:f,handleUpdateCustomerInformation:M,handleHideEditForm:U,handleInputChange:T}):null]})};export{Je as CustomerInformation,Je as default}; +import{jsxs as F,jsx as d,Fragment as ue}from"@dropins/tools/preact-jsx-runtime.js";import{classes as re,Slot as me}from"@dropins/tools/lib.js";import{F as fe,d as he,g as ge,n as D,C as we}from"../chunks/CustomerInformationCard.js";import*as E from"@dropins/tools/preact-compat.js";import{Card as Q,Header as X,InLineAlert as te,InputPassword as R,Button as H}from"@dropins/tools/components.js";import{useState as m,useEffect as B,useCallback as C,useMemo as G}from"@dropins/tools/preact-hooks.js";import"@dropins/tools/event-bus.js";import{a as Ce,u as Pe,g as pe,c as ee,b as be}from"../chunks/updateCustomer.js";import{useText as x}from"@dropins/tools/i18n.js";import{c as Ve}from"../chunks/removeCustomerAddress.js";import"@dropins/tools/preact.js";import"@dropins/tools/fetch-graphql.js";const Ee=e=>E.createElement("svg",{id:"Icon_Warning_Base",width:24,height:24,viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",...e},E.createElement("g",{clipPath:"url(#clip0_841_1324)"},E.createElement("path",{vectorEffect:"non-scaling-stroke",d:"M11.9949 2.30237L0.802734 21.6977H23.1977L11.9949 2.30237Z",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round"}),E.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"})),E.createElement("defs",null,E.createElement("clipPath",{id:"clip0_841_1324"},E.createElement("rect",{width:24,height:21,fill:"white",transform:"translate(0 1.5)"})))),ye=e=>E.createElement("svg",{width:24,height:24,viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",...e},E.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"}),E.createElement("path",{vectorEffect:"non-scaling-stroke",d:"M6.75 12.762L10.2385 15.75L17.25 9",stroke:"currentColor"})),Ie=e=>E.createElement("svg",{width:24,height:24,viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",...e},E.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"}),E.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"})),Le=()=>{const[e,t]=m(null);return B(()=>{const a=sessionStorage.getItem("accountStoreConfig"),r=a?JSON.parse(a):null;if(r){const{minLength:n,requiredCharacterClasses:s}=r;t({minLength:n,requiredCharacterClasses:s})}else Ce().then(n=>{if(n){const{minLength:s,requiredCharacterClasses:P}=n;sessionStorage.setItem("accountStoreConfig",JSON.stringify(n)),t({minLength:s,requiredCharacterClasses:P})}})},[]),{passwordConfigs:e}},ve=({currentPassword:e,newPassword:t,confirmPassword:a,translations:r})=>{let n={...K};const s=!e.length&&!t.length&&!a.length,P=e.length&&t!==a;return s?(n={...n,currentPassword:r.requiredFieldError,newPassword:r.requiredFieldError,confirmPassword:r.requiredFieldError},{isValid:!1,errors:n}):e.length?t.length?a.length?P?(n={...n,currentPassword:"",newPassword:"",confirmPassword:r.passwordMismatch},{isValid:!1,errors:n}):{isValid:!0,errors:n}:(n={...n,confirmPassword:r.requiredFieldError},{isValid:!1,errors:n}):(n={...n,newPassword:r.requiredFieldError},{isValid:!1,errors:n}):(n={...n,currentPassword:r.requiredFieldError},{isValid:!1,errors:n})},ne=(e,t)=>{if(t<=1)return!0;const a=/[0-9]/.test(e)?1:0,r=/[a-z]/.test(e)?1:0,n=/[A-Z]/.test(e)?1:0,s=/[^a-zA-Z0-9\s]/.test(e)?1:0;return a+r+n+s>=t},K={currentPassword:"",newPassword:"",confirmPassword:""},Fe=({passwordConfigs:e,handleSetInLineAlert:t,handleHideChangePassword:a})=>{const r=x({requiredFieldError:"Account.FormText.requiredFieldError",passwordMismatch:"Account.minifiedView.CustomerInformation.changePassword.passwordValidationMessage.passwordMismatch",incorrectCurrentPassword:"Account.minifiedView.CustomerInformation.changePassword.passwordValidationMessage.incorrectCurrentPassword",passwordUpdateMessage:"Account.minifiedView.CustomerInformation.changePassword.passwordValidationMessage.passwordUpdateMessage"}),[n,s]=m(!1),[P,l]=m(!1),[c,p]=m(""),[h,u]=m(""),[A,y]=m(""),[I,b]=m({currentPassword:"",newPassword:"",confirmPassword:""}),i=C(()=>{a(()=>{t({}),b(K)})},[a,t]),_=C(f=>{p(f),b(V=>({...V,currentPassword:f?"":r.requiredFieldError}))},[r]),w=C(f=>{u(f),b(V=>({...V,newPassword:f?"":r.requiredFieldError}))},[r]),U=C(f=>{y(f),b(V=>({...V,confirmPassword:f?"":r.requiredFieldError}))},[r]),M=C(f=>{const{name:V,value:Z}=f==null?void 0:f.target;b(L=>({...L,[V]:Z?"":r.requiredFieldError}))},[r]),T=C(()=>{const{isValid:f,errors:V}=ve({currentPassword:c,newPassword:h,confirmPassword:A,translations:r});return b(V),f},[c,h,A,r]),O=C(f=>{f.preventDefault(),l(!0);const V=(e==null?void 0:e.requiredCharacterClasses)??0,Z=(e==null?void 0:e.minLength)??1;if(!T()){s(!0),l(!1);return}if(!ne(h,V)||Z>(h==null?void 0:h.length)){s(!0),l(!1);return}Pe({currentPassword:c,newPassword:h}).then(L=>{if(!(L!=null&&L.length)){l(!1);return}p(""),u(""),y(""),b(K),s(!1),t({type:"success",text:r.passwordUpdateMessage})}).catch(L=>{L.message==="Invalid login or password."&&t({type:"error",text:r.incorrectCurrentPassword}),L.message==="The account is locked."&&t({type:"error",text:L.message})}),l(!1)},[e,T,h,c,t,r]);return{hideChangePassword:i,handleOnBlurPassword:M,handleConfirmPasswordChange:U,handleNewPasswordChange:w,handleCurrentPasswordChange:_,mutationChangePassword:O,currentPassword:c,newPassword:h,confirmPassword:A,passwordErrors:I,submitLoading:P,isClickSubmit:n}},_e=({passwordConfigs:e,isClickSubmit:t,password:a})=>{const r=x({messageLengthPassword:"Account.minifiedView.CustomerInformation.changePassword.passwordValidationMessage.messageLengthPassword"}),[n,s]=m("pending");B(()=>{if(!e)return;const l=ne(a,e.requiredCharacterClasses);t&&a.length>0?s(l?"success":"error"):t&&a.length===0?s("pending"):s(l?"success":"pending")},[t,e,a]);const P=G(()=>{var c;if(!e)return;const l={status:"pending",icon:"pending",message:(c=r.messageLengthPassword)==null?void 0:c.replace("{minLength}",`${e.minLength}`)};return a.length&&a.length>=e.minLength?{...l,icon:"success",status:"success"}:a.length&&a.length{const{passwordConfigs:r}=Le(),{hideChangePassword:n,handleOnBlurPassword:s,handleConfirmPasswordChange:P,handleNewPasswordChange:l,handleCurrentPasswordChange:c,mutationChangePassword:p,currentPassword:h,newPassword:u,confirmPassword:A,passwordErrors:y,submitLoading:I,isClickSubmit:b}=Fe({passwordConfigs:r,handleSetInLineAlert:t,handleHideChangePassword:e}),{isValidUniqueSymbols:i,defaultLengthMessage:_}=_e({password:u,isClickSubmit:b,passwordConfigs:r}),w=x({containerTitle:"Account.minifiedView.CustomerInformation.changePassword.containerTitle",currentPasswordPlaceholder:"Account.minifiedView.CustomerInformation.changePassword.currentPassword.placeholder",currentPasswordFloatingLabel:"Account.minifiedView.CustomerInformation.changePassword.currentPassword.floatingLabel",newPasswordPlaceholder:"Account.minifiedView.CustomerInformation.changePassword.newPassword.placeholder",newPasswordFloatingLabel:"Account.minifiedView.CustomerInformation.changePassword.newPassword.floatingLabel",confirmPasswordPlaceholder:"Account.minifiedView.CustomerInformation.changePassword.confirmPassword.placeholder",confirmPasswordFloatingLabel:"Account.minifiedView.CustomerInformation.changePassword.confirmPassword.floatingLabel",buttonSecondary:"Account.minifiedView.CustomerInformation.changePassword.buttonSecondary",buttonPrimary:"Account.minifiedView.CustomerInformation.changePassword.buttonPrimary"});return F(Q,{className:"account-change-password",variant:"secondary",children:[d(X,{title:w.containerTitle,divider:!1,className:"account-change-password__title"}),a.text?d(te,{className:"account-change-password__notification",type:a.type,variant:"secondary",heading:a.text,icon:a.icon,"data-testid":"changePasswordInLineAlert"}):null,F("div",{className:"account-change-password__fields",children:[d(R,{className:"account-change-password__fields-item",autoComplete:"currentPassword",name:"currentPassword",placeholder:w.currentPasswordPlaceholder,floatingLabel:w.currentPasswordFloatingLabel,errorMessage:y.currentPassword,defaultValue:h,onValue:c,onBlur:s}),d(R,{className:"account-change-password__fields-item",autoComplete:"newPassword",name:"newPassword",placeholder:w.newPasswordPlaceholder,floatingLabel:w.newPasswordFloatingLabel,minLength:r==null?void 0:r.minLength,validateLengthConfig:_,uniqueSymbolsStatus:i,requiredCharacterClasses:r==null?void 0:r.requiredCharacterClasses,errorMessage:i==="error"||(_==null?void 0:_.status)==="error"||b&&u.length<=0?y.newPassword:void 0,defaultValue:u,onValue:l,onBlur:s}),d(R,{className:"account-change-password__fields-item",autoComplete:"confirmPassword",name:"confirmPassword",placeholder:w.confirmPasswordPlaceholder,floatingLabel:w.confirmPasswordFloatingLabel,errorMessage:y.confirmPassword,defaultValue:A,onValue:P,onBlur:s})]}),F("div",{className:"account-change-password__actions",children:[d(H,{type:"button",disabled:I,onClick:n,variant:"secondary",children:w.buttonSecondary}),d(H,{variant:"primary",type:"button",disabled:I,onClick:p,children:w.buttonPrimary})]})]})},Me=({inLineAlertProps:e,errorPasswordEmpty:t,passwordValue:a,showPasswordOnEmailChange:r,submitLoading:n,formFieldsList:s,handleHideEditForm:P,handleUpdateCustomerInformation:l,handleInputChange:c,handleSetPassword:p,handleOnBlurPassword:h})=>{const u=x({buttonSecondary:"Account.minifiedView.CustomerInformation.editCustomerInformation.buttonSecondary",buttonPrimary:"Account.minifiedView.CustomerInformation.editCustomerInformation.buttonPrimary",placeholder:"Account.minifiedView.CustomerInformation.editCustomerInformation.passwordField.placeholder",floatingLabel:"Account.minifiedView.CustomerInformation.editCustomerInformation.passwordField.floatingLabel",containerTitle:"Account.minifiedView.CustomerInformation.editCustomerInformation.containerTitle",requiredFieldError:"Account.FormText.requiredFieldError"});return F(Q,{variant:"secondary",className:"account-edit-customer-information",children:[d(X,{title:u.containerTitle,divider:!1,className:"account-edit-customer-information__title"}),e.text?d(te,{className:"account-edit-customer-information__notification",type:e.type,variant:"secondary",heading:e.text,icon:e.icon,"data-testid":"editCustomerInLineAlert"}):null,F(fe,{loading:n,fieldsConfig:s||[],name:"editCustomerInformation",className:"account-edit-customer-information-form",onSubmit:l,setInputChange:c,children:[r?d("div",{className:"account-edit-customer-information__password",children:d(R,{autoComplete:"password",name:"password",placeholder:u.placeholder,floatingLabel:u.floatingLabel,errorMessage:t?u.requiredFieldError:void 0,defaultValue:a,onValue:p,onBlur:h})}):null,F("div",{className:"account-edit-customer-information__actions",children:[d(H,{disabled:n,type:"button",variant:"secondary",onClick:()=>P(),children:u.buttonSecondary}),d(H,{disabled:n,type:"submit",variant:"primary",children:u.buttonPrimary})]})]})]})},Se=({createdAt:e,slots:t,orderedCustomerData:a,showEditForm:r,showChangePassword:n,handleShowChangePassword:s,handleShowEditForm:P})=>{const l=x({buttonSecondary:"Account.minifiedView.CustomerInformation.customerInformationCard.buttonSecondary",buttonPrimary:"Account.minifiedView.CustomerInformation.customerInformationCard.buttonPrimary",accountCreation:"Account.minifiedView.CustomerInformation.customerInformationCard.accountCreation"});return d(Q,{variant:"secondary",className:re(["account-customer-information-card",["account-customer-information-card-short",n||r]]),children:F("div",{className:"account-customer-information-card__wrapper",children:[d("div",{className:"account-customer-information-card__content",children:t!=null&&t.CustomerData?d(me,{name:"CustomerData",slot:t==null?void 0:t.CustomerData,context:{customerData:a}}):F(ue,{children:[a==null?void 0:a.map((c,p)=>{const h=c!=null&&c.label?`${c.label}: ${c==null?void 0:c.value}`:c==null?void 0:c.value;return d("p",{"data-testid":`${c.name}_${p}`,children:h},`${c.name}_${p}`)}),F("p",{children:[l.accountCreation,": ",e]})]})}),F("div",{className:"account-customer-information-card__actions",children:[d(H,{type:"button",variant:"tertiary",onClick:s,children:l.buttonSecondary}),d(H,{type:"button",variant:"tertiary",onClick:P,children:l.buttonPrimary})]})]})})},Ne=({handleSetInLineAlert:e})=>{const t=x({accountSuccess:"Account.minifiedView.CustomerInformation.editCustomerInformation.accountSuccess",accountError:"Account.minifiedView.CustomerInformation.editCustomerInformation.accountError",genderMale:"Account.minifiedView.CustomerInformation.genderMale",genderFemale:"Account.minifiedView.CustomerInformation.genderFemale"}),[a,r]=m(!0),[n,s]=m(!1),[P,l]=m(!1),[c,p]=m(!1),[h,u]=m(!1),[A,y]=m(!1),[I,b]=m([]),[i,_]=m(null),[w,U]=m([]),[M,T]=m({}),[O,f]=m(""),[V,Z]=m(""),L=C(o=>{const{value:g}=o==null?void 0:o.target;g.length&&u(!1),g.length||u(!0)},[]),S=C(o=>{f(o)},[]),oe=C(o=>{T(o)},[]),ae=C(()=>{l(!0),p(!1),e(),S("")},[e,S]),se=C(o=>{o==null||o(),l(!1)},[]),ie=C(()=>{p(!0),l(!1),e(),S("")},[e,S]),ce=C(o=>{o==null||o(),p(!1)},[]),N=C((o,g)=>{o==="success"?e({type:"success",text:g??t.accountSuccess}):o==="error"?e({type:"error",text:g??t.accountError}):e(),s(!1)},[e,t]),W=C(()=>{pe().then(o=>{var v;const g=(v=o==null?void 0:o.createdAt)==null?void 0:v.split(" ")[0],z={...o,gender:o.gender===1?t.genderMale:t.genderFemale};_(z),Z(g)})},[t.genderFemale,t.genderMale]);B(()=>{W()},[]),B(()=>{Ve("customer_account_edit").then(o=>{U(o);const g=o.map(({name:z,customUpperCode:v,orderNumber:q,label:j})=>({name:v,orderNumber:q,label:he.includes(z)?null:j}));b(g)})},[]),B(()=>{M.email&&M.email!==(i==null?void 0:i.email)?y(!0):M.email&&M.email===(i==null?void 0:i.email)&&y(!1)},[i==null?void 0:i.email,M]);const $=G(()=>!I||!i?[]:I.filter(({name:g})=>g!==void 0&&i[g]).map(g=>({name:g.name,orderNumber:g.orderNumber,value:i[g.name],label:g.label})),[i,I]);B(()=>{$!=null&&$.length&&r(!1)},[$]);const de=G(()=>w==null?void 0:w.map(o=>({...o,defaultValue:o!=null&&o.customUpperCode&&i?i[o==null?void 0:o.customUpperCode]??"":""})).map(o=>o.customUpperCode==="gender"?{...o,defaultValue:o.defaultValue==="Male"?1:2}:o),[w,i]),le=C(async(o,g)=>{const z=ge(o.target),{email:v,password:q,...j}=z,Y=v!==(i==null?void 0:i.email)&&q.length===0;if(!g){Y&&u(!0);return}if(u(!1),s(!0),v===(i==null?void 0:i.email)){S(""),ee(D(j,"account")).then(k=>{k&&(W(),N("success"))}).catch(k=>{N("error",k.message)});return}if(Y){u(!0),s(!1);return}v!=null&&v.length&&(q!=null&&q.length)&&be({email:v,password:q}).then(k=>{k&&ee(D(j,"account")).then(J=>{J&&(W(),N("success"))}).catch(J=>{N("error",J.message)})}).catch(k=>{N("error",k.message)})},[i==null?void 0:i.email,S,W,N]);return{createdAt:V,errorPasswordEmpty:h,passwordValue:O,showPasswordOnEmailChange:A,orderedCustomerData:$,loading:a,normalizeFieldsConfig:de,submitLoading:n,showEditForm:c,showChangePassword:P,handleShowChangePassword:ae,handleHideChangePassword:se,handleShowEditForm:ie,handleHideEditForm:ce,handleUpdateCustomerInformation:le,handleInputChange:oe,handleSetPassword:S,handleOnBlurPassword:L,renderAlertMessage:N}},qe={success:d(ye,{}),warning:d(Ee,{}),error:d(Ie,{})},ke=()=>{const[e,t]=m({}),a=C(r=>{if(!(r!=null&&r.type)){t({});return}const n=qe[r.type];t({...r,icon:n})},[]);return{inLineAlertProps:e,handleSetInLineAlert:a}},Re=({className:e,withHeader:t=!0,slots:a})=>{const r=x({containerTitle:"Account.minifiedView.CustomerInformation.containerTitle"}),{inLineAlertProps:n,handleSetInLineAlert:s}=ke(),{createdAt:P,errorPasswordEmpty:l,passwordValue:c,showPasswordOnEmailChange:p,orderedCustomerData:h,loading:u,normalizeFieldsConfig:A,submitLoading:y,showEditForm:I,showChangePassword:b,handleShowChangePassword:i,handleHideChangePassword:_,handleShowEditForm:w,handleHideEditForm:U,handleUpdateCustomerInformation:M,handleInputChange:T,handleSetPassword:O,handleOnBlurPassword:f}=Ne({handleSetInLineAlert:s});return u?d("div",{"data-testid":"customerInformationLoader",children:d(we,{withCard:!0})}):F("div",{className:re(["account-customer-information",e]),children:[t?d(X,{title:r.containerTitle,divider:!1,className:"customer-information__title"}):null,d(Se,{createdAt:P,slots:a,orderedCustomerData:h,showEditForm:I,showChangePassword:b,handleShowChangePassword:i,handleShowEditForm:w}),b?d(Ae,{inLineAlertProps:n,handleSetInLineAlert:s,handleHideChangePassword:_}):null,I?d(Me,{inLineAlertProps:n,submitLoading:y,formFieldsList:A,errorPasswordEmpty:l,passwordValue:c,showPasswordOnEmailChange:p,handleSetPassword:O,handleOnBlurPassword:f,handleUpdateCustomerInformation:M,handleHideEditForm:U,handleInputChange:T}):null]})};export{Re as CustomerInformation,Re as default}; diff --git a/scripts/__dropins__/storefront-account/containers/OrdersList.js b/scripts/__dropins__/storefront-account/containers/OrdersList.js index 4b594a5824..ee1cfb13ef 100644 --- a/scripts/__dropins__/storefront-account/containers/OrdersList.js +++ b/scripts/__dropins__/storefront-account/containers/OrdersList.js @@ -1,3 +1 @@ -/*! Copyright 2024 Adobe -All Rights Reserved. */ -import{jsx as s,jsxs as u,Fragment as N}from"@dropins/tools/preact-jsx-runtime.js";import{classes as C,Slot as j}from"@dropins/tools/lib.js";import{S as B,c as m,E as U,C as Q}from"../chunks/CustomerInformationCard.js";import"@dropins/tools/preact-compat.js";import{Card as G,Icon as F,ContentGrid as R,Image as J,Header as X,Picker as Z,Pagination as rr}from"@dropins/tools/components.js";import{useText as z}from"@dropins/tools/i18n.js";import{useState as S,useEffect as P,useMemo as tr,useCallback as K}from"@dropins/tools/preact-hooks.js";import"@dropins/tools/event-bus.js";import{g as sr}from"../chunks/getOrderHistoryList.js";import{g as er}from"../chunks/getStoreConfig.js";import"../chunks/removeCustomerAddress.js";import"@dropins/tools/fetch-graphql.js";import"@dropins/tools/preact.js";const V={size:"32",stroke:"2"},W=({minifiedView:a,orderNumber:c,orderToken:r,routeOrdersList:e,routeOrderDetails:L})=>{const n=a?"minifiedView":"fullSizeView",h=z({viewAllOrdersButton:`Account.${n}.OrdersList.viewAllOrdersButton`,ariaLabelLink:`Account.${n}.OrdersList.ariaLabelLink`});return e?s("a",{className:C(["account-orders-list-action",["account-orders-list-action--minifiedView",a]]),"data-testid":"ordersListActionButtonMinifiedView",href:e(),children:s(G,{"data-testid":"ordersListActionMinifiedView",variant:"secondary",children:u("div",{className:"account-orders-list-action__card-wrapper",children:[s("p",{children:h.viewAllOrdersButton}),s(F,{source:B,...V})]})})}):s("a",{"aria-label":`${h.ariaLabelLink} ${c??r}`,href:m(L)?L(c,r):"#",className:"account-orders-list-action","data-testid":"ordersListActionButton",children:s(F,{source:B,...V})})},ar=()=>{const[a,c]=S(window.innerWidth<768);return P(()=>{const r=()=>{c(window.innerWidth<768)};return window.addEventListener("resize",r),()=>{window.removeEventListener("resize",r)}},[]),a},cr=({placeholderImage:a,minifiedView:c,item:r,withThumbnails:e,children:L,slots:n,routeTracking:h,routeOrderProduct:O,routeReturnDetails:A,...b})=>{var p,$,_,k,w,I,x,f,M;const o=c?"minifiedView":"fullSizeView",g=z({orderNumber:`Account.${o}.OrdersList.OrdersListCard.orderNumber`,itemsAmount:`Account.${o}.OrdersList.OrdersListCard.itemsAmount`,carrier:`Account.${o}.OrdersList.OrdersListCard.carrier`,returnsText:`Account.${o}.OrdersList.OrdersListCard.returns`,deliveryDateText:`Account.${o}.OrdersList.OrdersListCard.orderDate`}),d=ar(),y=m(O);return u(G,{variant:"secondary",...b,className:C(["account-orders-list-card",["account-orders-list-card--full",((p=r==null?void 0:r.items)==null?void 0:p.length)>6]]),children:[s("div",{className:"account-orders-list-card__content",children:n!=null&&n.OrdersListCard?s(j,{"data-testid":`ordersListCard${r.id}`,name:"OrdersListCard",slot:n==null?void 0:n.OrdersListCard,context:{orderHistoryListItem:r}}):u(N,{children:[s("div",{children:r==null?void 0:r.status}),u("p",{children:[g.deliveryDateText," ",r==null?void 0:r.orderDate]}),u("p",{children:[g.orderNumber," ",r.number]}),($=r==null?void 0:r.shipments)==null?void 0:$.map(t=>{var l;return(l=t==null?void 0:t.tracking)==null?void 0:l.map(i=>{const v=h==null?void 0:h(i);return u("p",{"data-testid":i.number,children:[s("span",{children:`${g.carrier} ${i.carrier.toLocaleUpperCase()} `}),v?s("a",{href:v,target:"_blank",className:"account-orders-list-card__content--track_number",rel:"noreferrer",children:i.number}):s("span",{className:"account-orders-list-card__content--track_number",children:i.number})]},t.id)})}),r!=null&&r.returns&&((_=r.returns)!=null&&_.length)?u("p",{"data-testid":r.number,children:[u("span",{children:[g.returnsText," "]}),(k=r==null?void 0:r.returns)==null?void 0:k.map(t=>s("span",{"data-testid":t.number,children:u("a",{href:(A==null?void 0:A({orderNumber:r.number,orderToken:r.token,returnNumber:t.number}))??"#",className:"account-orders-list-card__content--return_number",children:[t.number," "]})},t.uid))]},r.id):null,u("p",{children:["$",(w=r==null?void 0:r.total)==null?void 0:w.grandTotal.value]}),u("p",{"data-testid":"itemsAmount",children:[(I=r==null?void 0:r.items)!=null&&I.length?(x=r==null?void 0:r.items)==null?void 0:x.reduce((t,l)=>{const i=(l==null?void 0:l.quantityOrdered)||0;return t+i},0):0," ",g.itemsAmount]}),(f=r==null?void 0:r.items)==null?void 0:f.map((t,l)=>{if(l>=0&&l<10)return u("p",{className:"account-orders-list-card__content--product-name",children:[u("span",{className:"account-orders-list-card__content--quantity",children:[(t==null?void 0:t.quantityOrdered)>1?t==null?void 0:t.quantityOrdered:null," "]}),t==null?void 0:t.productName.replaceAll("-"," ")]},`${l}_${t.id}`);if(l===11)return s("p",{children:"..."},"ellipsis")})]})}),e&&((M=r==null?void 0:r.items)!=null&&M.length)?s(R,{maxColumns:d?3:9,emptyGridContent:s(N,{}),className:C(["account-orders-list-card__images",["account-orders-list-card__images-3",d]]),"data-testid":"ordersListCardImages",children:r.items.map((t,l)=>{var Y,D,E,H,q;const i=(E=(D=(Y=t==null?void 0:t.product)==null?void 0:Y.smallImage)==null?void 0:D.url)!=null&&E.length?(q=(H=t==null?void 0:t.product)==null?void 0:H.smallImage)==null?void 0:q.url:a,v=(t==null?void 0:t.productName)??"";return y?s("a",{href:(O==null?void 0:O(t))??"",target:"_blank",rel:"noreferrer",children:s(J,{src:i,width:65,height:65,alt:v})},t.id+l):s(J,{src:i,width:65,height:65,alt:v},t.id+l)})}):null,s("div",{className:"account-orders-list-card__actions",children:L})]})},nr=({ordersInMinifiedView:a,minifiedView:c,pageSize:r,selectedDate:e,selectedPage:L,handleSetFirstOrderDate:n})=>{const[h,O]=S([]),[A,b]=S({totalPages:1,currentPage:1,pageSize:1}),[o,g]=S(!1),[d,y]=S("");return P(()=>{er().then(p=>{y(p.baseMediaUrl)})},[]),P(()=>{g(!0),sr(c?a:r,e,L).then(p=>{!p||!p.items||(b(p.pageInfo),O(p.items),n==null||n(p.dateOfFirstOrder))}).finally(()=>{g(!1)})},[n,c,a,r,e,L]),{loading:o,orderHistoryListItems:h,pageInfo:A,placeholderImage:d}},T=(a,c=1)=>{const r=new Date,e=new Date(r);switch(a){case"sixMonthsAgo":{e.setMonth(e.getMonth()-c);break}case"oneYearAgo":{e.setFullYear(e.getFullYear()-c);break}default:return""}return{from:e==null?void 0:e.toISOString().split("T")[0],to:`${r==null?void 0:r.toISOString().split("T")[0]} 23:59:59`}},or=a=>{const c=[],r=new Date().getFullYear();for(let e=a;e<=r-1;e++)c.push({value:`{"from":"${e}-01-01","to":"${e+1}-01-01 23:59:59"}`,text:e.toString()});return c},dr=()=>{const a=z({pastSixMonths:"Account.fullSizeView.OrdersList.OrdersListSelectDate.pastSixMonths",currentYear:"Account.fullSizeView.OrdersList.OrdersListSelectDate.currentYear",viewAll:"Account.fullSizeView.OrdersList.OrdersListSelectDate.viewAll"}),[c,r]=S(),[e,L]=S(JSON.stringify(T("sixMonthsAgo",6))),[n,h]=S(1);P(()=>{window==null||window.scrollTo({top:100,behavior:"smooth"})},[n]);const O=tr(()=>{const o=[{value:JSON.stringify(T("sixMonthsAgo",6)),text:a.pastSixMonths},{value:JSON.stringify(T("oneYearAgo",1)),text:a.currentYear},{value:"viewAll",text:a.viewAll}];if(c){const d=new Date(c).getFullYear();o==null||o.splice(2,0,...or(d))}return o},[a,c]),A=K(o=>{r(o)},[]),b=K(o=>{const d=o.target.value;L(d),h(1)},[]);return{selectableDateList:O,selectedDate:e,selectedPage:n,handleSelectDate:b,setSelectedPage:h,handleSetFirstOrderDate:A}},ir=({className:a,withHeader:c=!0,minifiedView:r=!1,withThumbnails:e=!0,withFilter:L=!0,ordersInMinifiedView:n=1,pageSize:h=10,routeOrdersList:O,routeOrderDetails:A,routeReturnDetails:b,routeTracking:o,routeOrderProduct:g,slots:d})=>{const y=r?"minifiedView":"fullSizeView",p=z({containerTitle:`Account.${y}.OrdersList.containerTitle`,dateOrderPlaced:`Account.${y}.OrdersList.dateOrderPlaced`}),{selectableDateList:$,selectedDate:_,handleSelectDate:k,selectedPage:w,setSelectedPage:I,handleSetFirstOrderDate:x}=dr(),{pageInfo:f,loading:M,orderHistoryListItems:t,placeholderImage:l}=nr({minifiedView:r,pageSize:h,ordersInMinifiedView:n,selectedDate:_,selectedPage:w,handleSetFirstOrderDate:x});return u("div",{children:[c?s(X,{"aria-label":p.containerTitle,role:"region",title:p.containerTitle,divider:!r,className:r?"account-orders-list-header":""}):null,u("div",{className:C(["account-orders-list",a]),children:[!r&&L?u("div",{className:"account-orders-list__date-select",children:[s("span",{children:p.dateOrderPlaced}),s(Z,{value:_,name:"orderDatePicker",options:$,handleSelect:k})]}):null,M?s(N,{children:Array.from(Array(f==null?void 0:f.pageSize).keys()).map(i=>s(Q,{testId:"orderSkeletonLoader",withCard:!1},i))}):s(N,{children:t.length?s(N,{children:t.map((i,v)=>s(cr,{placeholderImage:l,routeTracking:o,routeOrderProduct:g,routeReturnDetails:b,minifiedView:r,item:i,withThumbnails:e,slots:d,children:d!=null&&d.OrdersListAction?s(j,{"data-testid":`ordersListActionSlot_${v}`,name:"OrdersListAction",slot:d==null?void 0:d.OrdersListAction,context:{orderHistoryListItem:i}}):s(W,{minifiedView:r,orderNumber:i.number,orderToken:i.token,routeOrderDetails:A})},v))}):s(U,{isEmpty:!t.length,typeList:"orders",minifiedView:r})}),!r&&(f==null?void 0:f.totalPages)>1?s(rr,{totalPages:f==null?void 0:f.totalPages,currentPage:w,onChange:I}):null,r?s(W,{minifiedView:r,routeOrdersList:O}):null]})]})},_r=({className:a,withHeader:c,minifiedView:r,withThumbnails:e,withFilter:L,ordersInMinifiedView:n,pageSize:h,routeOrdersList:O,routeOrderDetails:A,routeReturnDetails:b,routeTracking:o,routeOrderProduct:g,slots:d})=>s("div",{className:C(["account-orders-list",a]),"data-testid":"ordersListId",children:s(ir,{className:a,withHeader:c,minifiedView:r,withThumbnails:e,withFilter:L,ordersInMinifiedView:n,pageSize:h,routeOrdersList:O,routeOrderDetails:A,routeReturnDetails:b,routeTracking:o,routeOrderProduct:g,slots:d})});export{_r as OrdersList,_r as default}; +import{jsx as t,jsxs as L,Fragment as N}from"@dropins/tools/preact-jsx-runtime.js";import{classes as C,Slot as F}from"@dropins/tools/lib.js";import{S as Y,c as J,E as V,C as W}from"../chunks/CustomerInformationCard.js";import"@dropins/tools/preact-compat.js";import{Card as K,Icon as D,ContentGrid as j,Image as E,Header as G,Picker as U,Pagination as m}from"@dropins/tools/components.js";import{useText as I}from"@dropins/tools/i18n.js";import{useState as v,useEffect as z,useMemo as Q,useCallback as H}from"@dropins/tools/preact-hooks.js";import"@dropins/tools/event-bus.js";import{g as R}from"../chunks/getOrderHistoryList.js";import"../chunks/removeCustomerAddress.js";import"@dropins/tools/fetch-graphql.js";import"@dropins/tools/preact.js";const q={size:"32",stroke:"2"},B=({minifiedView:n,orderNumber:r,orderToken:e,routeOrdersList:a,routeOrderDetails:d})=>{const i=n?"minifiedView":"fullSizeView",h=I({viewAllOrdersButton:`Account.${i}.OrdersList.viewAllOrdersButton`,ariaLabelLink:`Account.${i}.OrdersList.ariaLabelLink`});return a?t("a",{className:C(["account-orders-list-action",["account-orders-list-action--minifiedView",n]]),"data-testid":"ordersListActionButtonMinifiedView",href:a(),children:t(K,{"data-testid":"ordersListActionMinifiedView",variant:"secondary",children:L("div",{className:"account-orders-list-action__card-wrapper",children:[t("p",{children:h.viewAllOrdersButton}),t(D,{source:Y,...q})]})})}):t("a",{"aria-label":`${h.ariaLabelLink} ${r??e}`,href:J(d)?d(r,e):"#",className:"account-orders-list-action","data-testid":"ordersListActionButton",children:t(D,{source:Y,...q})})},X=()=>{const[n,r]=v(window.innerWidth<768);return z(()=>{const e=()=>{r(window.innerWidth<768)};return window.addEventListener("resize",e),()=>{window.removeEventListener("resize",e)}},[]),n},Z=({minifiedView:n,item:r,withThumbnails:e,children:a,slots:d,routeTracking:i,routeOrderProduct:h,routeReturnDetails:O,...A})=>{var S,y,$,_,k,w,x,M,g;const p=n?"minifiedView":"fullSizeView",o=I({orderNumber:`Account.${p}.OrdersList.OrdersListCard.orderNumber`,itemsAmount:`Account.${p}.OrdersList.OrdersListCard.itemsAmount`,carrier:`Account.${p}.OrdersList.OrdersListCard.carrier`,returnsText:`Account.${p}.OrdersList.OrdersListCard.returns`,deliveryDateText:`Account.${p}.OrdersList.OrdersListCard.orderDate`}),f=X(),c=J(h);return L(K,{variant:"secondary",...A,className:C(["account-orders-list-card",["account-orders-list-card--full",((S=r==null?void 0:r.items)==null?void 0:S.length)>6]]),children:[t("div",{className:"account-orders-list-card__content",children:d!=null&&d.OrdersListCard?t(F,{"data-testid":`ordersListCard${r.id}`,name:"OrdersListCard",slot:d==null?void 0:d.OrdersListCard,context:{orderHistoryListItem:r}}):L(N,{children:[t("div",{children:r==null?void 0:r.status}),L("p",{children:[o.deliveryDateText," ",r==null?void 0:r.orderDate]}),L("p",{children:[o.orderNumber," ",r.number]}),(y=r==null?void 0:r.shipments)==null?void 0:y.map(s=>{var l;return(l=s==null?void 0:s.tracking)==null?void 0:l.map(u=>{const b=i==null?void 0:i(u);return L("p",{"data-testid":u.number,children:[t("span",{children:`${o.carrier} ${u.carrier.toLocaleUpperCase()} `}),b?t("a",{href:b,target:"_blank",className:"account-orders-list-card__content--track_number",rel:"noreferrer",children:u.number}):t("span",{className:"account-orders-list-card__content--track_number",children:u.number})]},s.id)})}),r!=null&&r.returns&&(($=r.returns)!=null&&$.length)?L("p",{"data-testid":r.number,children:[L("span",{children:[o.returnsText," "]}),(_=r==null?void 0:r.returns)==null?void 0:_.map(s=>t("span",{"data-testid":s.number,children:L("a",{href:(O==null?void 0:O({orderNumber:r.number,orderToken:r.token,returnNumber:s.number}))??"#",className:"account-orders-list-card__content--return_number",children:[s.number," "]})},s.uid))]},r.id):null,L("p",{children:["$",(k=r==null?void 0:r.total)==null?void 0:k.grandTotal.value]}),L("p",{"data-testid":"itemsAmount",children:[(w=r==null?void 0:r.items)!=null&&w.length?(x=r==null?void 0:r.items)==null?void 0:x.reduce((s,l)=>{const u=(l==null?void 0:l.quantityOrdered)||0;return s+u},0):0," ",o.itemsAmount]}),(M=r==null?void 0:r.items)==null?void 0:M.map((s,l)=>{if(l>=0&&l<10)return L("p",{className:"account-orders-list-card__content--product-name",children:[L("span",{className:"account-orders-list-card__content--quantity",children:[(s==null?void 0:s.quantityOrdered)>1?s==null?void 0:s.quantityOrdered:null," "]}),s==null?void 0:s.productName.replaceAll("-"," ")]},`${l}_${s.id}`);if(l===11)return t("p",{children:"..."},"ellipsis")})]})}),e&&((g=r==null?void 0:r.items)!=null&&g.length)?t(j,{maxColumns:f?3:9,emptyGridContent:t(N,{}),className:C(["account-orders-list-card__images",["account-orders-list-card__images-3",f]]),"data-testid":"ordersListCardImages",children:r.items.map((s,l)=>{var T;const u=(T=s==null?void 0:s.product)==null?void 0:T.smallImage.url,b=s==null?void 0:s.productName;return c?t("a",{href:h==null?void 0:h(s),target:"_blank",rel:"noreferrer",children:t(E,{src:u,width:65,height:65,alt:b})},s.id+l):t(E,{src:u,width:65,height:65,alt:b},s.id+l)})}):null,t("div",{className:"account-orders-list-card__actions",children:a})]})},rr=({ordersInMinifiedView:n,minifiedView:r,pageSize:e,selectedDate:a,selectedPage:d,handleSetFirstOrderDate:i})=>{const[h,O]=v([]),[A,p]=v({totalPages:1,currentPage:1,pageSize:1}),[o,f]=v(!1);return z(()=>{f(!0),R(r?n:e,a,d).then(c=>{!c||!c.items||(p(c.pageInfo),O(c.items),i==null||i(c.dateOfFirstOrder))}).finally(()=>{f(!1)})},[i,r,n,e,a,d]),{loading:o,orderHistoryListItems:h,pageInfo:A}},P=(n,r=1)=>{const e=new Date,a=new Date(e);switch(n){case"sixMonthsAgo":{a.setMonth(a.getMonth()-r);break}case"oneYearAgo":{a.setFullYear(a.getFullYear()-r);break}default:return""}return{from:a==null?void 0:a.toISOString().split("T")[0],to:`${e==null?void 0:e.toISOString().split("T")[0]} 23:59:59`}},tr=n=>{const r=[],e=new Date().getFullYear();for(let a=n;a<=e-1;a++)r.push({value:`{"from":"${a}-01-01","to":"${a+1}-01-01 23:59:59"}`,text:a.toString()});return r},sr=()=>{const n=I({pastSixMonths:"Account.fullSizeView.OrdersList.OrdersListSelectDate.pastSixMonths",currentYear:"Account.fullSizeView.OrdersList.OrdersListSelectDate.currentYear",viewAll:"Account.fullSizeView.OrdersList.OrdersListSelectDate.viewAll"}),[r,e]=v(),[a,d]=v(JSON.stringify(P("sixMonthsAgo",6))),[i,h]=v(1);z(()=>{window==null||window.scrollTo({top:100,behavior:"smooth"})},[i]);const O=Q(()=>{const o=[{value:JSON.stringify(P("sixMonthsAgo",6)),text:n.pastSixMonths},{value:JSON.stringify(P("oneYearAgo",1)),text:n.currentYear},{value:"viewAll",text:n.viewAll}];if(r){const c=new Date(r).getFullYear();o==null||o.splice(2,0,...tr(c))}return o},[n,r]),A=H(o=>{e(o)},[]),p=H(o=>{const c=o.target.value;d(c),h(1)},[]);return{selectableDateList:O,selectedDate:a,selectedPage:i,handleSelectDate:p,setSelectedPage:h,handleSetFirstOrderDate:A}},er=({className:n,withHeader:r=!0,minifiedView:e=!1,withThumbnails:a=!0,withFilter:d=!0,ordersInMinifiedView:i=1,pageSize:h=10,routeOrdersList:O,routeOrderDetails:A,routeReturnDetails:p,routeTracking:o,routeOrderProduct:f,slots:c})=>{const S=e?"minifiedView":"fullSizeView",y=I({containerTitle:`Account.${S}.OrdersList.containerTitle`,dateOrderPlaced:`Account.${S}.OrdersList.dateOrderPlaced`}),{selectableDateList:$,selectedDate:_,handleSelectDate:k,selectedPage:w,setSelectedPage:x,handleSetFirstOrderDate:M}=sr(),{pageInfo:g,loading:s,orderHistoryListItems:l}=rr({minifiedView:e,pageSize:h,ordersInMinifiedView:i,selectedDate:_,selectedPage:w,handleSetFirstOrderDate:M});return L("div",{children:[r?t(G,{"aria-label":y.containerTitle,role:"region",title:y.containerTitle,divider:!e,className:e?"account-orders-list-header":""}):null,L("div",{className:C(["account-orders-list",n]),children:[!e&&d?L("div",{className:"account-orders-list__date-select",children:[t("span",{children:y.dateOrderPlaced}),t(U,{value:_,name:"orderDatePicker",options:$,handleSelect:k})]}):null,s?t(N,{children:Array.from(Array(g==null?void 0:g.pageSize).keys()).map(u=>t(W,{testId:"orderSkeletonLoader",withCard:!1},u))}):t(N,{children:l.length?t(N,{children:l.map((u,b)=>t(Z,{routeTracking:o,routeOrderProduct:f,routeReturnDetails:p,minifiedView:e,item:u,withThumbnails:a,slots:c,children:c!=null&&c.OrdersListAction?t(F,{"data-testid":`ordersListActionSlot_${b}`,name:"OrdersListAction",slot:c==null?void 0:c.OrdersListAction,context:{orderHistoryListItem:u}}):t(B,{minifiedView:e,orderNumber:u.number,orderToken:u.token,routeOrderDetails:A})},b))}):t(V,{isEmpty:!l.length,typeList:"orders",minifiedView:e})}),!e&&(g==null?void 0:g.totalPages)>1?t(m,{totalPages:g==null?void 0:g.totalPages,currentPage:w,onChange:x}):null,e?t(B,{minifiedView:e,routeOrdersList:O}):null]})]})},Or=({className:n,withHeader:r,minifiedView:e,withThumbnails:a,withFilter:d,ordersInMinifiedView:i,pageSize:h,routeOrdersList:O,routeOrderDetails:A,routeReturnDetails:p,routeTracking:o,routeOrderProduct:f,slots:c})=>t("div",{className:C(["account-orders-list",n]),"data-testid":"ordersListId",children:t(er,{className:n,withHeader:r,minifiedView:e,withThumbnails:a,withFilter:d,ordersInMinifiedView:i,pageSize:h,routeOrdersList:O,routeOrderDetails:A,routeReturnDetails:p,routeTracking:o,routeOrderProduct:f,slots:c})});export{Or as OrdersList,Or as default}; diff --git a/scripts/__dropins__/storefront-account/data/models/customer.d.ts b/scripts/__dropins__/storefront-account/data/models/customer.d.ts index c39c90e098..31da09a4e5 100644 --- a/scripts/__dropins__/storefront-account/data/models/customer.d.ts +++ b/scripts/__dropins__/storefront-account/data/models/customer.d.ts @@ -3,6 +3,7 @@ export interface CustomerDataModelShort { lastName: string; middleName: string; dateOfBirth: string; + dob: string; prefix: string; gender: 1 | 2 | string; suffix: string; diff --git a/scripts/__dropins__/storefront-account/data/models/store-config.d.ts b/scripts/__dropins__/storefront-account/data/models/store-config.d.ts index d1252c83b8..2f2ba6e973 100644 --- a/scripts/__dropins__/storefront-account/data/models/store-config.d.ts +++ b/scripts/__dropins__/storefront-account/data/models/store-config.d.ts @@ -1,5 +1,4 @@ export interface StoreConfigModel { - baseMediaUrl: string; minLength: number; requiredCharacterClasses: number; } diff --git a/scripts/__dropins__/storefront-account/data/transforms/transform-customer-address.d.ts b/scripts/__dropins__/storefront-account/data/transforms/transform-customer-address.d.ts index f623e26f76..b87aad14d4 100644 --- a/scripts/__dropins__/storefront-account/data/transforms/transform-customer-address.d.ts +++ b/scripts/__dropins__/storefront-account/data/transforms/transform-customer-address.d.ts @@ -1,6 +1,7 @@ import { CustomerAddressesModel } from '../models'; import { AddressResponse, UserAddressesProps } from '../../types'; +export declare const expandArraysInObject: (inputObject: UserAddressesProps) => Record; export declare const transformSingleAddress: (addressData: UserAddressesProps) => CustomerAddressesModel; export declare const transformMultipleAddresses: (response: AddressResponse) => CustomerAddressesModel[] | [ ]; diff --git a/scripts/__dropins__/storefront-account/hooks/containers/useOrdersList.d.ts b/scripts/__dropins__/storefront-account/hooks/containers/useOrdersList.d.ts index c96ecc7466..2ec3945b4d 100644 --- a/scripts/__dropins__/storefront-account/hooks/containers/useOrdersList.d.ts +++ b/scripts/__dropins__/storefront-account/hooks/containers/useOrdersList.d.ts @@ -9,6 +9,5 @@ export declare const useOrdersList: ({ ordersInMinifiedView, minifiedView, pageS currentPage: number; pageSize: number; }; - placeholderImage: string; }; //# sourceMappingURL=useOrdersList.d.ts.map \ No newline at end of file diff --git a/scripts/__dropins__/storefront-account/lib/transformDefaultValuesAddresses.d.ts b/scripts/__dropins__/storefront-account/lib/transformDefaultValuesAddresses.d.ts deleted file mode 100644 index a1343fb736..0000000000 --- a/scripts/__dropins__/storefront-account/lib/transformDefaultValuesAddresses.d.ts +++ /dev/null @@ -1,11 +0,0 @@ -import { CustomerAddressesModel } from '../data/models'; - -type CustomAttributesType = { - customAttributes?: { - code: string; - value: string; - }[]; -}; -export declare const transformDefaultValuesAddresses: (address?: CustomerAddressesModel & CustomAttributesType) => CustomerAddressesModel; -export {}; -//# sourceMappingURL=transformDefaultValuesAddresses.d.ts.map \ No newline at end of file diff --git a/scripts/__dropins__/storefront-account/reload b/scripts/__dropins__/storefront-account/reload deleted file mode 100644 index a954be1565..0000000000 --- a/scripts/__dropins__/storefront-account/reload +++ /dev/null @@ -1 +0,0 @@ -{"at":1733243331774} \ No newline at end of file diff --git a/scripts/__dropins__/storefront-account/render.js b/scripts/__dropins__/storefront-account/render.js index 88b34a3306..fe3b541d85 100644 --- a/scripts/__dropins__/storefront-account/render.js +++ b/scripts/__dropins__/storefront-account/render.js @@ -1,5 +1,3 @@ -/*! Copyright 2024 Adobe -All Rights Reserved. */ (function(e,r){try{if(typeof document<"u"){const a=document.createElement("style"),o=r.styleId;for(const t in r.attributes)a.setAttribute(t,r.attributes[t]);a.setAttribute("data-dropin",o),a.appendChild(document.createTextNode(e));const c=document.querySelector('style[data-dropin="sdk"]');if(c)c.after(a);else{const t=document.querySelector('link[rel="stylesheet"], style');t?t.before(a):document.head.append(a)}}}catch(a){console.error("dropin-styles (injectCodeFunction)",a)}})(`.account-orders-list-header{margin-bottom:var(--spacing-medium)}.account-orders-list ul{list-style:none;margin:0;padding:0}.account-orders-list__date-select{margin-bottom:var(--spacing-xbig)}.account-orders-list__date-select span{display:inline-block;font:var(--type-details-caption-1-font);letter-spacing:var(--type-details-caption-1-letter-spacing);margin-bottom:var(--spacing-xsmall)}.account-orders-list__date-select .dropin-picker{max-width:224px} .account-form{display:grid;flex-direction:column;gap:var(--spacing-medium)}@media (min-width: 768px){.account-form{display:grid;grid-template-columns:repeat(2,1fr)}.account-form>.dropin-field:nth-child(1),.account-form>.dropin-field:nth-child(2){grid-column:span 1}.account-form>.dropin-field:nth-child(3),.account-form>.dropin-field:nth-child(4),.account-form>.dropin-field:nth-child(5){grid-column:span 2}.account-form>.dropin-field:nth-child(6),.account-form>.dropin-field:nth-child(7){grid-column:span 1}.account-form>.dropin-field:nth-child(8),.account-form>.dropin-field:nth-child(9){grid-column:span 1}.account-form>.dropin-field:nth-child(n+10){grid-column:span 2}}.account-form [class$=-hidden]{position:absolute;opacity:0;height:0;width:0;overflow:hidden;clip:rect(0,0,0,0)}.account-account-loaders--card-loader{margin-bottom:var(--spacing-small)}.account-account-loaders--picker-loader div:first-child{max-width:200px}.account-account-loaders--picker-loader div:nth-child(3){max-width:400px}.account-address-card{margin-bottom:var(--spacing-small)}.account-address-card .dropin-card__content{display:grid;grid-template-columns:1fr auto;gap:var(--spacing-small) 0px;grid-template-areas:"description action" "labels action"}.account-address-card .account-address-card__action{display:flex;justify-content:flex-end;align-items:baseline;cursor:pointer;grid-area:action}.account-address-card .account-address-card__action--editbutton{margin-left:var(--spacing-small)}.account-address-card .account-address-card__action button{padding:0}.account-address-card .account-address-card__action button:hover{text-decoration:underline}.account-address-card .account-address-card__description{grid-area:description;margin:0;padding:0}.account-address-card .account-address-card__labels{display:flex;gap:0 var(--spacing-xsmall);grid-area:labels}.account-address-card .account-address-card__description p{font:var(--type-body-1-default-font);letter-spacing:var(--type-body-1-default-letter-spacing);line-height:var(--spacing-xbig);color:var(--color-neutral-800);padding:0;margin:0 var(--spacing-xsmall) 0 0}.account-address-card .account-address-card__description p:nth-child(1),.account-address-card .account-address-card__description p:nth-child(2){margin:0 var(--spacing-xsmall) var(--spacing-xsmall) 0;color:var(--color-neutral-800);font:var(--type-button-2-font);font-weight:500;cursor:default}.account-address-card .account-address-card__description p:nth-child(1),.account-address-card .account-address-card__description p:nth-child(3),.account-address-card .account-address-card__description p:nth-child(4),.account-address-card .account-address-card__description p:nth-child(6){float:left}.account-actions-address{cursor:pointer;padding:var(--spacing-xsmall) var(--spacing-medium);border-radius:var(--shape-border-radius-2);border:var(--shape-border-width-2) solid var(--color-neutral-400);background-color:var(--color-neutral-50);width:100%;height:88px;display:flex;align-items:center;justify-content:space-between}.account-actions-address--selectable{max-width:100%;width:auto}.account-actions-address__title{font:var(--type-button-2-font);letter-spacing:var(--type-button-2-letter-spacing)}.account-actions-address svg{stroke:var(--shape-icon-stroke-4);color:var(--color-neutral-800)}.account-address-modal{position:relative;padding:var(--spacing-xbig) var(--spacing-xxbig) var(--spacing-xxbig) var(--spacing-xxbig);width:100%;margin:auto;max-width:721px}.dropin-modal__body--medium>.dropin-modal__header-title,.dropin-modal__body--full>.dropin-modal__header-title,.account-address-modal .dropin-modal__content{margin:0;align-items:center}.account-address-modal .dropin-modal__header-title-content h3{font:var(--type-headline-1-font);letter-spacing:var(--type-headline-1-letter-spacing);margin:0;padding:0}.account-address-modal .account-address-modal__spinner{position:absolute;top:0;left:0;background-color:var(--color-neutral-200);opacity:.8;width:100%;height:100%;display:flex;justify-content:center;align-items:center;z-index:1}.account-address-modal p{color:var(--color-neutral-800);font:var(--type-body-2-strong-font);letter-spacing:var(--type-body-2-strong-letter-spacing);margin-bottom:var(--spacing-medium)}.account-address-modal .account-address-modal__buttons{display:flex;align-items:center;justify-content:right;gap:0 var(--spacing-small)}.account-empty-list{margin-bottom:var(--spacing-small)}.account-empty-list.account-empty-list--minified,.account-empty-list .dropin-card{border:none}.account-empty-list .dropin-card__content{gap:0;padding:var(--spacing-xxbig)}.account-empty-list.account-empty-list--minified .dropin-card__content{flex-direction:row;align-items:center;padding:var(--spacing-big) var(--spacing-small)}.account-empty-list .dropin-card__content svg{width:64px;height:64px;margin-bottom:var(--spacing-medium)}.account-empty-list.account-empty-list--minified .dropin-card__content svg{margin:0 var(--spacing-small) 0 0;width:32px;height:32px}.account-empty-list .dropin-card__content svg path{fill:var(--color-neutral-800)}.account-empty-list.account-empty-list--minified .dropin-card__content svg path{fill:var(--color-neutral-500)}.account-empty-list .dropin-card__content p{font:var(--type-headline-1-font);letter-spacing:var(--type-headline-1-letter-spacing);color:var(--color-neutral-800)}.account-empty-list.account-empty-list--minified .dropin-card__content p{font:var(--type-body-1-strong-font);color:var(--color-neutral-800)}.account-orders-list-action{margin:0;padding:0;border:none;background-color:transparent;cursor:pointer;text-decoration:none}.account-orders-list-action--minifiedView{width:100%;text-align:left;font:var(--type-body-1-default-font)}.account-orders-list-action.account-orders-list-action--minifiedView:hover{text-decoration:none}.account-orders-list-action--minifiedView .account-orders-list-action__card-wrapper{display:flex;justify-content:space-between;align-items:center;color:var(--color-neutral-800);height:calc(88px - var(--spacing-small) * 2)}.account-orders-list-action__card-wrapper>p{font:var(--type-button-2-font);letter-spacing:var(--type-button-2-letter-spacing)}.account-orders-list-action__card-wrapper svg,.account-orders-list-action svg{color:var(--color-neutral-800)}.account-orders-list-action--minifiedView .dropin-card__content{padding:var(--spacing-small) var(--spacing-medium)}.account-orders-list-action--minifiedView p{font:var(--type-body-1-strong-font)}.account-orders-list-card{height:100%;margin-bottom:var(--spacing-small)}.account-orders-list-card .dropin-card__content{padding:var(--spacing-medium);display:grid;grid-template-areas:"content actions" "imageList actions";gap:0;max-height:100%}.account-orders-list-card .account-orders-list-card__content{grid-area:content;margin-bottom:var(--spacing-small)}.account-orders-list-card__content--quantity{font-weight:500;color:var(--color-neutral-800)}.account-orders-list-card__content--track_number,.account-orders-list-card__content--return_number{font:var(--type-body-1-strong-font);letter-spacing:var(--type-body-1-strong-letter-spacing)}.account-orders-list-card .account-orders-list-card__content>div:first-child{font-weight:500}.account-orders-list-card .account-orders-list-card__content p,.account-orders-list-card .account-orders-list-card__content div{padding:0;text-align:left;font:var(--type-body-1-default-font);margin:0 0 var(--spacing-small) 0;color:var(--color-neutral-800)}.account-orders-list-card p.account-orders-list-card__content--product-name{margin:0}.account-orders-list-card .account-orders-list-card__content p:last-child{margin:0}.account-orders-list-card .account-orders-list-card__content div{font:var(--type-button-2-font);margin-bottom:var(--spacing-small)}.account-orders-list-card .account-orders-list-card__actions{grid-area:actions}.account-orders-list-card .account-orders-list-card__images{overflow:auto}.account-orders-list-card .account-orders-list-card__images .dropin-content-grid__content{grid-template-columns:repeat(6,max-content)!important}.account-orders-list-card .account-orders-list-card__images-3 .dropin-content-grid__content{grid-template-columns:repeat(3,max-content)!important}.account-orders-list-card .account-orders-list-card__images img{object-fit:contain;width:65px;height:65px}.account-orders-list-card .account-orders-list-card__actions{position:relative;align-self:center;margin-left:auto}@media (min-width: 768px){.account-orders-list-card.account-orders-list-card--full .dropin-card__content{max-height:100%}}.account-addresses-header{margin-bottom:var(--spacing-medium)}.account-addresses-wrapper{box-sizing:border-box;position:relative}.account-addresses-wrapper--select-view{position:relative;margin:0;padding:0;border:none}.account-addresses-wrapper--select-view input[type=radio]{position:absolute;clip:rect(0,0,0,0);width:1px;height:1px;padding:0;margin:-1px;border:0;overflow:hidden}.account-addresses-wrapper--select-view .account-addresses-wrapper__label{cursor:pointer;display:block;border-radius:0}.account-addresses-wrapper--select-view .account-addresses-wrapper__label .account-address-card{border-radius:0}.account-addresses-wrapper--select-view .account-addresses-wrapper__label:nth-child(2){border-radius:var(--shape-border-radius-1) var(--shape-border-radius-1) 0 0}.account-addresses-wrapper--select-view>.account-addresses-wrapper__label:nth-child(2)>.account-address-card{border-radius:var(--shape-border-radius-1) var(--shape-border-radius-1) 0 0}.account-addresses-wrapper--select-view>.account-addresses-wrapper__label:last-child,.account-addresses-wrapper--select-view>.account-addresses-wrapper__label:last-child>.account-actions-address.account-actions-address--address{border-radius:0 0 var(--shape-border-radius-1) var(--shape-border-radius-1)}.account-addresses-wrapper--select-view .account-addresses-wrapper__label .account-address-card,.account-addresses-wrapper--select-view .account-addresses-wrapper__label .account-actions-address.account-actions-address--address{background-color:var(--color-neutral-200)}.account-addresses-wrapper--select-view input[type=radio]:checked+.account-addresses-wrapper__label>.account-address-card{border:var(--shape-border-width-1) solid var(--color-neutral-900);position:relative}.account-addresses-wrapper--select-view input[type=radio]:checked+.account-addresses-wrapper__label>.account-addresses-form__footer__wrapper{border:var(--shape-border-width-1) solid var(--color-neutral-900);position:relative}.account-addresses-wrapper--select-view input[type=radio]:checked+.account-addresses-wrapper__label .account-address-card,.account-addresses-wrapper--select-view input[type=radio]:checked+.account-addresses-wrapper__label .account-actions-address.account-actions-address--address{background-color:var(--color-neutral-50)}.account-addresses-wrapper--select-view .account-address-card{margin:0}.account-addresses-wrapper--select-view .account-addresses-form__footer__wrapper{padding:var(--spacing-medium)}.account-address-form-wrapper{box-sizing:border-box;background-color:var(--color-neutral-50)}.account-address-form-wrapper__notification{margin-bottom:var(--spacing-medium)}.account-address-form-wrapper__title{color:var(--color-neutral-800);font:var(--type-headline-2-strong-font);letter-spacing:var(--type-headline-2-strong-letter-spacing);margin-bottom:var(--spacing-medium)}.account-address-form-wrapper__buttons{display:flex;align-items:center;justify-content:end;gap:0 var(--spacing-medium);margin-top:var(--spacing-medium)}.account-address-form-wrapper__buttons--empty{gap:0;margin:0;padding:0;display:inline-block}.account-address-form-wrapper__buttons button{min-width:142px}.account-change-password .dropin-card__content{gap:0}.account-change-password__title,.account-change-password .account-change-password__notification,.account-change-password .account-change-password__fields .account-change-password__fields-item{margin-bottom:var(--spacing-medium)}.account-change-password .account-change-password__fields .account-change-password__fields-item:last-child{margin-bottom:0}.account-change-password .account-change-password__actions{display:flex;justify-content:right;align-items:center;gap:0 var(--grid-3-gutters);margin-top:var(--spacing-xlarge)}.account-change-password .account-change-password__actions button{min-width:144px}.account-edit-customer-information__title{margin-bottom:var(--spacing-medium)}.account-edit-customer-information .dropin-card__content{gap:0}.account-edit-customer-information .account-edit-customer-information__notification{margin-bottom:var(--spacing-medium)}.account-edit-customer-information .account-edit-customer-information-form__field:nth-child(n+3),.account-edit-customer-information .account-edit-customer-information__password{grid-column:span 2}.account-edit-customer-information .account-edit-customer-information__actions{display:flex;justify-content:end;align-items:center;gap:0 var(--grid-2-gutters);grid-column:span 2}.account-edit-customer-information .account-edit-customer-information__actions button{min-width:144px}.customer-information__title{margin-bottom:var(--spacing-medium)}.account-customer-information-card-short{margin-bottom:var(--spacing-small)}.account-customer-information-card .dropin-card__content{gap:0}.account-customer-information-card__wrapper{display:grid;grid-template-columns:1fr auto;align-items:start}.account-customer-information-card .account-customer-information-card__actions{display:flex;justify-content:space-between;align-items:center;gap:0 var(--grid-2-gutters)}.account-customer-information-card .account-customer-information-card__actions button{cursor:pointer;margin:0;padding:0}.account-customer-information-card__content p{font:var(--type-body-1-default-font);margin:0 var(--spacing-xsmall) 0 0;line-height:var(--spacing-xbig);padding:0}.account-customer-information-card__content p:nth-child(1),.account-customer-information-card__content p:nth-child(2){font:var(--type-body-1-strong-font);font-weight:500;margin:0 var(--spacing-xsmall) var(--spacing-xsmall) 0}.account-customer-information-card__content p:nth-child(1){float:left}`,{styleId:"account"}); import{jsx as r}from"@dropins/tools/preact-jsx-runtime.js";import{Render as o}from"@dropins/tools/lib.js";import{useState as n,useEffect as i}from"@dropins/tools/preact-hooks.js";import{UIProvider as l}from"@dropins/tools/components.js";import{events as c}from"@dropins/tools/event-bus.js";const m={minifiedView:{CustomerInformation:{containerTitle:"Account settings",genderMale:"Male",genderFemale:"Female",changePassword:{passwordValidationMessage:{chartTwoSymbols:"Use characters and numbers or symbols",chartThreeSymbols:"Use characters, numbers and symbols",chartFourSymbols:"Use uppercase characters, lowercase characters, numbers and symbols",messageLengthPassword:"At least {minLength} characters long",passwordMismatch:"Passwords do not match. Please make sure both password fields are identical",incorrectCurrentPassword:"The current password you entered is incorrect. Please check and try again.",passwordUpdateMessage:"Your password has been updated"},containerTitle:"Change password",currentPassword:{placeholder:"Password",floatingLabel:"Password"},newPassword:{placeholder:"New Password",floatingLabel:"New Password"},confirmPassword:{placeholder:"Confirm new password",floatingLabel:"Confirm new password"},buttonSecondary:"Cancel",buttonPrimary:"Save"},customerInformationCard:{buttonSecondary:"Change password",buttonPrimary:"Edit",accountCreation:"Account creation date"},editCustomerInformation:{containerTitle:"Edit details",buttonSecondary:"Cancel",buttonPrimary:"Save",accountSuccess:"Your account information has been updated.",accountError:"Your account information has not been updated.",passwordField:{placeholder:"Password",floatingLabel:"Password"}}},Addresses:{containerTitle:"Addresses",editAddressFormTitle:"Edit address",differentAddressFormTitle:"Deliver to new address",viewAllAddressesButton:"View address list",differentAddressButton:"Use a different address",addressCard:{actionRemove:"Remove",actionEdit:"Edit",cardLabelShipping:"Shipping",cardLabelBilling:"Billing",defaultLabelText:"DEFAULT"},removeAddressModal:{title:"Remove address",description:"Are you sure you would like to remove this address?",actionCancel:"Cancel",actionConfirm:"Remove"}},OrdersList:{containerTitle:"Recent orders",viewAllOrdersButton:"View all orders",ariaLabelLink:"Redirect to full order information",dateOrderPlaced:"Date order placed",OrdersListCard:{orderNumber:"Order number:",itemsAmount:"items",carrier:"Carrier:",returns:"Return(s):",orderDate:"Placed on"},OrdersListSelectDate:{pastSixMonths:"Past 6 months",currentYear:"Current year",viewAll:"View all"}},EmptyList:{Addresses:{message:"No saved addresses"},OrdersList:{message:"No orders"}}},fullSizeView:{Addresses:{containerTitle:"Addresses",editAddressFormTitle:"Edit address",differentAddressFormTitle:"Deliver to new address",newAddressFormTitle:"Add address",addNewAddressButton:"Create new",differentAddressButton:"Use a different address",addressCard:{actionRemove:"Remove",actionEdit:"Edit",cardLabelShipping:"Shipping",cardLabelBilling:"Billing",defaultLabelText:"DEFAULT"},removeAddressModal:{title:"Remove address",description:"Are you sure you would like to remove this address?",actionCancel:"Cancel",actionConfirm:"Remove"}},OrdersList:{containerTitle:"Your orders",ariaLabelLink:"Redirect to full order information",dateOrderPlaced:"Date order placed",OrdersListCard:{orderNumber:"Order number:",itemsAmount:"items",carrier:"Carrier:",returns:"Return(s):",orderDate:"Placed on"},OrdersListSelectDate:{pastSixMonths:"Past 6 months",currentYear:"Current year",viewAll:"View all"}},EmptyList:{Addresses:{message:"No saved addresses"},OrdersList:{message:"No orders"}}},AddressForm:{formText:{secondaryButton:"Cancel",primaryButton:"Save",defaultShippingLabel:"Set as default shipping address",defaultBillingLabel:"Set as default billing address",saveAddressBook:"Save in address book"}},FormText:{requiredFieldError:"This is a required field.",numericError:"Only numeric values are allowed.",alphaNumWithSpacesError:"Only alphanumeric characters and spaces are allowed.",alphaNumericError:"Only alphanumeric characters are allowed.",alphaError:"Only alphabetic characters are allowed.",emailError:"Please enter a valid email address.",dateError:"Please enter a valid date.",dateLengthError:"Date must be between {min} and {max}.",urlError:"Please enter a valid URL, e.g., http://www.adobe.com.",lengthTextError:"Text length must be between {min} and {max} characters."}},u={Account:m},w={default:u},p=({children:a})=>{const[s,t]=n("en_US");return i(()=>{const e=c.on("locale",d=>{t(d)},{eager:!0});return()=>{e==null||e.off()}},[]),r(l,{lang:s,langDefinitions:w,children:a})},L=new o(r(p,{}));export{L as render}; diff --git a/scripts/__dropins__/storefront-account/types/api/getCustomer.types.d.ts b/scripts/__dropins__/storefront-account/types/api/getCustomer.types.d.ts index 501fb4f10a..c373f4955a 100644 --- a/scripts/__dropins__/storefront-account/types/api/getCustomer.types.d.ts +++ b/scripts/__dropins__/storefront-account/types/api/getCustomer.types.d.ts @@ -9,6 +9,7 @@ export interface getCustomerShortResponse { lastname: string; email: string; date_of_birth: string; + dob: string; gender: 1 | 2; middlename: string; prefix: string; diff --git a/scripts/__dropins__/storefront-account/types/api/getCustomerAddress.type.d.ts b/scripts/__dropins__/storefront-account/types/api/getCustomerAddress.type.d.ts index cc57850f6e..4efa9bc01d 100644 --- a/scripts/__dropins__/storefront-account/types/api/getCustomerAddress.type.d.ts +++ b/scripts/__dropins__/storefront-account/types/api/getCustomerAddress.type.d.ts @@ -4,10 +4,6 @@ export type RegionProps = { region_id: string | number; }; export interface UserAddressesProps { - middlename: string; - fax: string; - prefix: string; - suffix: string; firstname: string; lastname: string; city: string; diff --git a/scripts/__dropins__/storefront-account/types/api/storeConfig.types.d.ts b/scripts/__dropins__/storefront-account/types/api/storeConfig.types.d.ts index 56dd9f4dec..ae72c8c484 100644 --- a/scripts/__dropins__/storefront-account/types/api/storeConfig.types.d.ts +++ b/scripts/__dropins__/storefront-account/types/api/storeConfig.types.d.ts @@ -1,5 +1,4 @@ export interface StoreConfigProps { - base_media_url: string; minimum_password_length: number; required_character_classes_number: string; } diff --git a/scripts/__dropins__/storefront-account/types/ordersList.types.d.ts b/scripts/__dropins__/storefront-account/types/ordersList.types.d.ts index 3609bc9598..e4fd484f5a 100644 --- a/scripts/__dropins__/storefront-account/types/ordersList.types.d.ts +++ b/scripts/__dropins__/storefront-account/types/ordersList.types.d.ts @@ -32,7 +32,6 @@ export interface OrdersListProps extends HTMLAttributes { export interface OrdersListWrapperProps extends OrdersListProps { } export interface OrdersListCardProps extends HTMLAttributes { - placeholderImage: string; minifiedView: boolean; item: OrderDetails; withThumbnails: boolean; diff --git a/scripts/__dropins__/storefront-auth/api.js b/scripts/__dropins__/storefront-auth/api.js index 8a2c1509f8..960a560c6b 100644 --- a/scripts/__dropins__/storefront-auth/api.js +++ b/scripts/__dropins__/storefront-auth/api.js @@ -1 +1,3 @@ -import{c as p,a as f,g}from"./chunks/createCustomerAddress.js";import{g as c,a as x}from"./chunks/getCustomerToken.js";import{g as h}from"./chunks/getStoreConfig.js";import{r as C}from"./chunks/requestPasswordResetEmail.js";import{r as E}from"./chunks/resetPassword.js";import{r as G}from"./chunks/revokeCustomerToken.js";import{c as k}from"./chunks/confirmEmail.js";import{r as b}from"./chunks/resendConfirmationEmail.js";import{c as w,i as A}from"./chunks/initialize.js";import{f as T,g as q,r as z,s as D,a as R,b as S}from"./chunks/network-error.js";import"./chunks/setReCaptchaToken.js";import"@dropins/tools/recaptcha.js";import"@dropins/tools/event-bus.js";import"./chunks/transform-attributes-form.js";import"@dropins/tools/lib.js";import"@dropins/tools/fetch-graphql.js";export{w as config,k as confirmEmail,p as createCustomer,f as createCustomerAddress,T as fetchGraphQl,g as getAttributesForm,q as getConfig,c as getCustomerData,x as getCustomerToken,h as getStoreConfig,A as initialize,z as removeFetchGraphQlHeader,C as requestPasswordResetEmail,b as resendConfirmationEmail,E as resetPassword,G as revokeCustomerToken,D as setEndpoint,R as setFetchGraphQlHeader,S as setFetchGraphQlHeaders}; +/*! Copyright 2024 Adobe +All Rights Reserved. */ +import{c as f,a as g,g as n}from"./chunks/createCustomerAddress.js";import{g as x,a as d}from"./chunks/getCustomerToken.js";import{g as l}from"./chunks/getStoreConfig.js";import{r as u}from"./chunks/requestPasswordResetEmail.js";import{r as F}from"./chunks/resetPassword.js";import{r as Q}from"./chunks/revokeCustomerToken.js";import{c as H}from"./chunks/confirmEmail.js";import{r as v}from"./chunks/resendConfirmationEmail.js";import{c as A,i as P}from"./chunks/initialize.js";import{f as q,g as z,r as D,s as R,a as S,b as j}from"./chunks/network-error.js";import"./fragments.js";import"./chunks/setReCaptchaToken.js";import"@dropins/tools/recaptcha.js";import"@dropins/tools/event-bus.js";import"@dropins/tools/lib.js";import"./chunks/transform-attributes-form.js";import"@dropins/tools/fetch-graphql.js";export{A as config,H as confirmEmail,f as createCustomer,g as createCustomerAddress,q as fetchGraphQl,n as getAttributesForm,z as getConfig,x as getCustomerData,d as getCustomerToken,l as getStoreConfig,P as initialize,D as removeFetchGraphQlHeader,u as requestPasswordResetEmail,v as resendConfirmationEmail,F as resetPassword,Q as revokeCustomerToken,R as setEndpoint,S as setFetchGraphQlHeader,j as setFetchGraphQlHeaders}; diff --git a/scripts/__dropins__/storefront-auth/api/confirmEmail/graphql/confirmEmail.graphql.d.ts b/scripts/__dropins__/storefront-auth/api/confirmEmail/graphql/confirmEmail.graphql.d.ts index 510361027a..cd22d3a02c 100644 --- a/scripts/__dropins__/storefront-auth/api/confirmEmail/graphql/confirmEmail.graphql.d.ts +++ b/scripts/__dropins__/storefront-auth/api/confirmEmail/graphql/confirmEmail.graphql.d.ts @@ -1,2 +1,2 @@ -export declare const CONFIRM_EMAIL = "\n mutation CONFIRM_EMAIL($email: String!, $confirmation_key: String!) {\n confirmEmail(input: {\n email: $email,\n confirmation_key: $confirmation_key\n }) {\n customer {\n email\n }\n }\n }\n"; +export declare const CONFIRM_EMAIL = "\n mutation CONFIRM_EMAIL($email: String!, $confirmation_key: String!) {\n confirmEmail(\n input: { email: $email, confirmation_key: $confirmation_key }\n ) {\n customer {\n email\n }\n }\n }\n"; //# sourceMappingURL=confirmEmail.graphql.d.ts.map \ No newline at end of file diff --git a/scripts/__dropins__/storefront-auth/api/createCustomer/createCustomer.d.ts b/scripts/__dropins__/storefront-auth/api/createCustomer/createCustomer.d.ts index 304d6fcd70..fc641b3605 100644 --- a/scripts/__dropins__/storefront-auth/api/createCustomer/createCustomer.d.ts +++ b/scripts/__dropins__/storefront-auth/api/createCustomer/createCustomer.d.ts @@ -1,4 +1,5 @@ -import { CreateCustomerDataResponse, Customer } from '../../types'; +import { Customer } from '../../types'; +import { CustomerModel } from '../../data/models'; -export declare const createCustomer: (forms: Customer, apiVersion2: boolean) => Promise; +export declare const createCustomer: (forms: Customer, apiVersion2: boolean) => Promise; //# sourceMappingURL=createCustomer.d.ts.map \ No newline at end of file diff --git a/scripts/__dropins__/storefront-auth/api/createCustomer/graphql/createCustomer.graphql.d.ts b/scripts/__dropins__/storefront-auth/api/createCustomer/graphql/createCustomer.graphql.d.ts index 124881eb75..38b05c9335 100644 --- a/scripts/__dropins__/storefront-auth/api/createCustomer/graphql/createCustomer.graphql.d.ts +++ b/scripts/__dropins__/storefront-auth/api/createCustomer/graphql/createCustomer.graphql.d.ts @@ -1,2 +1,2 @@ -export declare const CREATE_CUSTOMER = "\n mutation CREATE_CUSTOMER($input: CustomerInput!) {\n createCustomer(input: $input) {\n customer {\n firstname\n lastname\n email\n is_subscribed\n }\n }\n }\n"; +export declare const CREATE_CUSTOMER: string; //# sourceMappingURL=createCustomer.graphql.d.ts.map \ No newline at end of file diff --git a/scripts/__dropins__/storefront-auth/api/createCustomer/graphql/createCustomerV2.graphql.d.ts b/scripts/__dropins__/storefront-auth/api/createCustomer/graphql/createCustomerV2.graphql.d.ts index fbc15f282c..4495aeef1e 100644 --- a/scripts/__dropins__/storefront-auth/api/createCustomer/graphql/createCustomerV2.graphql.d.ts +++ b/scripts/__dropins__/storefront-auth/api/createCustomer/graphql/createCustomerV2.graphql.d.ts @@ -1,2 +1,2 @@ -export declare const CREATE_CUSTOMER_V2 = "\n mutation CREATE_CUSTOMER_V2($input: CustomerCreateInput!) {\n createCustomerV2(input: $input) {\n customer {\n firstname\n lastname\n email\n is_subscribed\n }\n }\n }\n"; +export declare const CREATE_CUSTOMER_V2: string; //# sourceMappingURL=createCustomerV2.graphql.d.ts.map \ No newline at end of file diff --git a/scripts/__dropins__/storefront-auth/api/createCustomerAddress/graphql/createCustomerAddress.graphql.d.ts b/scripts/__dropins__/storefront-auth/api/createCustomerAddress/graphql/createCustomerAddress.graphql.d.ts index 670c2ea98c..ce704ced84 100644 --- a/scripts/__dropins__/storefront-auth/api/createCustomerAddress/graphql/createCustomerAddress.graphql.d.ts +++ b/scripts/__dropins__/storefront-auth/api/createCustomerAddress/graphql/createCustomerAddress.graphql.d.ts @@ -1,2 +1,2 @@ -export declare const CREATE_CUSTOMER_ADDRESS = "\n mutation CREATE_CUSTOMER_ADDRESS($input: CustomerAddressInput!) {\n createCustomerAddress(input:$input) {\n firstname\n }\n }\n"; +export declare const CREATE_CUSTOMER_ADDRESS = "\n mutation CREATE_CUSTOMER_ADDRESS($input: CustomerAddressInput!) {\n createCustomerAddress(input: $input) {\n firstname\n }\n }\n"; //# sourceMappingURL=createCustomerAddress.graphql.d.ts.map \ No newline at end of file diff --git a/scripts/__dropins__/storefront-auth/api/fragments.d.ts b/scripts/__dropins__/storefront-auth/api/fragments.d.ts new file mode 100644 index 0000000000..7f396f1d5a --- /dev/null +++ b/scripts/__dropins__/storefront-auth/api/fragments.d.ts @@ -0,0 +1,2 @@ +export { CUSTOMER_INFORMATION_FRAGMENT } from './graphql/CustomerFragment.graphql'; +//# sourceMappingURL=fragments.d.ts.map \ No newline at end of file diff --git a/scripts/__dropins__/storefront-auth/api/getCustomerData/getCustomerData.d.ts b/scripts/__dropins__/storefront-auth/api/getCustomerData/getCustomerData.d.ts index 0fd1706b17..323e619944 100644 --- a/scripts/__dropins__/storefront-auth/api/getCustomerData/getCustomerData.d.ts +++ b/scripts/__dropins__/storefront-auth/api/getCustomerData/getCustomerData.d.ts @@ -1,4 +1,4 @@ -import { CustomerDataModel } from '../../data/models'; +import { CustomerModel } from '../../data/models'; -export declare const getCustomerData: (user_token: string) => Promise; +export declare const getCustomerData: (user_token: string) => Promise; //# sourceMappingURL=getCustomerData.d.ts.map \ No newline at end of file diff --git a/scripts/__dropins__/storefront-auth/api/getCustomerData/graphql/getCustomerData.graphql.d.ts b/scripts/__dropins__/storefront-auth/api/getCustomerData/graphql/getCustomerData.graphql.d.ts index 312aff8592..2628990282 100644 --- a/scripts/__dropins__/storefront-auth/api/getCustomerData/graphql/getCustomerData.graphql.d.ts +++ b/scripts/__dropins__/storefront-auth/api/getCustomerData/graphql/getCustomerData.graphql.d.ts @@ -1,2 +1,2 @@ -export declare const GET_CUSTOMER_DATA = "\n query GET_CUSTOMER_DATA {\n customer {\n firstname\n lastname\n email\n }\n }\n"; +export declare const GET_CUSTOMER_DATA: string; //# sourceMappingURL=getCustomerData.graphql.d.ts.map \ No newline at end of file diff --git a/scripts/__dropins__/storefront-auth/api/graphql/CustomerFragment.graphql.d.ts b/scripts/__dropins__/storefront-auth/api/graphql/CustomerFragment.graphql.d.ts new file mode 100644 index 0000000000..4070778a61 --- /dev/null +++ b/scripts/__dropins__/storefront-auth/api/graphql/CustomerFragment.graphql.d.ts @@ -0,0 +1,2 @@ +export declare const CUSTOMER_INFORMATION_FRAGMENT = "\n fragment CUSTOMER_INFORMATION_FRAGMENT on Customer {\n __typename\n firstname\n lastname\n email\n is_subscribed\n }\n"; +//# sourceMappingURL=CustomerFragment.graphql.d.ts.map \ No newline at end of file diff --git a/scripts/__dropins__/storefront-auth/api/initialize/initialize.d.ts b/scripts/__dropins__/storefront-auth/api/initialize/initialize.d.ts index 4b94607a6a..778ad190d7 100644 --- a/scripts/__dropins__/storefront-auth/api/initialize/initialize.d.ts +++ b/scripts/__dropins__/storefront-auth/api/initialize/initialize.d.ts @@ -1,5 +1,6 @@ -import { Initializer } from '@dropins/tools/types/elsie/src/lib'; +import { Initializer, Model } from '@dropins/tools/types/elsie/src/lib'; import { Lang } from '@dropins/tools/types/elsie/src/i18n'; +import { CustomerModel } from '../../data/models'; type ConfigProps = { langDefinitions?: Lang; @@ -7,6 +8,9 @@ type ConfigProps = { header: string; tokenPrefix: string; }; + models?: { + CustomerModel?: Model; + }; }; export declare const initialize: Initializer; export declare const config: import('@dropins/tools/types/elsie/src/lib').Config; diff --git a/scripts/__dropins__/storefront-auth/api/resendConfirmationEmail/graphql/resendConfirmationEmail.graphql.d.ts b/scripts/__dropins__/storefront-auth/api/resendConfirmationEmail/graphql/resendConfirmationEmail.graphql.d.ts index fc38a9d607..819d68bae2 100644 --- a/scripts/__dropins__/storefront-auth/api/resendConfirmationEmail/graphql/resendConfirmationEmail.graphql.d.ts +++ b/scripts/__dropins__/storefront-auth/api/resendConfirmationEmail/graphql/resendConfirmationEmail.graphql.d.ts @@ -1,2 +1,2 @@ -export declare const RESEND_CONFIRMATION_EMAIL = "\nmutation RESEND_CONFIRMATION_EMAIL($email: String!) {\n resendConfirmationEmail(email: $email)\n}"; +export declare const RESEND_CONFIRMATION_EMAIL = "\n mutation RESEND_CONFIRMATION_EMAIL($email: String!) {\n resendConfirmationEmail(email: $email)\n }\n"; //# sourceMappingURL=resendConfirmationEmail.graphql.d.ts.map \ No newline at end of file diff --git a/scripts/__dropins__/storefront-auth/api/resetPassword/graphql/resetPassword.graphql.d.ts b/scripts/__dropins__/storefront-auth/api/resetPassword/graphql/resetPassword.graphql.d.ts index 205ddbafdc..3603770846 100644 --- a/scripts/__dropins__/storefront-auth/api/resetPassword/graphql/resetPassword.graphql.d.ts +++ b/scripts/__dropins__/storefront-auth/api/resetPassword/graphql/resetPassword.graphql.d.ts @@ -1,2 +1,2 @@ -export declare const RESET_PASSWORD = "\n mutation RESET_PASSWORD($email: String!, $resetPasswordToken: String!, $newPassword: String!){\n resetPassword(email: $email,resetPasswordToken: $resetPasswordToken,newPassword: $newPassword)\n }\n"; +export declare const RESET_PASSWORD = "\n mutation RESET_PASSWORD(\n $email: String!\n $resetPasswordToken: String!\n $newPassword: String!\n ) {\n resetPassword(\n email: $email\n resetPasswordToken: $resetPasswordToken\n newPassword: $newPassword\n )\n }\n"; //# sourceMappingURL=resetPassword.graphql.d.ts.map \ No newline at end of file diff --git a/scripts/__dropins__/storefront-auth/chunks/EmailConfirmationForm.js b/scripts/__dropins__/storefront-auth/chunks/EmailConfirmationForm.js index c882357f8d..bb9d5a5acc 100644 --- a/scripts/__dropins__/storefront-auth/chunks/EmailConfirmationForm.js +++ b/scripts/__dropins__/storefront-auth/chunks/EmailConfirmationForm.js @@ -1 +1,3 @@ +/*! Copyright 2024 Adobe +All Rights Reserved. */ import{jsxs as c,jsx as n}from"@dropins/tools/preact-jsx-runtime.js";import{classes as b}from"@dropins/tools/lib.js";import"@dropins/tools/event-bus.js";import"@dropins/tools/recaptcha.js";import{useState as C,useCallback as y}from"@dropins/tools/preact-hooks.js";import{InLineAlert as x,Header as p}from"@dropins/tools/components.js";import{B as f}from"./UpdatePasswordForm.js";/* empty css */import{r as E}from"./resendConfirmationEmail.js";import{useText as d}from"@dropins/tools/i18n.js";const _=({userEmail:r,handleSetInLineAlertProps:i})=>{const a=d({emailConfirmationMessage:"Auth.Notification.emailConfirmationMessage",technicalErrorSendEmail:"Auth.Notification.technicalErrors.technicalErrorSendEmail"}),[l,e]=C(!1);return{handleEmailConfirmation:y(async()=>{var o,m;if(e(!0),r){const t=await E(r);if(t){const u=(o=t==null?void 0:t.errors)==null?void 0:o.length,h=(m=t==null?void 0:t.data)==null?void 0:m.resendConfirmationEmail;i(u?{type:"error",text:a.technicalErrorSendEmail}:{type:h?"success":"error",text:a.emailConfirmationMessage})}}e(!1)},[i,a,r]),disabledButton:l}},$=({formSize:r,userEmail:i,inLineAlertProps:a,hideCloseBtnOnEmailConfirmation:l,handleSetInLineAlertProps:e,onPrimaryButtonClick:s})=>{const o=d({title:"Auth.EmailConfirmationForm.title",subtitle:"Auth.EmailConfirmationForm.subtitle",mainText:"Auth.EmailConfirmationForm.mainText",buttonPrimary:"Auth.EmailConfirmationForm.buttonPrimary",buttonSecondary:"Auth.EmailConfirmationForm.buttonSecondary"}),{handleEmailConfirmation:m,disabledButton:t}=_({userEmail:i,handleSetInLineAlertProps:e});return c("div",{className:b(["auth-email-confirmation-form",`auth-email-confirmation-form--${r}`]),children:[a.text?n(x,{className:"auth-signInForm__notification",type:a.type,variant:"secondary",heading:a.text,icon:a.icon,"data-testid":"authInLineAlert"}):null,n(p,{title:o.title,divider:!1,className:"auth-email-confirmation-form__title"}),i!=null&&i.length?n("span",{className:"auth-email-confirmation-form__subtitle",children:`${o.subtitle} ${i}`}):null,n("span",{className:"auth-email-confirmation-form__text",children:o.mainText}),c("div",{className:"auth-email-confirmation-form__buttons",children:[n(f,{type:"button",variant:"tertiary",style:{padding:0},buttonText:o.buttonSecondary,enableLoader:!1,onClick:m,disabled:t}),l?null:n(f,{type:"submit",buttonText:o.buttonPrimary,variant:"primary",enableLoader:!1,disabled:t,onClick:s})]})]})};export{$ as E}; diff --git a/scripts/__dropins__/storefront-auth/chunks/ResetPasswordForm.js b/scripts/__dropins__/storefront-auth/chunks/ResetPasswordForm.js index bb574e0fec..746f61fa3c 100644 --- a/scripts/__dropins__/storefront-auth/chunks/ResetPasswordForm.js +++ b/scripts/__dropins__/storefront-auth/chunks/ResetPasswordForm.js @@ -1 +1,3 @@ +/*! Copyright 2024 Adobe +All Rights Reserved. */ import{jsxs as w,jsx as o}from"@dropins/tools/preact-jsx-runtime.js";import{classes as h}from"@dropins/tools/lib.js";import{g as F,c as l,u as P,F as _,B as p}from"./UpdatePasswordForm.js";import"@dropins/tools/event-bus.js";import"@dropins/tools/recaptcha.js";import{r as b}from"./requestPasswordResetEmail.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 v,InLineAlert as N}from"@dropins/tools/components.js";/* empty css */import{s as E,D as T}from"./simplifyTransformAttributesForm.js";import*as y from"@dropins/tools/preact-compat.js";const D=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"})),L=({routeSignIn:t,onErrorCallback:a,setActiveComponent:i,handleSetInLineAlertProps:s})=>{const c=R({successPasswordResetEmailNotification:"Auth.Notification.successPasswordResetEmailNotification"}),[m,e]=x(!1),d=g(async u=>{u.preventDefault(),e(!0);const r=F(u.target);if(r&&r.email){const f=await b(r.email);f.success?s==null||s({type:"success",text:c.successPasswordResetEmailNotification.replace("{email}",r.email)}):(a==null||a(f),s==null||s({type:"error",text:f.message}))}e(!1)},[s,a,c.successPasswordResetEmailNotification]),n=g(()=>{if(l(i)){i("signInForm");return}l(t)&&(window.location.href=t())},[i,t]);return{isLoading:m,submitResetPassword:d,redirectToSignInPage:n}},z=({formSize:t="default",routeSignIn:a,setActiveComponent:i,onErrorCallback:s,...c})=>{const m=R({title:"Auth.ResetPasswordForm.title",buttonPrimary:"Auth.ResetPasswordForm.buttonPrimary",buttonSecondary:"Auth.ResetPasswordForm.buttonSecondary"}),{inLineAlertProps:e,handleSetInLineAlertProps:d}=P(),{isLoading:n,submitResetPassword:u,redirectToSignInPage:r}=L({routeSignIn:a,setActiveComponent:i,onErrorCallback:s,handleSetInLineAlertProps:d});return w("div",{...c,className:h(["auth-reset-password-form",`auth-reset-password-form--${t}`]),"data-testid":"resetPasswordForm",children:[o(v,{title:m.title,divider:!1,className:"auth-reset-password-form__title"}),e.text?o(N,{className:"auth-reset-password-form__notification",type:e.type,variant:"secondary",heading:e.text,icon:e.icon}):null,o(_,{name:"resetPassword_form",className:"auth-reset-password-form__form",onSubmit:u,loading:n,fieldsConfig:E(T),children:w("div",{className:"auth-reset-password-form__buttons",children:[o(p,{type:"button",variant:"tertiary",style:{padding:"0"},icon:o(D,{style:{transform:"rotate(90deg)"}}),buttonText:m.buttonSecondary,enableLoader:!1,onClick:r}),o(p,{type:"submit",buttonText:m.buttonPrimary,variant:"primary",enableLoader:n})]})}),o("div",{id:"requestPasswordResetEmail"})]})};export{z as R}; diff --git a/scripts/__dropins__/storefront-auth/chunks/SignInForm.js b/scripts/__dropins__/storefront-auth/chunks/SignInForm.js index 176029a77c..b75a00e04c 100644 --- a/scripts/__dropins__/storefront-auth/chunks/SignInForm.js +++ b/scripts/__dropins__/storefront-auth/chunks/SignInForm.js @@ -1 +1,3 @@ +/*! Copyright 2024 Adobe +All Rights Reserved. */ import{jsx as u,jsxs as A}from"@dropins/tools/preact-jsx-runtime.js";import{Slot as Z,classes as z}from"@dropins/tools/lib.js";import{g as V,c as _,u as O,F as R,B as H}from"./UpdatePasswordForm.js";import{useState as g,useCallback as F,useEffect as J,useMemo as tt}from"@dropins/tools/preact-hooks.js";import"@dropins/tools/event-bus.js";import"@dropins/tools/recaptcha.js";import{a as at}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{Header as st,InLineAlert as nt,InputPassword as mt}from"@dropins/tools/components.js";/* empty css */import{E as ct}from"./EmailConfirmationForm.js";const ut=({emailConfirmationStatusMessage:t,translations:r,initialEmailValue:i,routeSignUp:l,routeForgotPassword:m,routeRedirectOnSignIn:E,onErrorCallback:w,setActiveComponent:a,onSuccessCallback:f,onSignUpLinkClick:h,handleSetInLineAlertProps:e,routeRedirectOnEmailConfirmationClose:N})=>{const[k,P]=g(""),[L,s]=g(!1),[M,d]=g(""),[T,y]=g(!1),[S,C]=g({userName:"",status:!1}),[B,b]=g(!1),[p,x]=g([]),I=F(async n=>{e(),s(!0),y(!1),x([]),await rt(n)},[e]),v=F(n=>{n.length?y(!1):y(!0),d(n)},[]);J(()=>{t!=null&&t.text&&e({text:t.text,type:t.status?t.status:void 0})},[t,e]);const U=F(async n=>{var K;e(),b(!0);const c=V(n.target);if(c.password||(y(!0),b(!1)),c!=null&&c.email&&(c!=null&&c.password)){const{email:G,password:X}=c,o=await at({email:G,password:X,handleSetInLineAlertProps:e,onErrorCallback:w,translations:r});if((K=o==null?void 0:o.errorMessage)!=null&&K.length){P(G);const $=o.errorMessage.includes("This account isn't confirmed. Verify and try again."),Y=$?r.resendEmailInformationText:o.errorMessage;x($?[{label:r.resendEmailButtonText,onClick:()=>{I(G)}}]:[]),e({text:Y,type:"error"}),d("")}o!=null&&o.userName&&(n.target.reset(),_(E)?window.location.href=E():(f==null||f({userName:o==null?void 0:o.userName,status:!0}),C({userName:o==null?void 0:o.userName,status:!0}))),y(!1)}b(!1)},[e,w,r,I,E,f]),q=F(()=>{if(_(a)){a("resetPasswordForm");return}_(m)&&(window.location.href=m())},[m,a]),j=F(()=>{if(_(h)&&h(),_(a)){a("signUpForm");return}_(l)&&(window.location.href=l())},[h,l,a]),D=tt(()=>{const n=et(ot);return i!=null&&i.length?n==null?void 0:n.map(c=>({...c,defaultValue:i})):n},[i]),W=F(()=>{e(),_(N)?window.location.href=N():s(!1)},[e,N]);return{additionalActionsAlert:p,userEmail:k,defaultEnhancedEmailFields:D,passwordError:T,isSuccessful:S,isLoading:B,signInPasswordValue:M,showEmailConfirmationForm:L,setShowEmailConfirmationForm:s,setSignInPasswordValue:d,submitLogInUser:U,forgotPasswordCallback:q,onSignUpLinkClickCallback:j,handledOnPrimaryButtonClick:W,handleSetPassword:v}},ft=()=>{let t=new URL(window.location.href),r=t.searchParams.get("email"),i=t.searchParams.get("key");r&&i&&(t.searchParams.delete("email"),t.searchParams.delete("key"),window.history.replaceState({},document.title,t.toString()))},dt=({enableEmailConfirmation:t})=>{const r=Q({accountConfirmMessage:"Auth.EmailConfirmationForm.accountConfirmMessage",accountConfirmationEmailSuccessMessage:"Auth.EmailConfirmationForm.accountConfirmationEmailSuccessMessage"}),[i,l]=g({text:"",status:""});return J(()=>{if(t){const{search:m}=window.location;m.includes("email=")&&m.includes("key=")&&(async()=>{var f,h,e;const w=new URLSearchParams(m),a=await it({customerEmail:w.get("email"),customerConfirmationKey:w.get("key")});if(!a)return null;(f=a==null?void 0:a.errors)!=null&&f.length?l({text:a==null?void 0:a.errors[0].message,status:"error"}):(l({text:a.data.confirmEmail.customer.email?r.accountConfirmationEmailSuccessMessage.replace("{email}",(e=(h=a==null?void 0:a.data)==null?void 0:h.confirmEmail.customer)==null?void 0:e.email):r.accountConfirmMessage,status:"success"}),ft())})()}},[t,r]),{emailConfirmationStatusMessage:i}},At=({slots:t,labels:r,formSize:i="default",initialEmailValue:l="",renderSignUpLink:m=!1,enableEmailConfirmation:E=!1,hideCloseBtnOnEmailConfirmation:w=!1,routeRedirectOnEmailConfirmationClose:a,routeRedirectOnSignIn:f,routeForgotPassword:h,routeSignUp:e,onSuccessCallback:N,setActiveComponent:k,onErrorCallback:P,onSignUpLinkClick:L})=>{const s=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",requiredFieldError:"Auth.FormText.requiredFieldError"}),{emailConfirmationStatusMessage:M}=dt({enableEmailConfirmation:E}),{inLineAlertProps:d,handleSetInLineAlertProps:T}=O(),{userEmail:y,additionalActionsAlert:S,defaultEnhancedEmailFields:C,passwordError:B,isSuccessful:b,isLoading:p,signInPasswordValue:x,showEmailConfirmationForm:I,submitLogInUser:v,forgotPasswordCallback:U,onSignUpLinkClickCallback:q,handledOnPrimaryButtonClick:j,handleSetPassword:D}=ut({translations:s,emailConfirmationStatusMessage:M,initialEmailValue:l,routeSignUp:e,routeForgotPassword:h,routeRedirectOnSignIn:f,setActiveComponent:k,onErrorCallback:P,onSuccessCallback:N,onSignUpLinkClick:L,handleSetInLineAlertProps:T,routeRedirectOnEmailConfirmationClose:a});return b.status&&(t!=null&&t.SuccessNotification)?u(Z,{"data-testid":"successNotificationTestId",name:"SuccessNotification",slot:t==null?void 0:t.SuccessNotification,context:{isSuccessful:b}}):I?u(ct,{formSize:i,userEmail:y,inLineAlertProps:d,hideCloseBtnOnEmailConfirmation:w,handleSetInLineAlertProps:T,onPrimaryButtonClick:j}):A("div",{className:z(["auth-sign-in-form",`auth-sign-in-form--${i}`]),"data-testid":"signInForm",children:[u(st,{title:(r==null?void 0:r.formTitleText)??s.title,divider:!1,className:"auth-sign-in-form__title"}),d.text?u(nt,{"data-testid":"authInLineAlert",className:"auth-sign-in-form__notification",type:d.type,variant:"secondary",heading:d.text,icon:d.icon,additionalActions:S}):null,A(R,{name:"signIn_form",className:"auth-sign-in-form__form",onSubmit:v,loading:p,fieldsConfig:C,children:[u(mt,{hideStatusIndicator:!0,className:"auth-sign-in-form__form__password",autoComplete:"current-password",errorMessage:B?s.requiredFieldError:void 0,defaultValue:x,onValue:D,placeholder:s.placeholder,floatingLabel:s.floatingLabel}),A("div",{className:"auth-sign-in-form__form__buttons",children:[A("div",{className:"auth-sign-in-form__form__buttons__combine",children:[u(H,{type:"button",variant:"tertiary",style:{padding:0},buttonText:s.buttonTertiary,className:"auth-sign-in-form__button auth-sign-in-form__button--forgot",enableLoader:!1,onClick:U,"data-testid":"switchToSignUp"}),m?u("span",{}):null,m?u(H,{type:"button",variant:"tertiary",style:{padding:0},buttonText:s.buttonSecondary,className:"auth-sign-in-form__button auth-sign-in-form__button--signup",enableLoader:!1,onClick:q}):null]}),u(H,{type:"submit",buttonText:(r==null?void 0:r.primaryButtonText)??s.buttonPrimary,variant:"primary",className:"auth-sign-in-form__button auth-sign-in-form__button--submit",enableLoader:p})]})]}),u("div",{id:"generateCustomerToken"})]})};export{At as S}; diff --git a/scripts/__dropins__/storefront-auth/chunks/SignUpForm.js b/scripts/__dropins__/storefront-auth/chunks/SignUpForm.js index 6a8460f92f..0b5c463d8c 100644 --- a/scripts/__dropins__/storefront-auth/chunks/SignUpForm.js +++ b/scripts/__dropins__/storefront-auth/chunks/SignUpForm.js @@ -1 +1,3 @@ -import{jsx as o,jsxs as A}from"@dropins/tools/preact-jsx-runtime.js";import{Slot as Fe,classes as _e}from"@dropins/tools/lib.js";import"@dropins/tools/event-bus.js";import"@dropins/tools/recaptcha.js";import{g as Pe,c as we,a as Ne}from"./createCustomerAddress.js";import{useState as d,useEffect as Le,useCallback as q}from"@dropins/tools/preact-hooks.js";import{s as ae,b as ye}from"./simplifyTransformAttributesForm.js";import{v as Ue,u as Te,a as xe}from"./usePasswordValidationMessage.js";import{a as Ee}from"./getCustomerToken.js";import{p as me,E as ne}from"./getStoreConfig.js";import{c as I,g as Me,u as Se,F as Ce,B as ue}from"./UpdatePasswordForm.js";import{c as ve}from"./transform-attributes-form.js";import{Header as Ae,InLineAlert as qe,InputPassword as ce,Field as R,Checkbox as ee}from"@dropins/tools/components.js";/* empty css */import{S as Ke}from"./SkeletonLoader.js";import{E as Be}from"./EmailConfirmationForm.js";import{useText as je}from"@dropins/tools/i18n.js";const le=(m,e)=>e!=null&&e.length?m.map(r=>{var n;const t=(n=e.find(({code:a})=>a===r.code))==null?void 0:n.defaultValue;return t?{...r,defaultValue:t}:r}):m,Ge=({inputsDefaultValueSet:m,fieldsConfigForApiVersion1:e,apiVersion2:r})=>{const[t,n]=d([]);return Le(()=>{(async()=>{if(r){const s=await Pe("customer_account_create");if(s!=null&&s.length)if(m!=null&&m.length){const f=le(s,m);n(f)}else n(s)}else{const s=ae(ye),f=ae(e),F=le(s,m);n(e&&e.length?f:F)}})()},[r,e,m]),{fieldsListConfigs:t}},He=(m,e)=>{const r=["date_of_birth","dob","email","firstname","gender","is_subscribed","lastname","middlename","password","prefix","suffix","taxvat"],t=ve(m,"snakeCase",{firstName:"firstname",lastName:"lastname"});if(!e)return{...t,...t!=null&&t.gender?{gender:Number(t==null?void 0:t.gender)}:{}};const n={},a=[];return Object.keys(t).forEach(s=>{r.includes(s)?n[s]=s.includes("gender")?Number(t[s]):t[s]:a.push({attribute_code:s,value:t[s]})}),a.length>0&&(n.custom_attributes=a),n},Ie=({requireRetypePassword:m,addressesData:e,translations:r,isEmailConfirmationRequired:t,apiVersion2:n=!0,passwordConfigs:a,isAutoSignInEnabled:s,routeRedirectOnSignIn:f,routeSignIn:F,onErrorCallback:w,onSuccessCallback:c,setActiveComponent:g,handleSetInLineAlertProps:h,routeRedirectOnEmailConfirmationClose:T})=>{const[N,V]=d(""),[p,i]=d(""),[l,x]=d(""),[K,_]=d(!1),[B,E]=d({userName:"",status:!1}),[L,M]=d(""),[W,$]=d(!1),[j,P]=d(!1),[S,G]=d(!0),J=q(u=>{V(u),i(u?L===u?"":r.passwordMismatch:r.requiredFieldError)},[r,L]),O=q(({target:u})=>{G(u.checked)},[]),Q=q(()=>{if(I(g)){g("signInForm");return}I(F)&&(window.location.href=F())},[g,F]),X=q(u=>{M(u)},[]),Y=q(()=>{h(),M(""),I(T)?window.location.href=T():(_(!1),g==null||g("signInForm"))},[h,T,g]),C=()=>{$(!0),P(!1)};return{confirmPassword:N,confirmPasswordMessage:p,isKeepMeLogged:S,userEmail:l,showEmailConfirmationForm:K,isSuccessful:B,isClickSubmit:W,signUpPasswordValue:L,isLoading:j,onSubmitSignUp:async(u,k)=>{var te,ie,se;if(h(),i(""),P(!0),!k){C(),!N&&i(r.requiredFieldError);return}if(m&&(p.length||L!==N)){C(),i(N.length?r.passwordMismatch:r.requiredFieldError);return}const de=n?"createCustomerV2":"createCustomer",{confirmPasswordField:Ve,...re}=Me(u.target),{email:z,password:v,is_subscribed:fe}=re,ge=(a==null?void 0:a.requiredCharacterClasses)||0,he=(a==null?void 0:a.minLength)||1;if(!Ue(v,ge)||he>(v==null?void 0:v.length)){C();return}const pe=He({...re,is_subscribed:!!fe||!1},n),{data:y,errors:U}=await we(pe,n),H=((ie=(te=y==null?void 0:y.createCustomer)==null?void 0:te.customer)==null?void 0:ie.firstname)||"";if(U&&(U!=null&&U.length))h==null||h({type:"error",text:U[0].message}),w==null||w(U),me(ne.CREATE_ACCOUNT_EVENT,{updateProfile:!1}),x(z);else{const D={email:"",...y==null?void 0:y[de]};if(me(ne.CREATE_ACCOUNT_EVENT,{email:D==null?void 0:D.email,updateProfile:!0}),t||!s){if(c==null||c({userName:H,status:!0}),t){(se=u.target)==null||se.reset(),M(""),_(!0),x(z),P(!1);return}if(!s){P(!1),E({userName:H,status:!0});return}}const b=await Ee({email:z,password:v,translations:r,handleSetInLineAlertProps:h,onErrorCallback:w});if(b!=null&&b.userName){if(e!=null&&e.length)for(const oe of e)try{await Ne(oe)}catch(be){console.error(r.failedCreateCustomerAddress,oe,be)}I(f)?window.location.href=f():(c==null||c({userName:b==null?void 0:b.userName,status:!0}),E({userName:b==null?void 0:b.userName,status:!0}))}else c==null||c({userName:H,status:!0}),E({userName:H,status:!0})}P(!1)},signInButton:Q,handleSetSignUpPasswordValue:X,onKeepMeLoggedChange:O,handleHideEmailConfirmationForm:Y,handleConfirmPasswordChange:J}},or=({requireRetypePassword:m=!1,addressesData:e,formSize:r="default",inputsDefaultValueSet:t,fieldsConfigForApiVersion1:n,apiVersion2:a=!0,isAutoSignInEnabled:s=!0,displayTermsOfUseCheckbox:f=!1,displayNewsletterCheckbox:F=!1,hideCloseBtnOnEmailConfirmation:w=!1,routeRedirectOnEmailConfirmationClose:c,routeRedirectOnSignIn:g,routeSignIn:h,onErrorCallback:T,onSuccessCallback:N,setActiveComponent:V,slots:p})=>{const i=je({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",requiredFieldError:"Auth.FormText.requiredFieldError",confirmPasswordPlaceholder:"Auth.SignUpForm.confirmPassword.placeholder",confirmPasswordFloatingLabel:"Auth.SignUpForm.confirmPassword.floatingLabel",passwordMismatch:"Auth.SignUpForm.confirmPassword.passwordMismatch"}),{passwordConfigs:l,isEmailConfirmationRequired:x}=Te(),{fieldsListConfigs:K}=Ge({fieldsConfigForApiVersion1:n,apiVersion2:a,inputsDefaultValueSet:t}),{inLineAlertProps:_,handleSetInLineAlertProps:B}=Se(),{confirmPassword:E,confirmPasswordMessage:L,isKeepMeLogged:M,userEmail:W,showEmailConfirmationForm:$,isSuccessful:j,isClickSubmit:P,signUpPasswordValue:S,isLoading:G,onSubmitSignUp:J,signInButton:O,handleSetSignUpPasswordValue:Q,onKeepMeLoggedChange:X,handleHideEmailConfirmationForm:Y,handleConfirmPasswordChange:C}=Ie({requireRetypePassword:m,addressesData:e,translations:i,isEmailConfirmationRequired:x,apiVersion2:a,passwordConfigs:l,isAutoSignInEnabled:s,routeRedirectOnSignIn:g,routeSignIn:h,onErrorCallback:T,onSuccessCallback:N,setActiveComponent:V,handleSetInLineAlertProps:B,routeRedirectOnEmailConfirmationClose:c}),{isValidUniqueSymbols:Z,defaultLengthMessage:u}=xe({password:S,isClickSubmit:P,passwordConfigs:l}),k=!x&&(e==null?void 0:e.length);return!K.length&&a?o("div",{className:`auth-sign-up-form auth-sign-up-form--${r} skeleton-loader`,"data-testid":"SignUpForm",children:o(Ke,{activeSkeleton:"signUpForm"})}):j.status&&(p!=null&&p.SuccessNotification)?o(Fe,{"data-testid":"successNotificationTestId",name:"SuccessNotification",slot:p==null?void 0:p.SuccessNotification,context:{isSuccessful:j}}):$?o(Be,{formSize:r,userEmail:W,inLineAlertProps:_,hideCloseBtnOnEmailConfirmation:w,handleSetInLineAlertProps:B,onPrimaryButtonClick:Y}):A("div",{className:_e(["auth-sign-up-form",`auth-sign-up-form--${r}`]),"data-testid":"SignUpForm",children:[o(Ae,{title:i.title,divider:!1,className:"auth-sign-up-form__title"}),_.text?o(qe,{className:"auth-sign-up-form__notification",type:_.type,variant:"secondary",heading:_.text,icon:_.icon}):null,A(Ce,{onSubmit:J,className:"auth-sign-up-form__form",loading:G,name:"signUp_form",fieldsConfig:K,children:[A(ce,{validateLengthConfig:u,className:"auth-sign-up-form__form__field",autoComplete:"current-password",name:"password",minLength:l==null?void 0:l.minLength,errorMessage:Z==="error"||(u==null?void 0:u.status)==="error"||P&&S.length<=0?i.requiredFieldError:void 0,defaultValue:S,uniqueSymbolsStatus:Z,requiredCharacterClasses:l==null?void 0:l.requiredCharacterClasses,onValue:Q,placeholder:i.placeholder,floatingLabel:i.floatingLabel,children:[m?o("div",{className:"auth-sign-up-form__form__confirm-wrapper",children:o(ce,{className:"auth-sign-up-form__form__field auth-sign-up-form__form__field--confirm-password",autoComplete:"confirmPassword",name:"confirmPasswordField",placeholder:i.confirmPasswordPlaceholder,floatingLabel:i.confirmPasswordFloatingLabel,errorMessage:L,defaultValue:E,onValue:C})}):null,k?o("div",{className:"auth-sign-up-form__automatic-login","data-testid":"automaticLogin",children:o(R,{children:o(ee,{name:"",placeholder:i.keepMeLoggedText,label:i.keepMeLoggedText,checked:M,onChange:X})})}):null]}),F||f?A("div",{className:"auth-sign-up-form__item auth-sign-up-form__checkbox",children:[F?o(R,{children:o(ee,{"data-testid":"isSubscribed",name:"is_subscribed",placeholder:i.subscribedDefaultText,label:i.subscribedDefaultText})}):null,f?o(R,{children:o(ee,{"data-testid":"privacyPolicy",name:"privacyPolicy",placeholder:i.privacyPolicyDefaultText,label:i.privacyPolicyDefaultText})}):null]}):null,A("div",{className:"auth-sign-up-form-buttons",children:[o(ue,{type:"button",variant:"tertiary",style:{padding:0},buttonText:i.buttonSecondary,enableLoader:!1,onClick:O}),o(ue,{type:"submit",buttonText:i.buttonPrimary,variant:"primary",enableLoader:G})]})]}),o("div",{id:"createCustomerV2"})]})};export{or as S}; +/*! Copyright 2024 Adobe +All Rights Reserved. */ +import{jsx as m,jsxs as K}from"@dropins/tools/preact-jsx-runtime.js";import{Slot as Pe,classes as _e}from"@dropins/tools/lib.js";import"@dropins/tools/event-bus.js";import"@dropins/tools/recaptcha.js";import{g as Ne,c as Ee,a as Ue}from"./createCustomerAddress.js";import{useState as p,useEffect as ye,useCallback as T,useMemo as Le}from"@dropins/tools/preact-hooks.js";import{s as ue,b as Me}from"./simplifyTransformAttributesForm.js";import{v as Te,u as xe,a as Se}from"./usePasswordValidationMessage.js";import{a as ve}from"./getCustomerToken.js";import{p as de,E as ce}from"./getStoreConfig.js";import{c as V,g as qe,u as Ce,F as Ae,B as le}from"./UpdatePasswordForm.js";import{c as Be}from"./transform-attributes-form.js";import{Header as Ke,InLineAlert as je,InputPassword as fe,Field as re,Checkbox as te}from"@dropins/tools/components.js";/* empty css */import{S as Ie}from"./SkeletonLoader.js";import{E as Ge}from"./EmailConfirmationForm.js";import{useText as He}from"@dropins/tools/i18n.js";const he=(u,r)=>r!=null&&r.length?u.map(e=>{var d;const t=(d=r.find(({code:n})=>n===e.code))==null?void 0:d.defaultValue;return t?{...e,defaultValue:t}:e}):u,Ve=({inputsDefaultValueSet:u,fieldsConfigForApiVersion1:r,apiVersion2:e})=>{const[t,d]=p([]);return ye(()=>{(async()=>{if(e){const s=await Ne("customer_account_create");if(s!=null&&s.length)if(u!=null&&u.length){const w=he(s,u);d(w)}else d(s)}else{const s=ue(Me),w=ue(r),E=he(s,u);d(r&&r.length?w:E)}})()},[e,r,u]),{fieldsListConfigs:t}},We=(u,r)=>{const e=["date_of_birth","email","firstname","gender","is_subscribed","lastname","middlename","password","prefix","suffix","taxvat"],t=Be(u,"snakeCase",{firstName:"firstname",lastName:"lastname"});if(!r)return{...t,...t!=null&&t.gender?{gender:Number(t==null?void 0:t.gender)}:{}};const d={},n=[];return Object.keys(t).forEach(s=>{e.includes(s)?d[s]=s.includes("gender")?Number(t[s]):t[s]:n.push({attribute_code:s,value:t[s]})}),n.length>0&&(d.custom_attributes=n),d},$e=({requireRetypePassword:u,addressesData:r,translations:e,isEmailConfirmationRequired:t,apiVersion2:d=!0,passwordConfigs:n,isAutoSignInEnabled:s,routeRedirectOnSignIn:w,routeSignIn:E,onErrorCallback:x,onSuccessCallback:h,setActiveComponent:b,handleSetInLineAlertProps:P,routeRedirectOnEmailConfirmationClose:S})=>{const[W,v]=p(!1),[o,a]=p(""),[g,c]=p(""),[j,U]=p(""),[I,q]=p(!1),[$,C]=p({userName:"",status:!1}),[l,A]=p(""),[J,G]=p(!1),[O,y]=p(!1),[H,Q]=p(!0),X=T(i=>{const f=i.target.value;v(!f.length),f.length&&o.length&&f!==o&&c(e.passwordMismatch)},[o,e.passwordMismatch]),Y=T(i=>{const f=i.target.value;c(f.length?"":e.requiredFieldError),f.length&&l.length&&f!==l&&c(e.passwordMismatch)},[l,e.passwordMismatch,e.requiredFieldError]),Z=T(i=>{a(i),c(i?l===i?"":e.passwordMismatch:e.requiredFieldError)},[e,l]),k=T(({target:i})=>{Q(i.checked)},[]),z=T(()=>{if(V(b)){b("signInForm");return}V(E)&&(window.location.href=E())},[b,E]),D=T(i=>{A(i),v(!i.length),i===o&&c("")},[o]),R=T(()=>{P(),A(""),V(S)?window.location.href=S():(q(!1),b==null||b("signInForm"))},[P,S,b]),L=()=>{G(!0),y(!1)},_=()=>{const i=l.length&&o.length,f=l!==o;L(),v(!l.length),o||c(e.requiredFieldError),i&&f&&c(e.passwordMismatch)};return{showPasswordErrorMessage:W,confirmPassword:o,confirmPasswordMessage:g,isKeepMeLogged:H,userEmail:j,showEmailConfirmationForm:I,isSuccessful:$,isClickSubmit:J,signUpPasswordValue:l,isLoading:O,onSubmitSignUp:async(i,f)=>{var oe,ae,me;if(P(),c(""),y(!0),!f){_();return}if(u&&(g.length||l!==o)){L(),c(o.length?e.passwordMismatch:e.requiredFieldError);return}const{confirmPasswordField:Je,...ie}=qe(i.target),{email:ee,password:B,is_subscribed:ge}=ie,pe=(n==null?void 0:n.requiredCharacterClasses)||0,Fe=(n==null?void 0:n.minLength)||1;if(!Te(B,pe)||Fe>(B==null?void 0:B.length)){L();return}const we=We({...ie,is_subscribed:!!ge||!1},d),F=await Ee(we,d);if((oe=F==null?void 0:F.errors)!=null&&oe.length){const{errors:M}=F;P==null||P({type:"error",text:(ae=M[0])==null?void 0:ae.message}),x==null||x(M),de(ce.CREATE_ACCOUNT_EVENT,{updateProfile:!1}),U(ee)}else{const M=F==null?void 0:F.firstName;if(de(ce.CREATE_ACCOUNT_EVENT,{email:F==null?void 0:F.email,updateProfile:!0}),t||!s){if(h==null||h({userName:M,status:!0}),t){(me=i.target)==null||me.reset(),A(""),q(!0),U(ee),y(!1);return}if(!s){y(!1),C({userName:M,status:!0});return}}const N=await ve({email:ee,password:B,translations:e,handleSetInLineAlertProps:P,onErrorCallback:x});if(N!=null&&N.userName){if(r!=null&&r.length)for(const ne of r)try{await Ue(ne)}catch(be){console.error(e.failedCreateCustomerAddress,ne,be)}V(w)?window.location.href=w():(h==null||h({userName:N==null?void 0:N.userName,status:!0}),C({userName:N==null?void 0:N.userName,status:!0}))}else h==null||h({userName:M,status:!0}),C({userName:M,status:!0})}y(!1)},signInButton:z,handleSetSignUpPasswordValue:D,onKeepMeLoggedChange:k,handleHideEmailConfirmationForm:R,handleConfirmPasswordChange:Z,onBlurPassword:X,onBlurConfirmPassword:Y}},nr=({requireRetypePassword:u=!1,addressesData:r,formSize:e="default",inputsDefaultValueSet:t,fieldsConfigForApiVersion1:d,apiVersion2:n=!0,isAutoSignInEnabled:s=!0,displayTermsOfUseCheckbox:w=!1,displayNewsletterCheckbox:E=!1,hideCloseBtnOnEmailConfirmation:x=!1,routeRedirectOnEmailConfirmationClose:h,routeRedirectOnSignIn:b,routeSignIn:P,onErrorCallback:S,onSuccessCallback:W,setActiveComponent:v,slots:o})=>{const a=He({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",requiredFieldError:"Auth.FormText.requiredFieldError",confirmPasswordPlaceholder:"Auth.SignUpForm.confirmPassword.placeholder",confirmPasswordFloatingLabel:"Auth.SignUpForm.confirmPassword.floatingLabel",passwordMismatch:"Auth.SignUpForm.confirmPassword.passwordMismatch"}),{passwordConfigs:g,isEmailConfirmationRequired:c}=xe(),{fieldsListConfigs:j}=Ve({fieldsConfigForApiVersion1:d,apiVersion2:n,inputsDefaultValueSet:t}),{inLineAlertProps:U,handleSetInLineAlertProps:I}=Ce(),{showPasswordErrorMessage:q,confirmPassword:$,confirmPasswordMessage:C,isKeepMeLogged:l,userEmail:A,showEmailConfirmationForm:J,isSuccessful:G,isClickSubmit:O,signUpPasswordValue:y,isLoading:H,onSubmitSignUp:Q,signInButton:X,handleSetSignUpPasswordValue:Y,onKeepMeLoggedChange:Z,handleHideEmailConfirmationForm:k,handleConfirmPasswordChange:z,onBlurPassword:D,onBlurConfirmPassword:R}=$e({requireRetypePassword:u,addressesData:r,translations:a,isEmailConfirmationRequired:c,apiVersion2:n,passwordConfigs:g,isAutoSignInEnabled:s,routeRedirectOnSignIn:b,routeSignIn:P,onErrorCallback:S,onSuccessCallback:W,setActiveComponent:v,handleSetInLineAlertProps:I,routeRedirectOnEmailConfirmationClose:h}),{isValidUniqueSymbols:L,defaultLengthMessage:_}=Se({password:y,isClickSubmit:O,passwordConfigs:g}),se=Le(()=>q?a.requiredFieldError:L==="error"||(_==null?void 0:_.status)==="error"?" ":"",[_==null?void 0:_.status,L,q,a.requiredFieldError]),i=!c&&(r==null?void 0:r.length);return!j.length&&n?m("div",{className:`auth-sign-up-form auth-sign-up-form--${e} skeleton-loader`,"data-testid":"SignUpForm",children:m(Ie,{activeSkeleton:"signUpForm"})}):G.status&&(o!=null&&o.SuccessNotification)?m(Pe,{"data-testid":"successNotificationTestId",name:"SuccessNotification",slot:o==null?void 0:o.SuccessNotification,context:{isSuccessful:G}}):J?m(Ge,{formSize:e,userEmail:A,inLineAlertProps:U,hideCloseBtnOnEmailConfirmation:x,handleSetInLineAlertProps:I,onPrimaryButtonClick:k}):K("div",{className:_e(["auth-sign-up-form",`auth-sign-up-form--${e}`]),"data-testid":"SignUpForm",children:[m(Ke,{title:a.title,divider:!1,className:"auth-sign-up-form__title"}),U.text?m(je,{className:"auth-sign-up-form__notification",type:U.type,variant:"secondary",heading:U.text,icon:U.icon}):null,K(Ae,{onSubmit:Q,className:"auth-sign-up-form__form",loading:H,name:"signUp_form",fieldsConfig:j,children:[K(fe,{validateLengthConfig:_,className:"auth-sign-up-form__form__field",autoComplete:"current-password",name:"password",minLength:g==null?void 0:g.minLength,errorMessage:se,defaultValue:y,uniqueSymbolsStatus:L,requiredCharacterClasses:g==null?void 0:g.requiredCharacterClasses,onValue:Y,placeholder:a.placeholder,floatingLabel:a.floatingLabel,onBlur:D,children:[u?m("div",{className:"auth-sign-up-form__form__confirm-wrapper",children:m(fe,{className:"auth-sign-up-form__form__field auth-sign-up-form__form__field--confirm-password",autoComplete:"confirmPassword",name:"confirmPasswordField",placeholder:a.confirmPasswordPlaceholder,floatingLabel:a.confirmPasswordFloatingLabel,errorMessage:C,defaultValue:$,onValue:z,onBlur:R})}):null,i?m("div",{className:"auth-sign-up-form__automatic-login","data-testid":"automaticLogin",children:m(re,{children:m(te,{name:"",placeholder:a.keepMeLoggedText,label:a.keepMeLoggedText,checked:l,onChange:Z})})}):null]}),E||w?K("div",{className:"auth-sign-up-form__item auth-sign-up-form__checkbox",children:[E?m(re,{children:m(te,{"data-testid":"isSubscribed",name:"is_subscribed",placeholder:a.subscribedDefaultText,label:a.subscribedDefaultText})}):null,w?m(re,{children:m(te,{"data-testid":"privacyPolicy",name:"privacyPolicy",placeholder:a.privacyPolicyDefaultText,label:a.privacyPolicyDefaultText})}):null]}):null,K("div",{className:"auth-sign-up-form-buttons",children:[m(le,{type:"button",variant:"tertiary",style:{padding:0},buttonText:a.buttonSecondary,enableLoader:!1,onClick:X}),m(le,{type:"submit",buttonText:a.buttonPrimary,variant:"primary",enableLoader:H})]})]}),m("div",{id:"createCustomerV2"})]})};export{nr as S}; diff --git a/scripts/__dropins__/storefront-auth/chunks/SkeletonLoader.js b/scripts/__dropins__/storefront-auth/chunks/SkeletonLoader.js index efe1f36240..6bdfef8665 100644 --- a/scripts/__dropins__/storefront-auth/chunks/SkeletonLoader.js +++ b/scripts/__dropins__/storefront-auth/chunks/SkeletonLoader.js @@ -1 +1,3 @@ +/*! Copyright 2024 Adobe +All Rights Reserved. */ import{jsxs as l,jsx as e,Fragment as r}from"@dropins/tools/preact-jsx-runtime.js";import{useMemo as s}from"@dropins/tools/preact-hooks.js";import{Skeleton as a,SkeletonRow as i}from"@dropins/tools/components.js";const d=()=>l(a,{children:[e(i,{variant:"heading",size:"xlarge",fullWidth:!1,lines:1}),e(i,{variant:"heading",size:"xlarge",fullWidth:!0,lines:1}),e(i,{variant:"heading",size:"medium",fullWidth:!1,lines:1}),e(i,{variant:"heading",size:"medium",fullWidth:!1,lines:1})," ",e(i,{variant:"heading",size:"xlarge",fullWidth:!0,lines:1}),e(i,{variant:"heading",size:"xlarge",fullWidth:!0,lines:1}),e(i,{variant:"heading",size:"medium",fullWidth:!0,lines:1}),e(i,{variant:"heading",size:"xlarge",fullWidth:!0,lines:1}),e(i,{variant:"heading",size:"xlarge",fullWidth:!0,lines:1}),e(i,{variant:"heading",size:"medium",fullWidth:!1,lines:1}),e(i,{variant:"heading",size:"medium",fullWidth:!1,lines:1})]}),h=()=>l(a,{children:[e(i,{variant:"heading",size:"xlarge",fullWidth:!1,lines:1}),e(i,{variant:"heading",size:"xlarge",fullWidth:!0,lines:1}),e(i,{variant:"heading",size:"xlarge",fullWidth:!0,lines:1}),e(i,{variant:"heading",size:"medium",fullWidth:!1,lines:1})," ",e(i,{variant:"heading",size:"medium",fullWidth:!1,lines:1})]}),u=()=>l(a,{children:[e(i,{variant:"heading",size:"xlarge",fullWidth:!1,lines:1}),e(i,{variant:"heading",size:"xlarge",fullWidth:!0,lines:1}),e(i,{variant:"heading",size:"xlarge",fullWidth:!0,lines:1}),e(i,{variant:"heading",size:"medium",fullWidth:!1,lines:1})," ",e(i,{variant:"heading",size:"medium",fullWidth:!1,lines:1})]}),o=({activeSkeleton:n})=>{const t=s(()=>({signInForm:e(h,{}),signUpForm:e(d,{}),resetPasswordForm:e(u,{})}),[]);return e(r,{children:t[n]})};export{o as S}; diff --git a/scripts/__dropins__/storefront-auth/chunks/UpdatePasswordForm.js b/scripts/__dropins__/storefront-auth/chunks/UpdatePasswordForm.js index e26482daa9..20bc85a664 100644 --- a/scripts/__dropins__/storefront-auth/chunks/UpdatePasswordForm.js +++ b/scripts/__dropins__/storefront-auth/chunks/UpdatePasswordForm.js @@ -1 +1,3 @@ +/*! Copyright 2024 Adobe +All Rights Reserved. */ import{jsx as h,Fragment as Z,jsxs as U}from"@dropins/tools/preact-jsx-runtime.js";import{useState as R,useCallback as v,useRef as H,useEffect as P}from"@dropins/tools/preact-hooks.js";import*as $ from"@dropins/tools/preact-compat.js";import{memo as W,useCallback as _}from"@dropins/tools/preact-compat.js";import{initReCaptcha as G}from"@dropins/tools/recaptcha.js";import{useText as j}from"@dropins/tools/i18n.js";import{classes as L}from"@dropins/tools/lib.js";import{Field as w,Picker as q,Input as X,InputDate as C,Checkbox as z,TextArea as B,Button as J}from"@dropins/tools/components.js";const Ir=r=>{if(!r)return null;const t=new FormData(r);if(t&&typeof t.entries=="function"){const n=t.entries();if(n&&typeof n[Symbol.iterator]=="function")return JSON.parse(JSON.stringify(Object.fromEntries(n)))||{}}return{}},Dr=r=>typeof r=="function",Y=r=>$.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},$.createElement("g",{clipPath:"url(#clip0_841_1324)"},$.createElement("path",{vectorEffect:"non-scaling-stroke",d:"M11.9949 2.30237L0.802734 21.6977H23.1977L11.9949 2.30237Z",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round"}),$.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"})),$.createElement("defs",null,$.createElement("clipPath",{id:"clip0_841_1324"},$.createElement("rect",{width:24,height:21,fill:"white",transform:"translate(0 1.5)"})))),K=r=>$.createElement("svg",{width:24,height:24,viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",...r},$.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"}),$.createElement("path",{vectorEffect:"non-scaling-stroke",d:"M6.75 12.762L10.2385 15.75L17.25 9",stroke:"currentColor"})),Q=r=>$.createElement("svg",{width:24,height:24,viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",...r},$.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"}),$.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"})),g={success:h(K,{}),warning:h(Y,{}),error:h(Q,{})},xr=()=>{const[r,t]=R({}),n=v(l=>{if(!l||!l.type){t({});return}const c=g[l.type];t({...l,icon:c})},[]);return{inLineAlertProps:r,handleSetInLineAlertProps:n}};var m=(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))(m||{});const rr=W(({loading:r,values:t,fields:n=[],errors:l,className:c="",onChange:u,onBlur:p,onFocus:A})=>{const s=`${c}__field`,f=_((e,o,a)=>{var T;const E=(T=e.options.find(N=>N.isDefault))==null?void 0:T.value;return h(w,{error:a,className:L([s,`${s}--${e.id}`,[`${s}--${e.id}-hidden`,e.isHidden],e.className]),"data-testid":`${c}--${e.id}`,disabled:r||e.disabled,children:h(q,{name:e.customUpperCode,floatingLabel:`${e.label} ${e.required?"*":""}`,placeholder:e.label,"aria-label":e.label,options:e.options,onBlur:p,handleSelect:u,defaultValue:E??o??e.defaultValue,value:E??o??e.defaultValue})},e.id)},[c,r,s,p,u]),D=_((e,o,a)=>h(w,{error:a,className:L([s,`${s}--${e.id}`,[`${s}--${e.id}-hidden`,e.isHidden],e.className]),"data-testid":`${c}--${e.id}`,disabled:r,children:h(X,{type:"text",name:e.customUpperCode,value:o??e.defaultValue,placeholder:e.label,floatingLabel:`${e.label} ${e.required?"*":""}`,onBlur:p,onChange:u,onFocus:A})},e.id),[c,r,s,p,u,A]),x=_((e,o,a)=>h(w,{error:a,className:L([s,`${s}--${e.id}`,[`${s}--${e.id}-hidden`,e.isHidden],e.className]),"data-testid":`${c}--${e.id}`,disabled:r||e.disabled,children:h(C,{type:"text",name:e.customUpperCode,value:o||e.defaultValue,placeholder:e.label,floatingLabel:`${e.label} ${e.required?"*":""}`,onBlur:p,onChange:u,disabled:r||e.disabled})},e.id),[c,r,s,p,u]),b=_((e,o,a)=>h(w,{error:a,className:L([s,`${s}--${e.id}`,[`${s}--${e.id}-hidden`,e.isHidden],e.className]),"data-testid":`${c}--${e.id}`,disabled:r,children:h(z,{name:e.customUpperCode,checked:o||e.defaultValue,placeholder:e.label,label:`${e.label} ${e.required?"*":""}`,onBlur:p,onChange:u})},e.id),[c,r,s,p,u]),M=_((e,o,a)=>h(w,{error:a,className:L([s,`${s}--${e.id}`,[`${s}--${e.id}-hidden`,e.isHidden],e.className]),"data-testid":`${c}--${e.id}`,disabled:r,children:h(B,{type:"text",name:e.customUpperCode,value:o??e.defaultValue,label:`${e.label} ${e.required?"*":""}`,onBlur:p,onChange:u})},e.id),[c,r,s,p,u]);return n.length?h(Z,{children:n.map(e=>{const o=l==null?void 0:l[e.customUpperCode],a=t==null?void 0:t[e.customUpperCode];switch(e.fieldType){case m.TEXT:return e.options.length?f(e,a,o):D(e,a,o);case m.MULTILINE:return D(e,a,o);case m.SELECT:return f(e,a,o);case m.DATE:return x(e,a,o);case m.BOOLEAN:return b(e,a,o);case m.TEXTAREA:return M(e,a,o);default:return null}})}):null}),er=r=>r.reduce((t,{customUpperCode:n,required:l,defaultValue:c})=>(l&&n&&(t.initialData[n]=c||"",t.errorList[n]=""),t),{initialData:{},errorList:{}}),tr=r=>r.reduce((t,n)=>({...t,[n.name]:n.value}),{}),ar=r=>/^\d+$/.test(r),nr=r=>/^[a-zA-Z0-9\s]+$/.test(r),or=r=>/^[a-zA-Z0-9]+$/.test(r),lr=r=>/^[a-zA-Z]+$/.test(r),sr=r=>/^[a-z0-9,!\#\$%&'\*\+\/=\?\^_`\{\|\}~-]+(\.[a-z0-9,!\#\$%&'\*\+\/=\?\^_`\{\|\}~-]+)*@([a-z0-9-]+\.)+[a-z]{2,}$/i.test(r),cr=r=>/^\d{4}-\d{2}-\d{2}$/.test(r)&&!isNaN(Date.parse(r)),dr=(r,t,n)=>{const l=new Date(r).getTime()/1e3;return!(isNaN(l)||l<0||typeof t<"u"&&ln)},k=r=>{if(!r||r.trim()==="")return"";const t=parseInt(r,10);if(!isNaN(t)){const c=new Date(t*1e3);return isNaN(c.getTime())?"":c.toISOString().split("T")[0]}const n=new Date(r);if(isNaN(n.getTime()))return"";const l=parseInt(r.split("-")[1],10);return l>12||l<1?"":n.toISOString().split("T")[0]},ur=r=>/^(https?|ftp):\/\/(([A-Z0-9]([A-Z0-9_-]*[A-Z0-9]|))(\.[A-Z0-9]([A-Z0-9_-]*[A-Z0-9]|))*)(:(\d+))?(\/[A-Z0-9~](([A-Z0-9_~-]|\.)*[A-Z0-9~]|))*\/?(.*)?$/i.test(r),ir=(r,t,n)=>{const l=r.length;return l>=t&&l<=n},O=(r,t,n,l)=>{var y,F;const{requiredFieldError:c,lengthTextError:u,numericError:p,alphaNumWithSpacesError:A,alphaNumericError:s,alphaError:f,emailError:D,dateError:x,urlError:b,dateLengthError:M,dateMaxError:e,dateMinError:o}=n,a=t==null?void 0:t.customUpperCode,E={[a]:""};if(l[a]&&delete l[a],t!=null&&t.required&&!r)return{[a]:c};if(!(t!=null&&t.required)&&!r||!((y=t==null?void 0:t.validateRules)!=null&&y.length))return E;const T=tr(t==null?void 0:t.validateRules),N=T.MIN_TEXT_LENGTH??1,I=T.MAX_TEXT_LENGTH??255,d=T.DATE_RANGE_MIN,i=T.DATE_RANGE_MAX;if(!ir(r,+N,+I)&&!(d||i))return{[a]:u.replace("{min}",N).replace("{max}",I)};if(!dr(r,+d,+i)&&(d||i)){if(d&&d)return{[a]:M.replace("{min}",k(d)).replace("{max}",k(i))};if(typeof d>"u"||typeof i>"u")return{[a]:i?e.replace("{max}",k(i)):o.replace("{min}",k(d))}}const V={numeric:{validate:ar,error:p},"alphanum-with-spaces":{validate:nr,error:A},alphanumeric:{validate:or,error:s},alpha:{validate:lr,error:f},email:{validate:sr,error:D},date:{validate:cr,error:x},url:{validate:ur,error:b}}[T.INPUT_VALIDATION];return V&&!V.validate(r)&&!((F=l[a])!=null&&F.length)?{[a]:V.error}:E},pr=({fieldsConfig:r,onSubmit:t})=>{const n=j({requiredFieldError:"Auth.FormText.requiredFieldError",lengthTextError:"Auth.FormText.lengthTextError",numericError:"Auth.FormText.numericError",alphaNumWithSpacesError:"Account.FormText.alphaNumWithSpacesError",alphaNumericError:"Auth.FormText.alphaNumericError",alphaError:"Auth.FormText.alphaError",emailError:"Auth.FormText.emailError",dateError:"Auth.FormText.dateError",dateLengthError:"Auth.FormText.dateLengthError",dateMaxError:"Auth.FormText.dateMaxError",dateMinError:"Auth.FormText.dateMinError",urlError:"Auth.FormText.urlError"}),l=H(null),c=H(!1),[u,p]=R({}),[A,s]=R({}),f=v(()=>{let e=!0;const o={...A};let a=null;for(const[E,T]of Object.entries(u)){const N=r==null?void 0:r.find(d=>{var i;return(i=d==null?void 0:d.customUpperCode)==null?void 0:i.includes(E)}),I=O(T.toString(),N,n,o);I[E]&&(Object.assign(o,I),e=!1),a||(a=Object.keys(o).find(d=>o[d])||null)}if(s(o),a&&l.current){const E=l.current.elements.namedItem(a);E==null||E.focus()}return e},[A,r,u,n]);P(()=>{if(r!=null&&r.length){const{initialData:e,errorList:o}=er(r);p(a=>({...e,...a})),s(o)}},[JSON.stringify(r)]);const D=v(async()=>{c.current||(await G(0),c.current=!0)},[]),x=v(e=>{const{name:o,value:a,type:E,checked:T}=e==null?void 0:e.target,N=E==="checkbox"?T:a;p(i=>({...i,[o]:N}));const I=r==null?void 0:r.find(i=>{var S;return(S=i==null?void 0:i.customUpperCode)==null?void 0:S.includes(o)});let d={...A};if(I){const i=O(N.toString(),I,n,d);i&&Object.assign(d,i),s(d)}},[r,A,n]),b=v(e=>{const{name:o,value:a,type:E,checked:T}=e==null?void 0:e.target,N=E==="checkbox"?T:a,I=r==null?void 0:r.find(d=>d.customUpperCode===o);if(I){const d={...A},i=O(N.toString(),I,n,d);i&&Object.assign(d,i),s(d)}},[A,r,n]),M=v(e=>{e.preventDefault();const o=f();t==null||t(e,o)},[f,t]);return{formData:u,errors:A,formRef:l,handleChange:x,handleBlur:b,handleSubmit:M,handleFocus:D}},br=({name:r,loading:t,children:n,className:l="defaultForm",fieldsConfig:c=[],onSubmit:u})=>{const{formData:p,errors:A,formRef:s,handleChange:f,handleBlur:D,handleSubmit:x,handleFocus:b}=pr({onSubmit:u,fieldsConfig:c});return U("form",{className:l,onSubmit:x,name:r,ref:s,onFocus:b,children:[h(rr,{className:l,onFocus:b,fields:c,onChange:f,onBlur:D,errors:A,values:p,loading:t}),n]})},mr=({type:r,buttonText:t,variant:n,className:l="",enableLoader:c=!1,onClick:u,style:p,icon:A,...s})=>{const f=v(x=>{u==null||u(x)},[u]);return U(J,{icon:A,style:p,type:r,variant:n,className:L(["auth-button",l,c?"enableLoader":""]),onClick:f,...s,children:[h("span",{className:"auth-button__text",children:t}),c?h("div",{className:"auth-button__wrapper",children:h("span",{className:"auth-button__loader"})}):null]})};export{mr as B,br as F,Dr as c,Ir as g,xr as u}; diff --git a/scripts/__dropins__/storefront-auth/chunks/confirmEmail.js b/scripts/__dropins__/storefront-auth/chunks/confirmEmail.js index e4872b447c..c422fff4b9 100644 --- a/scripts/__dropins__/storefront-auth/chunks/confirmEmail.js +++ b/scripts/__dropins__/storefront-auth/chunks/confirmEmail.js @@ -1,9 +1,10 @@ +/*! Copyright 2024 Adobe +All Rights Reserved. */ import{f as o,h as r}from"./network-error.js";const t=` mutation CONFIRM_EMAIL($email: String!, $confirmation_key: String!) { - confirmEmail(input: { - email: $email, - confirmation_key: $confirmation_key - }) { + confirmEmail( + input: { email: $email, confirmation_key: $confirmation_key } + ) { customer { email } diff --git a/scripts/__dropins__/storefront-auth/chunks/createCustomerAddress.js b/scripts/__dropins__/storefront-auth/chunks/createCustomerAddress.js index de04a0fab1..dcbc8606a1 100644 --- a/scripts/__dropins__/storefront-auth/chunks/createCustomerAddress.js +++ b/scripts/__dropins__/storefront-auth/chunks/createCustomerAddress.js @@ -1,26 +1,24 @@ -import{f as a,h as s}from"./network-error.js";import{s as n}from"./setReCaptchaToken.js";import{t as u}from"./transform-attributes-form.js";import{h as o}from"./getStoreConfig.js";const i=` +/*! Copyright 2024 Adobe +All Rights Reserved. */ +import{CUSTOMER_INFORMATION_FRAGMENT as N}from"../fragments.js";import{f as m,h as u}from"./network-error.js";import{s as I}from"./setReCaptchaToken.js";import"@dropins/tools/event-bus.js";import"@dropins/tools/recaptcha.js";import{merge as U}from"@dropins/tools/lib.js";import{c as g}from"./initialize.js";import{t as $}from"./transform-attributes-form.js";import{h as F}from"./getStoreConfig.js";const v=` mutation CREATE_CUSTOMER($input: CustomerInput!) { createCustomer(input: $input) { customer { - firstname - lastname - email - is_subscribed + ...CUSTOMER_INFORMATION_FRAGMENT } } } -`,m=` + ${N} +`,y=` mutation CREATE_CUSTOMER_V2($input: CustomerCreateInput!) { createCustomerV2(input: $input) { customer { - firstname - lastname - email - is_subscribed + ...CUSTOMER_INFORMATION_FRAGMENT } } } -`,T=async(r,t)=>(await n(),await a(t?m:i,{method:"POST",variables:{input:{...r}}}).catch(s)),c=` + ${N} +`,G=(r,e)=>{var i,a,c,n,C,l,f,E,T,_,R,A,h,S,b,M,O,d,s,p;let o;if(e){const{data:t}=r;o={firstName:((a=(i=t==null?void 0:t.createCustomerV2)==null?void 0:i.customer)==null?void 0:a.firstname)??"",lastName:((n=(c=t==null?void 0:t.createCustomerV2)==null?void 0:c.customer)==null?void 0:n.lastname)??"",email:((l=(C=t==null?void 0:t.createCustomerV2)==null?void 0:C.customer)==null?void 0:l.email)??"",isSubscribed:((E=(f=t==null?void 0:t.createCustomerV2)==null?void 0:f.customer)==null?void 0:E.is_subscribed)??!1,customAttributes:((T=t==null?void 0:t.createCustomerV2)==null?void 0:T.custom_attributes)??[],errors:(r==null?void 0:r.errors)??[]}}else{const{data:t}=r;o={firstName:((R=(_=t==null?void 0:t.createCustomer)==null?void 0:_.customer)==null?void 0:R.firstname)??"",lastName:((h=(A=t==null?void 0:t.createCustomer)==null?void 0:A.customer)==null?void 0:h.lastname)??"",email:((b=(S=t==null?void 0:t.createCustomer)==null?void 0:S.customer)==null?void 0:b.email)??"",isSubscribed:((O=(M=t==null?void 0:t.createCustomer)==null?void 0:M.customer)==null?void 0:O.is_subscribed)??!1,errors:(r==null?void 0:r.errors)??[]}}return U(o,(p=(s=(d=g.getConfig().models)==null?void 0:d.CustomerModel)==null?void 0:s.transformer)==null?void 0:p.call(s,r))},H=async(r,e)=>{await I();const o=await m(e?y:v,{method:"POST",variables:{input:{...r}}}).catch(u);return G(o,e)},V=` query GET_ATTRIBUTES_FORM($formCode: String!) { attributesForm(formCode: $formCode) { items { @@ -52,10 +50,10 @@ import{f as a,h as s}from"./network-error.js";import{s as n}from"./setReCaptchaT } } } -`,p=async r=>await a(c,{method:"GET",cache:"force-cache",variables:{formCode:r}}).then(t=>{var e;return(e=t.errors)!=null&&e.length?o(t.errors):u(t)}).catch(s),d=` +`,J=async r=>await m(V,{method:"GET",cache:"force-cache",variables:{formCode:r}}).then(e=>{var o;return(o=e.errors)!=null&&o.length?F(e.errors):$(e)}).catch(u),w=` mutation CREATE_CUSTOMER_ADDRESS($input: CustomerAddressInput!) { - createCustomerAddress(input:$input) { + createCustomerAddress(input: $input) { firstname - } + } } -`,f=async r=>await a(d,{method:"POST",variables:{input:r}}).then(t=>{var e;return(e=t.errors)!=null&&e.length?o(t.errors):t.data.createCustomerAddress.firstname||""}).catch(s);export{f as a,T as c,p as g}; +`,K=async r=>await m(w,{method:"POST",variables:{input:r}}).then(e=>{var o;return(o=e.errors)!=null&&o.length?F(e.errors):e.data.createCustomerAddress.firstname||""}).catch(u);export{K as a,H as c,J as g}; diff --git a/scripts/__dropins__/storefront-auth/chunks/getCustomerToken.js b/scripts/__dropins__/storefront-auth/chunks/getCustomerToken.js index cada7215c0..1a249bbf30 100644 --- a/scripts/__dropins__/storefront-auth/chunks/getCustomerToken.js +++ b/scripts/__dropins__/storefront-auth/chunks/getCustomerToken.js @@ -1,15 +1,16 @@ -import{a as y,f as k,h as x}from"./network-error.js";import"@dropins/tools/recaptcha.js";import{h as R,p as T,E as g,a as v,C as O}from"./getStoreConfig.js";import{events as D}from"@dropins/tools/event-bus.js";import{c as U}from"./initialize.js";import{s as K}from"./setReCaptchaToken.js";const F=t=>{var m,r,e,c,a,f;return{email:((r=(m=t==null?void 0:t.data)==null?void 0:m.customer)==null?void 0:r.email)||"",firstname:((c=(e=t==null?void 0:t.data)==null?void 0:e.customer)==null?void 0:c.firstname)||"",lastname:((f=(a=t==null?void 0:t.data)==null?void 0:a.customer)==null?void 0:f.lastname)||""}},H=` +/*! Copyright 2024 Adobe +All Rights Reserved. */ +import{a as U,f as w,h as k}from"./network-error.js";import"@dropins/tools/recaptcha.js";import{events as x}from"@dropins/tools/event-bus.js";import{merge as y}from"@dropins/tools/lib.js";import{c as C}from"./initialize.js";import{CUSTOMER_INFORMATION_FRAGMENT as F}from"../fragments.js";import{p as E,E as O,a as S,C as R}from"./getStoreConfig.js";import{s as v}from"./setReCaptchaToken.js";const D=t=>{var f,e,i,a,r,o,u,T,s,g,N,c,_;const m={email:((e=(f=t==null?void 0:t.data)==null?void 0:f.customer)==null?void 0:e.email)??"",firstName:((a=(i=t==null?void 0:t.data)==null?void 0:i.customer)==null?void 0:a.firstname)??"",lastName:((o=(r=t==null?void 0:t.data)==null?void 0:r.customer)==null?void 0:o.lastname)??"",isSubscribed:((T=(u=t==null?void 0:t.data)==null?void 0:u.customer)==null?void 0:T.is_subscribed)??!1};return y(m,(_=(c=(N=(g=(s=C)==null?void 0:s.getConfig())==null?void 0:g.models)==null?void 0:N.CustomerModel)==null?void 0:c.transformer)==null?void 0:_.call(c,t.data))},K=` query GET_CUSTOMER_DATA { customer { - firstname - lastname - email + ...CUSTOMER_INFORMATION_FRAGMENT } } -`,Q=async t=>{if(t){const{authHeaderConfig:m}=U.getConfig();y(m.header,m.tokenPrefix?`${m.tokenPrefix} ${t}`:t)}return await k(H,{method:"GET",cache:"force-cache"}).then(m=>{var r;return(r=m.errors)!=null&&r.length?R(m.errors):F(m)}).catch(x)},S=` + ${F} +`,H=async t=>{if(t){const{authHeaderConfig:m}=C.getConfig();U(m.header,m.tokenPrefix?`${m.tokenPrefix} ${t}`:t)}return await w(K,{method:"GET",cache:"force-cache"}).then(m=>D(m)).catch(k)},I=` mutation GET_CUSTOMER_TOKEN($email: String!, $password: String!) { generateCustomerToken(email: $email, password: $password) { token } } -`,J=async({email:t,password:m,translations:r,onErrorCallback:e,handleSetInLineAlertProps:c})=>{var E,N,d,$,M,G,w;await K();const a=await k(S,{method:"POST",variables:{email:t,password:m}}).catch(x);if(!((N=(E=a==null?void 0:a.data)==null?void 0:E.generateCustomerToken)!=null&&N.token)){const o=r.customerTokenErrorMessage,u=a!=null&&a.errors?a.errors[0].message:o;return e==null||e(u),c==null||c({type:"error",text:u}),T((d=g)==null?void 0:d.SIGN_IN,{}),{errorMessage:u,userName:""}}const f=(M=($=a==null?void 0:a.data)==null?void 0:$.generateCustomerToken)==null?void 0:M.token,i=await Q(f);if(!(i!=null&&i.firstname)||!(i!=null&&i.email)){const o=r.customerTokenErrorMessage;return e==null||e(o),c==null||c({type:"error",text:o}),T((G=g)==null?void 0:G.SIGN_IN,{}),{errorMessage:o,userName:""}}const h=i==null?void 0:i.firstname,s=i==null?void 0:i.email,_=await v();return document.cookie=`${O.auth_dropin_firstname}=${h}; path=/; ${_}; `,document.cookie=`${O.auth_dropin_user_token}=${f}; path=/; ${_}; `,D.emit("authenticated",!!f),T((w=g)==null?void 0:w.SIGN_IN,s?{email:s}:{}),{errorMessage:"",userName:h}};export{J as a,Q as g}; +`,W=async({email:t,password:m,translations:f,onErrorCallback:e,handleSetInLineAlertProps:i})=>{var g,N,c,_,h,$,G;await v();const a=await w(I,{method:"POST",variables:{email:t,password:m}}).catch(k);if(!((N=(g=a==null?void 0:a.data)==null?void 0:g.generateCustomerToken)!=null&&N.token)){const d=f.customerTokenErrorMessage,M=a!=null&&a.errors?a.errors[0].message:d;return e==null||e(M),i==null||i({type:"error",text:M}),E((c=O)==null?void 0:c.SIGN_IN,{}),{errorMessage:M,userName:""}}const r=(h=(_=a==null?void 0:a.data)==null?void 0:_.generateCustomerToken)==null?void 0:h.token,o=await H(r),u=o==null?void 0:o.firstName,T=o==null?void 0:o.email;if(!u||!T){const d=f.customerTokenErrorMessage;return e==null||e(d),i==null||i({type:"error",text:d}),E(($=O)==null?void 0:$.SIGN_IN,{}),{errorMessage:d,userName:""}}const s=await S();return document.cookie=`${R.auth_dropin_firstname}=${u}; path=/; ${s}; `,document.cookie=`${R.auth_dropin_user_token}=${r}; path=/; ${s}; `,x.emit("authenticated",!!r),E((G=O)==null?void 0:G.SIGN_IN,{email:T}),{errorMessage:"",userName:u}};export{W as a,H as g}; diff --git a/scripts/__dropins__/storefront-auth/chunks/getStoreConfig.js b/scripts/__dropins__/storefront-auth/chunks/getStoreConfig.js index bf7f59943c..4023c8da2a 100644 --- a/scripts/__dropins__/storefront-auth/chunks/getStoreConfig.js +++ b/scripts/__dropins__/storefront-auth/chunks/getStoreConfig.js @@ -1,3 +1,5 @@ +/*! Copyright 2024 Adobe +All Rights Reserved. */ import"@dropins/tools/event-bus.js";import"@dropins/tools/recaptcha.js";import{f as l,h as E}from"./network-error.js";const T=e=>({personalEmail:{address:(e==null?void 0:e.email)||""},userAccount:{login:!0},commerce:{commerceScope:{storeCode:(e==null?void 0:e.store_code)||""}}}),S=e=>({userAccount:{logout:!0},commerce:{commerceScope:{storeCode:(e==null?void 0:e.store_code)||""}}}),N=e=>({personalEmail:{address:(e==null?void 0:e.email)||""},userAccount:{updateProfile:e==null?void 0:e.updateProfile},commerce:{commerceScope:{storeCode:(e==null?void 0:e.store_code)||""}}}),D={auth_dropin_user_token:"auth_dropin_user_token",auth_dropin_firstname:"auth_dropin_firstname"},c=3600,I=e=>{var t,o,r,a,m,_,f,g,d,C;return{autocompleteOnStorefront:((o=(t=e==null?void 0:e.data)==null?void 0:t.storeConfig)==null?void 0:o.autocomplete_on_storefront)||!1,minLength:((a=(r=e==null?void 0:e.data)==null?void 0:r.storeConfig)==null?void 0:a.minimum_password_length)||3,requiredCharacterClasses:+((_=(m=e==null?void 0:e.data)==null?void 0:m.storeConfig)==null?void 0:_.required_character_classes_number)||0,createAccountConfirmation:((g=(f=e==null?void 0:e.data)==null?void 0:f.storeConfig)==null?void 0:g.create_account_confirmation)||!1,customerAccessTokenLifetime:((C=(d=e==null?void 0:e.data)==null?void 0:d.storeConfig)==null?void 0:C.customer_access_token_lifetime)*c||c}},O=e=>{const t=e.map(o=>o.message).join(" ");throw Error(t)},U=e=>{document.cookie=`${e}=; expires=Thu, 01 Jan 1970 00:00:00 UTC; path=/;`},R=async()=>{try{const e=sessionStorage.getItem("storeConfig");let o=(e?JSON.parse(e):{}).customerAccessTokenLifetime;if(!o){const r=await b();sessionStorage.setItem("storeConfig",JSON.stringify(r)),o=(r==null?void 0:r.customerAccessTokenLifetime)||c}return`Max-Age=${o}`}catch(e){return console.error("getCookiesLifetime() Error:",e),`Max-Age=${c}`}};var A=(e=>(e.CREATE_ACCOUNT_EVENT="create-account",e.SIGN_IN="sign-in",e.SIGN_OUT="sign-out",e))(A||{});const s="authContext",h="shopperContext",i={CREATE_ACCOUNT:"create-account",SIGN_IN:"sign-in",SIGN_OUT:"sign-out"};function n(e,t){const o=window.adobeDataLayer||[];o.push({[e]:null}),o.push({[e]:t})}function u(e){(window.adobeDataLayer||[]).push(o=>{const r=o.getState?o.getState():{};o.push({event:e,eventInfo:{...r}})})}function k(e){const t=N(e);n(s,t),u(i.CREATE_ACCOUNT)}function p(e){const t=T(e);n(s,t),n(h,{shopperId:"logged-in"}),u(i.SIGN_IN)}function w(e){const t=S(e);n(s,t),n(h,{shopperId:"guest"}),u(i.SIGN_OUT)}const M=(e,t)=>{const o=sessionStorage.getItem("storeConfig"),a={...o?JSON.parse(o):{},...t};switch(e){case"create-account":k(a);break;case"sign-in":p(a);break;case"sign-out":w(a);break;default:return null}},G=` query GET_STORE_CONFIG { storeConfig { diff --git a/scripts/__dropins__/storefront-auth/chunks/index.js b/scripts/__dropins__/storefront-auth/chunks/index.js index 24ff0945c9..ca991f000c 100644 --- a/scripts/__dropins__/storefront-auth/chunks/index.js +++ b/scripts/__dropins__/storefront-auth/chunks/index.js @@ -1 +1,3 @@ +/*! Copyright 2024 Adobe +All Rights Reserved. */ import{R as b,R as c}from"./ResetPasswordForm.js";import"@dropins/tools/preact-jsx-runtime.js";import"@dropins/tools/lib.js";import"./UpdatePasswordForm.js";import"@dropins/tools/preact-hooks.js";import"@dropins/tools/preact-compat.js";import"@dropins/tools/recaptcha.js";import"@dropins/tools/i18n.js";import"@dropins/tools/components.js";import"@dropins/tools/event-bus.js";import"./requestPasswordResetEmail.js";import"./network-error.js";import"@dropins/tools/fetch-graphql.js";import"./setReCaptchaToken.js";/* empty css */import"./simplifyTransformAttributesForm.js";import"./transform-attributes-form.js";export{b as ResetPasswordForm,c as default}; diff --git a/scripts/__dropins__/storefront-auth/chunks/index2.js b/scripts/__dropins__/storefront-auth/chunks/index2.js index 00bfd0a9af..4d1706e9fa 100644 --- a/scripts/__dropins__/storefront-auth/chunks/index2.js +++ b/scripts/__dropins__/storefront-auth/chunks/index2.js @@ -1 +1,3 @@ -import{S as k,S as q}from"./SignInForm.js";import"@dropins/tools/preact-jsx-runtime.js";import"@dropins/tools/lib.js";import"./UpdatePasswordForm.js";import"@dropins/tools/preact-hooks.js";import"@dropins/tools/preact-compat.js";import"@dropins/tools/recaptcha.js";import"@dropins/tools/i18n.js";import"@dropins/tools/components.js";import"@dropins/tools/event-bus.js";import"./getCustomerToken.js";import"./network-error.js";import"@dropins/tools/fetch-graphql.js";import"./getStoreConfig.js";import"./initialize.js";import"./setReCaptchaToken.js";import"./resendConfirmationEmail.js";import"./simplifyTransformAttributesForm.js";import"./transform-attributes-form.js";import"./confirmEmail.js";/* empty css */import"./EmailConfirmationForm.js";export{k as SignInForm,q as default}; +/*! Copyright 2024 Adobe +All Rights Reserved. */ +import{S as q,S as v}from"./SignInForm.js";import"@dropins/tools/preact-jsx-runtime.js";import"@dropins/tools/lib.js";import"./UpdatePasswordForm.js";import"@dropins/tools/preact-hooks.js";import"@dropins/tools/preact-compat.js";import"@dropins/tools/recaptcha.js";import"@dropins/tools/i18n.js";import"@dropins/tools/components.js";import"@dropins/tools/event-bus.js";import"./getCustomerToken.js";import"./network-error.js";import"@dropins/tools/fetch-graphql.js";import"./initialize.js";import"../fragments.js";import"./getStoreConfig.js";import"./setReCaptchaToken.js";import"./resendConfirmationEmail.js";import"./simplifyTransformAttributesForm.js";import"./transform-attributes-form.js";import"./confirmEmail.js";/* empty css */import"./EmailConfirmationForm.js";export{q as SignInForm,v as default}; diff --git a/scripts/__dropins__/storefront-auth/chunks/index3.js b/scripts/__dropins__/storefront-auth/chunks/index3.js index a952dfc42d..f7f5d70058 100644 --- a/scripts/__dropins__/storefront-auth/chunks/index3.js +++ b/scripts/__dropins__/storefront-auth/chunks/index3.js @@ -1 +1,3 @@ -import{S as v,S as w}from"./SignUpForm.js";import"@dropins/tools/preact-jsx-runtime.js";import"@dropins/tools/lib.js";import"@dropins/tools/event-bus.js";import"@dropins/tools/recaptcha.js";import"./createCustomerAddress.js";import"./network-error.js";import"@dropins/tools/fetch-graphql.js";import"./setReCaptchaToken.js";import"./transform-attributes-form.js";import"./getStoreConfig.js";import"@dropins/tools/preact-hooks.js";import"./simplifyTransformAttributesForm.js";import"./usePasswordValidationMessage.js";import"@dropins/tools/i18n.js";import"./getCustomerToken.js";import"./initialize.js";import"./UpdatePasswordForm.js";import"@dropins/tools/preact-compat.js";import"@dropins/tools/components.js";/* empty css */import"./SkeletonLoader.js";import"./EmailConfirmationForm.js";import"./resendConfirmationEmail.js";export{v as SignUpForm,w as default}; +/*! Copyright 2024 Adobe +All Rights Reserved. */ +import{S as w,S as y}from"./SignUpForm.js";import"@dropins/tools/preact-jsx-runtime.js";import"@dropins/tools/lib.js";import"@dropins/tools/event-bus.js";import"@dropins/tools/recaptcha.js";import"./createCustomerAddress.js";import"../fragments.js";import"./network-error.js";import"@dropins/tools/fetch-graphql.js";import"./setReCaptchaToken.js";import"./initialize.js";import"./transform-attributes-form.js";import"./getStoreConfig.js";import"@dropins/tools/preact-hooks.js";import"./simplifyTransformAttributesForm.js";import"./usePasswordValidationMessage.js";import"@dropins/tools/i18n.js";import"./getCustomerToken.js";import"./UpdatePasswordForm.js";import"@dropins/tools/preact-compat.js";import"@dropins/tools/components.js";/* empty css */import"./SkeletonLoader.js";import"./EmailConfirmationForm.js";import"./resendConfirmationEmail.js";export{w as SignUpForm,y as default}; diff --git a/scripts/__dropins__/storefront-auth/chunks/initialize.js b/scripts/__dropins__/storefront-auth/chunks/initialize.js index 4694336287..48b5b4b6df 100644 --- a/scripts/__dropins__/storefront-auth/chunks/initialize.js +++ b/scripts/__dropins__/storefront-auth/chunks/initialize.js @@ -1 +1,3 @@ +/*! Copyright 2024 Adobe +All Rights Reserved. */ import{Initializer as o}from"@dropins/tools/lib.js";const i=new o({init:async n=>{const e={authHeaderConfig:{header:"Authorization",tokenPrefix:"Bearer"}};i.config.setConfig({...e,...n})},listeners:()=>[]}),a=i.config;export{a as c,i}; diff --git a/scripts/__dropins__/storefront-auth/chunks/network-error.js b/scripts/__dropins__/storefront-auth/chunks/network-error.js index f2d0406a8c..b42c878118 100644 --- a/scripts/__dropins__/storefront-auth/chunks/network-error.js +++ b/scripts/__dropins__/storefront-auth/chunks/network-error.js @@ -1 +1,3 @@ +/*! Copyright 2024 Adobe +All Rights Reserved. */ import{FetchGraphQL as e}from"@dropins/tools/fetch-graphql.js";import{events as r}from"@dropins/tools/event-bus.js";const{setEndpoint:h,setFetchGraphQlHeader:n,removeFetchGraphQlHeader:c,setFetchGraphQlHeaders:p,fetchGraphQl:i,getConfig:f}=new e().getMethods(),m=t=>{throw t instanceof DOMException&&t.name==="AbortError"||r.emit("auth/error",{source:"auth",type:"network",error:t}),t};export{n as a,p as b,i as f,f as g,m as h,c as r,h as s}; diff --git a/scripts/__dropins__/storefront-auth/chunks/requestPasswordResetEmail.js b/scripts/__dropins__/storefront-auth/chunks/requestPasswordResetEmail.js index 0a42afb41c..bc522e0e36 100644 --- a/scripts/__dropins__/storefront-auth/chunks/requestPasswordResetEmail.js +++ b/scripts/__dropins__/storefront-auth/chunks/requestPasswordResetEmail.js @@ -1,3 +1,5 @@ +/*! Copyright 2024 Adobe +All Rights Reserved. */ import{f as E,h as l}from"./network-error.js";import{s as e}from"./setReCaptchaToken.js";const R=a=>{var r,m,i;let t="";return(r=a==null?void 0:a.errors)!=null&&r.length&&(t=(m=a==null?void 0:a.errors[0])==null?void 0:m.message),{message:t,success:!!((i=a==null?void 0:a.data)!=null&&i.requestPasswordResetEmail)}},c=` mutation REQUEST_PASSWORD_RESET_EMAIL($email: String!) { requestPasswordResetEmail(email: $email) diff --git a/scripts/__dropins__/storefront-auth/chunks/resendConfirmationEmail.js b/scripts/__dropins__/storefront-auth/chunks/resendConfirmationEmail.js index 745cd5dcf0..bee8145f76 100644 --- a/scripts/__dropins__/storefront-auth/chunks/resendConfirmationEmail.js +++ b/scripts/__dropins__/storefront-auth/chunks/resendConfirmationEmail.js @@ -1,4 +1,7 @@ +/*! Copyright 2024 Adobe +All Rights Reserved. */ import{f as r,h as e}from"./network-error.js";const i=` -mutation RESEND_CONFIRMATION_EMAIL($email: String!) { - resendConfirmationEmail(email: $email) -}`,n=async a=>await r(i,{method:"POST",variables:{email:a}}).catch(e);export{n as r}; + mutation RESEND_CONFIRMATION_EMAIL($email: String!) { + resendConfirmationEmail(email: $email) + } +`,n=async a=>await r(i,{method:"POST",variables:{email:a}}).catch(e);export{n as r}; diff --git a/scripts/__dropins__/storefront-auth/chunks/resetPassword.js b/scripts/__dropins__/storefront-auth/chunks/resetPassword.js index 119699aa02..1584ee7812 100644 --- a/scripts/__dropins__/storefront-auth/chunks/resetPassword.js +++ b/scripts/__dropins__/storefront-auth/chunks/resetPassword.js @@ -1,5 +1,15 @@ +/*! Copyright 2024 Adobe +All Rights Reserved. */ import{f as o,h as w}from"./network-error.js";import{s as d}from"./setReCaptchaToken.js";const i=` - mutation RESET_PASSWORD($email: String!, $resetPasswordToken: String!, $newPassword: String!){ - resetPassword(email: $email,resetPasswordToken: $resetPasswordToken,newPassword: $newPassword) + mutation RESET_PASSWORD( + $email: String! + $resetPasswordToken: String! + $newPassword: String! + ) { + resetPassword( + email: $email + resetPasswordToken: $resetPasswordToken + newPassword: $newPassword + ) } `,P=a=>{var r,s,e;let t="";return(r=a==null?void 0:a.errors)!=null&&r.length&&(t=(s=a==null?void 0:a.errors[0])==null?void 0:s.message),{message:t,success:!!((e=a==null?void 0:a.data)!=null&&e.resetPassword)}},S=async(a,t,r)=>(await d(),await o(i,{method:"POST",variables:{email:a,resetPasswordToken:t,newPassword:r}}).then(s=>P(s)).catch(w));export{S as r}; diff --git a/scripts/__dropins__/storefront-auth/chunks/revokeCustomerToken.js b/scripts/__dropins__/storefront-auth/chunks/revokeCustomerToken.js index e8033febf4..4b64ef7150 100644 --- a/scripts/__dropins__/storefront-auth/chunks/revokeCustomerToken.js +++ b/scripts/__dropins__/storefront-auth/chunks/revokeCustomerToken.js @@ -1,3 +1,5 @@ +/*! Copyright 2024 Adobe +All Rights Reserved. */ import{f as u,h as n}from"./network-error.js";import{C as m,d as s,p as c,E}from"./getStoreConfig.js";import{events as i}from"@dropins/tools/event-bus.js";const k=t=>{var r,o,a;let e="";return(r=t==null?void 0:t.errors)!=null&&r.length&&(e=((o=t==null?void 0:t.errors[0])==null?void 0:o.message)||"Unknown error"),{message:e,success:!!((a=t==null?void 0:t.data)!=null&&a.revokeCustomerToken)}},h=` mutation REVOKE_CUSTOMER_TOKEN { revokeCustomerToken { diff --git a/scripts/__dropins__/storefront-auth/chunks/setReCaptchaToken.js b/scripts/__dropins__/storefront-auth/chunks/setReCaptchaToken.js index ffad115ea0..7c2f91394c 100644 --- a/scripts/__dropins__/storefront-auth/chunks/setReCaptchaToken.js +++ b/scripts/__dropins__/storefront-auth/chunks/setReCaptchaToken.js @@ -1 +1,3 @@ +/*! Copyright 2024 Adobe +All Rights Reserved. */ import{verifyReCaptcha as t}from"@dropins/tools/recaptcha.js";import"@dropins/tools/event-bus.js";import{a as e}from"./network-error.js";const s=async()=>{const a=await t();a&&e("X-ReCaptcha",a)};export{s}; diff --git a/scripts/__dropins__/storefront-auth/chunks/simplifyTransformAttributesForm.js b/scripts/__dropins__/storefront-auth/chunks/simplifyTransformAttributesForm.js index 0854d46240..b0ff94f9ef 100644 --- a/scripts/__dropins__/storefront-auth/chunks/simplifyTransformAttributesForm.js +++ b/scripts/__dropins__/storefront-auth/chunks/simplifyTransformAttributesForm.js @@ -1 +1,3 @@ +/*! Copyright 2024 Adobe +All Rights Reserved. */ import{t}from"./transform-attributes-form.js";const s=[{customUpperCode:"email",code:"email",default_value:"",entity_type:"CUSTOMER",frontend_class:"auth-sign-in-form__form__email",frontend_input:"TEXT",is_required:!0,multiline_count:1,sort_order:1,is_unique:!1,label:"Email",options:[]}],n=[{customUpperCode:"email",code:"email",default_value:"",entity_type:"CUSTOMER",frontend_class:"auth-reset-password-form__form__item",frontend_input:"TEXT",is_required:!0,is_unique:!1,label:"Email",options:[]}],_=[{customUpperCode:"email",code:"email",default_value:"",entity_type:"CUSTOMER",frontend_class:"",frontend_input:"TEXT",is_required:!0,is_unique:!1,label:"Email",multiline_count:1,sort_order:1,options:[]},{customUpperCode:"firstname",code:"firstname",default_value:"",entity_type:"CUSTOMER",frontend_class:"",frontend_input:"TEXT",is_required:!0,is_unique:!1,label:"First name",multiline_count:1,sort_order:2,options:[]},{customUpperCode:"lastname",code:"lastname",default_value:"",entity_type:"CUSTOMER",frontend_class:"",frontend_input:"TEXT",is_required:!1,is_unique:!1,label:"Last name",multiline_count:1,sort_order:3,options:[]}],a=e=>e!=null&&e.length?t({data:{attributesForm:{items:e}}}):[];export{n as D,s as a,_ as b,a as s}; diff --git a/scripts/__dropins__/storefront-auth/chunks/transform-attributes-form.js b/scripts/__dropins__/storefront-auth/chunks/transform-attributes-form.js index fe968f794f..1e6a358e67 100644 --- a/scripts/__dropins__/storefront-auth/chunks/transform-attributes-form.js +++ b/scripts/__dropins__/storefront-auth/chunks/transform-attributes-form.js @@ -1 +1,3 @@ +/*! Copyright 2024 Adobe +All Rights Reserved. */ const _=t=>t.replace(/_([a-z])/g,(n,e)=>e.toUpperCase()),p=t=>t.replace(/([A-Z])/g,n=>`_${n.toLowerCase()}`),m=(t,n,e)=>{const s=["string","boolean","number"],a=n==="camelCase"?_:p;return Array.isArray(t)?t.map(o=>s.includes(typeof o)||o===null?o:typeof o=="object"?m(o,n,e):o):t!==null&&typeof t=="object"?Object.entries(t).reduce((o,[i,c])=>{const r=e&&e[i]?e[i]:a(i);return o[r]=s.includes(typeof c)||c===null?c:m(c,n,e),o},{}):t},b=t=>{let n=[];for(const e of t)if(!(e.frontend_input!=="MULTILINE"||e.multiline_count<2))for(let s=2;s<=e.multiline_count;s++){const a={...e,is_required:!1,name:`${e.code}_multiline_${s}`,code:`${e.code}_multiline_${s}`,id:`${e.code}_multiline_${s}`};n.push(a)}return n},C=t=>{var o,i,c;const n=((i=(o=t==null?void 0:t.data)==null?void 0:o.attributesForm)==null?void 0:i.items)||[];if(!n.length)return[];const e=(c=n.filter(r=>{var u;return!((u=r.frontend_input)!=null&&u.includes("HIDDEN"))}))==null?void 0:c.map(({code:r,...u})=>{const l=r!=="country_id"?r:"country_code";return{...u,name:l,id:l,code:l}}),s=b(e);return e.concat(s).map(r=>{var d;const u=r.code==="firstname"?"firstName":r.code==="lastname"?"lastName":_(r.code),l=(d=r.options)==null?void 0:d.map(f=>({isDefault:f.is_default,text:f.label,value:f.value}));return m({...r,options:l,customUpperCode:u},"camelCase",{frontend_input:"fieldType",frontend_class:"className",is_required:"required",sort_order:"orderNumber"})}).sort((r,u)=>r.orderNumber-u.orderNumber)};export{m as c,C as t}; diff --git a/scripts/__dropins__/storefront-auth/chunks/usePasswordValidationMessage.js b/scripts/__dropins__/storefront-auth/chunks/usePasswordValidationMessage.js index 7068e90f82..ef6ef183ab 100644 --- a/scripts/__dropins__/storefront-auth/chunks/usePasswordValidationMessage.js +++ b/scripts/__dropins__/storefront-auth/chunks/usePasswordValidationMessage.js @@ -1 +1,3 @@ +/*! Copyright 2024 Adobe +All Rights Reserved. */ import"@dropins/tools/event-bus.js";import"@dropins/tools/recaptcha.js";import{g as m}from"./getStoreConfig.js";import{useState as c,useEffect as u,useMemo as h}from"@dropins/tools/preact-hooks.js";import{useText as f}from"@dropins/tools/i18n.js";const A=()=>{const[e,n]=c(!1),[t,i]=c(null);return u(()=>{const a=sessionStorage.getItem("storeConfig"),r=a?JSON.parse(a):null;if(r){const{minLength:o,requiredCharacterClasses:s,createAccountConfirmation:g}=r;i({minLength:o,requiredCharacterClasses:s}),n(g)}else m().then(o=>{if(o){const{minLength:s,requiredCharacterClasses:g,createAccountConfirmation:l}=o;sessionStorage.setItem("storeConfig",JSON.stringify(o)),i({minLength:s,requiredCharacterClasses:g}),n(l)}})},[]),{passwordConfigs:t,isEmailConfirmationRequired:e}},L=(e,n)=>{if(n<=1)return!0;const t=/[0-9]/.test(e)?1:0,i=/[a-z]/.test(e)?1:0,a=/[A-Z]/.test(e)?1:0,r=/[^a-zA-Z0-9\s]/.test(e)?1:0;return t+i+a+r>=n},M=({passwordConfigs:e,isClickSubmit:n,password:t})=>{const i=f({messageLengthPassword:"Auth.PasswordValidationMessage.messageLengthPassword"}),[a,r]=c("pending");u(()=>{if(!e)return;const s=L(t,e.requiredCharacterClasses);n&&t.length>0?r(s?"success":"error"):n&&t.length===0?r("pending"):r(s?"success":"pending")},[n,e,t]);const o=h(()=>{var g;if(!e)return;const s={status:"pending",icon:"pending",message:(g=i.messageLengthPassword)==null?void 0:g.replace("{minLength}",`${e.minLength}`)};return t.length&&t.length>=e.minLength?{...s,icon:"success",status:"success"}:t.length&&t.length0){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}; diff --git a/scripts/__dropins__/storefront-auth/containers/ResetPassword.js b/scripts/__dropins__/storefront-auth/containers/ResetPassword.js index 702f474f33..dc132fd911 100644 --- a/scripts/__dropins__/storefront-auth/containers/ResetPassword.js +++ b/scripts/__dropins__/storefront-auth/containers/ResetPassword.js @@ -1 +1,3 @@ +/*! Copyright 2024 Adobe +All Rights Reserved. */ import{jsx as r}from"@dropins/tools/preact-jsx-runtime.js";import{R as i}from"../chunks/ResetPasswordForm.js";import"@dropins/tools/lib.js";import"../chunks/UpdatePasswordForm.js";import"@dropins/tools/preact-hooks.js";import"@dropins/tools/preact-compat.js";import"@dropins/tools/recaptcha.js";import"@dropins/tools/i18n.js";import"@dropins/tools/components.js";import"@dropins/tools/event-bus.js";import"../chunks/requestPasswordResetEmail.js";import"../chunks/network-error.js";import"@dropins/tools/fetch-graphql.js";import"../chunks/setReCaptchaToken.js";/* empty css */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}; diff --git a/scripts/__dropins__/storefront-auth/containers/SignIn.js b/scripts/__dropins__/storefront-auth/containers/SignIn.js index 154ff81df8..8ff307abb1 100644 --- a/scripts/__dropins__/storefront-auth/containers/SignIn.js +++ b/scripts/__dropins__/storefront-auth/containers/SignIn.js @@ -1 +1,3 @@ -import{jsx as r}from"@dropins/tools/preact-jsx-runtime.js";import{S as u}from"../chunks/SignInForm.js";import"@dropins/tools/lib.js";import"../chunks/UpdatePasswordForm.js";import"@dropins/tools/preact-hooks.js";import"@dropins/tools/preact-compat.js";import"@dropins/tools/recaptcha.js";import"@dropins/tools/i18n.js";import"@dropins/tools/components.js";import"@dropins/tools/event-bus.js";import"../chunks/getCustomerToken.js";import"../chunks/network-error.js";import"@dropins/tools/fetch-graphql.js";import"../chunks/getStoreConfig.js";import"../chunks/initialize.js";import"../chunks/setReCaptchaToken.js";import"../chunks/resendConfirmationEmail.js";import"../chunks/simplifyTransformAttributesForm.js";import"../chunks/transform-attributes-form.js";import"../chunks/confirmEmail.js";/* empty css */import"../chunks/EmailConfirmationForm.js";const K=({slots:i,labels:o,enableEmailConfirmation:t,initialEmailValue:m,formSize:p,renderSignUpLink:n,hideCloseBtnOnEmailConfirmation:s,routeRedirectOnEmailConfirmationClose:a,routeRedirectOnSignIn:e,routeForgotPassword:c,routeSignUp:d,onSuccessCallback:f,onErrorCallback:g,onSignUpLinkClick:l})=>r("div",{className:"auth-sign-in",children:r(u,{slots:i,labels:o,formSize:p,renderSignUpLink:n,initialEmailValue:m,enableEmailConfirmation:t,hideCloseBtnOnEmailConfirmation:s,routeRedirectOnEmailConfirmationClose:a,routeSignUp:d,onErrorCallback:g,onSuccessCallback:f,onSignUpLinkClick:l,routeForgotPassword:c,routeRedirectOnSignIn:e})});export{K as SignIn,K as default}; +/*! Copyright 2024 Adobe +All Rights Reserved. */ +import{jsx as r}from"@dropins/tools/preact-jsx-runtime.js";import{S as u}from"../chunks/SignInForm.js";import"@dropins/tools/lib.js";import"../chunks/UpdatePasswordForm.js";import"@dropins/tools/preact-hooks.js";import"@dropins/tools/preact-compat.js";import"@dropins/tools/recaptcha.js";import"@dropins/tools/i18n.js";import"@dropins/tools/components.js";import"@dropins/tools/event-bus.js";import"../chunks/getCustomerToken.js";import"../chunks/network-error.js";import"@dropins/tools/fetch-graphql.js";import"../chunks/initialize.js";import"../fragments.js";import"../chunks/getStoreConfig.js";import"../chunks/setReCaptchaToken.js";import"../chunks/resendConfirmationEmail.js";import"../chunks/simplifyTransformAttributesForm.js";import"../chunks/transform-attributes-form.js";import"../chunks/confirmEmail.js";/* empty css */import"../chunks/EmailConfirmationForm.js";const L=({slots:i,labels:o,enableEmailConfirmation:t,initialEmailValue:m,formSize:p,renderSignUpLink:n,hideCloseBtnOnEmailConfirmation:s,routeRedirectOnEmailConfirmationClose:a,routeRedirectOnSignIn:e,routeForgotPassword:c,routeSignUp:d,onSuccessCallback:f,onErrorCallback:g,onSignUpLinkClick:l})=>r("div",{className:"auth-sign-in",children:r(u,{slots:i,labels:o,formSize:p,renderSignUpLink:n,initialEmailValue:m,enableEmailConfirmation:t,hideCloseBtnOnEmailConfirmation:s,routeRedirectOnEmailConfirmationClose:a,routeSignUp:d,onErrorCallback:g,onSuccessCallback:f,onSignUpLinkClick:l,routeForgotPassword:c,routeRedirectOnSignIn:e})});export{L as SignIn,L as default}; diff --git a/scripts/__dropins__/storefront-auth/containers/SignUp.js b/scripts/__dropins__/storefront-auth/containers/SignUp.js index 2e8cc6b5ff..3d9ba183c0 100644 --- a/scripts/__dropins__/storefront-auth/containers/SignUp.js +++ b/scripts/__dropins__/storefront-auth/containers/SignUp.js @@ -1 +1,3 @@ -import{jsx as r}from"@dropins/tools/preact-jsx-runtime.js";import{S as h}from"../chunks/SignUpForm.js";import"@dropins/tools/lib.js";import"@dropins/tools/event-bus.js";import"@dropins/tools/recaptcha.js";import"../chunks/createCustomerAddress.js";import"../chunks/network-error.js";import"@dropins/tools/fetch-graphql.js";import"../chunks/setReCaptchaToken.js";import"../chunks/transform-attributes-form.js";import"../chunks/getStoreConfig.js";import"@dropins/tools/preact-hooks.js";import"../chunks/simplifyTransformAttributesForm.js";import"../chunks/usePasswordValidationMessage.js";import"@dropins/tools/i18n.js";import"../chunks/getCustomerToken.js";import"../chunks/initialize.js";import"../chunks/UpdatePasswordForm.js";import"@dropins/tools/preact-compat.js";import"@dropins/tools/components.js";/* empty css */import"../chunks/SkeletonLoader.js";import"../chunks/EmailConfirmationForm.js";import"../chunks/resendConfirmationEmail.js";const O=({slots:i,formSize:o,apiVersion2:t,addressesData:m,isAutoSignInEnabled:p,requireRetypePassword:s,inputsDefaultValueSet:a,displayNewsletterCheckbox:n,displayTermsOfUseCheckbox:e,fieldsConfigForApiVersion1:u,hideCloseBtnOnEmailConfirmation:c,routeRedirectOnEmailConfirmationClose:d,routeRedirectOnSignIn:f,onSuccessCallback:g,onErrorCallback:l,routeSignIn:S})=>r("div",{className:"auth-sign-up",children:r(h,{requireRetypePassword:s,formSize:o,apiVersion2:t,addressesData:m,isAutoSignInEnabled:p,inputsDefaultValueSet:a,fieldsConfigForApiVersion1:u,displayNewsletterCheckbox:n,displayTermsOfUseCheckbox:e,hideCloseBtnOnEmailConfirmation:c,routeRedirectOnEmailConfirmationClose:d,routeRedirectOnSignIn:f,routeSignIn:S,slots:i,onErrorCallback:l,onSuccessCallback:g})});export{O as SignUp,O as default}; +/*! Copyright 2024 Adobe +All Rights Reserved. */ +import{jsx as r}from"@dropins/tools/preact-jsx-runtime.js";import{S as h}from"../chunks/SignUpForm.js";import"@dropins/tools/lib.js";import"@dropins/tools/event-bus.js";import"@dropins/tools/recaptcha.js";import"../chunks/createCustomerAddress.js";import"../fragments.js";import"../chunks/network-error.js";import"@dropins/tools/fetch-graphql.js";import"../chunks/setReCaptchaToken.js";import"../chunks/initialize.js";import"../chunks/transform-attributes-form.js";import"../chunks/getStoreConfig.js";import"@dropins/tools/preact-hooks.js";import"../chunks/simplifyTransformAttributesForm.js";import"../chunks/usePasswordValidationMessage.js";import"@dropins/tools/i18n.js";import"../chunks/getCustomerToken.js";import"../chunks/UpdatePasswordForm.js";import"@dropins/tools/preact-compat.js";import"@dropins/tools/components.js";/* empty css */import"../chunks/SkeletonLoader.js";import"../chunks/EmailConfirmationForm.js";import"../chunks/resendConfirmationEmail.js";const P=({slots:i,formSize:o,apiVersion2:t,addressesData:m,isAutoSignInEnabled:p,requireRetypePassword:s,inputsDefaultValueSet:a,displayNewsletterCheckbox:n,displayTermsOfUseCheckbox:e,fieldsConfigForApiVersion1:u,hideCloseBtnOnEmailConfirmation:c,routeRedirectOnEmailConfirmationClose:d,routeRedirectOnSignIn:f,onSuccessCallback:g,onErrorCallback:l,routeSignIn:S})=>r("div",{className:"auth-sign-up",children:r(h,{requireRetypePassword:s,formSize:o,apiVersion2:t,addressesData:m,isAutoSignInEnabled:p,inputsDefaultValueSet:a,fieldsConfigForApiVersion1:u,displayNewsletterCheckbox:n,displayTermsOfUseCheckbox:e,hideCloseBtnOnEmailConfirmation:c,routeRedirectOnEmailConfirmationClose:d,routeRedirectOnSignIn:f,routeSignIn:S,slots:i,onErrorCallback:l,onSuccessCallback:g})});export{P as SignUp,P as default}; diff --git a/scripts/__dropins__/storefront-auth/containers/SuccessNotification.js b/scripts/__dropins__/storefront-auth/containers/SuccessNotification.js index 8fd6c7cff4..dc6647bc86 100644 --- a/scripts/__dropins__/storefront-auth/containers/SuccessNotification.js +++ b/scripts/__dropins__/storefront-auth/containers/SuccessNotification.js @@ -1 +1,3 @@ +/*! Copyright 2024 Adobe +All Rights Reserved. */ 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";/* empty css */import{Button as s}from"@dropins/tools/components.js";import"@dropins/tools/event-bus.js";import"@dropins/tools/recaptcha.js";import{r as f}from"../chunks/revokeCustomerToken.js";import{useText as d}from"@dropins/tools/i18n.js";import"../chunks/network-error.js";import"@dropins/tools/fetch-graphql.js";import"../chunks/getStoreConfig.js";const h=({formSize:n="default",className:e="",slots:t,labels:i})=>{const c=d({headingText:"Auth.SuccessNotification.headingText",messageText:"Auth.SuccessNotification.messageText",primaryButtonText:"Auth.SuccessNotification.primaryButtonText",secondaryButtonText:"Auth.SuccessNotification.secondaryButtonText"});return a("div",{className:u(["auth-success-notification-form",`auth-success-notification-form--${n}`,e]),children:[o("p",{className:"auth-success-notification-form__title","data-testid":"notification-title",children:(i==null?void 0:i.headingText)||c.headingText}),o("p",{className:"auth-success-notification-form__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-success-notification-form__button auth-success-notification-form__button--top",onClick:()=>window.location.href="/",children:c.primaryButtonText}),o(s,{"data-testid":"secondaryButton",type:"button",variant:"tertiary",onClick:async()=>{await f(),window.location.href="/"},children:c.secondaryButtonText})]})]})},k=({formSize:n="default",slots:e,className:t,labels:i})=>o("div",{className:"auth-success-notification",children:o(h,{formSize:n,className:t,slots:e,labels:i})});export{k as SuccessNotification,k as default}; diff --git a/scripts/__dropins__/storefront-auth/containers/UpdatePassword.js b/scripts/__dropins__/storefront-auth/containers/UpdatePassword.js index 4d9cd26da6..29c4c90698 100644 --- a/scripts/__dropins__/storefront-auth/containers/UpdatePassword.js +++ b/scripts/__dropins__/storefront-auth/containers/UpdatePassword.js @@ -1 +1,3 @@ -import{jsx as u,jsxs as H}from"@dropins/tools/preact-jsx-runtime.js";import{Slot as Z,classes as $}from"@dropins/tools/lib.js";import{v as k,u as S,a as W}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 j,g as R,u as C,F as tt,B as et}from"../chunks/UpdatePasswordForm.js";import{useState as h,useEffect as z,useCallback as I}from"@dropins/tools/preact-hooks.js";import{useText as K}from"@dropins/tools/i18n.js";import{Header as at,InLineAlert as st,InputPassword as rt}from"@dropins/tools/components.js";/* empty css */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=(d,p)=>d.split("&").filter(r=>r.includes(p)).map(r=>r.split("=")[1])[0],it=({isEmailConfirmationRequired:d,signInOnSuccess:p,passwordConfigs:t,routeRedirectOnSignIn:r,routeWrongUrlRedirect:w,onErrorCallback:a,onSuccessCallback:i,handleSetInLineAlertProps:m,routeRedirectOnPasswordUpdate:N,routeSignInPage:o})=>{const s=K({errorNotification:"Auth.Notification.errorNotification",updatePasswordMessage:"Auth.Notification.updatePasswordMessage",updatePasswordActionMessage:"Auth.Notification.updatePasswordActionMessage",customerTokenErrorMessage:"Auth.Api.customerTokenErrorMessage"}),[U,n]=h({userName:"",status:!1}),[x,F]=h(""),[v,A]=h(!1),[P,L]=h(""),[y,M]=h(""),[T,c]=h(!1),[_,q]=h(!1),[b,B]=h([]);z(()=>{v&&!b.length&&(x.length?q(!1):q(!0))},[v,x,b]),z(()=>{const{search:f}=window.location;!f.includes("token=")&&!f.includes("email=")&&j(w)&&(window.location.href=w());const e=decodeURIComponent(f),V=J(e,"token"),E=J(e,"email");L(E),M(V)},[w]);const Q=I(async f=>{f.preventDefault(),c(!0),B([]);const e=R(f.target),V=(e==null?void 0:e.password)&&P&&y;e!=null&&e.password||(q(!0),c(!1));const E=(t==null?void 0:t.requiredCharacterClasses)??0,Y=(t==null?void 0:t.minLength)??0;if(!k(e==null?void 0:e.password,E)||e.password.length<+Y){A(!0),c(!1);return}if(!V){m({type:"error",text:s.errorNotification}),c(!1);return}const{message:D,success:G}=await g(P,y,e.password);if(G){if(d||!d&&!p){i==null||i(),j(N)&&(window.location.href=N()),A(!0),c(!1),q(!1),F(""),B([{label:s.updatePasswordActionMessage,onClick:()=>{window.location.href=o==null?void 0:o()}}]),m({type:"success",text:s.updatePasswordMessage});return}const l=await O({email:P,password:e.password,handleSetInLineAlertProps:m,onErrorCallback:a,translations:s});l!=null&&l.userName&&(i==null||i(l==null?void 0:l.userName),j(r)?window.location.href=r():n({userName:l==null?void 0:l.userName,status:!0}))}else m({type:"error",text:D}),a==null||a({message:D,success:G});c(!1)},[P,y,t==null?void 0:t.requiredCharacterClasses,t==null?void 0:t.minLength,s,d,p,o,a,i,r,m,N]),X=I(f=>{F(f)},[]);return{additionalActionsAlert:b,passwordError:_,isSuccessful:U,updatePasswordValue:x,isClickSubmit:v,isLoading:T,submitUpdatePassword:Q,handleSetUpdatePasswordValue:X,setIsClickSubmit:A}},ot=({signInOnSuccess:d=!0,formSize:p="default",routeRedirectOnSignIn:t,routeWrongUrlRedirect:r,routeSignInPage:w,slots:a,onErrorCallback:i,onSuccessCallback:m,routeRedirectOnPasswordUpdate:N})=>{const o=K({title:"Auth.UpdatePasswordForm.title",buttonPrimary:"Auth.UpdatePasswordForm.buttonPrimary",placeholder:"Auth.InputPassword.placeholder",floatingLabel:"Auth.InputPassword.floatingLabel",requiredFieldError:"Auth.FormText.requiredFieldError"}),{passwordConfigs:s,isEmailConfirmationRequired:U}=S(),{inLineAlertProps:n,handleSetInLineAlertProps:x}=C(),{additionalActionsAlert:F,passwordError:v,isSuccessful:A,updatePasswordValue:P,isClickSubmit:L,isLoading:y,submitUpdatePassword:M,handleSetUpdatePasswordValue:T}=it({isEmailConfirmationRequired:U,signInOnSuccess:d,passwordConfigs:s,routeRedirectOnSignIn:t,routeWrongUrlRedirect:r,onErrorCallback:i,onSuccessCallback:m,handleSetInLineAlertProps:x,routeRedirectOnPasswordUpdate:N,routeSignInPage:w}),{isValidUniqueSymbols:c,defaultLengthMessage:_}=W({password:P,isClickSubmit:L,passwordConfigs:s});return A.status&&(a!=null&&a.SuccessNotification)?u(Z,{"data-testid":"successNotificationTestId",name:"SuccessNotification",slot:a==null?void 0:a.SuccessNotification,context:{isSuccessful:A}}):H("div",{className:$(["auth-update-password-form",`auth-update-password-form--${p}`]),children:[u(at,{title:o.title,divider:!1,className:"auth-update-password-form__title"}),u(st,{className:$(["auth-update-password-form__notification",["auth-update-password-form__notification--show",!!(n!=null&&n.text)]]),variant:"secondary",heading:n==null?void 0:n.text,icon:n.icon,additionalActions:F}),H(tt,{name:"updatePassword_form",className:"auth-update-password-form__form",onSubmit:M,loading:y,fieldsConfig:[],children:[u("div",{style:"display: none;",children:u("input",{type:"text",id:"username",name:"username",autoComplete:"username"})}),u(rt,{defaultValue:P,onValue:T,className:"auth-update-password-form__form__item",autoComplete:"new-password",name:"password",errorMessage:v||c==="error"||(_==null?void 0:_.status)==="error"?o.requiredFieldError:void 0,minLength:s==null?void 0:s.minLength,uniqueSymbolsStatus:c,validateLengthConfig:_,requiredCharacterClasses:s==null?void 0:s.requiredCharacterClasses,placeholder:o.placeholder,floatingLabel:o.floatingLabel}),u("div",{className:"auth-update-password-form__button",children:u(et,{type:"submit",buttonText:o.buttonPrimary,variant:"primary",enableLoader:y})})]})]})},qt=({slots:d,formSize:p,signInOnSuccess:t,routeRedirectOnPasswordUpdate:r,routeRedirectOnSignIn:w,routeSignInPage:a,routeWrongUrlRedirect:i,onErrorCallback:m,onSuccessCallback:N})=>u("div",{className:"auth-update-password",children:u(ot,{formSize:p,signInOnSuccess:t,routeSignInPage:a,routeRedirectOnSignIn:w,routeWrongUrlRedirect:i,onErrorCallback:m,onSuccessCallback:N,slots:d,routeRedirectOnPasswordUpdate:r})});export{qt as UpdatePassword,qt as default}; +/*! Copyright 2024 Adobe +All Rights Reserved. */ +import{jsx as u,jsxs as H}from"@dropins/tools/preact-jsx-runtime.js";import{Slot as Z,classes as $}from"@dropins/tools/lib.js";import{v as k,u as S,a as W}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 j,g as R,u as C,F as tt,B as et}from"../chunks/UpdatePasswordForm.js";import{useState as h,useEffect as z,useCallback as I}from"@dropins/tools/preact-hooks.js";import{useText as K}from"@dropins/tools/i18n.js";import{Header as at,InLineAlert as st,InputPassword as rt}from"@dropins/tools/components.js";/* empty css */import"../chunks/getStoreConfig.js";import"../chunks/network-error.js";import"@dropins/tools/fetch-graphql.js";import"../chunks/initialize.js";import"../fragments.js";import"../chunks/setReCaptchaToken.js";import"@dropins/tools/preact-compat.js";const J=(d,p)=>d.split("&").filter(r=>r.includes(p)).map(r=>r.split("=")[1])[0],it=({isEmailConfirmationRequired:d,signInOnSuccess:p,passwordConfigs:t,routeRedirectOnSignIn:r,routeWrongUrlRedirect:w,onErrorCallback:a,onSuccessCallback:i,handleSetInLineAlertProps:m,routeRedirectOnPasswordUpdate:N,routeSignInPage:o})=>{const s=K({errorNotification:"Auth.Notification.errorNotification",updatePasswordMessage:"Auth.Notification.updatePasswordMessage",updatePasswordActionMessage:"Auth.Notification.updatePasswordActionMessage",customerTokenErrorMessage:"Auth.Api.customerTokenErrorMessage"}),[U,n]=h({userName:"",status:!1}),[x,F]=h(""),[v,A]=h(!1),[P,L]=h(""),[y,M]=h(""),[T,c]=h(!1),[_,q]=h(!1),[b,B]=h([]);z(()=>{v&&!b.length&&(x.length?q(!1):q(!0))},[v,x,b]),z(()=>{const{search:f}=window.location;!f.includes("token=")&&!f.includes("email=")&&j(w)&&(window.location.href=w());const e=decodeURIComponent(f),V=J(e,"token"),E=J(e,"email");L(E),M(V)},[w]);const Q=I(async f=>{f.preventDefault(),c(!0),B([]);const e=R(f.target),V=(e==null?void 0:e.password)&&P&&y;e!=null&&e.password||(q(!0),c(!1));const E=(t==null?void 0:t.requiredCharacterClasses)??0,Y=(t==null?void 0:t.minLength)??0;if(!k(e==null?void 0:e.password,E)||e.password.length<+Y){A(!0),c(!1);return}if(!V){m({type:"error",text:s.errorNotification}),c(!1);return}const{message:D,success:G}=await g(P,y,e.password);if(G){if(d||!d&&!p){i==null||i(),j(N)&&(window.location.href=N()),A(!0),c(!1),q(!1),F(""),B([{label:s.updatePasswordActionMessage,onClick:()=>{window.location.href=o==null?void 0:o()}}]),m({type:"success",text:s.updatePasswordMessage});return}const l=await O({email:P,password:e.password,handleSetInLineAlertProps:m,onErrorCallback:a,translations:s});l!=null&&l.userName&&(i==null||i(l==null?void 0:l.userName),j(r)?window.location.href=r():n({userName:l==null?void 0:l.userName,status:!0}))}else m({type:"error",text:D}),a==null||a({message:D,success:G});c(!1)},[P,y,t==null?void 0:t.requiredCharacterClasses,t==null?void 0:t.minLength,s,d,p,o,a,i,r,m,N]),X=I(f=>{F(f)},[]);return{additionalActionsAlert:b,passwordError:_,isSuccessful:U,updatePasswordValue:x,isClickSubmit:v,isLoading:T,submitUpdatePassword:Q,handleSetUpdatePasswordValue:X,setIsClickSubmit:A}},ot=({signInOnSuccess:d=!0,formSize:p="default",routeRedirectOnSignIn:t,routeWrongUrlRedirect:r,routeSignInPage:w,slots:a,onErrorCallback:i,onSuccessCallback:m,routeRedirectOnPasswordUpdate:N})=>{const o=K({title:"Auth.UpdatePasswordForm.title",buttonPrimary:"Auth.UpdatePasswordForm.buttonPrimary",placeholder:"Auth.InputPassword.placeholder",floatingLabel:"Auth.InputPassword.floatingLabel",requiredFieldError:"Auth.FormText.requiredFieldError"}),{passwordConfigs:s,isEmailConfirmationRequired:U}=S(),{inLineAlertProps:n,handleSetInLineAlertProps:x}=C(),{additionalActionsAlert:F,passwordError:v,isSuccessful:A,updatePasswordValue:P,isClickSubmit:L,isLoading:y,submitUpdatePassword:M,handleSetUpdatePasswordValue:T}=it({isEmailConfirmationRequired:U,signInOnSuccess:d,passwordConfigs:s,routeRedirectOnSignIn:t,routeWrongUrlRedirect:r,onErrorCallback:i,onSuccessCallback:m,handleSetInLineAlertProps:x,routeRedirectOnPasswordUpdate:N,routeSignInPage:w}),{isValidUniqueSymbols:c,defaultLengthMessage:_}=W({password:P,isClickSubmit:L,passwordConfigs:s});return A.status&&(a!=null&&a.SuccessNotification)?u(Z,{"data-testid":"successNotificationTestId",name:"SuccessNotification",slot:a==null?void 0:a.SuccessNotification,context:{isSuccessful:A}}):H("div",{className:$(["auth-update-password-form",`auth-update-password-form--${p}`]),children:[u(at,{title:o.title,divider:!1,className:"auth-update-password-form__title"}),u(st,{className:$(["auth-update-password-form__notification",["auth-update-password-form__notification--show",!!(n!=null&&n.text)]]),variant:"secondary",heading:n==null?void 0:n.text,icon:n.icon,additionalActions:F}),H(tt,{name:"updatePassword_form",className:"auth-update-password-form__form",onSubmit:M,loading:y,fieldsConfig:[],children:[u("div",{style:"display: none;",children:u("input",{type:"text",id:"username",name:"username",autoComplete:"username"})}),u(rt,{defaultValue:P,onValue:T,className:"auth-update-password-form__form__item",autoComplete:"new-password",name:"password",errorMessage:v||c==="error"||(_==null?void 0:_.status)==="error"?o.requiredFieldError:void 0,minLength:s==null?void 0:s.minLength,uniqueSymbolsStatus:c,validateLengthConfig:_,requiredCharacterClasses:s==null?void 0:s.requiredCharacterClasses,placeholder:o.placeholder,floatingLabel:o.floatingLabel}),u("div",{className:"auth-update-password-form__button",children:u(et,{type:"submit",buttonText:o.buttonPrimary,variant:"primary",enableLoader:y})})]})]})},Ut=({slots:d,formSize:p,signInOnSuccess:t,routeRedirectOnPasswordUpdate:r,routeRedirectOnSignIn:w,routeSignInPage:a,routeWrongUrlRedirect:i,onErrorCallback:m,onSuccessCallback:N})=>u("div",{className:"auth-update-password",children:u(ot,{formSize:p,signInOnSuccess:t,routeSignInPage:a,routeRedirectOnSignIn:w,routeWrongUrlRedirect:i,onErrorCallback:m,onSuccessCallback:N,slots:d,routeRedirectOnPasswordUpdate:r})});export{Ut as UpdatePassword,Ut as default}; diff --git a/scripts/__dropins__/storefront-auth/data/models/customer-data.d.ts b/scripts/__dropins__/storefront-auth/data/models/customer-data.d.ts index c72d4d5aa2..6afa4e7dca 100644 --- a/scripts/__dropins__/storefront-auth/data/models/customer-data.d.ts +++ b/scripts/__dropins__/storefront-auth/data/models/customer-data.d.ts @@ -1,6 +1,11 @@ -export interface CustomerDataModel { - firstname: string; - lastname: string; +export interface CustomerModel { + firstName: string; + lastName: string; email: string; + isSubscribed: boolean; + customAttributes?: Record[]; + errors?: { + message: string; + }[]; } //# sourceMappingURL=customer-data.d.ts.map \ No newline at end of file diff --git a/scripts/__dropins__/storefront-auth/data/transforms/index.d.ts b/scripts/__dropins__/storefront-auth/data/transforms/index.d.ts index 1db615bd3e..9c77cdfb90 100644 --- a/scripts/__dropins__/storefront-auth/data/transforms/index.d.ts +++ b/scripts/__dropins__/storefront-auth/data/transforms/index.d.ts @@ -4,4 +4,5 @@ export * from './transform-password-reset-email'; export * from './transform-revoke-customer-token'; export * from './transform-customer-data'; export * from './transform-attributes-form'; +export * from './transform-create-customer'; //# sourceMappingURL=index.d.ts.map \ No newline at end of file diff --git a/scripts/__dropins__/storefront-auth/data/transforms/transform-create-customer.d.ts b/scripts/__dropins__/storefront-auth/data/transforms/transform-create-customer.d.ts new file mode 100644 index 0000000000..88ef279d24 --- /dev/null +++ b/scripts/__dropins__/storefront-auth/data/transforms/transform-create-customer.d.ts @@ -0,0 +1,7 @@ +import { DataCreateCustomerV2, DataCreateCustomer } from '../../types'; +import { CustomerModel } from '../models'; + +type ApiResponse = T extends true ? DataCreateCustomerV2 : DataCreateCustomer; +export declare const transformCreateCustomer: (response: ApiResponse, apiVersion2: T) => CustomerModel; +export {}; +//# sourceMappingURL=transform-create-customer.d.ts.map \ No newline at end of file diff --git a/scripts/__dropins__/storefront-auth/data/transforms/transform-customer-data.d.ts b/scripts/__dropins__/storefront-auth/data/transforms/transform-customer-data.d.ts index 5d30914b4a..5233ce10bf 100644 --- a/scripts/__dropins__/storefront-auth/data/transforms/transform-customer-data.d.ts +++ b/scripts/__dropins__/storefront-auth/data/transforms/transform-customer-data.d.ts @@ -1,5 +1,5 @@ import { getCustomerDataResponse } from '../../types'; -import { CustomerDataModel } from '../models'; +import { CustomerModel } from '../models'; -export declare const transformCustomerData: (response: getCustomerDataResponse) => CustomerDataModel; +export declare const transformCustomerData: (response: getCustomerDataResponse) => CustomerModel; //# sourceMappingURL=transform-customer-data.d.ts.map \ No newline at end of file diff --git a/scripts/__dropins__/storefront-auth/fragments.d.ts b/scripts/__dropins__/storefront-auth/fragments.d.ts new file mode 100644 index 0000000000..4d0b3af3f9 --- /dev/null +++ b/scripts/__dropins__/storefront-auth/fragments.d.ts @@ -0,0 +1 @@ +export * from './api/fragments' diff --git a/scripts/__dropins__/storefront-auth/fragments.js b/scripts/__dropins__/storefront-auth/fragments.js new file mode 100644 index 0000000000..d53e0e47f3 --- /dev/null +++ b/scripts/__dropins__/storefront-auth/fragments.js @@ -0,0 +1,12 @@ +const e = (`fragment CUSTOMER_INFORMATION_FRAGMENT on Customer { + __typename + firstname + lastname + email + is_subscribed + gender + prefix +}`); +export { +e as CUSTOMER_INFORMATION_FRAGMENT +}; \ No newline at end of file diff --git a/scripts/__dropins__/storefront-auth/fragments.original.js b/scripts/__dropins__/storefront-auth/fragments.original.js new file mode 100644 index 0000000000..4bcbe599f7 --- /dev/null +++ b/scripts/__dropins__/storefront-auth/fragments.original.js @@ -0,0 +1,11 @@ +/*! Copyright 2024 Adobe +All Rights Reserved. */ +const e=` + fragment CUSTOMER_INFORMATION_FRAGMENT on Customer { + __typename + firstname + lastname + email + is_subscribed + } +`;export{e as CUSTOMER_INFORMATION_FRAGMENT}; diff --git a/scripts/__dropins__/storefront-auth/hooks/components/useSignUpForm.d.ts b/scripts/__dropins__/storefront-auth/hooks/components/useSignUpForm.d.ts index 28a34ae2cd..afc0e6d5ef 100644 --- a/scripts/__dropins__/storefront-auth/hooks/components/useSignUpForm.d.ts +++ b/scripts/__dropins__/storefront-auth/hooks/components/useSignUpForm.d.ts @@ -1,6 +1,7 @@ import { UseSingUpFormProps } from '../../types'; export declare const useSignUpForm: ({ requireRetypePassword, addressesData, translations, isEmailConfirmationRequired, apiVersion2, passwordConfigs, isAutoSignInEnabled, routeRedirectOnSignIn, routeSignIn, onErrorCallback, onSuccessCallback, setActiveComponent, handleSetInLineAlertProps, routeRedirectOnEmailConfirmationClose, }: UseSingUpFormProps) => { + showPasswordErrorMessage: boolean; confirmPassword: string; confirmPasswordMessage: string; isKeepMeLogged: boolean; @@ -19,5 +20,7 @@ export declare const useSignUpForm: ({ requireRetypePassword, addressesData, tra onKeepMeLoggedChange: ({ target }: any) => void; handleHideEmailConfirmationForm: () => void; handleConfirmPasswordChange: (value: string) => void; + onBlurPassword: (event: Event) => void; + onBlurConfirmPassword: (event: Event) => void; }; //# sourceMappingURL=useSignUpForm.d.ts.map \ No newline at end of file diff --git a/scripts/__dropins__/storefront-auth/render.js b/scripts/__dropins__/storefront-auth/render.js index 36f3496487..6b4deee20a 100644 --- a/scripts/__dropins__/storefront-auth/render.js +++ b/scripts/__dropins__/storefront-auth/render.js @@ -1,3 +1,5 @@ +/*! Copyright 2024 Adobe +All Rights Reserved. */ (function(o,t){try{if(typeof document<"u"){const a=document.createElement("style"),n=t.styleId;for(const i in t.attributes)a.setAttribute(i,t.attributes[i]);a.setAttribute("data-dropin",n),a.appendChild(document.createTextNode(o));const r=document.querySelector('style[data-dropin="sdk"]');if(r)r.after(a);else{const i=document.querySelector('link[rel="stylesheet"], style');i?i.before(a):document.head.append(a)}}}catch(a){console.error("dropin-styles (injectCodeFunction)",a)}})(`.auth-success-notification-form{display:flex;justify-content:center;align-items:center;flex-direction:column;border-radius:var(--shape-border-radius-2);background:var(--color-neutral-50, #fff);padding:var(--spacing-xbig) var(--spacing-small) var(--spacing-medium) var(--spacing-small)}@media (min-width: 768px){.auth-success-notification-form{padding:var(--spacing-big) var(--spacing-xbig) var(--spacing-xxbig) var(--spacing-xbig)}}.auth-success-notification-form.auth-success-notification-form--small{padding:var(--spacing-small) var(--spacing-small) var(--spacing-medium) var(--spacing-small)}.auth-success-notification-form__title{color:var(--color-neutral-800, #2b2b2b);font:var(--type-headline-2-strong-font);letter-spacing:var(--type-details-caption-1-letter-spacing);margin-bottom:var(--spacing-medium)}.auth-success-notification-form__content-text{color:var(--color-neutral-800, #2b2b2b);font:var(--type-body-1-default-font);letter-spacing:var(--type-body-1-default-letter-spacing);text-align:center;margin-bottom:var(--spacing-xxbig)}.auth-success-notification-form__button--top{margin-bottom:var(--spacing-xsmall)} .auth-email-confirmation-form{border-radius:8px;background-color:var(--color-neutral-50, #fff);padding:var(--spacing-small) var(--spacing-small) var(--spacing-medium) var(--spacing-small);text-align:start}@media (min-width: 768px){.auth-email-confirmation-form{padding:var(--spacing-big) var(--spacing-xbig) var(--spacing-xxbig) var(--spacing-xbig)}}.auth-email-confirmation-form__title{font:var(--type-headline-2-default-font);letter-spacing:var(--type-display-1-letter-spacing);color:var(--color-neutral-800, #3d3d3d)}.auth-email-confirmation-form__subtitle{display:block;font:var(--type-details-caption-2-font);letter-spacing:var(--type-button-2-letter-spacing);color:var(--color-neutral-700, #666666)}.auth-email-confirmation-form__notification{margin-bottom:var(--spacing-medium)}.auth-email-confirmation-form.auth-email-confirmation-form--small{padding:var(--spacing-small) var(--spacing-small) var(--spacing-medium) var(--spacing-small)}.auth-email-confirmation-form.auth-email-confirmation-form--small .auth-email-confirmation-form__buttons{grid-template-columns:1fr;gap:20px 0}.auth-email-confirmation-form__buttons{display:grid;grid-template-columns:auto auto;justify-content:space-between}@media (max-width: 768px){.auth-email-confirmation-form__buttons{gap:20px 0;grid-template-columns:1fr}}.auth-email-confirmation-form__text{display:block;font-family:var(--type-body-1-default-font);letter-spacing:var(--type-display-1-letter-spacing);color:var(--neutrals-neutral-800);padding:var(--spacing-big) 0}.auth-email-confirmation-form.auth-email-confirmation-form--small .auth-email-confirmation-form__buttons{justify-content:center;flex-wrap:wrap}.auth-email-confirmation-form.auth-email-confirmation-form--small .auth-email-confirmation-form__buttons{flex-basis:100%;margin-top:var(--spacing-medium)}.auth-email-confirmation-form.auth-email-confirmation-form--small .auth-email-confirmation-form__buttons>span{display:none}.auth-email-confirmation-form__buttons>span{border:1px solid var(--color-brand-500);margin:var(--spacing-small) var(--spacing-xsmall);font:var(--type-button-2-font)}@media (max-width: 768px){.auth-email-confirmation-form__buttons{justify-content:center;flex-wrap:wrap}.auth-email-confirmation-form__buttons{flex-basis:100%;margin-top:var(--spacing-medium)}.auth-email-confirmation-form__buttons>span{display:none}} .auth-sign-up-form{border-radius:var(--shape-border-radius-2);background-color:var(--color-neutral-50, #fff);padding:var(--spacing-small) var(--spacing-small) var(--spacing-medium) var(--spacing-small)}@media (min-width: 768px){.auth-sign-up-form{padding:var(--spacing-big) var(--spacing-xxbig) var(--spacing-xxbig) var(--spacing-xxbig)}}.auth-sign-up-form.auth-sign-up-form--small{padding:var(--spacing-small) var(--spacing-small) var(--spacing-medium) var(--spacing-small)}.auth-sign-up-form.auth-sign-up-form--small .auth-sign-up-form__title{margin-bottom:var(--spacing-small)}.auth-sign-up-form.auth-sign-up-form--small .auth-sign-up-form__form__field .auth-sign-up-form__form__field:nth-child(2),.auth-sign-up-form.auth-sign-up-form--small .auth-sign-up-form__form__field .auth-sign-up-form__form__field:nth-child(3){flex-basis:100%}.auth-sign-up-form.auth-sign-up-form--small .auth-sign-up-form__form{grid-template-columns:1fr}.auth-sign-up-form__form__confirm-wrapper>.auth-sign-up-form__form__field--confirm-password{margin:var(--spacing-medium) 0}.auth-sign-up-form__title{margin-bottom:var(--spacing-big)}@media (min-width: 768px){.auth-sign-up-form__title{margin-bottom:var(--spacing-xxbig)}}.auth-sign-up-form__notification{margin-bottom:var(--spacing-medium)}.auth-sign-up-form__form{display:flex;flex-wrap:wrap;flex-direction:row;gap:0 13px}.auth-sign-up-form__form__field{margin-bottom:var(--spacing-medium);flex-basis:100%;flex-grow:1;flex-shrink:0}.auth-sign-up-form__checkbox{margin-bottom:12px}.auth-sign-up-form__automatic-login{margin-top:12px}.auth-sign-up-form__form__field:nth-child(2),.auth-sign-up-form__form__field:nth-child(3){flex-shrink:1;flex-grow:1;flex-basis:100%}.auth-sign-up-form-buttons{flex-basis:100%;display:grid;grid-template-columns:1fr;gap:var(--spacing-medium) 0;justify-content:center;grid-area:buttons}@media (min-width: 768px){.auth-sign-up-form-buttons{display:grid;grid-template-columns:auto auto;justify-content:space-between}.auth-sign-up-form__form__field:nth-child(2),.auth-sign-up-form__form__field:nth-child(3){flex-shrink:1;flex-grow:.5;flex-basis:48%}}.auth-sign-in-form{border-radius:var(--shape-border-radius-2);background-color:var(--color-neutral-50, #fff);padding:var(--spacing-small) var(--spacing-small) var(--spacing-medium) var(--spacing-small)}@media (min-width: 768px){.auth-sign-in-form{padding:var(--spacing-big) var(--spacing-xxbig) var(--spacing-xxbig) var(--spacing-xxbig)}}.auth-sign-in-form__notification{margin-bottom:var(--spacing-medium)}.auth-sign-in-form.auth-sign-in-form--small{padding:var(--spacing-small) var(--spacing-small) var(--spacing-medium) var(--spacing-small)}.auth-sign-in-form.auth-sign-in-form--small .auth-sign-in-form__form__email,.auth-sign-in-form.auth-sign-in-form--small .auth-sign-in-form__form__password,.auth-sign-in-form.auth-sign-in-form--small .auth-sign-in-form__title{margin-bottom:var(--spacing-medium)}.auth-sign-in-form.auth-sign-in-form--small .auth-sign-in-form__form__buttons{grid-template-columns:1fr;gap:20px 0}.auth-sign-in-form__title{margin-bottom:var(--spacing-big)}@media (min-width: 768px){.auth-sign-in-form__title{margin-bottom:var(--spacing-xxbig)}}.auth-sign-in-form__form{display:grid;grid-template-columns:1fr}.auth-sign-in-form__form__email{margin-bottom:var(--spacing-medium)}.auth-sign-in-form__form__password{margin-bottom:var(--spacing-big)}.auth-sign-in-form__form__buttons{display:grid;grid-template-columns:auto auto;justify-content:space-between}@media (max-width: 768px){.auth-sign-in-form__form__buttons{gap:20px 0;grid-template-columns:1fr}}.auth-sign-in-form.auth-sign-in-form--small .auth-sign-in-form__form__buttons .auth-sign-in-form__form__buttons__combine{justify-content:center;flex-wrap:wrap}.auth-sign-in-form.auth-sign-in-form--small .auth-sign-in-form__form__buttons .auth-sign-in-form__form__buttons__combine .auth-sign-in-form__button--signup{flex-basis:100%;margin-top:20px}.auth-sign-in-form.auth-sign-in-form--small .auth-sign-in-form__form__buttons .auth-sign-in-form__form__buttons__combine>span{display:none}.auth-sign-in-form__form__buttons .auth-sign-in-form__form__buttons__combine{display:flex}.auth-sign-in-form__form__buttons .auth-sign-in-form__form__buttons__combine>span{border:var(--shape-border-width-1) solid var(--color-brand-500);margin:13px 10px;font:var(--type-button-2-font)}.auth-sign-in-form__resend-email-notification button{font:var(--type-button-3-font);color:var(--textColor);display:inline;background-color:transparent;border:none;cursor:pointer;padding:0;margin:0}.auth-sign-in-form__resend-email-notification button:hover{color:var(--color-brand-700);text-decoration:solid underline var(--color-brand-700);text-underline-offset:6px;color:var(--color-informational-500)}@media (max-width: 768px){.auth-sign-in-form__form__buttons .auth-sign-in-form__form__buttons__combine{justify-content:center;flex-wrap:wrap}.auth-sign-in-form__form__buttons .auth-sign-in-form__form__buttons__combine .auth-sign-in-form__button--signup{flex-basis:100%;margin-top:20px}.auth-sign-in-form__form__buttons .auth-sign-in-form__form__buttons__combine>span{display:none}}.auth-reset-password-form{border-radius:var(--shape-border-radius-2);background-color:var(--color-neutral-50, #fff);padding:var(--spacing-small) var(--spacing-small) var(--spacing-medium) var(--spacing-small)}@media (min-width: 768px){.auth-reset-password-form{padding:var(--spacing-big) var(--spacing-xxbig) var(--spacing-xxbig) var(--spacing-xxbig)}}.auth-reset-password-form.auth-reset-password-form--small{padding:var(--spacing-small) var(--spacing-small) var(--spacing-medium) var(--spacing-small)}.auth-reset-password-form.auth-reset-password-form--small .auth-reset-password-form__form__item,.auth-reset-password-form.auth-reset-password-form--small .auth-reset-password-form__title{margin-bottom:var(--spacing-medium)}.auth-reset-password-form__form{display:grid;grid-template-columns:1fr}.auth-reset-password-form__form__item{margin-bottom:var(--spacing-medium)}.auth-reset-password-form__buttons{display:grid;grid-template-columns:1fr;gap:20px 0}.auth-reset-password-form.auth-reset-password-form--small{grid-template-columns:1fr;gap:20px 0}.auth-reset-password-form__notification{margin-bottom:var(--spacing-medium)}.auth-reset-password-form__title{margin-bottom:var(--spacing-big)}@media (min-width: 768px){.auth-reset-password-form__title{margin-bottom:var(--spacing-xxbig)}}@media (min-width: 600px){.auth-reset-password-form__buttons{grid-template-columns:auto auto;justify-content:space-between}}.auth-button{position:relative}.auth-button__wrapper{position:absolute;top:50%;left:50%;transform:translate(-50%,-50%);opacity:0;display:none}.auth-custom-button__loader{width:20px;height:20px;border:5px solid #fff;border-radius:50%;display:inline-block;box-sizing:border-box;position:relative;animation:pulse 1s linear infinite}.auth-button__loader:after{content:"";position:absolute;width:20px;height:20px;border:5px solid #fff;border-radius:50%;display:inline-block;box-sizing:border-box;left:50%;top:50%;transform:translate(-50%,-50%);animation:scaleUp 1s linear infinite}@keyframes scaleUp{0%{transform:translate(-50%,-50%) scale(0)}60%,to{transform:translate(-50%,-50%) scale(1)}}@keyframes pulse{0%,60%,to{transform:scale(1)}80%{transform:scale(1.2)}}.auth-button.enableLoader .auth-button__text{opacity:0}.auth-button.enableLoader .auth-button__wrapper{opacity:1;display:inline-flex}.auth-update-password-form{border-radius:var(--shape-border-radius-2);background-color:var(--color-neutral-50, #fff);padding:var(--spacing-small) var(--spacing-small) var(--spacing-medium) var(--spacing-small)}@media (min-width: 768px){.auth-update-password-form{padding:var(--spacing-big) var(--spacing-xxbig) var(--spacing-xxbig) var(--spacing-xxbig)}}.auth-update-password-form.auth-update-password-form--small{padding:var(--spacing-small) var(--spacing-small) var(--spacing-medium) var(--spacing-small)}.auth-update-password-form.auth-update-password-form--small .auth-update-password-form__form__item{margin-bottom:var(--spacing-big)}.auth-update-password-form.auth-update-password-form--small .auth-update-password-form__title{margin-bottom:var(--spacing-small)}.auth-update-password-form__title{margin-bottom:var(--spacing-big)}@media (min-width: 768px){.auth-update-password-form__title{margin-bottom:var(--spacing-xxbig)}}.auth-update-password-form__form .auth-update-password-form__form__item{margin-bottom:var(--spacing-big)}@media (min-width: 768px){.auth-update-password-form__form .auth-update-password-form__form__item{margin-bottom:var(--spacing-xxbig)}}.auth-update-password-form__notification{display:none}.auth-update-password-form__notification--show{display:grid;margin-bottom:var(--spacing-medium)}`,{styleId:"Auth"}); diff --git a/scripts/__dropins__/storefront-auth/types/api/createCustomer.types.d.ts b/scripts/__dropins__/storefront-auth/types/api/createCustomer.types.d.ts index a202edda15..975c4122b3 100644 --- a/scripts/__dropins__/storefront-auth/types/api/createCustomer.types.d.ts +++ b/scripts/__dropins__/storefront-auth/types/api/createCustomer.types.d.ts @@ -1,24 +1,29 @@ +type customAttributesProps = { + custom_attributes: Record[]; +}; +type errorProps = { + message: string; +}; export interface Customer { firstname: string; lastname: string; email: string; is_subscribed: boolean; - custom_attributes?: Record[]; } interface CreateCustomerResponse { customer: Customer; } -interface DataCreateCustomerV2 { - createCustomer: CreateCustomerResponse; +export interface DataCreateCustomerV2 { + data: { + createCustomerV2: CreateCustomerResponse & customAttributesProps; + }; + errors?: errorProps[]; } -interface DataCreateCustomer { - createCustomer: CreateCustomerResponse; -} -export interface CreateCustomerDataResponse { - data: DataCreateCustomerV2 | DataCreateCustomer | null; - errors?: { - message: string; - }[]; +export interface DataCreateCustomer { + data: { + createCustomer: CreateCustomerResponse; + }; + errors?: errorProps[]; } export {}; //# sourceMappingURL=createCustomer.types.d.ts.map \ No newline at end of file diff --git a/scripts/__dropins__/storefront-auth/types/api/getCustomerData.types.d.ts b/scripts/__dropins__/storefront-auth/types/api/getCustomerData.types.d.ts index 6dc5f63de2..25122c40b1 100644 --- a/scripts/__dropins__/storefront-auth/types/api/getCustomerData.types.d.ts +++ b/scripts/__dropins__/storefront-auth/types/api/getCustomerData.types.d.ts @@ -4,6 +4,7 @@ export interface getCustomerDataResponse { firstname: string; lastname: string; email: string; + is_subscribed: boolean; }; }; errors?: { diff --git a/scripts/__dropins__/storefront-checkout/api/graphql/CartAddressFragment.graphql.d.ts b/scripts/__dropins__/storefront-checkout/api/graphql/CartAddressFragment.graphql.d.ts index cc29b8a5a8..8915d46c20 100644 --- a/scripts/__dropins__/storefront-checkout/api/graphql/CartAddressFragment.graphql.d.ts +++ b/scripts/__dropins__/storefront-checkout/api/graphql/CartAddressFragment.graphql.d.ts @@ -14,6 +14,6 @@ * is strictly forbidden unless prior written permission is obtained * from Adobe. *******************************************************************/ -export declare const BILLING_CART_ADDRESS_FRAGMENT = "\n fragment BILLING_CART_ADDRESS_FRAGMENT on BillingCartAddress {\n id\n city\n country {\n code\n label\n }\n firstname\n lastname\n company\n postcode\n vat_id\n region {\n region_id\n code\n label\n }\n street\n telephone\n custom_attributes {\n ... on AttributeValue {\n code\n value\n }\n }\n }\n"; -export declare const SHIPPING_CART_ADDRESS_FRAGMENT = "\n fragment SHIPPING_CART_ADDRESS_FRAGMENT on ShippingCartAddress {\n id\n firstname\n lastname\n company\n street\n city\n postcode\n vat_id\n region {\n region_id\n code\n label\n }\n country {\n code\n label\n }\n telephone\n custom_attributes {\n ... on AttributeValue {\n code\n value\n }\n }\n available_shipping_methods {\n amount {\n currency\n value\n }\n available\n carrier_code\n carrier_title\n error_message\n method_code\n method_title\n price_excl_tax {\n value\n currency\n }\n price_incl_tax {\n value\n currency\n }\n }\n selected_shipping_method {\n amount {\n value\n currency\n }\n carrier_code\n carrier_title\n method_code\n method_title\n price_excl_tax {\n value\n currency\n }\n price_incl_tax {\n value\n currency\n }\n }\n same_as_billing\n }\n"; +export declare const BILLING_CART_ADDRESS_FRAGMENT = "\n fragment BILLING_CART_ADDRESS_FRAGMENT on BillingCartAddress {\n id\n city\n country {\n code\n label\n }\n firstname\n lastname\n company\n postcode\n vat_id\n region {\n region_id\n code\n label\n }\n street\n telephone\n custom_attributes {\n ... on AttributeValue {\n code\n value\n }\n }\n prefix\n suffix\n middlename\n fax\n }\n"; +export declare const SHIPPING_CART_ADDRESS_FRAGMENT = "\n fragment SHIPPING_CART_ADDRESS_FRAGMENT on ShippingCartAddress {\n id\n firstname\n lastname\n company\n street\n city\n postcode\n vat_id\n region {\n region_id\n code\n label\n }\n country {\n code\n label\n }\n telephone\n custom_attributes {\n ... on AttributeValue {\n code\n value\n }\n }\n available_shipping_methods {\n amount {\n currency\n value\n }\n available\n carrier_code\n carrier_title\n error_message\n method_code\n method_title\n price_excl_tax {\n value\n currency\n }\n price_incl_tax {\n value\n currency\n }\n }\n selected_shipping_method {\n amount {\n value\n currency\n }\n carrier_code\n carrier_title\n method_code\n method_title\n price_excl_tax {\n value\n currency\n }\n price_incl_tax {\n value\n currency\n }\n }\n same_as_billing\n prefix\n suffix\n middlename\n fax\n }\n"; //# sourceMappingURL=CartAddressFragment.graphql.d.ts.map \ No newline at end of file diff --git a/scripts/__dropins__/storefront-checkout/api/graphql/OrderFragment.graphql.d.ts b/scripts/__dropins__/storefront-checkout/api/graphql/OrderFragment.graphql.d.ts index b40b208fa9..d207dd7594 100644 --- a/scripts/__dropins__/storefront-checkout/api/graphql/OrderFragment.graphql.d.ts +++ b/scripts/__dropins__/storefront-checkout/api/graphql/OrderFragment.graphql.d.ts @@ -14,6 +14,6 @@ * is strictly forbidden unless prior written permission is obtained * from Adobe. *******************************************************************/ -export declare const ORDER_SUMMARY_FRAGMENT = "\n fragment ORDER_SUMMARY_FRAGMENT on OrderTotal {\n grand_total {\n value\n currency\n }\n total_giftcard {\n currency\n value\n }\n subtotal {\n currency\n value\n }\n taxes {\n amount {\n currency\n value\n }\n rate\n }\n total_tax {\n currency\n value\n }\n total_shipping {\n currency\n value\n }\n discounts {\n amount {\n currency\n value\n }\n label\n }\n }\n"; +export declare const ORDER_SUMMARY_FRAGMENT = "\n fragment ORDER_SUMMARY_FRAGMENT on OrderTotal {\n grand_total {\n value\n currency\n }\n total_giftcard {\n currency\n value\n }\n subtotal {\n currency\n value\n }\n taxes {\n title\n amount {\n currency\n value\n }\n rate\n }\n total_tax {\n currency\n value\n }\n total_shipping {\n currency\n value\n }\n discounts {\n amount {\n currency\n value\n }\n label\n }\n }\n"; export declare const ORDER_FRAGMENT: string; //# sourceMappingURL=OrderFragment.graphql.d.ts.map \ No newline at end of file diff --git a/scripts/__dropins__/storefront-checkout/api/setPaymentMethod/setPaymentMethod.d.ts b/scripts/__dropins__/storefront-checkout/api/setPaymentMethod/setPaymentMethod.d.ts index ac50bd8332..b45d60c630 100644 --- a/scripts/__dropins__/storefront-checkout/api/setPaymentMethod/setPaymentMethod.d.ts +++ b/scripts/__dropins__/storefront-checkout/api/setPaymentMethod/setPaymentMethod.d.ts @@ -1,18 +1,4 @@ -/******************************************************************** -* ADOBE CONFIDENTIAL -* __________________ -* -* Copyright 2024 Adobe -* All Rights Reserved. -* -* NOTICE: All information contained herein is, and remains -* the property of Adobe and its suppliers, if any. The intellectual -* and technical concepts contained herein are proprietary to Adobe -* and its suppliers and are protected by all applicable intellectual -* property laws, including trade secret and copyright laws. -* Dissemination of this information or reproduction of this material -* is strictly forbidden unless prior written permission is obtained -* from Adobe. -*******************************************************************/ -export declare const setPaymentMethod: (paymentMethod: string) => Promise; +import { SetPaymentMethodOnCartInput } from '../../__generated__/types'; + +export declare const setPaymentMethod: (paymentMethod: SetPaymentMethodOnCartInput['payment_method']) => Promise; //# sourceMappingURL=setPaymentMethod.d.ts.map \ No newline at end of file diff --git a/scripts/__dropins__/storefront-checkout/chunks/fetch-graphql.js b/scripts/__dropins__/storefront-checkout/chunks/fetch-graphql.js index 1b61ddf501..a5275b07c6 100644 --- a/scripts/__dropins__/storefront-checkout/chunks/fetch-graphql.js +++ b/scripts/__dropins__/storefront-checkout/chunks/fetch-graphql.js @@ -1,6 +1,6 @@ /*! Copyright 2024 Adobe All Rights Reserved. */ -import{c as S,b as T,e as A,a as b,T as i}from"./store-config.js";import"./ServerErrorSignal.js";import{events as v}from"@dropins/tools/event-bus.js";import"@dropins/tools/lib.js";import{FetchGraphQL as G}from"@dropins/tools/fetch-graphql.js";const x={authenticated:!1,cartId:null,initialized:!1},V=new Proxy(x,{set(e,t,s){return e[t]=s,!0},get(e,t){return e[t]}});class w extends Error{constructor(t){super(t.map(s=>s.message).join(" ")),this.name="FetchError"}}class a extends Error{constructor(t){super(t),this.name="InvalidArgument"}}class j extends Error{constructor(t){super(t),this.name="UnexpectedError"}}class B extends a{constructor(){super("Cart ID is required")}}class z extends a{constructor(){super("Email is required")}}class Y extends a{constructor(){super("Payment method code is required")}}class $ extends a{constructor(){super("Shipping address is required")}}class J extends a{constructor(){super("Billing address is required")}}class K extends a{constructor(){super("Country Code is required")}}const p=[];function D(e){return new Promise((t,s)=>{p.push(e);const r=()=>{p[0]===e?e().then(t).catch(s).finally(()=>p.shift()):setTimeout(r,100)};r()})}const k=["sender_email","recipient_email"];function I(e){return e.filter(t=>!t.path||!k.some(s=>{var r;return((r=t.path)==null?void 0:r.at(-1))===s}))}const C=e=>{throw e instanceof DOMException&&e.name==="AbortError"||v.emit("error",{source:"checkout",type:"network",error:e}),e},M={cart:S,customer:T,estimateShippingMethods:A,storeConfig:b};function U(e,t){return t.split(".").reduce((s,r)=>s&&s[r]!==void 0?s[r]:void 0,e)}const E={cart:null,customer:null,estimateShippingMethods:null,storeConfig:null};async function q(e){const{defaultValueOnFail:t,query:s,options:r,path:c,signalType:d,type:y,transformer:h}=e,n=M[d],g=Symbol();E[d]=g,n.value={...n.value,pending:!0};try{const{data:l,errors:f}=await(y==="mutation"?D(()=>_(s,r).catch(C)):_(s,{method:"GET",cache:"no-cache",...r}).catch(C));if(f){const m=I(f);if(m.length>0)throw new w(m)}let o=U(l,c);if(o===void 0)throw new Error(`No data found at path: ${c}`);return h&&(o=h(o)),n.value={...n.value,data:o},setTimeout(()=>{n.value={...n.value,pending:E[d]===g?!1:n.value.pending}},0),o}catch(l){if(t)return n.value={pending:!1,data:t},t;if(l.name==="AbortError")return;throw n.value={...n.value,pending:!1},l}}const N=` +import{c as S,d as T,e as A,a as v,T as i}from"./store-config.js";import"./ServerErrorSignal.js";import{events as G}from"@dropins/tools/event-bus.js";import"@dropins/tools/lib.js";import{FetchGraphQL as b}from"@dropins/tools/fetch-graphql.js";const x={authenticated:!1,cartId:null,initialized:!1},V=new Proxy(x,{set(e,t,s){return e[t]=s,!0},get(e,t){return e[t]}});class w extends Error{constructor(t){super(t.map(s=>s.message).join(" ")),this.name="FetchError"}}class a extends Error{constructor(t){super(t),this.name="InvalidArgument"}}class j extends Error{constructor(t){super(t),this.name="UnexpectedError"}}class B extends a{constructor(){super("Cart ID is required")}}class z extends a{constructor(){super("Email is required")}}class Y extends a{constructor(){super("Payment method code is required")}}class $ extends a{constructor(){super("Shipping address is required")}}class J extends a{constructor(){super("Billing address is required")}}class K extends a{constructor(){super("Country Code is required")}}const p=[];function D(e){return new Promise((t,s)=>{p.push(e);const r=()=>{p[0]===e?e().then(t).catch(s).finally(()=>p.shift()):setTimeout(r,100)};r()})}const k=["sender_email","recipient_email"];function I(e){return e.filter(t=>!t.path||!k.some(s=>{var r;return((r=t.path)==null?void 0:r.at(-1))===s}))}const C=e=>{throw e instanceof DOMException&&e.name==="AbortError"||G.emit("error",{source:"checkout",type:"network",error:e}),e},M={cart:S,customer:T,estimateShippingMethods:A,storeConfig:v};function U(e,t){return t.split(".").reduce((s,r)=>s&&s[r]!==void 0?s[r]:void 0,e)}const E={cart:null,customer:null,estimateShippingMethods:null,storeConfig:null};async function q(e){const{defaultValueOnFail:t,query:s,options:r,path:c,signalType:d,type:y,transformer:h}=e,n=M[d],g=Symbol();E[d]=g,n.value={...n.value,pending:!0};try{const{data:l,errors:f}=await(y==="mutation"?D(()=>_(s,r).catch(C)):_(s,{method:"GET",cache:"no-cache",...r}).catch(C));if(f){const m=I(f);if(m.length>0)throw new w(m)}let o=U(l,c);if(o===void 0)throw new Error(`No data found at path: ${c}`);return h&&(o=h(o)),n.value={...n.value,data:o},setTimeout(()=>{n.value={...n.value,pending:E[d]===g?!1:n.value.pending}},0),o}catch(l){if(t)return n.value={pending:!1,data:t},t;if(l.name==="AbortError")return;throw n.value={...n.value,pending:!1},l}}const N=` query getStoreConfig { storeConfig { default_country @@ -9,4 +9,4 @@ import{c as S,b as T,e as A,a as b,T as i}from"./store-config.js";import"./Serve shopping_cart_display_shipping } } -`,F="US",u={defaultCountry:F,isGuestCheckoutEnabled:!1,isOnePageCheckoutEnabled:!1,shoppingCartDisplaySetting:{shipping:i.EXCLUDING_TAX}},W=async()=>await q({type:"query",query:N,options:{method:"GET",cache:"no-cache"},path:"storeConfig",signalType:"storeConfig",transformer:O,defaultValueOnFail:u});function L(e){switch(e){case 1:return i.EXCLUDING_TAX;case 2:return i.INCLUDING_TAX;case 3:return i.INCLUDING_EXCLUDING_TAX;default:return i.EXCLUDING_TAX}}function O(e){if(!e)return u;const{default_country:t,is_guest_checkout_enabled:s,is_one_page_checkout_enabled:r,shopping_cart_display_shipping:c}=e;return{defaultCountry:t||u.defaultCountry,isGuestCheckoutEnabled:s||u.isGuestCheckoutEnabled,isOnePageCheckoutEnabled:r||u.isOnePageCheckoutEnabled,shoppingCartDisplaySetting:{shipping:L(c)}}}const{setEndpoint:Z,setFetchGraphQlHeader:ee,removeFetchGraphQlHeader:te,setFetchGraphQlHeaders:se,fetchGraphQl:_,getConfig:re}=new G().getMethods();export{F as D,w as F,a as I,B as M,u as S,j as U,K as a,$ as b,z as c,q as d,Y as e,J as f,Z as g,ee as h,se as i,_ as j,re as k,W as l,C as m,te as r,V as s}; +`,F="US",u={defaultCountry:F,isGuestCheckoutEnabled:!1,isOnePageCheckoutEnabled:!1,shoppingCartDisplaySetting:{shipping:i.EXCLUDING_TAX}},W=async()=>await q({type:"query",query:N,options:{method:"GET",cache:"no-cache"},path:"storeConfig",signalType:"storeConfig",transformer:O,defaultValueOnFail:u});function L(e){switch(e){case 1:return i.EXCLUDING_TAX;case 2:return i.INCLUDING_TAX;case 3:return i.INCLUDING_EXCLUDING_TAX;default:return i.EXCLUDING_TAX}}function O(e){if(!e)return u;const{default_country:t,is_guest_checkout_enabled:s,is_one_page_checkout_enabled:r,shopping_cart_display_shipping:c}=e;return{defaultCountry:t||u.defaultCountry,isGuestCheckoutEnabled:s||u.isGuestCheckoutEnabled,isOnePageCheckoutEnabled:r||u.isOnePageCheckoutEnabled,shoppingCartDisplaySetting:{shipping:L(c)}}}const{setEndpoint:Z,setFetchGraphQlHeader:ee,removeFetchGraphQlHeader:te,setFetchGraphQlHeaders:se,fetchGraphQl:_,getConfig:re}=new b().getMethods();export{F as D,w as F,a as I,B as M,u as S,j as U,K as a,$ as b,z as c,q as d,Y as e,J as f,Z as g,ee as h,se as i,_ as j,re as k,W as l,C as m,te as r,V as s}; diff --git a/scripts/__dropins__/storefront-checkout/chunks/setPaymentMethod.js b/scripts/__dropins__/storefront-checkout/chunks/setPaymentMethod.js index 2f1bb9228f..0fa5c83e46 100644 --- a/scripts/__dropins__/storefront-checkout/chunks/setPaymentMethod.js +++ b/scripts/__dropins__/storefront-checkout/chunks/setPaymentMethod.js @@ -1,9 +1,12 @@ /*! Copyright 2024 Adobe All Rights Reserved. */ -import{s as r,M as o,e as n,d as s}from"./fetch-graphql.js";import{CHECKOUT_DATA_FRAGMENT as i}from"../fragments.js";import{b as m}from"./synchronizeCheckout.js";import"./store-config.js";import"./ServerErrorSignal.js";import{events as d}from"@dropins/tools/event-bus.js";import"@dropins/tools/lib.js";const p=` - mutation setPaymentMethod($cartId: String!, $paymentMethod: String!) { +import{s as o,M as r,e as n,d as s}from"./fetch-graphql.js";import{CHECKOUT_DATA_FRAGMENT as i}from"../fragments.js";import{b as m}from"./synchronizeCheckout.js";import"./store-config.js";import"./ServerErrorSignal.js";import{events as d}from"@dropins/tools/event-bus.js";import"@dropins/tools/lib.js";const p=` + mutation setPaymentMethod( + $cartId: String! + $paymentMethod: PaymentMethodInput! + ) { setPaymentMethodOnCart( - input: { cart_id: $cartId, payment_method: { code: $paymentMethod } } + input: { cart_id: $cartId, payment_method: $paymentMethod } ) { cart { ...CHECKOUT_DATA_FRAGMENT @@ -12,4 +15,4 @@ import{s as r,M as o,e as n,d as s}from"./fetch-graphql.js";import{CHECKOUT_DATA } ${i} -`,A=async t=>{const a=r.cartId;if(!a)throw new o;if(!t)throw new n;const e=await s({type:"mutation",query:p,options:{variables:{cartId:a,paymentMethod:t}},path:"setPaymentMethodOnCart.cart",signalType:"cart",transformer:m});return d.emit("checkout/updated",e||null),e};export{A as s}; +`,A=async t=>{const a=o.cartId;if(!a)throw new r;if(!t)throw new n;const e=await s({type:"mutation",query:p,options:{variables:{cartId:a,paymentMethod:t}},path:"setPaymentMethodOnCart.cart",signalType:"cart",transformer:m});return d.emit("checkout/updated",e||null),e};export{A as s}; diff --git a/scripts/__dropins__/storefront-checkout/chunks/store-config.js b/scripts/__dropins__/storefront-checkout/chunks/store-config.js index 9b96ba373b..c9eeae5f9a 100644 --- a/scripts/__dropins__/storefront-checkout/chunks/store-config.js +++ b/scripts/__dropins__/storefront-checkout/chunks/store-config.js @@ -1,3 +1,3 @@ /*! Copyright 2024 Adobe All Rights Reserved. */ -import{signal as i,effect as e}from"@dropins/tools/signals.js";const n=i(!0),s=i({pending:!1,data:void 0});e(()=>{var a;(a=s.value.data)!=null&&a.isVirtual&&(n.value=!1)});const d=i({pending:!1,data:void 0}),l=i({pending:!1,data:void 0}),g=i(void 0),N=i({data:void 0,pending:!1});var t=(a=>(a.EXCLUDING_TAX="EXCLUDING_TAX",a.INCLUDING_EXCLUDING_TAX="INCLUDING_AND_EXCLUDING_TAX",a.INCLUDING_TAX="INCLUDING_TAX",a))(t||{});export{t as T,N as a,d as b,s as c,l as e,n as i,g as s}; +import{signal as e,effect as i}from"@dropins/tools/signals.js";const n=e(!0),t=e({pending:!1,data:void 0});i(()=>{var a;(a=t.value.data)!=null&&a.isVirtual&&(n.value=!1)});const d=e({pending:!1,data:void 0}),l=e({pending:!1,data:void 0}),g=e(),c=e(void 0),N=e({data:void 0,pending:!1});var s=(a=>(a.EXCLUDING_TAX="EXCLUDING_TAX",a.INCLUDING_EXCLUDING_TAX="INCLUDING_AND_EXCLUDING_TAX",a.INCLUDING_TAX="INCLUDING_TAX",a))(s||{});export{s as T,N as a,g as b,t as c,d,l as e,n as i,c as s}; diff --git a/scripts/__dropins__/storefront-checkout/chunks/synchronizeCheckout.js b/scripts/__dropins__/storefront-checkout/chunks/synchronizeCheckout.js index 001453e6c0..0359575e51 100644 --- a/scripts/__dropins__/storefront-checkout/chunks/synchronizeCheckout.js +++ b/scripts/__dropins__/storefront-checkout/chunks/synchronizeCheckout.js @@ -1,13 +1,13 @@ /*! Copyright 2024 Adobe All Rights Reserved. */ -import{s as i,M as C,d as l,l as A}from"./fetch-graphql.js";import{b,a as M,c}from"./store-config.js";import"./ServerErrorSignal.js";import{events as s}from"@dropins/tools/event-bus.js";import{merge as a,Initializer as T}from"@dropins/tools/lib.js";import{CHECKOUT_DATA_FRAGMENT as u,CUSTOMER_FRAGMENT as S}from"../fragments.js";const I=async(e=!1)=>{i.authenticated=e,e?await K():b.value={pending:!1,data:null}},x=e=>e==null,E=(e,t)=>e.amount.value-t.amount.value,m=e=>!(!e||!e.method_code||!e.method_title||x(e.amount.value)||!e.amount.currency),f=e=>({amount:{value:e.amount.value,currency:e.amount.currency},title:e.method_title,code:e.method_code,carrier:{code:e.carrier_code,title:e.carrier_title},value:`${e.carrier_code} - ${e.method_code}`,...e.price_excl_tax&&{amountExclTax:{value:e.price_excl_tax.value,currency:e.price_excl_tax.currency}},...e.price_incl_tax&&{amountInclTax:{value:e.price_incl_tax.value,currency:e.price_incl_tax.currency}}}),N=e=>{if(m(e))return f(e)},k=e=>{if(e)return e.filter(m).map(t=>f(t)).sort(E)},w=e=>e?!!e.code&&!!e.label:!1,z=e=>{if(!w(e))return;const{code:t,label:r,region_id:n}=e;return n?{code:t,name:r,id:n}:{code:t,name:r}},R=e=>{const{code:t,label:r}=e;return{value:t,label:r}},q=e=>e?"code"in e&&"value"in e:!1,G=e=>e.filter(q).map(t=>{const{code:r,value:n}=t;return{code:r,value:n}}),d=e=>{const t=e.street.filter(Boolean);return{id:(e==null?void 0:e.id)||void 0,city:e.city,company:e.company||void 0,country:R(e.country),customAttributes:G(e.custom_attributes),firstName:e.firstname,lastName:e.lastname,postCode:e.postcode||void 0,region:z(e.region),street:t,telephone:e.telephone||void 0,vatId:e.vat_id||void 0}},O=e=>{if(e)return d(e)},P=e=>e.filter(t=>!!t).map(t=>{const{available_shipping_methods:r,selected_shipping_method:n,same_as_billing:o,...v}=t;return{...d(v),availableShippingMethods:k(r),selectedShippingMethod:N(n),sameAsBilling:o}}),ee=e=>({city:e.city,company:e.company,country_code:e.countryCode,custom_attributes:e.customAttributes.map(t=>({attribute_code:t.code,value:t.value})),firstname:e.firstName,lastname:e.lastName,postcode:e.postcode,region:e.region,region_id:e.regionId,save_in_address_book:e.saveInAddressBook??!0,street:e.street,telephone:e.telephone,vat_id:e.vatId}),$=e=>{if(e)return{code:e.code,title:e.title}},B=e=>{if(e)return e.filter(t=>!!t).map(t=>{const{code:r,title:n}=t;return{code:r,title:n}})},D=e=>{var r,n,o;if(!e)return;const t={availablePaymentMethods:B(e.available_payment_methods),billingAddress:O(e.billing_address),email:e.email??void 0,id:e.id,isEmpty:e.total_quantity===0,isVirtual:e.is_virtual,selectedPaymentMethod:$(e.selected_payment_method),shippingAddresses:P(e.shipping_addresses),isGuest:!i.authenticated};return a(t,(o=(n=(r=_.getConfig().models)==null?void 0:r.CartModel)==null?void 0:n.transformer)==null?void 0:o.call(n,e))},F=e=>{var r,n,o;if(!e)return;const t={firstName:e.firstname||"",lastName:e.lastname||"",email:e.email||""};return a(t,(o=(n=(r=_.getConfig().models)==null?void 0:r.CustomerModel)==null?void 0:n.transformer)==null?void 0:o.call(n,e))},U=` +import{s as i,M as C,d as l,l as A}from"./fetch-graphql.js";import{d as x,a as b,c}from"./store-config.js";import"./ServerErrorSignal.js";import{events as s}from"@dropins/tools/event-bus.js";import{merge as u,Initializer as M}from"@dropins/tools/lib.js";import{CHECKOUT_DATA_FRAGMENT as a,CUSTOMER_FRAGMENT as T}from"../fragments.js";const S=async(e=!1)=>{i.authenticated=e,e?await K():x.value={pending:!1,data:null}},I=e=>e==null,N=(e,t)=>e.amount.value-t.amount.value,m=e=>!(!e||!e.method_code||!e.method_title||I(e.amount.value)||!e.amount.currency),f=e=>({amount:{value:e.amount.value,currency:e.amount.currency},title:e.method_title,code:e.method_code,carrier:{code:e.carrier_code,title:e.carrier_title},value:`${e.carrier_code} - ${e.method_code}`,...e.price_excl_tax&&{amountExclTax:{value:e.price_excl_tax.value,currency:e.price_excl_tax.currency}},...e.price_incl_tax&&{amountInclTax:{value:e.price_incl_tax.value,currency:e.price_incl_tax.currency}}}),E=e=>{if(m(e))return f(e)},k=e=>{if(e)return e.filter(m).map(t=>f(t)).sort(N)},w=e=>e?!!e.code&&!!e.label:!1,z=e=>{if(!w(e))return;const{code:t,label:r,region_id:n}=e;return n?{code:t,name:r,id:n}:{code:t,name:r}},R=e=>{const{code:t,label:r}=e;return{value:t,label:r}},q=e=>e?"code"in e&&"value"in e:!1,G=e=>e.filter(q).map(t=>{const{code:r,value:n}=t;return{code:r,value:n}}),p=e=>{const t=e.street.filter(Boolean);return{id:(e==null?void 0:e.id)||void 0,city:e.city,company:e.company||void 0,country:R(e.country),customAttributes:G(e.custom_attributes),firstName:e.firstname,lastName:e.lastname,postCode:e.postcode||void 0,region:z(e.region),street:t,telephone:e.telephone||void 0,vatId:e.vat_id||void 0,prefix:e.prefix||void 0,suffix:e.suffix||void 0,middleName:e.middlename||void 0,fax:e.fax||void 0}},O=e=>{if(e)return p(e)},P=e=>e.filter(t=>!!t).map(t=>{const{available_shipping_methods:r,selected_shipping_method:n,same_as_billing:o,...v}=t;return{...p(v),availableShippingMethods:k(r),selectedShippingMethod:E(n),sameAsBilling:o}}),ee=e=>({city:e.city,company:e.company,country_code:e.countryCode,custom_attributes:e.customAttributes.map(t=>({attribute_code:t.code,value:t.value})),firstname:e.firstName,lastname:e.lastName,postcode:e.postcode,region:e.region,region_id:e.regionId,save_in_address_book:e.saveInAddressBook??!0,street:e.street,telephone:e.telephone,vat_id:e.vatId,prefix:e.prefix,suffix:e.suffix,middlename:e.middleName,fax:e.fax}),$=e=>{if(e)return{code:e.code,title:e.title}},B=e=>{if(e)return e.filter(t=>!!t).map(t=>{const{code:r,title:n}=t;return{code:r,title:n}})},D=e=>{var r,n,o;if(!e)return;const t={availablePaymentMethods:B(e.available_payment_methods),billingAddress:O(e.billing_address),email:e.email??void 0,id:e.id,isEmpty:e.total_quantity===0,isVirtual:e.is_virtual,selectedPaymentMethod:$(e.selected_payment_method),shippingAddresses:P(e.shipping_addresses),isGuest:!i.authenticated};return u(t,(o=(n=(r=_.getConfig().models)==null?void 0:r.CartModel)==null?void 0:n.transformer)==null?void 0:o.call(n,e))},F=e=>{var r,n,o;if(!e)return;const t={firstName:e.firstname||"",lastName:e.lastname||"",email:e.email||""};return u(t,(o=(n=(r=_.getConfig().models)==null?void 0:r.CustomerModel)==null?void 0:n.transformer)==null?void 0:o.call(n,e))},U=` query getCart($cartId: String!) { cart(cart_id: $cartId) { ...CHECKOUT_DATA_FRAGMENT } } - ${u} + ${a} `,V=` query getCustomerCart { cart: customerCart { @@ -15,13 +15,13 @@ import{s as i,M as C,d as l,l as A}from"./fetch-graphql.js";import{b,a as M,c}fr } } - ${u} -`,p=async()=>{const e=i.cartId,t=i.authenticated===!1,r=t?U:V,n=t?{cartId:e}:{};if(t&&!e)throw new C;return await l({type:"query",query:r,options:{method:"POST",cache:"no-cache",variables:n},path:"cart",signalType:"cart",transformer:D})},H=` + ${a} +`,d=async()=>{const e=i.cartId,t=i.authenticated===!1,r=t?U:V,n=t?{cartId:e}:{};if(t&&!e)throw new C;return await l({type:"query",query:r,options:{method:"POST",cache:"no-cache",variables:n},path:"cart",signalType:"cart",transformer:D})},H=` query getCustomer { customer { ...CUSTOMER_FRAGMENT } } - ${S} -`,K=async()=>{if(i.authenticated)return await l({type:"query",query:H,options:{method:"POST",cache:"no-cache"},path:"customer",signalType:"customer",transformer:F})},Q=()=>[s.on("authenticated",I,{eager:!0}),s.on("cart/initialized",h,{eager:!0}),s.on("cart/reset",L),s.on("cart/updated",y)],g=new T({init:async e=>{const t=e||{};g.config.setConfig(t),M.value.data||await A()},listeners:Q}),_=g.config,h=async e=>{if(i.initialized)return y(e);const t=e?e.id:null;i.cartId=t;const r=t?await p():null;c.value={pending:!1,data:r},i.initialized=!0,s.emit("checkout/initialized",r||null)},L=()=>{i.cartId=null,c.value={pending:!1,data:null},s.emit("checkout/updated",null)},y=async e=>{if(!i.initialized)return h(e);const t=e?e.id:null;i.cartId=t;const r=t?await p():null;c.value={pending:!1,data:r},s.emit("checkout/updated",r||null)};export{ee as a,D as b,_ as c,I as d,K as e,h as f,p as g,g as i,L as r,y as s,k as t}; + ${T} +`,K=async()=>{if(i.authenticated)return await l({type:"query",query:H,options:{method:"POST",cache:"no-cache"},path:"customer",signalType:"customer",transformer:F})},Q=()=>[s.on("authenticated",S,{eager:!0}),s.on("cart/initialized",h,{eager:!0}),s.on("cart/reset",L),s.on("cart/updated",y)],g=new M({init:async e=>{const t=e||{};g.config.setConfig(t),b.value.data||await A()},listeners:Q}),_=g.config,h=async e=>{if(i.initialized)return y(e);const t=e?e.id:null;i.cartId=t;const r=t?await d():null;c.value={pending:!1,data:r},i.initialized=!0,s.emit("checkout/initialized",r||null)},L=()=>{i.cartId=null,c.value={pending:!1,data:null},s.emit("checkout/updated",null)},y=async e=>{if(!i.initialized)return h(e);const t=e?e.id:null;i.cartId=t;const r=t?await d():null;c.value={pending:!1,data:r},s.emit("checkout/updated",r||null)};export{ee as a,D as b,_ as c,S as d,K as e,h as f,d as g,g as i,L as r,y as s,k as t}; diff --git a/scripts/__dropins__/storefront-checkout/containers/LoginForm.js b/scripts/__dropins__/storefront-checkout/containers/LoginForm.js index 66ee4978ca..f8c22680e4 100644 --- a/scripts/__dropins__/storefront-checkout/containers/LoginForm.js +++ b/scripts/__dropins__/storefront-checkout/containers/LoginForm.js @@ -1,3 +1,3 @@ /*! Copyright 2024 Adobe All Rights Reserved. */ -import{jsx as r,jsxs as s,Fragment as w}from"@dropins/tools/preact-jsx-runtime.js";import{s as H}from"../chunks/fetch-graphql.js";import{c as R,b as V}from"../chunks/store-config.js";import"../chunks/ServerErrorSignal.js";import"@dropins/tools/event-bus.js";import{classes as j}from"@dropins/tools/lib.js";import{i as q}from"../chunks/isEmailAvailable.js";import{s as D}from"../chunks/setGuestEmailOnCart.js";import{Field as W,Input as G,Skeleton as U,SkeletonRow as x}from"@dropins/tools/components.js";/* empty css *//* empty css */import{useText as b,Text as _}from"@dropins/tools/i18n.js";/* empty css *//* empty css *//* empty css */import{w as J}from"../chunks/withConditionalRendering.js";import{useState as v,useRef as K,useEffect as C}from"@dropins/tools/preact-hooks.js";import"@dropins/tools/fetch-graphql.js";import"@dropins/tools/signals.js";import"../fragments.js";import"../chunks/synchronizeCheckout.js";const O=({value:t,error:i,hint:g,onChange:h,onBlur:o,onInvalid:u})=>{const m=b({LoginFormLabel:"Checkout.LoginForm.ariaLabel",LoginFormFloatingLabel:"Checkout.LoginForm.floatingLabel",LoginFormPlaceholder:"Checkout.LoginForm.placeholder"});return r(W,{size:"medium",error:i,hint:g,children:r(G,{"aria-label":m.LoginFormLabel,"aria-required":!0,autocomplete:"email",floatingLabel:m.LoginFormFloatingLabel,id:"customer-email",name:"customer-email",onBlur:o,onChange:h,onInvalid:u,placeholder:m.LoginFormPlaceholder,required:!0,type:"email",value:t})})},Q=({onClick:t})=>s("div",{className:"checkout-login-form__sign-in",children:[r(_,{id:"Checkout.LoginForm.account"}),r("a",{"data-testid":"sign-in-link",className:"checkout-login-form__link",href:"#",target:"_blank",rel:"noreferrer",onClick:t,children:r(_,{id:"Checkout.LoginForm.signIn"})})]}),X=({className:t,customerDetails:i,email:g,error:h,hint:o,loading:u=!1,name:m,onEmailBlur:f,onEmailChange:k,onEmailInvalid:E,onSignInClick:a,onSignOutClick:F,...L})=>{const l=b({Title:"Checkout.LoginForm.title"});return u?r(Y,{}):s("div",{className:"checkout-login-form","data-testid":"checkout-login-form",children:[s("div",{className:"checkout-login-form__heading",children:[r("h2",{className:"checkout-login-form__title",children:l.Title}),i?r(Z,{onClick:d=>{d.preventDefault(),F==null||F()}}):r(Q,{onClick:d=>{d.preventDefault(),a==null||a(g)}})]}),i?s("div",{className:"checkout-login-form__customer-details",children:[r("div",{className:"checkout-login-form__customer-name",children:`${i.firstName} ${i.lastName}`}),r("div",{className:"checkout-login-form__customer-email",children:i.email})]}):r("div",{className:"checkout-login-form__content",children:s("form",{...L,className:j(["dropin-login-form__form",t]),name:m,noValidate:!0,children:[r("button",{type:"submit",disabled:!0,style:"display: none","aria-hidden":"true"}),r(O,{value:g,error:h,hint:o,onChange:k,onBlur:f,onInvalid:E})]})})]})},Y=()=>s(U,{"data-testid":"login-form-skeleton",children:[r(x,{variant:"heading",fullWidth:!0}),r(x,{size:"medium",fullWidth:!0})]}),Z=({onClick:t})=>s("p",{className:"checkout-login-form__sign-out",children:[r(_,{id:"Checkout.LoginForm.switch"}),r("a",{className:"checkout-login-form__link",href:"#",target:"_blank",rel:"noreferrer",onClick:t,children:r(_,{id:"Checkout.LoginForm.signOut"})})]}),S={EMAIL:/^[a-z0-9,!#$%&'*+/=?^_`{|}~-]+(\.[a-z0-9,!#$%&'*+/=?^_`{|}~-]+)*@([a-z0-9-]+\.)+[a-z]{2,}$/i},N=t=>S.EMAIL.test(t),rr=1e3,y=({onSignInClick:t,onSignOutClick:i,initialData:g,...h})=>{const[o,u]=v(""),[m,f]=v(""),[k,E]=v(!0),[a,F]=v(!0),L=K(""),l=R.value.data,d=(l==null?void 0:l.email)||"",p=V.value.data,c=b({LoginFormInvalidEmailError:"Checkout.LoginForm.invalidEmailError",LoginFormMissingEmailError:"Checkout.LoginForm.missingEmailError",LoginFormEmailExistsAlreadyHaveAccount:"Checkout.LoginForm.emailExists.alreadyHaveAccount",LoginFormEmailExistsSignInButton:"Checkout.LoginForm.emailExists.signInButton",LoginFormEmailExistsForFasterCheckout:"Checkout.LoginForm.emailExists.forFasterCheckout"}),A=e=>e.valid?"":e.valueMissing?c.LoginFormMissingEmailError:c.LoginFormInvalidEmailError,B=e=>N(e)?"":e===""?c.LoginFormMissingEmailError:c.LoginFormInvalidEmailError,M=e=>{const n=e.target;u(n.value),f(""),E(!0)},T=e=>{const n=e.target;f(B(n.value))},z=e=>{const n=e.target;f(A(n.validity))};C(()=>{!a||!l||(F(!1),u(l.email||""))},[l,a]),C(()=>{if(a||H.authenticated)return;const e=setTimeout(()=>{!N(o)||o===L.current||(L.current=o,q(o).then(n=>{E(n),d!==o&&D(o).catch(console.error)}).catch(n=>{console.error(n),E(!0)}))},rr);return()=>{e&&clearTimeout(e)}},[d,o,a]);const I=k?"":s(w,{children:[c.LoginFormEmailExistsAlreadyHaveAccount," ",r("a",{href:"#",onClick:e=>{e.preventDefault(),t==null||t(o)},children:c.LoginFormEmailExistsSignInButton})," ",c.LoginFormEmailExistsForFasterCheckout]}),$=e=>{t==null||t(N(e)?e:"")},P=p?{firstName:p.firstName,lastName:p.lastName,email:p.email}:void 0;return r(X,{...h,customerDetails:P,email:o,error:m,hint:I,loading:a,onEmailBlur:T,onEmailChange:M,onEmailInvalid:z,onSignInClick:$,onSignOutClick:i})};y.displayName="LoginFormContainer";const kr=J(y);export{kr as LoginForm,kr as default}; +import{jsx as r,jsxs as s,Fragment as w}from"@dropins/tools/preact-jsx-runtime.js";import{s as H}from"../chunks/fetch-graphql.js";import{c as R,d as V}from"../chunks/store-config.js";import"../chunks/ServerErrorSignal.js";import"@dropins/tools/event-bus.js";import{classes as j}from"@dropins/tools/lib.js";import{i as q}from"../chunks/isEmailAvailable.js";import{s as D}from"../chunks/setGuestEmailOnCart.js";import{Field as W,Input as G,Skeleton as U,SkeletonRow as x}from"@dropins/tools/components.js";/* empty css *//* empty css */import{useText as b,Text as _}from"@dropins/tools/i18n.js";/* empty css *//* empty css *//* empty css */import{w as J}from"../chunks/withConditionalRendering.js";import{useState as v,useRef as K,useEffect as C}from"@dropins/tools/preact-hooks.js";import"@dropins/tools/fetch-graphql.js";import"@dropins/tools/signals.js";import"../fragments.js";import"../chunks/synchronizeCheckout.js";const O=({value:t,error:i,hint:g,onChange:h,onBlur:o,onInvalid:u})=>{const m=b({LoginFormLabel:"Checkout.LoginForm.ariaLabel",LoginFormFloatingLabel:"Checkout.LoginForm.floatingLabel",LoginFormPlaceholder:"Checkout.LoginForm.placeholder"});return r(W,{size:"medium",error:i,hint:g,children:r(G,{"aria-label":m.LoginFormLabel,"aria-required":!0,autocomplete:"email",floatingLabel:m.LoginFormFloatingLabel,id:"customer-email",name:"customer-email",onBlur:o,onChange:h,onInvalid:u,placeholder:m.LoginFormPlaceholder,required:!0,type:"email",value:t})})},Q=({onClick:t})=>s("div",{className:"checkout-login-form__sign-in",children:[r(_,{id:"Checkout.LoginForm.account"}),r("a",{"data-testid":"sign-in-link",className:"checkout-login-form__link",href:"#",target:"_blank",rel:"noreferrer",onClick:t,children:r(_,{id:"Checkout.LoginForm.signIn"})})]}),X=({className:t,customerDetails:i,email:g,error:h,hint:o,loading:u=!1,name:m,onEmailBlur:f,onEmailChange:k,onEmailInvalid:E,onSignInClick:a,onSignOutClick:F,...L})=>{const l=b({Title:"Checkout.LoginForm.title"});return u?r(Y,{}):s("div",{className:"checkout-login-form","data-testid":"checkout-login-form",children:[s("div",{className:"checkout-login-form__heading",children:[r("h2",{className:"checkout-login-form__title",children:l.Title}),i?r(Z,{onClick:d=>{d.preventDefault(),F==null||F()}}):r(Q,{onClick:d=>{d.preventDefault(),a==null||a(g)}})]}),i?s("div",{className:"checkout-login-form__customer-details",children:[r("div",{className:"checkout-login-form__customer-name",children:`${i.firstName} ${i.lastName}`}),r("div",{className:"checkout-login-form__customer-email",children:i.email})]}):r("div",{className:"checkout-login-form__content",children:s("form",{...L,className:j(["dropin-login-form__form",t]),name:m,noValidate:!0,children:[r("button",{type:"submit",disabled:!0,style:"display: none","aria-hidden":"true"}),r(O,{value:g,error:h,hint:o,onChange:k,onBlur:f,onInvalid:E})]})})]})},Y=()=>s(U,{"data-testid":"login-form-skeleton",children:[r(x,{variant:"heading",fullWidth:!0}),r(x,{size:"medium",fullWidth:!0})]}),Z=({onClick:t})=>s("p",{className:"checkout-login-form__sign-out",children:[r(_,{id:"Checkout.LoginForm.switch"}),r("a",{className:"checkout-login-form__link",href:"#",target:"_blank",rel:"noreferrer",onClick:t,children:r(_,{id:"Checkout.LoginForm.signOut"})})]}),S={EMAIL:/^[a-z0-9,!#$%&'*+/=?^_`{|}~-]+(\.[a-z0-9,!#$%&'*+/=?^_`{|}~-]+)*@([a-z0-9-]+\.)+[a-z]{2,}$/i},N=t=>S.EMAIL.test(t),rr=1e3,y=({onSignInClick:t,onSignOutClick:i,initialData:g,...h})=>{const[o,u]=v(""),[m,f]=v(""),[k,E]=v(!0),[a,F]=v(!0),L=K(""),l=R.value.data,d=(l==null?void 0:l.email)||"",p=V.value.data,c=b({LoginFormInvalidEmailError:"Checkout.LoginForm.invalidEmailError",LoginFormMissingEmailError:"Checkout.LoginForm.missingEmailError",LoginFormEmailExistsAlreadyHaveAccount:"Checkout.LoginForm.emailExists.alreadyHaveAccount",LoginFormEmailExistsSignInButton:"Checkout.LoginForm.emailExists.signInButton",LoginFormEmailExistsForFasterCheckout:"Checkout.LoginForm.emailExists.forFasterCheckout"}),A=e=>e.valid?"":e.valueMissing?c.LoginFormMissingEmailError:c.LoginFormInvalidEmailError,B=e=>N(e)?"":e===""?c.LoginFormMissingEmailError:c.LoginFormInvalidEmailError,M=e=>{const n=e.target;u(n.value),f(""),E(!0)},T=e=>{const n=e.target;f(B(n.value))},z=e=>{const n=e.target;f(A(n.validity))};C(()=>{!a||!l||(F(!1),u(l.email||""))},[l,a]),C(()=>{if(a||H.authenticated)return;const e=setTimeout(()=>{!N(o)||o===L.current||(L.current=o,q(o).then(n=>{E(n),d!==o&&D(o).catch(console.error)}).catch(n=>{console.error(n),E(!0)}))},rr);return()=>{e&&clearTimeout(e)}},[d,o,a]);const I=k?"":s(w,{children:[c.LoginFormEmailExistsAlreadyHaveAccount," ",r("a",{href:"#",onClick:e=>{e.preventDefault(),t==null||t(o)},children:c.LoginFormEmailExistsSignInButton})," ",c.LoginFormEmailExistsForFasterCheckout]}),$=e=>{t==null||t(N(e)?e:"")},P=p?{firstName:p.firstName,lastName:p.lastName,email:p.email}:void 0;return r(X,{...h,customerDetails:P,email:o,error:m,hint:I,loading:a,onEmailBlur:T,onEmailChange:M,onEmailInvalid:z,onSignInClick:$,onSignOutClick:i})};y.displayName="LoginFormContainer";const kr=J(y);export{kr as LoginForm,kr as default}; diff --git a/scripts/__dropins__/storefront-checkout/containers/OrderConfirmationHeader.js b/scripts/__dropins__/storefront-checkout/containers/OrderConfirmationHeader.js index 84e921117e..382cb09e48 100644 --- a/scripts/__dropins__/storefront-checkout/containers/OrderConfirmationHeader.js +++ b/scripts/__dropins__/storefront-checkout/containers/OrderConfirmationHeader.js @@ -1,3 +1,3 @@ /*! Copyright 2024 Adobe All Rights Reserved. */ -import{jsx as t,jsxs as s}from"@dropins/tools/preact-jsx-runtime.js";/* empty css */import{Icon as A,Header as E,Button as y,Skeleton as N,SkeletonRow as r}from"@dropins/tools/components.js";/* empty css */import"@dropins/tools/lib.js";/* empty css *//* empty css *//* empty css */import*as o from"@dropins/tools/preact-compat.js";import{useState as C,useEffect as b}from"@dropins/tools/preact-compat.js";import{useText as z,Text as v}from"@dropins/tools/i18n.js";import{s as f}from"../chunks/fetch-graphql.js";import"../chunks/store-config.js";import"../chunks/ServerErrorSignal.js";import"@dropins/tools/event-bus.js";import{i as H}from"../chunks/isEmailAvailable.js";import"@dropins/tools/fetch-graphql.js";import"@dropins/tools/signals.js";function p(e){var c;return{region:{region_id:e!=null&&e.regionId?Number(e==null?void 0:e.regionId):null,region:e==null?void 0:e.region},city:e==null?void 0:e.city,company:e==null?void 0:e.company,country_code:e==null?void 0:e.country,firstname:e==null?void 0:e.firstName,lastname:e==null?void 0:e.lastName,middlename:e==null?void 0:e.middleName,postcode:e==null?void 0:e.postCode,street:e==null?void 0:e.street,telephone:e==null?void 0:e.telephone,custom_attributesV2:((c=e==null?void 0:e.customAttributes)==null?void 0:c.map(l=>({attribute_code:l.code,value:l.value})))||[]}}const V=e=>o.createElement("svg",{width:24,height:24,viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",...e},o.createElement("g",{clipPath:"url(#clip0_4797_15077)"},o.createElement("path",{vectorEffect:"non-scaling-stroke",d:"M10.15 20.85L1.5 17.53V6.63L10.15 10V20.85Z",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round"}),o.createElement("path",{vectorEffect:"non-scaling-stroke",d:"M1.5 6.63001L10.15 3.20001L18.8 6.63001L10.15 10L1.5 6.63001Z",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round"}),o.createElement("path",{vectorEffect:"non-scaling-stroke",d:"M6.17969 4.77002L14.8297 8.15002V11.47",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round"}),o.createElement("path",{vectorEffect:"non-scaling-stroke",d:"M18.7896 12.64V6.63L10.1396 10V20.85L14.8296 19.05",stroke:"currentColor",strokeLinejoin:"round"}),o.createElement("path",{className:"success-icon",vectorEffect:"non-scaling-stroke",d:"M15.71 17.26C15.71 15.38 17.23 13.86 19.11 13.86C20.99 13.86 22.51 15.38 22.51 17.26C22.51 19.14 20.99 20.66 19.11 20.66C17.23 20.66 15.71 19.14 15.71 17.26Z",stroke:"currentColor"}),o.createElement("path",{className:"success-icon",vectorEffect:"non-scaling-stroke",d:"M17.4805 17.49L18.5605 18.41L20.7205 16.33",stroke:"currentColor",strokeLinecap:"square",strokeLinejoin:"round"})),o.createElement("defs",null,o.createElement("clipPath",{id:"clip0_4797_15077"},o.createElement("rect",{width:22,height:18.65,fill:"white",transform:"translate(1 2.70001)"})))),d=({customerName:e,isLoading:c,orderNumber:l,onSignUpClick:a})=>{const i=z({title:t(v,{id:"Checkout.OrderConfirmationHeader.title",fields:{name:e}}),defaultTitle:"Checkout.OrderConfirmationHeader.defaultTitle",order:t(v,{id:"Checkout.OrderConfirmationHeader.order",fields:{order:l}}),createAccountMessage:"Checkout.OrderConfirmationHeader.CreateAccount.message",createAccountButton:"Checkout.OrderConfirmationHeader.CreateAccount.button"});return c?t(w,{}):s("div",{className:"order-confirmation-header order-confirmation__card",children:[t(A,{source:V,size:"64",className:"order-confirmation-header__icon"}),t(E,{className:"order-confirmation-header__title",title:i.title,size:"large",divider:!1,children:e?i.title:i.defaultTitle}),l&&t("p",{className:"order-confirmation-header__order",children:i.order}),a&&s("div",{className:"order-confirmation-create-account",children:[t("p",{className:"order-confirmation-create-account__message",children:i.createAccountMessage}),t(y,{"data-testid":"create-account-button",className:"order-confirmation-create-account__button",size:"medium",variant:"secondary",type:"submit",onClick:a,children:i.createAccountButton})]})]})},w=()=>s(N,{"data-testid":"order-confirmation-header-skeleton",className:"order-confirmation-header",children:[t(r,{variant:"empty",size:"xlarge",fullWidth:!0}),t(r,{variant:"empty",size:"medium"}),t(r,{variant:"empty",size:"medium"}),t(r,{variant:"empty",size:"medium"}),t(r,{variant:"empty",size:"medium"}),t(r,{variant:"empty",size:"medium"}),t(r,{size:"small",fullWidth:!0}),t(r,{variant:"heading",size:"xsmall",fullWidth:!0})]}),U=({orderData:e,onSignUpClick:c})=>{var g;const[l,a]=C(!f.authenticated),[i,h]=C();b(()=>{f.authenticated||H(e.email).then(m=>h(!m)).catch(()=>h(!0)).finally(()=>a(!1))},[e.email]);const _=c&&!f.authenticated&&i===!1?()=>{const m=e.shippingAddress,n=e.billingAddress,L=[{code:"firstname",defaultValue:(n==null?void 0:n.firstName)||""},{code:"lastname",defaultValue:(n==null?void 0:n.lastName)||""},{code:"email",defaultValue:e.email||""}];let u;if(m){const k={...p(m),default_shipping:!0};u=[{...p(n),default_billing:!0},k]}else u=[{...p(n),default_billing:!0,default_shipping:!0}];c({inputsDefaultValueSet:L,addressesData:u})}:void 0;return t("div",{children:t(d,{customerName:(g=e.billingAddress)==null?void 0:g.firstName,isLoading:l,onSignUpClick:_,orderNumber:e.number})})};export{U as OrderConfirmationHeader,U as default}; +import{jsx as e,jsxs as h}from"@dropins/tools/preact-jsx-runtime.js";/* empty css */import{Icon as A,Header as E,Button as y,Skeleton as N,SkeletonRow as r}from"@dropins/tools/components.js";/* empty css */import"@dropins/tools/lib.js";/* empty css *//* empty css *//* empty css */import*as o from"@dropins/tools/preact-compat.js";import{useState as s,useEffect as x}from"@dropins/tools/preact-compat.js";import{useText as b,Text as v}from"@dropins/tools/i18n.js";import{s as f}from"../chunks/fetch-graphql.js";import"../chunks/store-config.js";import"../chunks/ServerErrorSignal.js";import"@dropins/tools/event-bus.js";import{i as z}from"../chunks/isEmailAvailable.js";import"@dropins/tools/fetch-graphql.js";import"@dropins/tools/signals.js";function p(t){var c;return{region:{region_id:t!=null&&t.regionId?Number(t==null?void 0:t.regionId):null,region:t==null?void 0:t.region},city:t==null?void 0:t.city,company:t==null?void 0:t.company,country_code:t==null?void 0:t.country,firstname:t==null?void 0:t.firstName,lastname:t==null?void 0:t.lastName,middlename:t==null?void 0:t.middleName,postcode:t==null?void 0:t.postCode,street:t==null?void 0:t.street,telephone:t==null?void 0:t.telephone,custom_attributesV2:((c=t==null?void 0:t.customAttributes)==null?void 0:c.map(l=>({attribute_code:l.code,value:l.value})))||[],prefix:t==null?void 0:t.prefix,suffix:t==null?void 0:t.suffix,fax:t==null?void 0:t.fax}}const H=t=>o.createElement("svg",{width:24,height:24,viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",...t},o.createElement("g",{clipPath:"url(#clip0_4797_15077)"},o.createElement("path",{vectorEffect:"non-scaling-stroke",d:"M10.15 20.85L1.5 17.53V6.63L10.15 10V20.85Z",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round"}),o.createElement("path",{vectorEffect:"non-scaling-stroke",d:"M1.5 6.63001L10.15 3.20001L18.8 6.63001L10.15 10L1.5 6.63001Z",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round"}),o.createElement("path",{vectorEffect:"non-scaling-stroke",d:"M6.17969 4.77002L14.8297 8.15002V11.47",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round"}),o.createElement("path",{vectorEffect:"non-scaling-stroke",d:"M18.7896 12.64V6.63L10.1396 10V20.85L14.8296 19.05",stroke:"currentColor",strokeLinejoin:"round"}),o.createElement("path",{className:"success-icon",vectorEffect:"non-scaling-stroke",d:"M15.71 17.26C15.71 15.38 17.23 13.86 19.11 13.86C20.99 13.86 22.51 15.38 22.51 17.26C22.51 19.14 20.99 20.66 19.11 20.66C17.23 20.66 15.71 19.14 15.71 17.26Z",stroke:"currentColor"}),o.createElement("path",{className:"success-icon",vectorEffect:"non-scaling-stroke",d:"M17.4805 17.49L18.5605 18.41L20.7205 16.33",stroke:"currentColor",strokeLinecap:"square",strokeLinejoin:"round"})),o.createElement("defs",null,o.createElement("clipPath",{id:"clip0_4797_15077"},o.createElement("rect",{width:22,height:18.65,fill:"white",transform:"translate(1 2.70001)"})))),V=({customerName:t,isLoading:c,orderNumber:l,onSignUpClick:m})=>{const i=b({title:e(v,{id:"Checkout.OrderConfirmationHeader.title",fields:{name:t}}),defaultTitle:"Checkout.OrderConfirmationHeader.defaultTitle",order:e(v,{id:"Checkout.OrderConfirmationHeader.order",fields:{order:l}}),createAccountMessage:"Checkout.OrderConfirmationHeader.CreateAccount.message",createAccountButton:"Checkout.OrderConfirmationHeader.CreateAccount.button"});return c?e(w,{}):h("div",{className:"order-confirmation-header order-confirmation__card",children:[e(A,{source:H,size:"64",className:"order-confirmation-header__icon"}),e(E,{className:"order-confirmation-header__title",title:i.title,size:"large",divider:!1,children:t?i.title:i.defaultTitle}),l&&e("p",{className:"order-confirmation-header__order",children:i.order}),m&&h("div",{className:"order-confirmation-create-account",children:[e("p",{className:"order-confirmation-create-account__message",children:i.createAccountMessage}),e(y,{"data-testid":"create-account-button",className:"order-confirmation-create-account__button",size:"medium",variant:"secondary",type:"submit",onClick:m,children:i.createAccountButton})]})]})},w=()=>h(N,{"data-testid":"order-confirmation-header-skeleton",className:"order-confirmation-header",children:[e(r,{variant:"empty",size:"xlarge",fullWidth:!0}),e(r,{variant:"empty",size:"medium"}),e(r,{variant:"empty",size:"medium"}),e(r,{variant:"empty",size:"medium"}),e(r,{variant:"empty",size:"medium"}),e(r,{variant:"empty",size:"medium"}),e(r,{size:"small",fullWidth:!0}),e(r,{variant:"heading",size:"xsmall",fullWidth:!0})]}),X=({orderData:t,onSignUpClick:c})=>{var k;const[l,m]=s(!f.authenticated),[i,g]=s();x(()=>{f.authenticated||z(t.email).then(a=>g(!a)).catch(()=>g(!0)).finally(()=>m(!1))},[t.email]);const _=c&&!f.authenticated&&i===!1?()=>{const a=t.shippingAddress,n=t.billingAddress,L=[{code:"firstname",defaultValue:(n==null?void 0:n.firstName)||""},{code:"lastname",defaultValue:(n==null?void 0:n.lastName)||""},{code:"email",defaultValue:t.email||""}];let u;if(a){const C={...p(a),default_shipping:!0};u=[{...p(n),default_billing:!0},C]}else u=[{...p(n),default_billing:!0,default_shipping:!0}];c({inputsDefaultValueSet:L,addressesData:u})}:void 0;return e("div",{children:e(V,{customerName:(k=t.billingAddress)==null?void 0:k.firstName,isLoading:l,onSignUpClick:_,orderNumber:t.number})})};export{X as OrderConfirmationHeader,X as default}; diff --git a/scripts/__dropins__/storefront-checkout/containers/PaymentMethods.js b/scripts/__dropins__/storefront-checkout/containers/PaymentMethods.js index fe5f580b93..be65f4442e 100644 --- a/scripts/__dropins__/storefront-checkout/containers/PaymentMethods.js +++ b/scripts/__dropins__/storefront-checkout/containers/PaymentMethods.js @@ -1,3 +1,3 @@ /*! Copyright 2024 Adobe All Rights Reserved. */ -import{jsx as n,jsxs as M,Fragment as R}from"@dropins/tools/preact-jsx-runtime.js";import{s as D}from"../chunks/fetch-graphql.js";import{c as C}from"../chunks/store-config.js";import"../chunks/ServerErrorSignal.js";import"@dropins/tools/event-bus.js";import{classes as H,Slot as L}from"@dropins/tools/lib.js";import{s as $}from"../chunks/setPaymentMethod.js";/* empty css */import{IllustratedMessage as B,Icon as U,ProgressSpinner as Z,ToggleButton as F,Skeleton as q,SkeletonRow as y}from"@dropins/tools/components.js";import*as g from"@dropins/tools/preact-compat.js";import{useState as S,useCallback as T,useEffect as w}from"@dropins/tools/preact-compat.js";import{useText as G}from"@dropins/tools/i18n.js";import{w as J}from"../chunks/withConditionalRendering.js";import{useRef as K}from"@dropins/tools/preact-hooks.js";import"@dropins/tools/fetch-graphql.js";import"@dropins/tools/signals.js";import"../fragments.js";import"../chunks/synchronizeCheckout.js";const Q=e=>g.createElement("svg",{width:24,height:24,viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",...e},g.createElement("path",{vectorEffect:"non-scaling-stroke",d:"M17.93 14.8V18.75H5.97C4.75 18.75 3.75 17.97 3.75 17V6.5M3.75 6.5C3.75 5.53 4.74 4.75 5.97 4.75H15.94V8.25H5.97C4.75 8.25 3.75 7.47 3.75 6.5Z",stroke:"currentColor",strokeWidth:1,strokeLinecap:"round",strokeLinejoin:"round"}),g.createElement("path",{vectorEffect:"non-scaling-stroke",d:"M19.35 11.64H14.04V14.81H19.35V11.64Z",stroke:"currentColor",strokeWidth:1,strokeLinecap:"round",strokeLinejoin:"round"}),g.createElement("path",{vectorEffect:"non-scaling-stroke",d:"M17.9304 11.64V8.25H15.1504",stroke:"currentColor",strokeWidth:1,strokeLinecap:"round",strokeLinejoin:"round"})),X=({code:e,loading:a,selected:r,onChange:d,title:h})=>n(F,{className:"checkout-payment-methods__method",label:h,name:"payment-method",value:e,selected:r,onChange:d,busy:a}),Y=({className:e,paymentMethodContent:a,loading:r=!1,initializing:d=!1,onChange:h=()=>{},options:c,selection:k})=>{const o=G({Title:"Checkout.PaymentMethods.title",EmptyState:"Checkout.PaymentMethods.emptyState"});return d?n(ee,{}):M("div",{className:H(["checkout-payment-methods",e]),children:[n("h2",{className:"checkout-payment-methods__title",children:o.Title}),!r&&c.length===0&&n(B,{icon:n(U,{source:Q}),message:n("p",{children:o.EmptyState})}),M("div",{className:H(["checkout-payment-methods__wrapper"]),children:[r&&n(Z,{className:"checkout-payment-methods__spinner"}),n("div",{className:H(["checkout-payment-methods__methods",["checkout-payment-methods--loading",r],["checkout-payment-methods--full-width",c.length%2!==0]]),children:c==null?void 0:c.map(i=>n(X,{code:i.code,onChange:h,selected:i.code===k,title:i.title},i.code))}),a&&n("div",{className:"checkout-payment-methods__content",children:a})]})]})},ee=()=>M(q,{"data-testid":"payment-methods-skeleton",children:[n(y,{variant:"heading",size:"medium"}),n(y,{variant:"empty",size:"medium"}),n(y,{size:"xlarge",fullWidth:!0}),n(y,{size:"xlarge",fullWidth:!0})]}),N={free:e=>{const a=document.createElement("div");a.innerText="",e.replaceHTML(a)},checkmo:e=>{const a=document.createElement("div");a.innerText="",e.replaceHTML(a)}},te=(e,a)=>{const r=K(e);return a(r.current,e)||(r.current=e),r.current},V=({slots:e})=>{var x,_;const[a,r]=S(),[d,h]=S(N),[c,k]=S(!0),o=C.value.data,i=!!C.value.data,W=C.value.pending,j=(o==null?void 0:o.isVirtual)??!1,z=(x=o==null?void 0:o.shippingAddresses)==null?void 0:x[0],A=(o==null?void 0:o.availablePaymentMethods)||[],l=(_=o==null?void 0:o.selectedPaymentMethod)==null?void 0:_.code,E=j?!0:!!z,m=te(A,(t,s)=>t.length!==s.length?!1:t.every((p,v)=>p.code===s[v].code)),u=T(t=>{r(t),!(!t||!E)&&t!==l&&$(t).catch(console.error)},[E,l]);w(()=>{if(!i)return;if(!!!(m!=null&&m.length)){u(void 0);return}const s=m[0].code;if(!l){u(s);return}const p=m.some(v=>v.code===l);u(p?l:s)},[m,i,l,u]);const I=t=>{u(t)},b=T((t,s)=>{if(!t){console.warn("Payment method handler is ignored because it has no code");return}if(!s){console.warn("Payment method handler is ignored because it is empty");return}h(p=>({...p,[t]:s}))},[]);w(()=>{e!=null&&e.Handlers&&Object.entries(e.Handlers).forEach(([t,s])=>{b(t,s)})},[b,e==null?void 0:e.Handlers]);const f=e!=null&&e.Main?n(L,{name:"PaymentMethods",slot:e==null?void 0:e.Main,context:{replaceHTML(t){this.replaceWith(t),k(!1)}}}):null,P=a?d[a]:null,O=P?n(L,{name:"PaymentMethodContent",slot:P,context:{cartId:D.cartId||"",replaceHTML(t){this.replaceWith(t)}}},P):void 0;return w(()=>{!c&&d!=N&&console.warn("Payment method handlers you have added are ignored because the default content has been replaced")},[c,d]),M(R,{children:[f&&n(f.type,{ref:f.ref,...f.props}),c&&n(Y,{initializing:i===!1,loading:i&&W,onChange:I,options:m,paymentMethodContent:O,selection:a})]})};V.displayName="PaymentMethodsContainer";const ke=J(V);export{ke as PaymentMethods,ke as default}; +import{jsx as n,jsxs as v,Fragment as D}from"@dropins/tools/preact-jsx-runtime.js";import{s as $}from"../chunks/fetch-graphql.js";import{c as H,b as y}from"../chunks/store-config.js";import"../chunks/ServerErrorSignal.js";import"@dropins/tools/event-bus.js";import{classes as S,Slot as T}from"@dropins/tools/lib.js";import{s as B}from"../chunks/setPaymentMethod.js";/* empty css */import{IllustratedMessage as U,Icon as Z,ProgressSpinner as F,ToggleButton as q,Skeleton as G,SkeletonRow as g}from"@dropins/tools/components.js";import*as k from"@dropins/tools/preact-compat.js";import{useState as w,useCallback as N,useEffect as b}from"@dropins/tools/preact-compat.js";import{useText as J}from"@dropins/tools/i18n.js";import{w as K}from"../chunks/withConditionalRendering.js";import{useRef as Q}from"@dropins/tools/preact-hooks.js";import"@dropins/tools/fetch-graphql.js";import"@dropins/tools/signals.js";import"../fragments.js";import"../chunks/synchronizeCheckout.js";const X=e=>k.createElement("svg",{width:24,height:24,viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",...e},k.createElement("path",{vectorEffect:"non-scaling-stroke",d:"M17.93 14.8V18.75H5.97C4.75 18.75 3.75 17.97 3.75 17V6.5M3.75 6.5C3.75 5.53 4.74 4.75 5.97 4.75H15.94V8.25H5.97C4.75 8.25 3.75 7.47 3.75 6.5Z",stroke:"currentColor",strokeWidth:1,strokeLinecap:"round",strokeLinejoin:"round"}),k.createElement("path",{vectorEffect:"non-scaling-stroke",d:"M19.35 11.64H14.04V14.81H19.35V11.64Z",stroke:"currentColor",strokeWidth:1,strokeLinecap:"round",strokeLinejoin:"round"}),k.createElement("path",{vectorEffect:"non-scaling-stroke",d:"M17.9304 11.64V8.25H15.1504",stroke:"currentColor",strokeWidth:1,strokeLinecap:"round",strokeLinejoin:"round"})),Y=({code:e,loading:r,selected:o,onChange:d,title:h})=>n(q,{className:"checkout-payment-methods__method",label:h,name:"payment-method",value:e,selected:o,onChange:d,busy:r}),ee=({className:e,paymentMethodContent:r,loading:o=!1,initializing:d=!1,onChange:h=()=>{},options:c,selection:M})=>{const a=J({Title:"Checkout.PaymentMethods.title",EmptyState:"Checkout.PaymentMethods.emptyState"});return d?n(te,{}):v("div",{className:S(["checkout-payment-methods",e]),children:[n("h2",{className:"checkout-payment-methods__title",children:a.Title}),!o&&c.length===0&&n(U,{icon:n(Z,{source:X}),message:n("p",{children:a.EmptyState})}),v("div",{className:S(["checkout-payment-methods__wrapper"]),children:[o&&n(F,{className:"checkout-payment-methods__spinner"}),n("div",{className:S(["checkout-payment-methods__methods",["checkout-payment-methods--loading",o],["checkout-payment-methods--full-width",c.length%2!==0]]),children:c==null?void 0:c.map(i=>n(Y,{code:i.code,onChange:h,selected:i.code===M,title:i.title},i.code))}),r&&n("div",{className:"checkout-payment-methods__content",children:r})]})]})},te=()=>v(G,{"data-testid":"payment-methods-skeleton",children:[n(g,{variant:"heading",size:"medium"}),n(g,{variant:"empty",size:"medium"}),n(g,{size:"xlarge",fullWidth:!0}),n(g,{size:"xlarge",fullWidth:!0})]}),V={free:e=>{const r=document.createElement("div");r.innerText="",e.replaceHTML(r)},checkmo:e=>{const r=document.createElement("div");r.innerText="",e.replaceHTML(r)}},ne=(e,r)=>{const o=Q(e);return r(o.current,e)||(o.current=e),o.current},W=({slots:e,setOnChange:r={}})=>{var _,L;const[o]=w(r),[d,h]=w(V),[c,M]=w(!0),a=H.value.data,i=!!H.value.data,O=H.value.pending,j=(a==null?void 0:a.isVirtual)??!1,z=(_=a==null?void 0:a.shippingAddresses)==null?void 0:_[0],A=(a==null?void 0:a.availablePaymentMethods)||[],m=(L=a==null?void 0:a.selectedPaymentMethod)==null?void 0:L.code,E=j?!0:!!z,l=ne(A,(t,s)=>t.length!==s.length?!1:t.every((p,C)=>p.code===s[C].code)),u=N(t=>{y.value=t,!(!t||!E)&&t!==m&&o[t]!==!1&&B({code:t}).catch(console.error)},[E,m,o]);b(()=>{if(!i)return;if(!!!(l!=null&&l.length)){u(void 0);return}const s=l[0].code;if(!m){u(s);return}const p=l.some(C=>C.code===m);u(p?m:s)},[l,i,m,u]);const I=t=>{u(t)},x=N((t,s)=>{if(!t){console.warn("Payment method handler is ignored because it has no code");return}if(!s){console.warn("Payment method handler is ignored because it is empty");return}h(p=>({...p,[t]:s}))},[]);b(()=>{e!=null&&e.Handlers&&Object.entries(e.Handlers).forEach(([t,s])=>{x(t,s)})},[x,e==null?void 0:e.Handlers]);const f=e!=null&&e.Main?n(T,{name:"PaymentMethods",slot:e==null?void 0:e.Main,context:{replaceHTML(t){this.replaceWith(t),M(!1)}}}):null,P=y.value?d[y.value]:null,R=P?n(T,{name:"PaymentMethodContent",slot:P,context:{cartId:$.cartId||"",replaceHTML(t){this.replaceWith(t)}}},P):void 0;return b(()=>{!c&&d!=V&&console.warn("Payment method handlers you have added are ignored because the default content has been replaced")},[c,d]),v(D,{children:[f&&n(f.type,{ref:f.ref,...f.props}),c&&n(ee,{initializing:i===!1,loading:i&&O,onChange:I,options:l,paymentMethodContent:R,selection:y.value})]})};W.displayName="PaymentMethodsContainer";const Me=K(W);export{Me as PaymentMethods,Me as default}; diff --git a/scripts/__dropins__/storefront-checkout/containers/PaymentMethods/PaymentMethods.d.ts b/scripts/__dropins__/storefront-checkout/containers/PaymentMethods/PaymentMethods.d.ts index 5f3d0d99c1..53c3b1372f 100644 --- a/scripts/__dropins__/storefront-checkout/containers/PaymentMethods/PaymentMethods.d.ts +++ b/scripts/__dropins__/storefront-checkout/containers/PaymentMethods/PaymentMethods.d.ts @@ -12,6 +12,9 @@ export interface PaymentMethodHandlerSlotContext { replaceHTML: (domElement: HTMLElement) => void; } export interface PaymentMethodsProps extends HTMLAttributes { + setOnChange?: { + [key: string]: boolean; + } | undefined; slots?: { Main?: SlotProps; Handlers?: PaymentMethodHandlerSlots; diff --git a/scripts/__dropins__/storefront-checkout/containers/PlaceOrder.js b/scripts/__dropins__/storefront-checkout/containers/PlaceOrder.js index 0c1eb8427b..449034d296 100644 --- a/scripts/__dropins__/storefront-checkout/containers/PlaceOrder.js +++ b/scripts/__dropins__/storefront-checkout/containers/PlaceOrder.js @@ -1,3 +1,3 @@ /*! Copyright 2024 Adobe All Rights Reserved. */ -import{jsx as c}from"@dropins/tools/preact-jsx-runtime.js";import{U as E}from"../chunks/fetch-graphql.js";import{c as P}from"../chunks/store-config.js";import{s as g}from"../chunks/ServerErrorSignal.js";import{events as v}from"@dropins/tools/event-bus.js";import{classes as S}from"@dropins/tools/lib.js";import{p as b}from"../chunks/placeOrder2.js";/* empty css */import{Button as U}from"@dropins/tools/components.js";import{Text as w,useText as N}from"@dropins/tools/i18n.js";import{w as T}from"../chunks/withConditionalRendering.js";import{useState as z,useCallback as p,useEffect as H}from"@dropins/tools/preact-compat.js";import"@dropins/tools/fetch-graphql.js";import"@dropins/tools/signals.js";import"../fragments.js";import"../chunks/synchronizeCheckout.js";const I=r=>r instanceof TypeError||r instanceof E,M=({className:r,disabled:t=!1,onClick:o})=>c("div",{className:S(["checkout-place-order",r]),children:c(U,{className:"checkout-place-order__button","data-testid":"place-order-button",disabled:t,onClick:o,size:"medium",type:"submit",variant:"primary",children:c(w,{id:"Checkout.PlaceOrder.button"})},"placeOrder")}),u=({disabled:r=!1,handleValidation:t,onPlaceOrder:o,...f})=>{var l;const[h,O]=z(!1),{data:s,pending:k}=P.value,C=!!s,n=((l=s==null?void 0:s.selectedPaymentMethod)==null?void 0:l.code)||"",i=N({CheckoutUnexpectedError:"Checkout.ServerError.unexpected"}),m=p(e=>{g.value=I(e)?i.CheckoutUnexpectedError:e.message},[i]),x=p(async()=>{try{if(!(t?t():!0))return;o?await o({code:n}):await b()}catch(e){m(e)}},[t,o,n,m]);return H(()=>{const e=v.on("cart/initialized",a=>{const y=(a==null?void 0:a.items)||[];O(y.some(d=>d.outOfStock||d.insufficientQuantity))},{eager:!0});return()=>{e==null||e.off()}},[]),c(M,{...f,onClick:x,disabled:r||!C||k||h})};u.displayName="PlaceOrderContainer";const Y=T(u);export{Y as PlaceOrder,Y as default}; +import{jsx as a}from"@dropins/tools/preact-jsx-runtime.js";import{U as x}from"../chunks/fetch-graphql.js";import{c as E,b as g}from"../chunks/store-config.js";import{s as v}from"../chunks/ServerErrorSignal.js";import{events as y}from"@dropins/tools/event-bus.js";import{classes as S}from"@dropins/tools/lib.js";import{p as b}from"../chunks/placeOrder2.js";/* empty css */import{Button as P}from"@dropins/tools/components.js";import{Text as U,useText as w}from"@dropins/tools/i18n.js";import{w as N}from"../chunks/withConditionalRendering.js";import{useState as T,useCallback as m,useEffect as z}from"@dropins/tools/preact-compat.js";import"@dropins/tools/fetch-graphql.js";import"@dropins/tools/signals.js";import"../fragments.js";import"../chunks/synchronizeCheckout.js";const D=r=>r instanceof TypeError||r instanceof x,H=({className:r,disabled:t=!1,onClick:o})=>a("div",{className:S(["checkout-place-order",r]),children:a(P,{className:"checkout-place-order__button","data-testid":"place-order-button",disabled:t,onClick:o,size:"medium",type:"submit",variant:"primary",children:a(U,{id:"Checkout.PlaceOrder.button"})},"placeOrder")}),l=({disabled:r=!1,handleValidation:t,onPlaceOrder:o,...p})=>{const[u,d]=T(!1),{data:f,pending:O}=E.value,h=!!f,c=w({CheckoutUnexpectedError:"Checkout.ServerError.unexpected"}),n=m(e=>{v.value=D(e)?c.CheckoutUnexpectedError:e.message},[c]),k=m(async()=>{try{if(!(t?t():!0))return;o?await o({code:g.value||""}):await b()}catch(e){n(e)}},[t,o,n]);return z(()=>{const e=y.on("cart/initialized",s=>{const C=(s==null?void 0:s.items)||[];d(C.some(i=>i.outOfStock||i.insufficientQuantity))},{eager:!0});return()=>{e==null||e.off()}},[]),a(H,{...p,onClick:k,disabled:r||!h||O||u})};l.displayName="PlaceOrderContainer";const X=N(l);export{X as PlaceOrder,X as default}; diff --git a/scripts/__dropins__/storefront-checkout/containers/ShippingMethods.js b/scripts/__dropins__/storefront-checkout/containers/ShippingMethods.js index 91c21ba66d..976cddc010 100644 --- a/scripts/__dropins__/storefront-checkout/containers/ShippingMethods.js +++ b/scripts/__dropins__/storefront-checkout/containers/ShippingMethods.js @@ -1,3 +1,3 @@ /*! Copyright 2024 Adobe All Rights Reserved. */ -import{jsx as i,jsxs as L,Fragment as R}from"@dropins/tools/preact-jsx-runtime.js";import"../chunks/fetch-graphql.js";import{s as v,e as M,c as x,a as V}from"../chunks/store-config.js";import"../chunks/ServerErrorSignal.js";import{events as T}from"@dropins/tools/event-bus.js";import{classes as W,Slot as O}from"@dropins/tools/lib.js";import{s as P}from"../chunks/setShippingMethods.js";/* empty css */import{IllustratedMessage as Z,Icon as $,ProgressSpinner as q,RadioButton as F,Price as G,Skeleton as J,SkeletonRow as S}from"@dropins/tools/components.js";import*as p from"@dropins/tools/preact-compat.js";import{useRef as K,useEffect as z,useCallback as Q,useMemo as X}from"@dropins/tools/preact-compat.js";import{useText as Y}from"@dropins/tools/i18n.js";import{useState as I,useEffect as _}from"@dropins/tools/preact-hooks.js";import{w as D}from"../chunks/withConditionalRendering.js";import"@dropins/tools/fetch-graphql.js";import"@dropins/tools/signals.js";import"../chunks/synchronizeCheckout.js";import"../fragments.js";const U=e=>({countryCode:e.country_id,postCode:e.postcode||"",...e.region_id?{regionId:Number(e.region_id)}:{...e.region?{region:e.region}:{}}}),ee=e=>({carrierCode:e.carrier.code||"",methodCode:e.code||"",amount:e.amount,amountExclTax:e.amountExclTax,amountInclTax:e.amountInclTax}),te=e=>p.createElement("svg",{width:24,height:24,viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",...e},p.createElement("path",{vectorEffect:"non-scaling-stroke",d:"M2.47266 4.90002H15.1851V10.9645H21.2495L23 12.715V17.6124H20.073",stroke:"currentColor",strokeWidth:1,strokeLinecap:"round",strokeLinejoin:"round"}),p.createElement("path",{vectorEffect:"non-scaling-stroke",d:"M15.1758 5.87573H19.0019L21.0394 10.7636",stroke:"currentColor",strokeWidth:1,strokeLinecap:"round",strokeLinejoin:"round"}),p.createElement("path",{vectorEffect:"non-scaling-stroke",d:"M9.76151 16.7898C9.76151 18.0525 8.72845 19.076 7.46582 19.076C6.20318 19.076 5.17969 18.0429 5.17969 16.7803C5.17969 15.5176 6.20318 14.4941 7.46582 14.4941C8.72845 14.4941 9.75195 15.5176 9.76151 16.7803C9.76151 16.7803 9.76151 16.7803 9.76151 16.7898Z",stroke:"currentColor",strokeWidth:1,strokeLinecap:"round",strokeLinejoin:"round"}),p.createElement("path",{vectorEffect:"non-scaling-stroke",d:"M19.8726 16.7898C19.8726 18.062 18.8491 19.0855 17.5769 19.0855C16.3047 19.0855 15.2812 18.062 15.2812 16.7898C15.2812 15.5176 16.3047 14.4941 17.5769 14.4941C18.8491 14.4941 19.8726 15.5176 19.8726 16.7898Z",stroke:"currentColor",strokeWidth:1,strokeLinecap:"round",strokeLinejoin:"round"}),p.createElement("path",{vectorEffect:"non-scaling-stroke",d:"M8.08792 7.63574H1.69824",stroke:"currentColor",strokeWidth:1,strokeLinecap:"round",strokeLinejoin:"round"}),p.createElement("path",{vectorEffect:"non-scaling-stroke",d:"M7.11229 10.3619H1",stroke:"currentColor",strokeWidth:1,strokeLinecap:"round",strokeLinejoin:"round"}),p.createElement("path",{vectorEffect:"non-scaling-stroke",d:"M5.16084 13.0402H1.92773",stroke:"currentColor",strokeWidth:1,strokeLinecap:"round",strokeLinejoin:"round"}),p.createElement("path",{vectorEffect:"non-scaling-stroke",d:"M9.76172 16.7611H15.2809",stroke:"currentColor",strokeWidth:1,strokeLinecap:"round",strokeLinejoin:"round"}),p.createElement("path",{vectorEffect:"non-scaling-stroke",d:"M2.38672 16.7611H5.17025",stroke:"currentColor",strokeWidth:1,strokeLinecap:"round",strokeLinejoin:"round"})),ne=({className:e,isLoading:t=!1,onSelectionChange:n=()=>{},options:r,selection:a,...s})=>{const c=Y({Title:"Checkout.ShippingMethods.title",EmptyState:"Checkout.ShippingMethods.emptyState"});return r===void 0?i(oe,{}):L("div",{...s,className:W(["checkout-shipping-methods",e]),children:[i("h3",{className:"checkout-shipping-methods__title",children:c.Title}),!t&&r.length===0&&i(Z,{icon:i($,{source:te}),message:i("p",{children:c.EmptyState})}),L("div",{className:W(["checkout-shipping-methods__content"]),children:[t&&i(q,{className:"checkout-shipping-methods__spinner"}),i("div",{className:W(["checkout-shipping-methods__options",["checkout-shipping-methods__options--loading",t]]),children:r.map(o=>i(F,{"data-testid":"shipping-method-radiobutton","aria-busy":t,id:o.value,name:"shipping-method",className:"checkout-shipping-methods__method",label:L(R,{children:[i(G,{amount:o.amount.value,currency:o.amount.currency})," ",i("span",{children:o.carrier.title})]}),description:o.title,value:o.value,checked:(a==null?void 0:a.value)===o.value,onChange:()=>n(o)},o.value))})]})]})},oe=()=>L(J,{"data-testid":"shipping-methods-skeleton",children:[i(S,{variant:"heading",size:"small"}),i(S,{variant:"empty",size:"small"}),i(S,{size:"medium",fullWidth:!0}),i(S,{size:"medium",fullWidth:!0})]});function ie(){var C;const[e,t]=I(),[n,r]=I();_(()=>{T.on("checkout/estimate-shipping-address",({address:j,isValid:g})=>{t({address:j,isValid:g})})},[]),_(()=>{r(v.value)},[v.value]),_(()=>{M.value.pending?r(void 0):r(v.value)},[M.value.pending]);const{country_id:a,region_id:s,region:c,postcode:o}=(e==null?void 0:e.address)||{},f=!!e,l=x.value.data,k=!!((C=l==null?void 0:l.shippingAddresses)!=null&&C[0]),u=e==null?void 0:e.isValid;_(()=>{k||u||!n||!f||T.emit("shipping/estimate",{address:U({country_id:a,region_id:s,region:c,postcode:o}),shippingMethod:ee(n)})},[n,a,s,c,o,f,k,u])}const b=(e,t)=>e.code===t.code&&e.carrier.code===t.carrier.code,re=e=>{var r,a,s,c;const t=(c=(s=(a=(r=x.value.data)==null?void 0:r.shippingAddresses)==null?void 0:a[0])==null?void 0:s.selectedShippingMethod)==null?void 0:c.carrier.code,n=K();z(()=>{t!==n.current&&(n.current=t,t&&(e==null||e()))},[t,e])};function se({onCheckoutDataUpdate:e,preSelectedMethod:t,onShippingMethodSelect:n}){const a=!V.value.data,s=x.value.data,c=x.value.pending,o=M.value.data,f=M.value.pending,l=v.value,k=s==null?void 0:s.shippingAddresses,u=k==null?void 0:k[0],C=!!u,j=u==null?void 0:u.availableShippingMethods,g=u==null?void 0:u.selectedShippingMethod,d=j||o,w=Q(m=>{if(!C)return;const E={method_code:m.code,carrier_code:m.carrier.code};P([E]).catch(y=>{console.error("Setting shipping methods on cart failed:",y)})},[C,e]),B=m=>{v.value=m,n==null||n(m)},h=X(()=>{if(!(d!=null&&d.length))return;const m=d[0],E=l||g;return E?d.some(H=>b(H,E))?E:m:d.find(N=>N.carrier.code===(t==null?void 0:t.carrierCode)&&N.code===(t==null?void 0:t.methodCode))||m},[l,g,d,t]);return z(()=>{h&&((!l||!b(h,l))&&(v.value=h,n==null||n(h)),(!g||!b(h,g))&&w(h))},[h,l,g,w,n]),{isLoading:c||a||f,options:d,selection:h,onSelectionChange:B}}const A=({preSelectedMethod:e,onCheckoutDataUpdate:t,shippingMethodsSlot:n,onShippingMethodSelect:r,initialData:a,...s})=>{const{isLoading:c,options:o,selection:f,onSelectionChange:l}=se({preSelectedMethod:e,onCheckoutDataUpdate:t,onShippingMethodSelect:r});return ie(),re(t),L(R,{children:[i(ne,{...s,isLoading:c,onSelectionChange:l,options:o,selection:f}),!c&&n&&i(O,{name:"ShippingMethods",slot:n})]})};A.displayName="ShippingMethodsContainer";const Me=D(A);export{Me as ShippingMethods,Me as default}; +import{jsx as o,jsxs as E,Fragment as I}from"@dropins/tools/preact-jsx-runtime.js";import"../chunks/fetch-graphql.js";import{s as k,e as M,c as x,a as B}from"../chunks/store-config.js";import"../chunks/ServerErrorSignal.js";import{events as N}from"@dropins/tools/event-bus.js";import{classes as j,Slot as V}from"@dropins/tools/lib.js";import{s as O}from"../chunks/setShippingMethods.js";/* empty css */import{IllustratedMessage as P,Icon as Z,ProgressSpinner as $,RadioButton as q,Price as F,Skeleton as G,SkeletonRow as S}from"@dropins/tools/components.js";import*as d from"@dropins/tools/preact-compat.js";import{useRef as J,useEffect as R,useCallback as K,useMemo as Q}from"@dropins/tools/preact-compat.js";import{useText as X}from"@dropins/tools/i18n.js";import{useState as T,useEffect as _}from"@dropins/tools/preact-hooks.js";import{w as Y}from"../chunks/withConditionalRendering.js";import"@dropins/tools/fetch-graphql.js";import"@dropins/tools/signals.js";import"../chunks/synchronizeCheckout.js";import"../fragments.js";const D=e=>({countryCode:e.country_id,postCode:e.postcode||"",...e.region_id?{regionId:Number(e.region_id)}:{...e.region?{region:e.region}:{}}}),U=e=>({carrierCode:e.carrier.code||"",methodCode:e.code||"",amount:e.amount,amountExclTax:e.amountExclTax,amountInclTax:e.amountInclTax}),ee=e=>d.createElement("svg",{width:24,height:24,viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",...e},d.createElement("path",{vectorEffect:"non-scaling-stroke",d:"M2.47266 4.90002H15.1851V10.9645H21.2495L23 12.715V17.6124H20.073",stroke:"currentColor",strokeWidth:1,strokeLinecap:"round",strokeLinejoin:"round"}),d.createElement("path",{vectorEffect:"non-scaling-stroke",d:"M15.1758 5.87573H19.0019L21.0394 10.7636",stroke:"currentColor",strokeWidth:1,strokeLinecap:"round",strokeLinejoin:"round"}),d.createElement("path",{vectorEffect:"non-scaling-stroke",d:"M9.76151 16.7898C9.76151 18.0525 8.72845 19.076 7.46582 19.076C6.20318 19.076 5.17969 18.0429 5.17969 16.7803C5.17969 15.5176 6.20318 14.4941 7.46582 14.4941C8.72845 14.4941 9.75195 15.5176 9.76151 16.7803C9.76151 16.7803 9.76151 16.7803 9.76151 16.7898Z",stroke:"currentColor",strokeWidth:1,strokeLinecap:"round",strokeLinejoin:"round"}),d.createElement("path",{vectorEffect:"non-scaling-stroke",d:"M19.8726 16.7898C19.8726 18.062 18.8491 19.0855 17.5769 19.0855C16.3047 19.0855 15.2812 18.062 15.2812 16.7898C15.2812 15.5176 16.3047 14.4941 17.5769 14.4941C18.8491 14.4941 19.8726 15.5176 19.8726 16.7898Z",stroke:"currentColor",strokeWidth:1,strokeLinecap:"round",strokeLinejoin:"round"}),d.createElement("path",{vectorEffect:"non-scaling-stroke",d:"M8.08792 7.63574H1.69824",stroke:"currentColor",strokeWidth:1,strokeLinecap:"round",strokeLinejoin:"round"}),d.createElement("path",{vectorEffect:"non-scaling-stroke",d:"M7.11229 10.3619H1",stroke:"currentColor",strokeWidth:1,strokeLinecap:"round",strokeLinejoin:"round"}),d.createElement("path",{vectorEffect:"non-scaling-stroke",d:"M5.16084 13.0402H1.92773",stroke:"currentColor",strokeWidth:1,strokeLinecap:"round",strokeLinejoin:"round"}),d.createElement("path",{vectorEffect:"non-scaling-stroke",d:"M9.76172 16.7611H15.2809",stroke:"currentColor",strokeWidth:1,strokeLinecap:"round",strokeLinejoin:"round"}),d.createElement("path",{vectorEffect:"non-scaling-stroke",d:"M2.38672 16.7611H5.17025",stroke:"currentColor",strokeWidth:1,strokeLinecap:"round",strokeLinejoin:"round"})),te=({className:e,isLoading:t=!1,onSelectionChange:c=()=>{},options:i,selection:r,...a})=>{const s=X({Title:"Checkout.ShippingMethods.title",EmptyState:"Checkout.ShippingMethods.emptyState"});return i===void 0?o(ne,{}):E("div",{...a,className:j(["checkout-shipping-methods",e]),children:[o("h3",{className:"checkout-shipping-methods__title",children:s.Title}),!t&&i.length===0&&o(P,{icon:o(Z,{source:ee}),message:o("p",{children:s.EmptyState})}),E("div",{className:j(["checkout-shipping-methods__content"]),children:[t&&o($,{className:"checkout-shipping-methods__spinner"}),o("div",{className:j(["checkout-shipping-methods__options",["checkout-shipping-methods__options--loading",t]]),children:i.map(n=>o(q,{"data-testid":"shipping-method-radiobutton","aria-busy":t,id:n.value,name:"shipping-method",className:"checkout-shipping-methods__method",label:E(I,{children:[o(F,{amount:n.amount.value,currency:n.amount.currency})," ",o("span",{children:n.carrier.title})]}),description:n.title,value:n.value,checked:(r==null?void 0:r.value)===n.value,onChange:()=>c(n)},n.value))})]})]})},ne=()=>E(G,{"data-testid":"shipping-methods-skeleton",children:[o(S,{variant:"heading",size:"small"}),o(S,{variant:"empty",size:"small"}),o(S,{size:"medium",fullWidth:!0}),o(S,{size:"medium",fullWidth:!0})]});function oe(){var L;const[e,t]=T(),[c,i]=T();_(()=>{N.on("checkout/estimate-shipping-address",({address:f,isValid:p})=>{t({address:f,isValid:p})})},[]),_(()=>{i(k.value)},[k.value]),_(()=>{M.value.pending?i(void 0):i(k.value)},[M.value.pending]);const{country_id:r,region_id:a,region:s,postcode:n}=(e==null?void 0:e.address)||{},l=!!e,h=x.value.data,u=!!((L=h==null?void 0:h.shippingAddresses)!=null&&L[0]),v=e==null?void 0:e.isValid;_(()=>{u||v||!c||!l||N.emit("shipping/estimate",{address:D({country_id:r,region_id:a,region:s,postcode:n}),shippingMethod:U(c)})},[c,r,a,s,n,l,u,v])}const W=(e,t)=>e.code===t.code&&e.carrier.code===t.carrier.code,ie=e=>{var i,r,a,s;const t=(s=(a=(r=(i=x.value.data)==null?void 0:i.shippingAddresses)==null?void 0:r[0])==null?void 0:a.selectedShippingMethod)==null?void 0:s.carrier.code,c=J();R(()=>{t!==c.current&&(c.current=t,t&&(e==null||e()))},[t,e])};function re({preSelectedMethod:e,onShippingMethodSelect:t}){const i=!B.value.data,r=x.value.data,a=x.value.pending,s=M.value.data,n=M.value.pending,l=k.value,h=r==null?void 0:r.shippingAddresses,u=h==null?void 0:h[0],v=!!u,L=u==null?void 0:u.availableShippingMethods,f=u==null?void 0:u.selectedShippingMethod,p=L||s,b=K(g=>{if(!v)return;const C={method_code:g.code,carrier_code:g.carrier.code};O([C]).catch(w=>{console.error("Setting shipping methods on cart failed:",w)})},[v]),A=g=>{k.value=g,t==null||t(g)},m=Q(()=>{if(!(p!=null&&p.length))return;const g=p[0],C=l||f;return C?p.some(y=>W(y,C))?C:g:p.find(H=>H.carrier.code===(e==null?void 0:e.carrierCode)&&H.code===(e==null?void 0:e.methodCode))||g},[l,f,p,e]);return R(()=>{m&&((!l||!W(m,l))&&(k.value=m,t==null||t(m)),(!f||!W(m,f))&&b(m))},[m,l,f,b,t]),{isLoading:a||i||n,options:p,selection:m,onSelectionChange:A}}const z=({preSelectedMethod:e,onCheckoutDataUpdate:t,shippingMethodsSlot:c,onShippingMethodSelect:i,initialData:r,...a})=>{const{isLoading:s,options:n,selection:l,onSelectionChange:h}=re({preSelectedMethod:e,onCheckoutDataUpdate:t,onShippingMethodSelect:i});return oe(),ie(t),E(I,{children:[o(te,{...a,isLoading:s,onSelectionChange:h,options:n,selection:l}),!s&&c&&o(V,{name:"ShippingMethods",slot:c})]})};z.displayName="ShippingMethodsContainer";const _e=Y(z);export{_e as ShippingMethods,_e as default}; diff --git a/scripts/__dropins__/storefront-checkout/data/models/address.d.ts b/scripts/__dropins__/storefront-checkout/data/models/address.d.ts index 91e1c6032d..d4e9d1db26 100644 --- a/scripts/__dropins__/storefront-checkout/data/models/address.d.ts +++ b/scripts/__dropins__/storefront-checkout/data/models/address.d.ts @@ -13,5 +13,9 @@ export interface Address { street: string[]; telephone?: string; vatId?: string; + prefix?: string; + suffix?: string; + middleName?: string; + fax?: string; } //# sourceMappingURL=address.d.ts.map \ No newline at end of file diff --git a/scripts/__dropins__/storefront-checkout/data/models/api.d.ts b/scripts/__dropins__/storefront-checkout/data/models/api.d.ts index 52bd1340ea..9f26adb175 100644 --- a/scripts/__dropins__/storefront-checkout/data/models/api.d.ts +++ b/scripts/__dropins__/storefront-checkout/data/models/api.d.ts @@ -14,6 +14,10 @@ export interface CartAddress { street: string[]; telephone?: string; vatId?: string; + prefix?: string; + suffix?: string; + middleName?: string; + fax?: string; } export interface ShippingAddressInput { address?: CartAddress; diff --git a/scripts/__dropins__/storefront-checkout/data/models/order.d.ts b/scripts/__dropins__/storefront-checkout/data/models/order.d.ts index 6f6ea55711..039fbc60e1 100644 --- a/scripts/__dropins__/storefront-checkout/data/models/order.d.ts +++ b/scripts/__dropins__/storefront-checkout/data/models/order.d.ts @@ -16,6 +16,9 @@ export type OrderAddressModel = { code: string; value: string; }[]; + prefix: string; + suffix: string; + fax: string; } | null; export type OrderItemProductModel = { stockStatus?: string; diff --git a/scripts/__dropins__/storefront-checkout/data/transforms/transform-address.d.ts b/scripts/__dropins__/storefront-checkout/data/transforms/transform-address.d.ts index 167c803715..d36611fd59 100644 --- a/scripts/__dropins__/storefront-checkout/data/transforms/transform-address.d.ts +++ b/scripts/__dropins__/storefront-checkout/data/transforms/transform-address.d.ts @@ -21,6 +21,10 @@ declare const transformShippingAddresses: (data: ({ vat_id?: string | null | undefined; telephone?: string | null | undefined; same_as_billing: boolean; + prefix?: string | null | undefined; + suffix?: string | null | undefined; + middlename?: string | null | undefined; + fax?: string | null | undefined; region?: { __typename?: "CartAddressRegion" | undefined; region_id?: number | null | undefined; diff --git a/scripts/__dropins__/storefront-checkout/fragments.js b/scripts/__dropins__/storefront-checkout/fragments.js index fbe3a85a4b..3c03a79432 100644 --- a/scripts/__dropins__/storefront-checkout/fragments.js +++ b/scripts/__dropins__/storefront-checkout/fragments.js @@ -26,6 +26,10 @@ const e=` value } } + prefix + suffix + middlename + fax } `,t=` fragment SHIPPING_CART_ADDRESS_FRAGMENT on ShippingCartAddress { @@ -92,6 +96,10 @@ const e=` } } same_as_billing + prefix + suffix + middlename + fax } `,d=` fragment CHECKOUT_DATA_FRAGMENT on Cart { @@ -259,6 +267,7 @@ const e=` value } taxes { + title amount { currency value diff --git a/scripts/__dropins__/storefront-checkout/fragments.original.js b/scripts/__dropins__/storefront-checkout/fragments.original.js index fbe3a85a4b..3c03a79432 100644 --- a/scripts/__dropins__/storefront-checkout/fragments.original.js +++ b/scripts/__dropins__/storefront-checkout/fragments.original.js @@ -26,6 +26,10 @@ const e=` value } } + prefix + suffix + middlename + fax } `,t=` fragment SHIPPING_CART_ADDRESS_FRAGMENT on ShippingCartAddress { @@ -92,6 +96,10 @@ const e=` } } same_as_billing + prefix + suffix + middlename + fax } `,d=` fragment CHECKOUT_DATA_FRAGMENT on Cart { @@ -259,6 +267,7 @@ const e=` value } taxes { + title amount { currency value diff --git a/scripts/__dropins__/storefront-checkout/msw/fixtures/fragments/billing-address.d.ts b/scripts/__dropins__/storefront-checkout/msw/fixtures/fragments/billing-address.d.ts index f3622f9f70..6d565a4879 100644 --- a/scripts/__dropins__/storefront-checkout/msw/fixtures/fragments/billing-address.d.ts +++ b/scripts/__dropins__/storefront-checkout/msw/fixtures/fragments/billing-address.d.ts @@ -1,19 +1,19 @@ /******************************************************************** -* ADOBE CONFIDENTIAL -* __________________ -* -* Copyright 2024 Adobe -* All Rights Reserved. -* -* NOTICE: All information contained herein is, and remains -* the property of Adobe and its suppliers, if any. The intellectual -* and technical concepts contained herein are proprietary to Adobe -* and its suppliers and are protected by all applicable intellectual -* property laws, including trade secret and copyright laws. -* Dissemination of this information or reproduction of this material -* is strictly forbidden unless prior written permission is obtained -* from Adobe. -*******************************************************************/ + * ADOBE CONFIDENTIAL + * __________________ + * + * Copyright 2024 Adobe + * All Rights Reserved. + * + * NOTICE: All information contained herein is, and remains + * the property of Adobe and its suppliers, if any. The intellectual + * and technical concepts contained herein are proprietary to Adobe + * and its suppliers and are protected by all applicable intellectual + * property laws, including trade secret and copyright laws. + * Dissemination of this information or reproduction of this material + * is strictly forbidden unless prior written permission is obtained + * from Adobe. + *******************************************************************/ export declare const billingAddressFixture: { firstname: string; lastname: string; @@ -33,6 +33,10 @@ export declare const billingAddressFixture: { }; telephone: string; custom_attributes: {}[]; + prefix: string; + suffix: string; + middlename: string; + fax: string; }; export declare const ukBillingAddressFixture: { firstname: string; @@ -48,5 +52,9 @@ export declare const ukBillingAddressFixture: { }; telephone: string; custom_attributes: {}[]; + prefix: string; + suffix: string; + middlename: string; + fax: string; }; //# sourceMappingURL=billing-address.d.ts.map \ No newline at end of file diff --git a/scripts/__dropins__/storefront-checkout/msw/fixtures/fragments/cart.d.ts b/scripts/__dropins__/storefront-checkout/msw/fixtures/fragments/cart.d.ts index a8e011e8fa..bcf29e47d3 100644 --- a/scripts/__dropins__/storefront-checkout/msw/fixtures/fragments/cart.d.ts +++ b/scripts/__dropins__/storefront-checkout/msw/fixtures/fragments/cart.d.ts @@ -31,6 +31,10 @@ export declare const cartFixture: { vat_id?: string | null | undefined; street: (string | null)[]; telephone?: string | null | undefined; + prefix?: string | null | undefined; + suffix?: string | null | undefined; + middlename?: string | null | undefined; + fax?: string | null | undefined; country: { __typename?: "CartAddressCountry" | undefined; code: string; @@ -62,6 +66,10 @@ export declare const cartFixture: { vat_id?: string | null | undefined; telephone?: string | null | undefined; same_as_billing: boolean; + prefix?: string | null | undefined; + suffix?: string | null | undefined; + middlename?: string | null | undefined; + fax?: string | null | undefined; region?: { __typename?: "CartAddressRegion" | undefined; region_id?: number | null | undefined; diff --git a/scripts/__dropins__/storefront-checkout/msw/fixtures/fragments/shipping-address.d.ts b/scripts/__dropins__/storefront-checkout/msw/fixtures/fragments/shipping-address.d.ts index bae9900a71..51a9827c53 100644 --- a/scripts/__dropins__/storefront-checkout/msw/fixtures/fragments/shipping-address.d.ts +++ b/scripts/__dropins__/storefront-checkout/msw/fixtures/fragments/shipping-address.d.ts @@ -1,19 +1,19 @@ /******************************************************************** -* ADOBE CONFIDENTIAL -* __________________ -* -* Copyright 2024 Adobe -* All Rights Reserved. -* -* NOTICE: All information contained herein is, and remains -* the property of Adobe and its suppliers, if any. The intellectual -* and technical concepts contained herein are proprietary to Adobe -* and its suppliers and are protected by all applicable intellectual -* property laws, including trade secret and copyright laws. -* Dissemination of this information or reproduction of this material -* is strictly forbidden unless prior written permission is obtained -* from Adobe. -*******************************************************************/ + * ADOBE CONFIDENTIAL + * __________________ + * + * Copyright 2024 Adobe + * All Rights Reserved. + * + * NOTICE: All information contained herein is, and remains + * the property of Adobe and its suppliers, if any. The intellectual + * and technical concepts contained herein are proprietary to Adobe + * and its suppliers and are protected by all applicable intellectual + * property laws, including trade secret and copyright laws. + * Dissemination of this information or reproduction of this material + * is strictly forbidden unless prior written permission is obtained + * from Adobe. + *******************************************************************/ export declare const shippingAddressFixture: { firstname: string; lastname: string; @@ -54,5 +54,9 @@ export declare const shippingAddressFixture: { }; }[]; selected_shipping_method: null; + prefix: string; + suffix: string; + middlename: string; + fax: string; }; //# sourceMappingURL=shipping-address.d.ts.map \ No newline at end of file diff --git a/scripts/__dropins__/storefront-checkout/render.js b/scripts/__dropins__/storefront-checkout/render.js index d4283259db..d4f75807c5 100644 --- a/scripts/__dropins__/storefront-checkout/render.js +++ b/scripts/__dropins__/storefront-checkout/render.js @@ -4,6 +4,6 @@ All Rights Reserved. */ .checkout-estimate-shipping{display:grid;grid-template-columns:1fr 1fr;gap:var(--spacing-xxsmall);align-items:center;color:var(--color-neutral-800)}.checkout-estimate-shipping__label,.checkout-estimate-shipping__price{font:var(--type-body-1-default-font);letter-spacing:var(--type-body-1-default-letter-spacing)}.checkout-estimate-shipping__label--muted{font:var(--type-body-2-default-font);letter-spacing:var(--type-body-2-default-letter-spacing);color:var(--color-neutral-700)}.checkout-estimate-shipping__price--muted{font:var(--type-body-2-default-font);letter-spacing:var(--type-body-2-default-letter-spacing)}.checkout-estimate-shipping__price{text-align:right}.checkout-estimate-shipping__label--bold,.checkout-estimate-shipping__price--bold{font:var(--type-body-1-emphasized-font);letter-spacing:var(--type-body-1-emphasized-letter-spacing)}.checkout-estimate-shipping__caption{font:var(--type-details-caption-2-font);letter-spacing:var(--type-details-caption-2-letter-spacing);color:var(--color-neutral-700)}.cart-order-summary__shipping .dropin-skeleton{grid-template-columns:1fr}.checkout-login-form__heading{display:grid;grid-template-columns:1fr max-content;grid-auto-rows:max-content}.checkout-login-form__content{grid-auto-rows:max-content}.checkout-login-form__content .dropin-field__hint a{font-weight:400}.checkout-login-form__customer-details{display:grid;grid-auto-flow:row;gap:var(--spacing-xxsmall)}.checkout-login-form__customer-name{font:var(--type-body-1-strong-font);letter-spacing:var(--type-body-1-default-letter-spacing)}.checkout-login-form__customer-email{font:var(--type-body-2-default-font);letter-spacing:var(--type-body-2-default-letter-spacing);color:var(--color-neutral-700)}.checkout-login-form__title{grid-column-start:1;color:var(--color-neutral-800);font:var(--type-headline-2-default-font);letter-spacing:var(--type-headline-2-default-letter-spacing);margin:0 0 var(--spacing-medium) 0}.checkout-login-form__sign-in,.checkout-login-form__sign-out{grid-column-start:2;color:var(--color-neutral-800);font:var(--type-body-2-default-font);letter-spacing:var(--type-body-2-default-letter-spacing);justify-self:flex-end;margin-top:var(--spacing-xxsmall)}a.checkout-login-form__link{font:var(--type-body-2-strong-font);letter-spacing:var(--type-body-2-strong-letter-spacing);margin-left:var(--spacing-xxsmall)}@media only screen and (min-width: 320px) and (max-width: 768px){.checkout-login-form__heading{grid-template-columns:repeat(1,1fr [col-start]);grid-template-rows:1fr}.checkout-login-form__sign-in,.checkout-login-form__sign-out{grid-column-start:1;align-self:flex-start;justify-self:flex-start;margin-top:0;margin-bottom:var(--spacing-medium)}}.order-confirmation-header{text-align:center;padding:var(--spacing-xxbig)}.order-confirmation-header__icon{margin-bottom:var(--spacing-small)}.order-confirmation-header__title{color:var(--color-neutral-800);font:var(--type-headline-1-font);letter-spacing:var(--type-headline-1-letter-spacing);justify-content:center;margin:0}.order-confirmation-header__title:first-letter{text-transform:uppercase}.order-confirmation-header__order{color:var(--color-neutral-700);font:var(--type-details-overline-font);letter-spacing:var(--type-details-overline-letter-spacing);margin:var(--spacing-xxsmall) 0 0 0}.order-confirmation-header .success-icon{color:var(--color-positive-500)}.order-confirmation-create-account{display:grid;gap:var(--spacing-small);margin-top:var(--spacing-large)}.order-confirmation-create-account__message{font:var(--type-body-2-default-font);letter-spacing:var(--type-body-2-default-letter-spacing);margin:0}.order-confirmation-create-account__button{display:flex;margin:0 auto;text-align:center}.checkout-out-of-stock.dropin-card{border-color:var(--color-warning-500)}.checkout-out-of-stock .dropin-card__content{gap:var(--spacing-small);padding:var(--spacing-small)}.checkout-out-of-stock__title{color:var(--color-neutral-900);font:var(--type-body-2-strong-font);margin:0;display:flex;gap:var(--spacing-xxsmall);align-items:center;justify-content:left;text-align:center}.checkout-out-of-stock__message{color:var(--color-neutral-800);font:var(--type-body-2-default-font);margin:0}.checkout-out-of-stock__items{display:grid;grid-template-columns:repeat(5,100px);grid-gap:var(--spacing-small);list-style:none;padding:0;margin:0}.checkout-out-of-stock__item img{width:100%;height:auto}.checkout-out-of-stock__actions{display:flex;gap:var(--spacing-small);justify-content:flex-end}a.checkout-out-of-stock__action{font:var(--type-details-caption-1-font)}.checkout-out-of-stock__action{background:none;border:none;padding:0;cursor:pointer}.checkout-out-of-stock__action:hover{--textColor: var(--color-brand-700);text-decoration:solid underline var(--textColor);text-underline-offset:6px}.checkout-server-error{position:relative;text-align:center}.checkout-server-error__icon .error-icon{color:var(--color-alert-500)}.checkout-server-error a{font:var(--type-body-2-strong-font);letter-spacing:var(--type-body-2-strong-letter-spacing)} .checkout-shipping-methods__title{color:var(--color-neutral-800);font:var(--type-body-1-default-font);letter-spacing:var(--type-body-1-default-letter-spacing);margin:0 0 var(--spacing-medium) 0}.checkout-shipping-methods__content{position:relative;display:block}.checkout-shipping-methods__method{margin-bottom:var(--spacing-medium);width:fit-content;cursor:pointer;font:var(--type-body-2-default-font);letter-spacing:var(--type-body-2-default-letter-spacing)}.checkout-shipping-methods__method:last-child{margin-bottom:0}.dropin-radio-button__label .dropin-price{color:var(--color-neutral-800);font-weight:400}.checkout-shipping-methods__options--loading{opacity:.4;pointer-events:none}.checkout-shipping-methods__spinner{margin:0 auto;position:absolute;z-index:999;left:0;right:0;top:calc(50% - (var(--size) / 2));bottom:0} .checkout-place-order{display:grid;padding-bottom:var(--spacing-big)}.checkout-place-order__button{align-self:flex-end;justify-self:flex-end}@media only screen and (min-width:320px) and (max-width: 768px){.checkout-place-order{background-color:var(--color-neutral-200);padding:var(--spacing-medium) var(--spacing-medium) var(--spacing-big) var(--spacing-medium)}.checkout-place-order__button{align-self:center;justify-self:stretch}} -.checkout-payment-methods__title{color:var(--color-neutral-800);font:var(--type-headline-2-default-font);letter-spacing:var(--type-headline-2-default-letter-spacing);margin:0 0 var(--spacing-medium) 0}.checkout-payment-methods__wrapper{position:relative;display:grid}.checkout-payment-methods__methods{display:grid;grid-template-columns:1fr 1fr;gap:var(--spacing-medium)}.checkout-payment-methods__content{margin-top:var(--spacing-medium)}.checkout-payment-methods--full-width{grid-template-columns:1fr}.checkout-payment-methods--loading{opacity:.4;pointer-events:none}.checkout-payment-methods__spinner{margin:0 auto;position:absolute;z-index:999;left:0;right:0;top:calc(50% - (var(--size) / 2));bottom:0}.checkout__content [data-slot=PaymentMethods]:empty{display:none}@media only screen and (min-width: 320px) and (max-width: 768px){.checkout-payment-methods__methods{grid-template-columns:1fr}} +.checkout-payment-methods__title{color:var(--color-neutral-800);font:var(--type-headline-2-default-font);letter-spacing:var(--type-headline-2-default-letter-spacing);margin:0 0 var(--spacing-medium) 0}.checkout-payment-methods__wrapper{position:relative;display:grid}.checkout-payment-methods__methods{display:grid;grid-template-columns:1fr 1fr;gap:var(--spacing-medium)}.checkout-payment-methods__content>div[data-slot=PaymentMethodSlot]:not(:empty){margin-top:var(--spacing-medium)}.checkout-payment-methods--full-width{grid-template-columns:1fr}.checkout-payment-methods--loading{opacity:.4;pointer-events:none}.checkout-payment-methods__spinner{margin:0 auto;position:absolute;z-index:999;left:0;right:0;top:calc(50% - (var(--size) / 2));bottom:0}.checkout__content [data-slot=PaymentMethods]:empty{display:none}@media only screen and (min-width: 320px) and (max-width: 768px){.checkout-payment-methods__methods{grid-template-columns:1fr}} .checkout-bill-to-shipping-address label{font:var(--type-body-2-default-font);letter-spacing:var(--type-body-2-default-letter-spacing);gap:0}`,{styleId:"checkout"}); import{jsx as f}from"@dropins/tools/preact-jsx-runtime.js";import{Render as d}from"@dropins/tools/lib.js";import"./chunks/fetch-graphql.js";import"./chunks/store-config.js";import"./chunks/ServerErrorSignal.js";import{events as p}from"@dropins/tools/event-bus.js";import{c as y}from"./chunks/synchronizeCheckout.js";import{UIProvider as g}from"@dropins/tools/components.js";import{useState as b,useEffect as h}from"@dropins/tools/preact-hooks.js";import"@dropins/tools/fetch-graphql.js";import"@dropins/tools/signals.js";import"./fragments.js";function O(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var S=function(r){return E(r)&&!v(r)};function E(e){return!!e&&typeof e=="object"}function v(e){var r=Object.prototype.toString.call(e);return r==="[object RegExp]"||r==="[object Date]"||M(e)}var w=typeof Symbol=="function"&&Symbol.for,j=w?Symbol.for("react.element"):60103;function M(e){return e.$$typeof===j}function A(e){return Array.isArray(e)?[]:{}}function i(e,r){return r.clone!==!1&&r.isMergeableObject(e)?a(A(e),e,r):e}function P(e,r,t){return e.concat(r).map(function(o){return i(o,t)})}function T(e,r){if(!r.customMerge)return a;var t=r.customMerge(e);return typeof t=="function"?t:a}function C(e){return Object.getOwnPropertySymbols?Object.getOwnPropertySymbols(e).filter(function(r){return Object.propertyIsEnumerable.call(e,r)}):[]}function l(e){return Object.keys(e).concat(C(e))}function m(e,r){try{return r in e}catch{return!1}}function I(e,r){return m(e,r)&&!(Object.hasOwnProperty.call(e,r)&&Object.propertyIsEnumerable.call(e,r))}function x(e,r,t){var o={};return t.isMergeableObject(e)&&l(e).forEach(function(n){o[n]=i(e[n],t)}),l(r).forEach(function(n){I(e,n)||(m(e,n)&&t.isMergeableObject(r[n])?o[n]=T(n,t)(e[n],r[n],t):o[n]=i(r[n],t))}),o}function a(e,r,t){t=t||{},t.arrayMerge=t.arrayMerge||P,t.isMergeableObject=t.isMergeableObject||S,t.cloneUnlessOtherwiseSpecified=i;var o=Array.isArray(r),n=Array.isArray(e),c=o===n;return c?o?t.arrayMerge(e,r,t):x(e,r,t):i(r,t)}a.all=function(r,t){if(!Array.isArray(r))throw new Error("first argument should be an array");return r.reduce(function(o,n){return a(o,n,t)},{})};var D=a,k=D;const R=O(k),B={title:"Checkout",LoginForm:{title:"Contact details",account:"Already have an account?",ariaLabel:"Email",invalidEmailError:"Please enter a valid email address.",missingEmailError:"Enter an email address.",emailExists:{alreadyHaveAccount:"It looks like you already have an account.",signInButton:"Sign in",forFasterCheckout:"for a faster checkout."},floatingLabel:"Email *",placeholder:"Enter your email address",signIn:"Sign In",switch:"Do you want to switch account?",signOut:"Sign Out"},ShippingMethods:{title:"Shipping options",emptyState:"This order can't be shipped to the address provided. Please review the address details you entered and make sure they're correct."},BillToShippingAddress:{title:"Bill to shipping address"},PaymentMethods:{title:"Payment",emptyState:"No payment methods available"},OutOfStock:{title:"Your cart contains items that are out of stock",message:"The following items are out of stock:",actions:{reviewCart:"Review cart",removeOutOfStock:"Remove out of stock items"},lowInventory:{one:"Last item!",many:"Only {{count}} left!"},alert:"Out of stock!"},PlaceOrder:{button:"Place Order"},ServerError:{title:"We were unable to process your order",contactSupport:"If you continue to have issues, please contact support.",unexpected:"An unexpected error occurred while processing your order. Please try again later.",button:"Try again"},EmptyCart:{title:"Your cart is empty",button:"Start shopping"},ErrorBanner:{genericMessage:"Server error detected. Please check your connection and try again."},MergedCartBanner:{items:{one:"1 item from a previous session was added to your cart. Please review your new subtotal.",many:"{{count}} items from a previous session were added to your cart. Please review your new subtotal."}},EstimateShipping:{estimated:"Estimated Shipping",freeShipping:"Free",label:"Shipping",taxToBeDetermined:"TBD",withTaxes:"Including taxes",withoutTaxes:"Excluding taxes"},OrderConfirmationHeader:{title:"{{name}}, thank you for your order!",defaultTitle:"Thank you for your order!",order:"ORDER #{{order}}",CreateAccount:{message:"Save your information for faster checkout next time.",button:"Create an account"}}},L={Checkout:B},_={default:L},U=({children:e})=>{var c;const[r,t]=b(),o=(c=y.getConfig())==null?void 0:c.langDefinitions;h(()=>{const s=p.on("locale",u=>{u!==r&&t(u)},{eager:!0});return()=>{s==null||s.off()}},[r]);const n=R(_,o??{});return f(g,{lang:r,langDefinitions:n,children:e})},Q=new d(f(U,{}));export{U as Provider,Q as render}; diff --git a/scripts/__dropins__/storefront-checkout/signals/SelectedPaymentMethodSignal.d.ts b/scripts/__dropins__/storefront-checkout/signals/SelectedPaymentMethodSignal.d.ts new file mode 100644 index 0000000000..aa304095e4 --- /dev/null +++ b/scripts/__dropins__/storefront-checkout/signals/SelectedPaymentMethodSignal.d.ts @@ -0,0 +1,18 @@ +/******************************************************************** + * ADOBE CONFIDENTIAL + * __________________ + * + * Copyright 2024 Adobe + * All Rights Reserved. + * + * NOTICE: All information contained herein is, and remains + * the property of Adobe and its suppliers, if any. The intellectual + * and technical concepts contained herein are proprietary to Adobe + * and its suppliers and are protected by all applicable intellectual + * property laws, including trade secret and copyright laws. + * Dissemination of this information or reproduction of this material + * is strictly forbidden unless prior written permission is obtained + * from Adobe. + *******************************************************************/ +export declare const selectedPaymentMethodSignal: import('@preact/signals-core').Signal; +//# sourceMappingURL=SelectedPaymentMethodSignal.d.ts.map \ No newline at end of file diff --git a/scripts/__dropins__/storefront-checkout/signals/index.d.ts b/scripts/__dropins__/storefront-checkout/signals/index.d.ts index a69bad694f..13ba0ea9ee 100644 --- a/scripts/__dropins__/storefront-checkout/signals/index.d.ts +++ b/scripts/__dropins__/storefront-checkout/signals/index.d.ts @@ -18,6 +18,7 @@ export * from './CartSignal'; export * from './CustomerSignal'; export * from './EstimateShippingMethodsSignal'; export * from './IsBillToShippingSignal'; +export * from './SelectedPaymentMethodSignal'; export * from './SelectedShippingMethodSignal'; export * from './ServerErrorSignal'; export * from './StoreConfigSignal'; diff --git a/scripts/__dropins__/storefront-order/api.js b/scripts/__dropins__/storefront-order/api.js index 6de3ff0c18..955e04c737 100644 --- a/scripts/__dropins__/storefront-order/api.js +++ b/scripts/__dropins__/storefront-order/api.js @@ -1,6 +1,6 @@ /*! Copyright 2024 Adobe All Rights Reserved. */ -import{c as q,r as X}from"./chunks/requestGuestOrderCancel.js";import{f as E,h as _}from"./chunks/fetch-graphql.js";import{g as Y,r as z,s as j,a as J,b as K}from"./chunks/fetch-graphql.js";import{g as Z}from"./chunks/getAttributesForm.js";import{g as te,a as re,r as ae}from"./chunks/requestGuestReturn.js";import{g as ne,a as se}from"./chunks/getGuestOrder.js";import{g as pe}from"./chunks/getCustomerOrdersReturn.js";import{c as T,P as R,a as A,G as D,O as g,B as O,b as h,A as C}from"./chunks/initialize.js";import{e as ue,g as de,d as le,i as me}from"./chunks/initialize.js";import{g as _e}from"./chunks/getStoreConfig.js";import{h as f}from"./chunks/network-error.js";import{events as u}from"@dropins/tools/event-bus.js";import{a as Re,c as Ae,r as De}from"./chunks/confirmCancelOrder.js";import"./chunks/GurestOrderFragment.graphql.js";import"@dropins/tools/fetch-graphql.js";import"./chunks/transform-attributes-form.js";import"./chunks/RequestReturnOrderFragment.graphql.js";import"@dropins/tools/lib.js";const G=(t,r)=>({id:t,totalQuantity:r.totalQuantity,possibleOnepageCheckout:!0,items:r.items.map(e=>{var a,o,n,s,i,p;return{canApplyMsrp:!0,formattedPrice:"",id:e.id,quantity:e.totalQuantity,product:{canonicalUrl:((a=e.product)==null?void 0:a.canonicalUrl)??"",mainImageUrl:((o=e.product)==null?void 0:o.image)??"",name:((n=e.product)==null?void 0:n.name)??"",productId:0,productType:(s=e.product)==null?void 0:s.productType,sku:((i=e.product)==null?void 0:i.sku)??""},prices:{price:{value:e.price.value,currency:e.price.currency}},configurableOptions:((p=e.selectedOptions)==null?void 0:p.map(c=>({optionLabel:c.label,valueLabel:c.value})))||[]}})}),M=t=>{var a,o,n;const r=t.coupons[0],e=(a=t.payments)==null?void 0:a[0];return{appliedCouponCode:(r==null?void 0:r.code)??"",email:t.email,grandTotal:t.grandTotal.value,orderId:t.number,orderType:"checkout",otherTax:0,salesTax:t.totalTax.value,shipping:{shippingMethod:((o=t.shipping)==null?void 0:o.code)??"",shippingAmount:((n=t.shipping)==null?void 0:n.amount)??0},subtotalExcludingTax:t.subtotal.value,subtotalIncludingTax:0,payments:e?[{paymentMethodCode:(e==null?void 0:e.code)||"",paymentMethodName:(e==null?void 0:e.name)||"",total:t.grandTotal.value}]:[]}},N=t=>{var e,a;const r=(a=(e=t==null?void 0:t.data)==null?void 0:e.placeOrder)==null?void 0:a.orderV2;return r?T(r):null},d={SHOPPING_CART_CONTEXT:"shoppingCartContext",ORDER_CONTEXT:"orderContext"},b={PLACE_ORDER:"place-order"};function m(){return window.adobeDataLayer=window.adobeDataLayer||[],window.adobeDataLayer}function l(t,r){const e=m();e.push({[t]:null}),e.push({[t]:r})}function I(t,r){m().push(a=>{const o=a.getState?a.getState():{};a.push({event:t,eventInfo:{...o,...r}})})}function L(t,r){const e=M(r),a=G(t,r);l(d.ORDER_CONTEXT,{...e}),l(d.SHOPPING_CART_CONTEXT,{...a}),I(b.PLACE_ORDER)}const S=` +import{c as H,r as q}from"./chunks/requestGuestOrderCancel.js";import{f as E,h as _}from"./chunks/fetch-graphql.js";import{g as V,r as Y,s as z,a as j,b as J}from"./chunks/fetch-graphql.js";import{g as W}from"./chunks/getAttributesForm.js";import{g as ee,a as te,r as re}from"./chunks/requestGuestReturn.js";import{g as oe,a as ne}from"./chunks/getGuestOrder.js";import{g as ie}from"./chunks/getCustomerOrdersReturn.js";import{a as T}from"./chunks/initialize.js";import{c as ce,g as ue,b as de,i as le}from"./chunks/initialize.js";import{g as Ee}from"./chunks/getStoreConfig.js";import{h as R}from"./chunks/network-error.js";import{events as u}from"@dropins/tools/event-bus.js";import{PRODUCT_DETAILS_FRAGMENT as D,PRICE_DETAILS_FRAGMENT as A,GIFT_CARD_DETAILS_FRAGMENT as g,ORDER_ITEM_DETAILS_FRAGMENT as O,BUNDLE_ORDER_ITEM_DETAILS_FRAGMENT as h,ORDER_SUMMARY_FRAGMENT as f,ADDRESS_FRAGMENT as C}from"./fragments.js";import{a as Te,c as Re,r as De}from"./chunks/confirmCancelOrder.js";import"@dropins/tools/fetch-graphql.js";import"./chunks/transform-attributes-form.js";import"@dropins/tools/lib.js";const G=(t,r)=>({id:t,totalQuantity:r.totalQuantity,possibleOnepageCheckout:!0,items:r.items.map(e=>{var a,o,n,s,i,p;return{canApplyMsrp:!0,formattedPrice:"",id:e.id,quantity:e.totalQuantity,product:{canonicalUrl:((a=e.product)==null?void 0:a.canonicalUrl)??"",mainImageUrl:((o=e.product)==null?void 0:o.image)??"",name:((n=e.product)==null?void 0:n.name)??"",productId:0,productType:(s=e.product)==null?void 0:s.productType,sku:((i=e.product)==null?void 0:i.sku)??""},prices:{price:{value:e.price.value,currency:e.price.currency}},configurableOptions:((p=e.selectedOptions)==null?void 0:p.map(c=>({optionLabel:c.label,valueLabel:c.value})))||[]}})}),M=t=>{var a,o,n;const r=t.coupons[0],e=(a=t.payments)==null?void 0:a[0];return{appliedCouponCode:(r==null?void 0:r.code)??"",email:t.email,grandTotal:t.grandTotal.value,orderId:t.number,orderType:"checkout",otherTax:0,salesTax:t.totalTax.value,shipping:{shippingMethod:((o=t.shipping)==null?void 0:o.code)??"",shippingAmount:((n=t.shipping)==null?void 0:n.amount)??0},subtotalExcludingTax:t.subtotal.value,subtotalIncludingTax:0,payments:e?[{paymentMethodCode:(e==null?void 0:e.code)||"",paymentMethodName:(e==null?void 0:e.name)||"",total:t.grandTotal.value}]:[]}},N=t=>{var e,a;const r=(a=(e=t==null?void 0:t.data)==null?void 0:e.placeOrder)==null?void 0:a.orderV2;return r?T(r):null},d={SHOPPING_CART_CONTEXT:"shoppingCartContext",ORDER_CONTEXT:"orderContext"},b={PLACE_ORDER:"place-order"};function m(){return window.adobeDataLayer=window.adobeDataLayer||[],window.adobeDataLayer}function l(t,r){const e=m();e.push({[t]:null}),e.push({[t]:r})}function I(t,r){m().push(a=>{const o=a.getState?a.getState():{};a.push({event:t,eventInfo:{...o,...r}})})}function L(t,r){const e=M(r),a=G(t,r);l(d.ORDER_CONTEXT,{...e}),l(d.SHOPPING_CART_CONTEXT,{...a}),I(b.PLACE_ORDER)}const S=` mutation PLACE_ORDER_MUTATION($cartId: String!) { placeOrder(input: { cart_id: $cartId }) { errors { @@ -82,11 +82,11 @@ import{c as q,r as X}from"./chunks/requestGuestOrderCancel.js";import{f as E,h a } } } - ${R} - ${A} ${D} + ${A} ${g} ${O} ${h} + ${f} ${C} -`,Q=async t=>{if(!t)throw new Error("No cart ID found");return E(S,{variables:{cartId:t}}).then(r=>{var a;(a=r.errors)!=null&&a.length&&_(r.errors);const e=N(r);return e&&(u.emit("order/placed",e),u.emit("cart/reset",void 0),L(t,e)),e}).catch(f)};export{q as cancelOrder,ue as config,Re as confirmCancelOrder,Ae as confirmGuestReturn,E as fetchGraphQl,Z as getAttributesForm,te as getAttributesList,Y as getConfig,ne as getCustomer,pe as getCustomerOrdersReturn,se as getGuestOrder,de as getOrderDetailsById,_e as getStoreConfig,le as guestOrderByToken,me as initialize,Q as placeOrder,z as removeFetchGraphQlHeader,De as reorderItems,X as requestGuestOrderCancel,re as requestGuestReturn,ae as requestReturn,j as setEndpoint,J as setFetchGraphQlHeader,K as setFetchGraphQlHeaders}; +`,k=async t=>{if(!t)throw new Error("No cart ID found");return E(S,{variables:{cartId:t}}).then(r=>{var a;(a=r.errors)!=null&&a.length&&_(r.errors);const e=N(r);return e&&(u.emit("order/placed",e),u.emit("cart/reset",void 0),L(t,e)),e}).catch(R)};export{H as cancelOrder,ce as config,Te as confirmCancelOrder,Re as confirmGuestReturn,E as fetchGraphQl,W as getAttributesForm,ee as getAttributesList,V as getConfig,oe as getCustomer,ie as getCustomerOrdersReturn,ne as getGuestOrder,ue as getOrderDetailsById,Ee as getStoreConfig,de as guestOrderByToken,le as initialize,k as placeOrder,Y as removeFetchGraphQlHeader,De as reorderItems,q as requestGuestOrderCancel,te as requestGuestReturn,re as requestReturn,z as setEndpoint,j as setFetchGraphQlHeader,J as setFetchGraphQlHeaders}; diff --git a/scripts/__dropins__/storefront-order/api/fragment.d.ts b/scripts/__dropins__/storefront-order/api/fragments.d.ts similarity index 93% rename from scripts/__dropins__/storefront-order/api/fragment.d.ts rename to scripts/__dropins__/storefront-order/api/fragments.d.ts index 9275ced8a6..3901508e5b 100644 --- a/scripts/__dropins__/storefront-order/api/fragment.d.ts +++ b/scripts/__dropins__/storefront-order/api/fragments.d.ts @@ -4,4 +4,4 @@ export { PRODUCT_DETAILS_FRAGMENT, PRICE_DETAILS_FRAGMENT, GIFT_CARD_DETAILS_FRA export { ORDER_SUMMARY_FRAGMENT } from './graphql/OrderSummaryFragment.graphql'; export { RETURNS_FRAGMENT } from './graphql/ReturnsFragment.graphql'; export { GUEST_ORDER_FRAGMENT } from './graphql/GurestOrderFragment.graphql'; -//# sourceMappingURL=fragment.d.ts.map \ No newline at end of file +//# sourceMappingURL=fragments.d.ts.map \ No newline at end of file diff --git a/scripts/__dropins__/storefront-order/chunks/GurestOrderFragment.graphql.js b/scripts/__dropins__/storefront-order/chunks/GurestOrderFragment.graphql.js deleted file mode 100644 index b3f1d975cb..0000000000 --- a/scripts/__dropins__/storefront-order/chunks/GurestOrderFragment.graphql.js +++ /dev/null @@ -1,99 +0,0 @@ -/*! Copyright 2024 Adobe -All Rights Reserved. */ -import{P as _,a as e,G as E,O as R,B as t,b as r,A as T,R as a}from"./initialize.js";const d=` - fragment GUEST_ORDER_FRAGMENT on CustomerOrder { - email - id - number - order_date - order_status_change_date - status - token - carrier - shipping_method - printed_card_included - gift_receipt_included - available_actions - is_virtual - items_eligible_for_return { - ...ORDER_ITEM_DETAILS_FRAGMENT - } - returns { - ...RETURNS_FRAGMENT - } - payment_methods { - name - type - } - applied_coupons { - code - } - shipments { - id - tracking { - title - number - carrier - } - comments { - message - timestamp - } - items { - __typename - id - product_sku - product_name - order_item { - ...ORDER_ITEM_DETAILS_FRAGMENT - ... on GiftCardOrderItem { - ...GIFT_CARD_DETAILS_FRAGMENT - product { - ...PRODUCT_DETAILS_FRAGMENT - } - } - } - } - } - payment_methods { - name - type - } - shipping_address { - ...ADDRESS_FRAGMENT - } - billing_address { - ...ADDRESS_FRAGMENT - } - items { - ...ORDER_ITEM_DETAILS_FRAGMENT - ... on BundleOrderItem { - ...BUNDLE_ORDER_ITEM_DETAILS_FRAGMENT - } - ... on GiftCardOrderItem { - ...GIFT_CARD_DETAILS_FRAGMENT - product { - ...PRODUCT_DETAILS_FRAGMENT - } - } - ... on DownloadableOrderItem { - product_name - downloadable_links { - sort_order - title - } - } - } - total { - ...ORDER_SUMMARY_FRAGMENT - } - } - ${_} - ${e} - ${E} - ${R} - ${t} - ${r} - ${T} - ${a} -`;export{d as G}; diff --git a/scripts/__dropins__/storefront-order/chunks/RequestReturnOrderFragment.graphql.js b/scripts/__dropins__/storefront-order/chunks/RequestReturnOrderFragment.graphql.js deleted file mode 100644 index fbf77e337f..0000000000 --- a/scripts/__dropins__/storefront-order/chunks/RequestReturnOrderFragment.graphql.js +++ /dev/null @@ -1,11 +0,0 @@ -/*! Copyright 2024 Adobe -All Rights Reserved. */ -const R=` - fragment REQUEST_RETURN_ORDER_FRAGMENT on Return { - __typename - uid - status - number - created_at - } -`;export{R}; diff --git a/scripts/__dropins__/storefront-order/chunks/confirmCancelOrder.js b/scripts/__dropins__/storefront-order/chunks/confirmCancelOrder.js index 0c05980aae..dce1a5dfeb 100644 --- a/scripts/__dropins__/storefront-order/chunks/confirmCancelOrder.js +++ b/scripts/__dropins__/storefront-order/chunks/confirmCancelOrder.js @@ -1,6 +1,6 @@ /*! Copyright 2024 Adobe All Rights Reserved. */ -import{h as d}from"./network-error.js";import{f as u,h as _}from"./fetch-graphql.js";import{R as I}from"./RequestReturnOrderFragment.graphql.js";import{G as a}from"./GurestOrderFragment.graphql.js";import{c as O}from"./initialize.js";import{events as T}from"@dropins/tools/event-bus.js";const N=` +import{h as f}from"./network-error.js";import{f as u,h as _}from"./fetch-graphql.js";import{REQUEST_RETURN_ORDER_FRAGMENT as I,GUEST_ORDER_FRAGMENT as O}from"../fragments.js";import{a}from"./initialize.js";import{events as T}from"@dropins/tools/event-bus.js";const N=` mutation REORDER_ITEMS_MUTATION($orderNumber: String!) { reorderItems(orderNumber: $orderNumber) { cart { @@ -17,7 +17,7 @@ import{h as d}from"./network-error.js";import{f as u,h as _}from"./fetch-graphql } } } -`,$=async E=>await u(N,{method:"POST",variables:{orderNumber:E}}).then(t=>{var n,o,i,c,m,R;if((n=t.errors)!=null&&n.length)return _(t.errors);const e=!!((c=(i=(o=t==null?void 0:t.data)==null?void 0:o.reorderItems)==null?void 0:i.cart)!=null&&c.itemsV2.items.length),r=((R=(m=t==null?void 0:t.data)==null?void 0:m.reorderItems)==null?void 0:R.userInputErrors)??[];return{success:e,userInputErrors:r}}).catch(d),l=` +`,$=async E=>await u(N,{method:"POST",variables:{orderNumber:E}}).then(t=>{var n,o,i,c,m,R;if((n=t.errors)!=null&&n.length)return _(t.errors);const e=!!((c=(i=(o=t==null?void 0:t.data)==null?void 0:o.reorderItems)==null?void 0:i.cart)!=null&&c.itemsV2.items.length),r=((R=(m=t==null?void 0:t.data)==null?void 0:m.reorderItems)==null?void 0:R.userInputErrors)??[];return{success:e,userInputErrors:r}}).catch(f),l=` mutation CONFIRM_RETURN_GUEST_ORDER( $orderId: ID! $confirmationKey: String! @@ -34,8 +34,8 @@ import{h as d}from"./network-error.js";import{f as u,h as _}from"./fetch-graphql } } ${I} - ${a} -`,s=async(E,t)=>await u(l,{method:"POST",variables:{orderId:E,confirmationKey:t}}).then(e=>{var r,n,o,i,c,m,R;if((r=e.errors)!=null&&r.length)return _(e.errors);if((i=(o=(n=e==null?void 0:e.data)==null?void 0:n.confirmReturn)==null?void 0:o.return)!=null&&i.order){const f=O((R=(m=(c=e==null?void 0:e.data)==null?void 0:c.confirmReturn)==null?void 0:m.return)==null?void 0:R.order);return T.emit("order/data",f),f}return null}).catch(d),h=` + ${O} +`,G=async(E,t)=>await u(l,{method:"POST",variables:{orderId:E,confirmationKey:t}}).then(e=>{var r,n,o,i,c,m,R;if((r=e.errors)!=null&&r.length)return _(e.errors);if((i=(o=(n=e==null?void 0:e.data)==null?void 0:n.confirmReturn)==null?void 0:o.return)!=null&&i.order){const d=a((R=(m=(c=e==null?void 0:e.data)==null?void 0:c.confirmReturn)==null?void 0:m.return)==null?void 0:R.order);return T.emit("order/data",d),d}return null}).catch(f),h=` mutation CONFIRM_CANCEL_ORDER_MUTATION( $orderId: ID! $confirmationKey: String! @@ -52,5 +52,5 @@ import{h as d}from"./network-error.js";import{f as u,h as _}from"./fetch-graphql } } } - ${a} -`,y=async(E,t)=>u(h,{variables:{orderId:E,confirmationKey:t}}).then(async({errors:e,data:r})=>{var i,c,m,R;const n=[...(i=r==null?void 0:r.confirmCancelOrder)!=null&&i.errorV2?[(c=r==null?void 0:r.confirmCancelOrder)==null?void 0:c.errorV2]:[],...e??[]];let o=null;return(m=r==null?void 0:r.confirmCancelOrder)!=null&&m.order&&(o=O((R=r==null?void 0:r.confirmCancelOrder)==null?void 0:R.order),T.emit("order/data",o)),n.length>0?_(n):o});export{y as a,s as c,$ as r}; + ${O} +`,y=async(E,t)=>u(h,{variables:{orderId:E,confirmationKey:t}}).then(async({errors:e,data:r})=>{var i,c,m,R;const n=[...(i=r==null?void 0:r.confirmCancelOrder)!=null&&i.errorV2?[(c=r==null?void 0:r.confirmCancelOrder)==null?void 0:c.errorV2]:[],...e??[]];let o=null;return(m=r==null?void 0:r.confirmCancelOrder)!=null&&m.order&&(o=a((R=r==null?void 0:r.confirmCancelOrder)==null?void 0:R.order),T.emit("order/data",o)),n.length>0?_(n):o});export{y as a,G as c,$ as r}; diff --git a/scripts/__dropins__/storefront-order/chunks/getCustomerOrdersReturn.js b/scripts/__dropins__/storefront-order/chunks/getCustomerOrdersReturn.js index 2d67bd0baf..6117fe0a7b 100644 --- a/scripts/__dropins__/storefront-order/chunks/getCustomerOrdersReturn.js +++ b/scripts/__dropins__/storefront-order/chunks/getCustomerOrdersReturn.js @@ -1,6 +1,6 @@ /*! Copyright 2024 Adobe All Rights Reserved. */ -import{h as R}from"./network-error.js";import{R as E,P as T,a as _,G as c,O as s,t as o}from"./initialize.js";import{f as n}from"./fetch-graphql.js";const u=` +import{h as R}from"./network-error.js";import{RETURNS_FRAGMENT as E,PRODUCT_DETAILS_FRAGMENT as T,PRICE_DETAILS_FRAGMENT as _,GIFT_CARD_DETAILS_FRAGMENT as o,ORDER_ITEM_DETAILS_FRAGMENT as c}from"../fragments.js";import{t as n}from"./initialize.js";import{f as u}from"./fetch-graphql.js";const m=` query GET_CUSTOMER_ORDERS_RETURN($currentPage: Int, $pageSize: Int) { customer { returns(currentPage: $currentPage, pageSize: $pageSize) { @@ -16,6 +16,6 @@ import{h as R}from"./network-error.js";import{R as E,P as T,a as _,G as c,O as s ${E} ${T} ${_} + ${o} ${c} - ${s} -`,G=async(e=10,t=1)=>await n(u,{method:"GET",cache:"force-cache",variables:{pageSize:e,currentPage:t}}).then(r=>{var a;return o((a=r==null?void 0:r.data)==null?void 0:a.customer.returns)}).catch(R);export{G as g}; +`,A=async(e=10,a=1)=>await u(m,{method:"GET",cache:"force-cache",variables:{pageSize:e,currentPage:a}}).then(r=>{var t;return n((t=r==null?void 0:r.data)==null?void 0:t.customer.returns)}).catch(R);export{A as g}; diff --git a/scripts/__dropins__/storefront-order/chunks/getGuestOrder.js b/scripts/__dropins__/storefront-order/chunks/getGuestOrder.js index d7d2442923..bb37f3d188 100644 --- a/scripts/__dropins__/storefront-order/chunks/getGuestOrder.js +++ b/scripts/__dropins__/storefront-order/chunks/getGuestOrder.js @@ -1,6 +1,6 @@ /*! Copyright 2024 Adobe All Rights Reserved. */ -import{h as E}from"./network-error.js";import{f as i,h}from"./fetch-graphql.js";import{G as n}from"./GurestOrderFragment.graphql.js";import{f as o}from"./initialize.js";const G=t=>{var a,r,m,c,u,e;return{email:((r=(a=t==null?void 0:t.data)==null?void 0:a.customer)==null?void 0:r.email)||"",firstname:((c=(m=t==null?void 0:t.data)==null?void 0:m.customer)==null?void 0:c.firstname)||"",lastname:((e=(u=t==null?void 0:t.data)==null?void 0:u.customer)==null?void 0:e.lastname)||""}},f=` +import{h as E}from"./network-error.js";import{f as i,h}from"./fetch-graphql.js";import{GUEST_ORDER_FRAGMENT as n}from"../fragments.js";import{d as o}from"./initialize.js";const G=t=>{var a,r,m,c,u,e;return{email:((r=(a=t==null?void 0:t.data)==null?void 0:a.customer)==null?void 0:r.email)||"",firstname:((c=(m=t==null?void 0:t.data)==null?void 0:m.customer)==null?void 0:c.firstname)||"",lastname:((e=(u=t==null?void 0:t.data)==null?void 0:u.customer)==null?void 0:e.lastname)||""}},f=` query GET_CUSTOMER { customer { firstname diff --git a/scripts/__dropins__/storefront-order/chunks/initialize.js b/scripts/__dropins__/storefront-order/chunks/initialize.js index ed56d3ced3..e91beacc46 100644 --- a/scripts/__dropins__/storefront-order/chunks/initialize.js +++ b/scripts/__dropins__/storefront-order/chunks/initialize.js @@ -1,205 +1,6 @@ /*! Copyright 2024 Adobe All Rights Reserved. */ -import{merge as z,Initializer as na}from"@dropins/tools/lib.js";import{events as q}from"@dropins/tools/event-bus.js";import{a as ta,h as Y}from"./network-error.js";import{f as Q}from"./fetch-graphql.js";const K=` - fragment ADDRESS_FRAGMENT on OrderAddress { - city - company - country_code - fax - firstname - lastname - middlename - postcode - prefix - region - region_id - street - suffix - telephone - vat_id - } -`,j=` - fragment PRODUCT_DETAILS_FRAGMENT on ProductInterface { - __typename - canonical_url - url_key - uid - name - sku - only_x_left_in_stock - stock_status - thumbnail { - label - url - } - price_range { - maximum_price { - regular_price { - currency - value - } - } - } - } -`,H=` - fragment PRICE_DETAILS_FRAGMENT on OrderItemInterface { - prices { - price_including_tax { - value - currency - } - original_price { - value - currency - } - original_price_including_tax { - value - currency - } - price { - value - currency - } - } - } -`,J=` - fragment GIFT_CARD_DETAILS_FRAGMENT on GiftCardOrderItem { - ...PRICE_DETAILS_FRAGMENT - gift_message { - message - } - gift_card { - recipient_name - recipient_email - sender_name - sender_email - message - } - } -`,V=` - fragment ORDER_ITEM_DETAILS_FRAGMENT on OrderItemInterface { - __typename - status - product_sku - eligible_for_return - product_name - product_url_key - id - quantity_ordered - quantity_shipped - quantity_canceled - quantity_invoiced - quantity_refunded - quantity_return_requested - product_sale_price { - value - currency - } - selected_options { - label - value - } - product { - ...PRODUCT_DETAILS_FRAGMENT - } - ...PRICE_DETAILS_FRAGMENT - } -`,W=` - fragment BUNDLE_ORDER_ITEM_DETAILS_FRAGMENT on BundleOrderItem { - ...PRICE_DETAILS_FRAGMENT - bundle_options { - uid - label - values { - uid - product_name - } - } - } -`,X=` - fragment ORDER_SUMMARY_FRAGMENT on OrderTotal { - grand_total { - value - currency - } - total_giftcard { - currency - value - } - subtotal_excl_tax { - currency - value - } - subtotal_incl_tax { - currency - value - } - taxes { - amount { - currency - value - } - rate - title - } - total_tax { - currency - value - } - total_shipping { - currency - value - } - discounts { - amount { - currency - value - } - label - } - } -`,Z=` - fragment RETURNS_FRAGMENT on Returns { - __typename - items { - number - status - created_at - shipping { - tracking { - status { - text - type - } - carrier { - uid - label - } - tracking_number - } - } - order { - number - token - } - items { - uid - quantity - status - request_quantity - order_item { - ...ORDER_ITEM_DETAILS_FRAGMENT - ... on GiftCardOrderItem { - ...GIFT_CARD_DETAILS_FRAGMENT - product { - ...PRODUCT_DETAILS_FRAGMENT - } - } - } - } - } - } -`,_a=a=>a||0,ua=a=>{var n,t,_;return{...a,canonicalUrl:(a==null?void 0:a.canonical_url)||"",urlKey:(a==null?void 0:a.url_key)||"",id:(a==null?void 0:a.uid)||"",name:(a==null?void 0:a.name)||"",sku:(a==null?void 0:a.sku)||"",image:((n=a==null?void 0:a.image)==null?void 0:n.url)||"",productType:(a==null?void 0:a.__typename)||"",thumbnail:{label:((t=a==null?void 0:a.thumbnail)==null?void 0:t.label)||"",url:((_=a==null?void 0:a.thumbnail)==null?void 0:_.url)||""}}},ea=a=>{if(!a||!("selected_options"in a))return;const n={};for(const t of a.selected_options)n[t.label]=t.value;return n},ia=a=>{const n=a==null?void 0:a.map(_=>({uid:_.uid,label:_.label,values:_.values.map(e=>e.product_name).join(", ")})),t={};return n==null||n.forEach(_=>{t[_.label]=_.values}),Object.keys(t).length>0?t:null},sa=a=>(a==null?void 0:a.length)>0?{count:a.length,result:a.map(n=>n.title).join(", ")}:null,la=a=>({quantityCanceled:(a==null?void 0:a.quantity_canceled)??0,quantityInvoiced:(a==null?void 0:a.quantity_invoiced)??0,quantityOrdered:(a==null?void 0:a.quantity_ordered)??0,quantityRefunded:(a==null?void 0:a.quantity_refunded)??0,quantityReturned:(a==null?void 0:a.quantity_returned)??0,quantityShipped:(a==null?void 0:a.quantity_shipped)??0,quantityReturnRequested:(a==null?void 0:a.quantity_return_requested)??0}),I=a=>a==null?void 0:a.filter(n=>n.__typename).map(n=>{var E,c,r,O,d,g,N,M,A,D,u,y,T,p,S,o,f,G,h,F,C,L,k,U,B,$,P,x,m,w;const{quantityCanceled:t,quantityInvoiced:_,quantityOrdered:e,quantityRefunded:i,quantityReturned:s,quantityShipped:l,quantityReturnRequested:R}=la(n);return{type:n==null?void 0:n.__typename,eligibleForReturn:n==null?void 0:n.eligible_for_return,productSku:n==null?void 0:n.product_sku,productName:n.product_name,productUrlKey:n.product_url_key,quantityCanceled:t,quantityInvoiced:_,quantityOrdered:e,quantityRefunded:i,quantityReturned:s,quantityShipped:l,quantityReturnRequested:R,id:n==null?void 0:n.id,discounted:((O=(r=(c=(E=n==null?void 0:n.product)==null?void 0:E.price_range)==null?void 0:c.maximum_price)==null?void 0:r.regular_price)==null?void 0:O.value)*(n==null?void 0:n.quantity_ordered)!==((d=n==null?void 0:n.product_sale_price)==null?void 0:d.value)*(n==null?void 0:n.quantity_ordered),total:{value:((g=n==null?void 0:n.product_sale_price)==null?void 0:g.value)*(n==null?void 0:n.quantity_ordered)||0,currency:((N=n==null?void 0:n.product_sale_price)==null?void 0:N.currency)||""},totalInclTax:{value:((M=n==null?void 0:n.product_sale_price)==null?void 0:M.value)*(n==null?void 0:n.quantity_ordered)||0,currency:(A=n==null?void 0:n.product_sale_price)==null?void 0:A.currency},price:{value:((D=n==null?void 0:n.product_sale_price)==null?void 0:D.value)||0,currency:(u=n==null?void 0:n.product_sale_price)==null?void 0:u.currency},priceInclTax:{value:((y=n==null?void 0:n.product_sale_price)==null?void 0:y.value)||0,currency:(T=n==null?void 0:n.product_sale_price)==null?void 0:T.currency},totalQuantity:_a(n==null?void 0:n.quantity_ordered),regularPrice:{value:(f=(o=(S=(p=n==null?void 0:n.product)==null?void 0:p.price_range)==null?void 0:S.maximum_price)==null?void 0:o.regular_price)==null?void 0:f.value,currency:(C=(F=(h=(G=n==null?void 0:n.product)==null?void 0:G.price_range)==null?void 0:h.maximum_price)==null?void 0:F.regular_price)==null?void 0:C.currency},product:ua(n==null?void 0:n.product),thumbnail:{label:((k=(L=n==null?void 0:n.product)==null?void 0:L.thumbnail)==null?void 0:k.label)||"",url:((B=(U=n==null?void 0:n.product)==null?void 0:U.thumbnail)==null?void 0:B.url)||""},giftCard:(n==null?void 0:n.__typename)==="GiftCardOrderItem"?{senderName:(($=n.gift_card)==null?void 0:$.sender_name)||"",senderEmail:((P=n.gift_card)==null?void 0:P.sender_email)||"",recipientEmail:((x=n.gift_card)==null?void 0:x.recipient_email)||"",recipientName:((m=n.gift_card)==null?void 0:m.recipient_name)||"",message:((w=n.gift_card)==null?void 0:w.message)||""}:void 0,configurableOptions:ea(n),bundleOptions:n.__typename==="BundleOrderItem"?ia(n.bundle_options):null,itemPrices:n.prices,downloadableLinks:n.__typename==="DownloadableOrderItem"?sa(n==null?void 0:n.downloadable_links):null}}),v=(a,n)=>{var O,d,g,N,M,A,D,u,y;const t=I(a.items),_=((O=ra(a==null?void 0:a.returns))==null?void 0:O.ordersReturn)??[],e=n?_.filter(T=>T.returnNumber===n):_,{total:i,...s}=ta({...a,items:t,returns:e},"camelCase",{applied_coupons:"coupons",__typename:"__typename",firstname:"firstName",middlename:"middleName",lastname:"lastName",postcode:"postCode",payment_methods:"payments"}),l=(d=a==null?void 0:a.payment_methods)==null?void 0:d[0],R=(l==null?void 0:l.type)||"",E=(l==null?void 0:l.name)||"",c=(g=s==null?void 0:s.items)==null?void 0:g.reduce((T,p)=>T+(p==null?void 0:p.totalQuantity),0),r={...i,...s,totalQuantity:c,shipping:{amount:((N=i==null?void 0:i.totalShipping)==null?void 0:N.value)??0,currency:((M=i==null?void 0:i.totalShipping)==null?void 0:M.currency)||"",code:s.shippingMethod??""},payments:[{code:R,name:E}]};return z(r,(y=(u=(D=(A=b==null?void 0:b.getConfig())==null?void 0:A.models)==null?void 0:D.OrderDataModel)==null?void 0:u.transformer)==null?void 0:y.call(u,a))},ca=(a,n,t)=>{var _,e,i,s,l,R,E;if((s=(i=(e=(_=n==null?void 0:n.data)==null?void 0:_.customer)==null?void 0:e.orders)==null?void 0:i.items)!=null&&s.length&&a==="orderData"){const c=(E=(R=(l=n==null?void 0:n.data)==null?void 0:l.customer)==null?void 0:R.orders)==null?void 0:E.items[0];return v(c,t)}return null},ra=a=>{var i,s,l,R,E;if(!((i=a==null?void 0:a.items)!=null&&i.length))return null;const n=a==null?void 0:a.items,t=a==null?void 0:a.page_info,e={ordersReturn:[...n].sort((c,r)=>+r.number-+c.number).map(c=>{var A,D;const{order:r,status:O,number:d,created_at:g}=c,N=((D=(A=c==null?void 0:c.shipping)==null?void 0:A.tracking)==null?void 0:D.map(u=>{const{status:y,carrier:T,tracking_number:p}=u;return{status:y,carrier:T,trackingNumber:p}}))??[],M=c.items.map(u=>{var G;const y=u==null?void 0:u.quantity,T=u==null?void 0:u.status,p=u==null?void 0:u.request_quantity,S=u==null?void 0:u.uid,o=u==null?void 0:u.order_item,f=((G=I([o]))==null?void 0:G.reduce((h,F)=>F,{}))??{};return{uid:S,quantity:y,status:T,requestQuantity:p,...f}});return{createdReturnAt:g,returnStatus:O,token:r==null?void 0:r.token,orderNumber:r==null?void 0:r.number,returnNumber:d,items:M,tracking:N}}),...t?{pageInfo:{pageSize:t.page_size,totalPages:t.total_pages,currentPage:t.current_page}}:{}};return z(e,(E=(R=(l=(s=b==null?void 0:b.getConfig())==null?void 0:s.models)==null?void 0:l.CustomerOrdersReturnModel)==null?void 0:R.transformer)==null?void 0:E.call(R,{...n,...t}))},Ma=(a,n)=>{var _,e;if(!((_=a==null?void 0:a.data)!=null&&_.guestOrder))return null;const t=(e=a==null?void 0:a.data)==null?void 0:e.guestOrder;return v(t,n)},Ra=(a,n)=>{var _,e;if(!((_=a==null?void 0:a.data)!=null&&_.guestOrderByToken))return null;const t=(e=a==null?void 0:a.data)==null?void 0:e.guestOrderByToken;return v(t,n)},Ea=` +import{merge as K,Initializer as na}from"@dropins/tools/lib.js";import{events as v}from"@dropins/tools/event-bus.js";import{a as ta,h as Q}from"./network-error.js";import{PRODUCT_DETAILS_FRAGMENT as x,PRICE_DETAILS_FRAGMENT as j,GIFT_CARD_DETAILS_FRAGMENT as H,ORDER_ITEM_DETAILS_FRAGMENT as J,BUNDLE_ORDER_ITEM_DETAILS_FRAGMENT as V,ORDER_SUMMARY_FRAGMENT as W,ADDRESS_FRAGMENT as X,RETURNS_FRAGMENT as Z}from"../fragments.js";import{f as m}from"./fetch-graphql.js";const _a=a=>a||0,ua=a=>{var n,t,_;return{...a,canonicalUrl:(a==null?void 0:a.canonical_url)||"",urlKey:(a==null?void 0:a.url_key)||"",id:(a==null?void 0:a.uid)||"",name:(a==null?void 0:a.name)||"",sku:(a==null?void 0:a.sku)||"",image:((n=a==null?void 0:a.image)==null?void 0:n.url)||"",productType:(a==null?void 0:a.__typename)||"",thumbnail:{label:((t=a==null?void 0:a.thumbnail)==null?void 0:t.label)||"",url:((_=a==null?void 0:a.thumbnail)==null?void 0:_.url)||""}}},ia=a=>{if(!a||!("selected_options"in a))return;const n={};for(const t of a.selected_options)n[t.label]=t.value;return n},sa=a=>{const n=a==null?void 0:a.map(_=>({uid:_.uid,label:_.label,values:_.values.map(i=>i.product_name).join(", ")})),t={};return n==null||n.forEach(_=>{t[_.label]=_.values}),Object.keys(t).length>0?t:null},la=a=>(a==null?void 0:a.length)>0?{count:a.length,result:a.map(n=>n.title).join(", ")}:null,ea=a=>({quantityCanceled:(a==null?void 0:a.quantity_canceled)??0,quantityInvoiced:(a==null?void 0:a.quantity_invoiced)??0,quantityOrdered:(a==null?void 0:a.quantity_ordered)??0,quantityRefunded:(a==null?void 0:a.quantity_refunded)??0,quantityReturned:(a==null?void 0:a.quantity_returned)??0,quantityShipped:(a==null?void 0:a.quantity_shipped)??0,quantityReturnRequested:(a==null?void 0:a.quantity_return_requested)??0}),I=a=>a==null?void 0:a.filter(n=>n.__typename).map(n=>{var E,s,e,S,r,b,g,M,D,O,u,T,A,y,N,f,F,G,C,q,k,d,B,$,U,o,w,P,z,Y;const{quantityCanceled:t,quantityInvoiced:_,quantityOrdered:i,quantityRefunded:l,quantityReturned:c,quantityShipped:p,quantityReturnRequested:R}=ea(n);return{type:n==null?void 0:n.__typename,eligibleForReturn:n==null?void 0:n.eligible_for_return,productSku:n==null?void 0:n.product_sku,productName:n.product_name,productUrlKey:n.product_url_key,quantityCanceled:t,quantityInvoiced:_,quantityOrdered:i,quantityRefunded:l,quantityReturned:c,quantityShipped:p,quantityReturnRequested:R,id:n==null?void 0:n.id,discounted:((S=(e=(s=(E=n==null?void 0:n.product)==null?void 0:E.price_range)==null?void 0:s.maximum_price)==null?void 0:e.regular_price)==null?void 0:S.value)*(n==null?void 0:n.quantity_ordered)!==((r=n==null?void 0:n.product_sale_price)==null?void 0:r.value)*(n==null?void 0:n.quantity_ordered),total:{value:((b=n==null?void 0:n.product_sale_price)==null?void 0:b.value)*(n==null?void 0:n.quantity_ordered)||0,currency:((g=n==null?void 0:n.product_sale_price)==null?void 0:g.currency)||""},totalInclTax:{value:((M=n==null?void 0:n.product_sale_price)==null?void 0:M.value)*(n==null?void 0:n.quantity_ordered)||0,currency:(D=n==null?void 0:n.product_sale_price)==null?void 0:D.currency},price:{value:((O=n==null?void 0:n.product_sale_price)==null?void 0:O.value)||0,currency:(u=n==null?void 0:n.product_sale_price)==null?void 0:u.currency},priceInclTax:{value:((T=n==null?void 0:n.product_sale_price)==null?void 0:T.value)||0,currency:(A=n==null?void 0:n.product_sale_price)==null?void 0:A.currency},totalQuantity:_a(n==null?void 0:n.quantity_ordered),regularPrice:{value:(F=(f=(N=(y=n==null?void 0:n.product)==null?void 0:y.price_range)==null?void 0:N.maximum_price)==null?void 0:f.regular_price)==null?void 0:F.value,currency:(k=(q=(C=(G=n==null?void 0:n.product)==null?void 0:G.price_range)==null?void 0:C.maximum_price)==null?void 0:q.regular_price)==null?void 0:k.currency},product:ua(n==null?void 0:n.product),thumbnail:{label:((B=(d=n==null?void 0:n.product)==null?void 0:d.thumbnail)==null?void 0:B.label)||"",url:((U=($=n==null?void 0:n.product)==null?void 0:$.thumbnail)==null?void 0:U.url)||""},giftCard:(n==null?void 0:n.__typename)==="GiftCardOrderItem"?{senderName:((o=n.gift_card)==null?void 0:o.sender_name)||"",senderEmail:((w=n.gift_card)==null?void 0:w.sender_email)||"",recipientEmail:((P=n.gift_card)==null?void 0:P.recipient_email)||"",recipientName:((z=n.gift_card)==null?void 0:z.recipient_name)||"",message:((Y=n.gift_card)==null?void 0:Y.message)||""}:void 0,configurableOptions:ia(n),bundleOptions:n.__typename==="BundleOrderItem"?sa(n.bundle_options):null,itemPrices:n.prices,downloadableLinks:n.__typename==="DownloadableOrderItem"?la(n==null?void 0:n.downloadable_links):null}}),L=(a,n)=>{var r,b,g,M,D,O,u,T,A;const t=I(a.items),_=((r=Ra(a==null?void 0:a.returns))==null?void 0:r.ordersReturn)??[],i=n?_.filter(y=>y.returnNumber===n):_,l=(b=a==null?void 0:a.payment_methods)==null?void 0:b[0],c=(l==null?void 0:l.type)||"",p=(l==null?void 0:l.name)||"",R=(g=e==null?void 0:e.items)==null?void 0:g.reduce((y,N)=>y+(N==null?void 0:N.totalQuantity),0),E={...a,items:t,returns:i};console.log("convertKeysCaseConfig",E);const{total:s,...e}=ta(E,"camelCase",{applied_coupons:"coupons",__typename:"__typename",firstname:"firstName",middlename:"middleName",lastname:"lastName",postcode:"postCode",payment_methods:"payments"}),S={...s,...e,totalQuantity:R,shipping:{amount:((M=s==null?void 0:s.totalShipping)==null?void 0:M.value)??0,currency:((D=s==null?void 0:s.totalShipping)==null?void 0:D.currency)||"",code:e.shippingMethod??""},payments:[{code:c,name:p}]};return K(S,(A=(T=(u=(O=h==null?void 0:h.getConfig())==null?void 0:O.models)==null?void 0:u.OrderDataModel)==null?void 0:T.transformer)==null?void 0:A.call(T,a))},ca=(a,n,t)=>{var _,i,l,c,p,R,E;if((c=(l=(i=(_=n==null?void 0:n.data)==null?void 0:_.customer)==null?void 0:i.orders)==null?void 0:l.items)!=null&&c.length&&a==="orderData"){const s=(E=(R=(p=n==null?void 0:n.data)==null?void 0:p.customer)==null?void 0:R.orders)==null?void 0:E.items[0];return L(s,t)}return null},Ra=a=>{var l,c,p,R,E;if(!((l=a==null?void 0:a.items)!=null&&l.length))return null;const n=a==null?void 0:a.items,t=a==null?void 0:a.page_info,i={ordersReturn:[...n].sort((s,e)=>+e.number-+s.number).map(s=>{var D,O;const{order:e,status:S,number:r,created_at:b}=s,g=((O=(D=s==null?void 0:s.shipping)==null?void 0:D.tracking)==null?void 0:O.map(u=>{const{status:T,carrier:A,tracking_number:y}=u;return{status:T,carrier:A,trackingNumber:y}}))??[],M=s.items.map(u=>{var G;const T=u==null?void 0:u.quantity,A=u==null?void 0:u.status,y=u==null?void 0:u.request_quantity,N=u==null?void 0:u.uid,f=u==null?void 0:u.order_item,F=((G=I([f]))==null?void 0:G.reduce((C,q)=>q,{}))??{};return{uid:N,quantity:T,status:A,requestQuantity:y,...F}});return{createdReturnAt:b,returnStatus:S,token:e==null?void 0:e.token,orderNumber:e==null?void 0:e.number,returnNumber:r,items:M,tracking:g}}),...t?{pageInfo:{pageSize:t.page_size,totalPages:t.total_pages,currentPage:t.current_page}}:{}};return K(i,(E=(R=(p=(c=h==null?void 0:h.getConfig())==null?void 0:c.models)==null?void 0:p.CustomerOrdersReturnModel)==null?void 0:R.transformer)==null?void 0:E.call(R,{...n,...t}))},Sa=(a,n)=>{var _,i;if(!((_=a==null?void 0:a.data)!=null&&_.guestOrder))return null;const t=(i=a==null?void 0:a.data)==null?void 0:i.guestOrder;return L(t,n)},Ea=(a,n)=>{var _,i;if(!((_=a==null?void 0:a.data)!=null&&_.guestOrderByToken))return null;const t=(i=a==null?void 0:a.data)==null?void 0:i.guestOrderByToken;return L(t,n)},Ta=` query ORDER_BY_NUMBER($orderNumber: String!, $pageSize: Int) { customer { orders(filter: { number: { eq: $orderNumber } }) { @@ -303,15 +104,15 @@ import{merge as z,Initializer as na}from"@dropins/tools/lib.js";import{events as } } } + ${x} ${j} ${H} ${J} ${V} ${W} ${X} - ${K} ${Z} -`,Ta=async({orderId:a,returnRef:n,queryType:t,returnsPageSize:_=50})=>await Q(Ea,{method:"GET",cache:"force-cache",variables:{orderNumber:a,pageSize:_}}).then(e=>ca(t??"orderData",e,n)).catch(Y),pa=` +`,ya=async({orderId:a,returnRef:n,queryType:t,returnsPageSize:_=50})=>await m(Ta,{method:"GET",cache:"force-cache",variables:{orderNumber:a,pageSize:_}}).then(i=>ca(t??"orderData",i,n)).catch(Q),pa=` query ORDER_BY_TOKEN($token: String!) { guestOrderByToken(input: { token: $token }) { email @@ -400,12 +201,12 @@ import{merge as z,Initializer as na}from"@dropins/tools/lib.js";import{events as } } } + ${x} ${j} ${H} ${J} ${V} ${W} ${X} - ${K} ${Z} -`,ya=async(a,n)=>await Q(pa,{method:"GET",cache:"no-cache",variables:{token:a}}).then(t=>Ra(t,n)).catch(Y),Aa="orderData",Da=async a=>{var s;const n=typeof(a==null?void 0:a.orderRef)=="string"?a==null?void 0:a.orderRef:"",t=typeof(a==null?void 0:a.returnRef)=="string"?a==null?void 0:a.returnRef:"",_=n&&typeof(a==null?void 0:a.orderRef)=="string"&&((s=a==null?void 0:a.orderRef)==null?void 0:s.length)>20,e=(a==null?void 0:a.orderData)??null;if(e){q.emit("order/data",{...e,returnNumber:t});return}if(!n)return;const i=_?await ya(n,t):await Ta({orderId:n,returnRef:t,queryType:Aa});i?q.emit("order/data",{...i,returnNumber:t}):q.emit("order/error",{source:"order",type:"network",error:"The data was not received."})},aa=new na({init:async a=>{const n={};aa.config.setConfig({...n,...a}),Da(a).catch(console.error)},listeners:()=>[]}),b=aa.config;export{K as A,W as B,J as G,V as O,j as P,Z as R,H as a,X as b,v as c,ya as d,b as e,Ma as f,Ta as g,aa as i,ra as t}; +`,Aa=async(a,n)=>await m(pa,{method:"GET",cache:"no-cache",variables:{token:a}}).then(t=>Ea(t,n)).catch(Q),Da="orderData",Oa=async a=>{var c;const n=typeof(a==null?void 0:a.orderRef)=="string"?a==null?void 0:a.orderRef:"",t=typeof(a==null?void 0:a.returnRef)=="string"?a==null?void 0:a.returnRef:"",_=n&&typeof(a==null?void 0:a.orderRef)=="string"&&((c=a==null?void 0:a.orderRef)==null?void 0:c.length)>20,i=(a==null?void 0:a.orderData)??null;if(i){v.emit("order/data",{...i,returnNumber:t});return}if(!n)return;const l=_?await Aa(n,t):await ya({orderId:n,returnRef:t,queryType:Da});l?v.emit("order/data",{...l,returnNumber:t}):v.emit("order/error",{source:"order",type:"network",error:"The data was not received."})},aa=new na({init:async a=>{const n={};aa.config.setConfig({...n,...a}),Oa(a).catch(console.error)},listeners:()=>[]}),h=aa.config;export{L as a,Aa as b,h as c,Sa as d,ya as g,aa as i,Ra as t}; diff --git a/scripts/__dropins__/storefront-order/chunks/requestGuestOrderCancel.js b/scripts/__dropins__/storefront-order/chunks/requestGuestOrderCancel.js index f135fe1bcb..93660ac157 100644 --- a/scripts/__dropins__/storefront-order/chunks/requestGuestOrderCancel.js +++ b/scripts/__dropins__/storefront-order/chunks/requestGuestOrderCancel.js @@ -1,6 +1,6 @@ /*! Copyright 2024 Adobe All Rights Reserved. */ -import{P as T,a as d,G as i,O as A,B as D,b as c,A as u,c as E}from"./initialize.js";import{f as s,h as R}from"./fetch-graphql.js";import{G}from"./GurestOrderFragment.graphql.js";const O=` +import{PRODUCT_DETAILS_FRAGMENT as d,PRICE_DETAILS_FRAGMENT as s,GIFT_CARD_DETAILS_FRAGMENT as i,ORDER_ITEM_DETAILS_FRAGMENT as A,BUNDLE_ORDER_ITEM_DETAILS_FRAGMENT as D,ORDER_SUMMARY_FRAGMENT as c,ADDRESS_FRAGMENT as u,GUEST_ORDER_FRAGMENT as G}from"../fragments.js";import{f as a,h as R}from"./fetch-graphql.js";import{a as T}from"./initialize.js";const N=` mutation CANCEL_ORDER_MUTATION($orderId: ID!, $reason: String!) { cancelOrder(input: { order_id: $orderId, reason: $reason }) { error @@ -79,14 +79,14 @@ import{P as T,a as d,G as i,O as A,B as D,b as c,A as u,c as E}from"./initialize } } } - ${T} ${d} + ${s} ${i} ${A} ${D} ${c} ${u} -`,M=async(r,e,_,t)=>{if(!r)throw new Error("No order ID found");if(!e)throw new Error("No reason found");return s(O,{variables:{orderId:r,reason:e}}).then(({errors:o,data:n})=>{if(o)return R(o);if(n.cancelOrder.error!=null){t();return}const a=E(n.cancelOrder.order);_(a)}).catch(()=>t())},N=` +`,M=async(r,e,_,t)=>{if(!r)throw new Error("No order ID found");if(!e)throw new Error("No reason found");return a(N,{variables:{orderId:r,reason:e}}).then(({errors:o,data:n})=>{if(o)return R(o);if(n.cancelOrder.error!=null){t();return}const E=T(n.cancelOrder.order);_(E)}).catch(()=>t())},O=` mutation REQUEST_GUEST_ORDER_CANCEL_MUTATION( $token: String! $reason: String! @@ -99,4 +99,4 @@ import{P as T,a as d,G as i,O as A,B as D,b as c,A as u,c as E}from"./initialize } } ${G} -`,S=async(r,e,_,t)=>{if(!r)throw new Error("No order token found");if(!e)throw new Error("No reason found");return s(N,{variables:{token:r,reason:e}}).then(({errors:o,data:n})=>{if(o)return R(o);n.requestGuestOrderCancel.error!=null&&t();const a=E(n.requestGuestOrderCancel.order);_(a)}).catch(()=>t())};export{M as c,S as r}; +`,S=async(r,e,_,t)=>{if(!r)throw new Error("No order token found");if(!e)throw new Error("No reason found");return a(O,{variables:{token:r,reason:e}}).then(({errors:o,data:n})=>{if(o)return R(o);n.requestGuestOrderCancel.error!=null&&t();const E=T(n.requestGuestOrderCancel.order);_(E)}).catch(()=>t())};export{M as c,S as r}; diff --git a/scripts/__dropins__/storefront-order/chunks/requestGuestReturn.js b/scripts/__dropins__/storefront-order/chunks/requestGuestReturn.js index 445a3d5263..353739859b 100644 --- a/scripts/__dropins__/storefront-order/chunks/requestGuestReturn.js +++ b/scripts/__dropins__/storefront-order/chunks/requestGuestReturn.js @@ -1,6 +1,6 @@ /*! Copyright 2024 Adobe All Rights Reserved. */ -import{h as i,a as _}from"./network-error.js";import{f as s,h as o}from"./fetch-graphql.js";import{t as d}from"./transform-attributes-form.js";import{R as m}from"./RequestReturnOrderFragment.graphql.js";import{merge as l}from"@dropins/tools/lib.js";import{e as f}from"./initialize.js";const h=r=>{var u,n,E,c,R,T;if(!((n=(u=r==null?void 0:r.data)==null?void 0:u.requestReturn)!=null&&n.return))return{};const{created_at:e,...t}=r.data.requestReturn.return,a={...t,createdAt:e};return l(a,(T=(R=(c=(E=f.getConfig())==null?void 0:E.models)==null?void 0:c.RequestReturnModel)==null?void 0:R.transformer)==null?void 0:T.call(R,r.data.requestReturn.return))},U=` +import{h as i,a as _}from"./network-error.js";import{f as o,h as s}from"./fetch-graphql.js";import{t as d}from"./transform-attributes-form.js";import{REQUEST_RETURN_ORDER_FRAGMENT as m}from"../fragments.js";import{merge as l}from"@dropins/tools/lib.js";import{c as f}from"./initialize.js";const h=r=>{var a,n,E,c,R,T;if(!((n=(a=r==null?void 0:r.data)==null?void 0:a.requestReturn)!=null&&n.return))return{};const{created_at:e,...t}=r.data.requestReturn.return,u={...t,createdAt:e};return l(u,(T=(R=(c=(E=f.getConfig())==null?void 0:E.models)==null?void 0:c.RequestReturnModel)==null?void 0:R.transformer)==null?void 0:T.call(R,r.data.requestReturn.return))},U=` query GET_ATTRIBUTES_LIST($entityType: AttributeEntityTypeEnum!) { attributesList(entityType: $entityType) { items { @@ -33,7 +33,7 @@ import{h as i,a as _}from"./network-error.js";import{f as s,h as o}from"./fetch- } } } -`,g=async r=>await s(U,{method:"GET",cache:"force-cache",variables:{entityType:r}}).then(e=>{var t,a,u;return(t=e.errors)!=null&&t.length?o(e.errors):d((u=(a=e==null?void 0:e.data)==null?void 0:a.attributesList)==null?void 0:u.items)}).catch(i),q=` +`,g=async r=>await o(U,{method:"GET",cache:"force-cache",variables:{entityType:r}}).then(e=>{var t,u,a;return(t=e.errors)!=null&&t.length?s(e.errors):d((a=(u=e==null?void 0:e.data)==null?void 0:u.attributesList)==null?void 0:a.items)}).catch(i),q=` mutation REQUEST_RETURN_ORDER($input: RequestReturnInput!) { requestReturn(input: $input) { return { @@ -42,7 +42,7 @@ import{h as i,a as _}from"./network-error.js";import{f as s,h as o}from"./fetch- } } ${m} -`,O=async r=>{const e=_(r,"snakeCase",{});return await s(q,{method:"POST",variables:{input:e}}).then(t=>{var a;return(a=t.errors)!=null&&a.length?o(t.errors):h(t)}).catch(i)},S=` +`,O=async r=>{const e=_(r,"snakeCase",{});return await o(q,{method:"POST",variables:{input:e}}).then(t=>{var u;return(u=t.errors)!=null&&u.length?s(t.errors):h(t)}).catch(i)},S=` mutation REQUEST_RETURN_GUEST_ORDER($input: RequestGuestReturnInput!) { requestGuestReturn(input: $input) { return { @@ -51,4 +51,4 @@ import{h as i,a as _}from"./network-error.js";import{f as s,h as o}from"./fetch- } } ${m} -`,v=async r=>{const e=_(r,"snakeCase",{});return await s(S,{method:"POST",variables:{input:e}}).then(t=>{var n;if((n=t.errors)!=null&&n.length)return o(t.errors);const{created_at:a,...u}=t.data.requestGuestReturn.return;return{...u,createdAt:a}}).catch(i)};export{v as a,g,O as r}; +`,v=async r=>{const e=_(r,"snakeCase",{});return await o(S,{method:"POST",variables:{input:e}}).then(t=>{var n;if((n=t.errors)!=null&&n.length)return s(t.errors);const{created_at:u,...a}=t.data.requestGuestReturn.return;return{...a,createdAt:u}}).catch(i)};export{v as a,g,O as r}; diff --git a/scripts/__dropins__/storefront-order/containers/CreateReturn.js b/scripts/__dropins__/storefront-order/containers/CreateReturn.js index a4eda97a2b..df04cdc644 100644 --- a/scripts/__dropins__/storefront-order/containers/CreateReturn.js +++ b/scripts/__dropins__/storefront-order/containers/CreateReturn.js @@ -1,3 +1,3 @@ /*! Copyright 2024 Adobe All Rights Reserved. */ -import{jsx as r,jsxs as N}from"@dropins/tools/preact-jsx-runtime.js";import{classes as B,Slot as H}from"@dropins/tools/lib.js";import{Icon as $,Header as W,InLineAlert as j,Button as M,Checkbox as G,CartItem as V,Image as Z}from"@dropins/tools/components.js";import{useState as w,useRef as D,useEffect as P,useCallback as F}from"@dropins/tools/preact-hooks.js";import{u as U,a as z}from"../chunks/ShippingStatusCard.js";import*as _ from"@dropins/tools/preact-compat.js";import{u as J}from"../chunks/useGetStoreConfig.js";import{createRef as K,Fragment as X}from"@dropins/tools/preact.js";import{s as Y,p as I,r as ee,m as te}from"../chunks/returnOrdersHelper.js";import{events as ne}from"@dropins/tools/event-bus.js";import{g as A}from"../chunks/getQueryParam.js";import{g as re,r as se,a as ae}from"../chunks/requestGuestReturn.js";import{s as ie}from"../chunks/setTaxStatus.js";import{S as ce,C as ue}from"../chunks/CartSummaryItem.js";import{a as oe}from"../chunks/OrderLoaders.js";import{useText as le}from"@dropins/tools/i18n.js";import"../chunks/getStoreConfig.js";import"../chunks/fetch-graphql.js";import"@dropins/tools/fetch-graphql.js";import"../chunks/getFormValues.js";import"../chunks/network-error.js";import"../chunks/transform-attributes-form.js";import"../chunks/RequestReturnOrderFragment.graphql.js";import"../chunks/initialize.js";const de=a=>_.createElement("svg",{id:"Icon_Warning_Base",width:24,height:24,viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",...a},_.createElement("g",{clipPath:"url(#clip0_841_1324)"},_.createElement("path",{vectorEffect:"non-scaling-stroke",d:"M11.9949 2.30237L0.802734 21.6977H23.1977L11.9949 2.30237Z",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round"}),_.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"})),_.createElement("defs",null,_.createElement("clipPath",{id:"clip0_841_1324"},_.createElement("rect",{width:24,height:21,fill:"white",transform:"translate(0 1.5)"})))),pe=a=>_.createElement("svg",{width:24,height:24,viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",...a},_.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"}),_.createElement("path",{vectorEffect:"non-scaling-stroke",d:"M6.75 12.762L10.2385 15.75L17.25 9",stroke:"currentColor"})),me=({onSuccess:a,onError:s,handleSetInLineAlert:i,orderData:l})=>{const[k,L]=w(!1),[o,R]=w({id:"",email:"",...l}),[v,x]=w("products"),[h,d]=w(!0),[g,f]=w([]),[C,t]=w([]),[m,e]=w([]),c=D([]);c.current.length!==g.length&&(c.current=g.map((n,p)=>c.current[p]||K())),P(()=>{const n=ne.on("order/data",p=>{var u;R(p);const O=Y(p);e(O),L(((u=A("orderRef"))==null?void 0:u.length)>20),d(!1)},{eager:!0});return()=>{n==null||n.off()}},[]),P(()=>{re("RMA_ITEM").then(n=>{n!=null&&n.length&&(t(n),d(!1))})},[]);const y=F(n=>{f(p=>p.findIndex(u=>(u==null?void 0:u.productSku)===(n==null?void 0:n.productSku))>-1?p.filter(u=>(u==null?void 0:u.productSku)!==(n==null?void 0:n.productSku)):[...p,n])},[]),S=F(n=>{x(n),i(),n==="products"&&f([])},[i]),E=F((n,p)=>{const O=g.map(u=>u.productSku===p?{...u,currentReturnOrderQuantity:n}:u);f(O)},[g]),Q=F(async(n,p)=>{if(!p)return;d(!0);const O={orderUid:o.id,contactEmail:o.email},u=I(c);k?ae({token:A("orderRef"),contactEmail:O.contactEmail,items:u,commentText:"."}).then(b=>{a==null||a(b),S("success"),i()}).catch(b=>{s==null||s(b.message),i({type:"error",heading:b.message})}):se({...O,items:u}).then(b=>{a==null||a(b),S("success"),i()}).catch(b=>{s==null||s(b.message),i({type:"error",heading:b.message})}),d(!1)},[S,s,a,i,o,k]);return{order:o,steps:v,loading:h,formsRef:c,attributesList:C,selectedProductList:g,itemsEligibleForReturn:m,handleSelectedProductList:y,handleSetQuantity:E,handleChangeStep:S,onSubmit:Q}},he={success:pe,warning:de,error:ce},ge=()=>{const[a,s]=w({type:"success",heading:""}),i=F(l=>{if(!(l!=null&&l.type)){s({type:"success",heading:""});return}const k=r($,{source:he[l.type]});s({...l,icon:k})},[]);return{inLineAlertProps:a,handleSetInLineAlert:i}},je=({className:a,orderData:s,slots:i,onSuccess:l,onError:k,routeReturnSuccess:L,showConfigurableOptions:o})=>{const R=le({headerText:"Order.CreateReturn.headerText",successTitle:"Order.CreateReturn.success.title",successMessage:"Order.CreateReturn.success.message",sender:"Order.CreateReturn.giftCard.sender",recipient:"Order.CreateReturn.giftCard.recipient",message:"Order.CreateReturn.giftCard.message",outOfStock:"Order.CreateReturn.stockStatus.outOfStock",nextStep:"Order.CreateReturn.buttons.nextStep",backStep:"Order.CreateReturn.buttons.backStep",submit:"Order.CreateReturn.buttons.submit",backStore:"Order.CreateReturn.buttons.backStore",downloadableCount:"Order.CreateReturn.downloadableCount",returnedItems:"Order.CreateReturn.returnedItems",configurationsListQuantity:"Order.CreateReturn.configurationsList.quantity"}),{inLineAlertProps:v,handleSetInLineAlert:x}=ge(),h=J(),{order:d,itemsEligibleForReturn:g,formsRef:f,attributesList:C,steps:t,loading:m,selectedProductList:e,handleSelectedProductList:c,handleSetQuantity:y,handleChangeStep:S,onSubmit:E}=me({orderData:s,onSuccess:l,onError:k,handleSetInLineAlert:x});if(m)return r("div",{children:r(oe,{})});if(!m&&!C.length)return r("div",{});const Q=(h==null?void 0:h.baseMediaUrl)??"",n={products:r(be,{itemsEligibleForReturn:g,placeholderImage:Q,taxConfig:ie((h==null?void 0:h.shoppingCartDisplayPrice)??0),slots:i,translations:R,loading:m,selectedProductList:e,handleSelectedProductList:c,showConfigurableOptions:o,handleSetQuantity:y,handleChangeStep:S}),attributes:r(ke,{placeholderImage:Q,slots:i,formsRef:f,loading:m,fieldsConfig:C,selectedProductList:e,handleChangeStep:S,translations:R,onSubmit:E}),success:r(fe,{translations:R,routeReturnSuccess:L,orderData:d}),error:null};return N("div",{className:B(["order-create-return",a]),children:[r(W,{title:R.headerText}),v.heading?r(j,{className:"order-create-return_notification",variant:"secondary","data-testid":"orderCreateReturnNotification",...v}):null,n[t]]})},fe=({routeReturnSuccess:a,translations:s,orderData:i})=>N("div",{className:"order-return-order-message",children:[r("p",{className:"order-return-order-message__title",children:s.successTitle}),r("p",{className:"order-return-order-message__subtitle",children:s.successMessage}),r(M,{href:(a==null?void 0:a(i))??"#",children:s.backStore})]}),be=({placeholderImage:a,itemsEligibleForReturn:s,slots:i,loading:l,taxConfig:k,translations:L,selectedProductList:o,handleSelectedProductList:R,showConfigurableOptions:v,handleSetQuantity:x,handleChangeStep:h})=>N("ul",{className:"order-return-order-product-list",children:[s==null?void 0:s.map((d,g)=>{const{quantityReturnRequested:f,quantityShipped:C,eligibleForReturn:t}=d,m=o.some(y=>(y==null?void 0:y.productSku)===d.productSku&&d.eligibleForReturn),e=C===f&&t||!t,c=C-f===0?f:C-f;return N("li",{className:B(["order-return-order-product-list__item",["order-return-order-product-list__item--blur",e]]),children:[r(G,{"data-testid":`key_${g}`,name:`key_${g}`,checked:m,disabled:e,onChange:()=>{R({...d,currentReturnOrderQuantity:1})}}),r(ue,{placeholderImage:a,loading:l,product:{...d,totalQuantity:c||1},itemType:"",taxConfig:k,translations:L,showConfigurableOptions:v,disabledIncrementer:!m,onQuantity:c>1?y=>{x(y,d.productSku)}:void 0}),r(H,{"data-testid":"returnOrderItem",name:"ReturnOrderItem",slot:i==null?void 0:i.ReturnOrderItem})]},d.id)}),r("li",{className:"order-return-order-product-list__item",children:r(M,{type:"button",onClick:()=>h("attributes"),disabled:!o.length,children:L.nextStep})})]}),ke=({placeholderImage:a,slots:s,formsRef:i,selectedProductList:l,loading:k,fieldsConfig:L,translations:o,handleChangeStep:R,onSubmit:v})=>{const{formData:x,errors:h,formRef:d,handleChange:g,handleBlur:f,handleSubmit:C}=U({fieldsConfig:ee(L,l==null?void 0:l.length),onSubmit:v});return N("form",{className:"order-return-reason-form",ref:d,onSubmit:C,name:"returnReasonForm",children:[l.map((t,m)=>{var p,O,u,b,T,q;const e=t==null?void 0:t.giftCard,c=t==null?void 0:t.product,y=te(L,m),S=`${t==null?void 0:t.id}_${m}`,E=(t==null?void 0:t.currentReturnOrderQuantity)??1,Q={...t!=null&&t.currentReturnOrderQuantity?{[o.configurationsListQuantity]:E}:{},...t.configurableOptions||{},...t.bundleOptions||{},...e!=null&&e.senderName?{[o.sender]:e==null?void 0:e.senderName}:{},...e!=null&&e.senderEmail?{[o.sender]:e==null?void 0:e.senderEmail}:{},...e!=null&&e.recipientName?{[o.recipient]:e==null?void 0:e.recipientName}:{},...e!=null&&e.recipientEmail?{[o.recipient]:e==null?void 0:e.recipientEmail}:{},...e!=null&&e.message?{[o.message]:e==null?void 0:e.message}:{},...t!=null&&t.downloadableLinks?{[`${(p=t==null?void 0:t.downloadableLinks)==null?void 0:p.count} ${o.downloadableCount}`]:(O=t==null?void 0:t.downloadableLinks)==null?void 0:O.result}:{}},n=(b=(u=c==null?void 0:c.thumbnail)==null?void 0:u.url)!=null&&b.length?c.thumbnail.url:a;return N(X,{children:[r(V,{loading:k,title:r("div",{"data-testid":"product-name",children:(T=t==null?void 0:t.product)==null?void 0:T.name}),sku:r("div",{children:c==null?void 0:c.sku}),image:r(Z,{src:n,alt:((q=c==null?void 0:c.thumbnail)==null?void 0:q.label)??"",loading:"lazy",width:"90",height:"120"}),configurations:Q}),r("form",{name:S,ref:i==null?void 0:i.current[m],"data-quantity":E,children:r(z,{className:"className",loading:k,fields:y,onChange:g,onBlur:f,errors:h,values:x})})]},t.id)}),r(H,{"data-testid":"returnFormActions",name:"ReturnFormActions",slot:s==null?void 0:s.ReturnFormActions,context:{handleChangeStep:R},children:N("div",{className:"order-return-reason-form__actions",children:[r(M,{variant:"secondary",type:"button",onClick:()=>{R("products")},children:o.backStep}),r(M,{children:o.submit})]})})]})};export{je as CreateReturn,je as default}; +import{jsx as r,jsxs as N}from"@dropins/tools/preact-jsx-runtime.js";import{classes as B,Slot as H}from"@dropins/tools/lib.js";import{Icon as $,Header as W,InLineAlert as j,Button as M,Checkbox as G,CartItem as V,Image as Z}from"@dropins/tools/components.js";import{useState as w,useRef as D,useEffect as P,useCallback as F}from"@dropins/tools/preact-hooks.js";import{u as U,a as z}from"../chunks/ShippingStatusCard.js";import*as _ from"@dropins/tools/preact-compat.js";import{u as J}from"../chunks/useGetStoreConfig.js";import{createRef as K,Fragment as X}from"@dropins/tools/preact.js";import{s as Y,p as I,r as ee,m as te}from"../chunks/returnOrdersHelper.js";import{events as ne}from"@dropins/tools/event-bus.js";import{g as A}from"../chunks/getQueryParam.js";import{g as re,r as se,a as ae}from"../chunks/requestGuestReturn.js";import{s as ie}from"../chunks/setTaxStatus.js";import{S as ce,C as ue}from"../chunks/CartSummaryItem.js";import{a as oe}from"../chunks/OrderLoaders.js";import{useText as le}from"@dropins/tools/i18n.js";import"../chunks/getStoreConfig.js";import"../chunks/fetch-graphql.js";import"@dropins/tools/fetch-graphql.js";import"../chunks/getFormValues.js";import"../chunks/network-error.js";import"../chunks/transform-attributes-form.js";import"../fragments.js";import"../chunks/initialize.js";const de=a=>_.createElement("svg",{id:"Icon_Warning_Base",width:24,height:24,viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",...a},_.createElement("g",{clipPath:"url(#clip0_841_1324)"},_.createElement("path",{vectorEffect:"non-scaling-stroke",d:"M11.9949 2.30237L0.802734 21.6977H23.1977L11.9949 2.30237Z",stroke:"currentColor",strokeLinecap:"round",strokeLinejoin:"round"}),_.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"})),_.createElement("defs",null,_.createElement("clipPath",{id:"clip0_841_1324"},_.createElement("rect",{width:24,height:21,fill:"white",transform:"translate(0 1.5)"})))),pe=a=>_.createElement("svg",{width:24,height:24,viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",...a},_.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"}),_.createElement("path",{vectorEffect:"non-scaling-stroke",d:"M6.75 12.762L10.2385 15.75L17.25 9",stroke:"currentColor"})),me=({onSuccess:a,onError:s,handleSetInLineAlert:i,orderData:l})=>{const[k,L]=w(!1),[o,R]=w({id:"",email:"",...l}),[v,x]=w("products"),[h,d]=w(!0),[g,f]=w([]),[C,t]=w([]),[m,e]=w([]),c=D([]);c.current.length!==g.length&&(c.current=g.map((n,p)=>c.current[p]||K())),P(()=>{const n=ne.on("order/data",p=>{var u;R(p);const O=Y(p);e(O),L(((u=A("orderRef"))==null?void 0:u.length)>20),d(!1)},{eager:!0});return()=>{n==null||n.off()}},[]),P(()=>{re("RMA_ITEM").then(n=>{n!=null&&n.length&&(t(n),d(!1))})},[]);const y=F(n=>{f(p=>p.findIndex(u=>(u==null?void 0:u.productSku)===(n==null?void 0:n.productSku))>-1?p.filter(u=>(u==null?void 0:u.productSku)!==(n==null?void 0:n.productSku)):[...p,n])},[]),S=F(n=>{x(n),i(),n==="products"&&f([])},[i]),E=F((n,p)=>{const O=g.map(u=>u.productSku===p?{...u,currentReturnOrderQuantity:n}:u);f(O)},[g]),Q=F(async(n,p)=>{if(!p)return;d(!0);const O={orderUid:o.id,contactEmail:o.email},u=I(c);k?ae({token:A("orderRef"),contactEmail:O.contactEmail,items:u,commentText:"."}).then(b=>{a==null||a(b),S("success"),i()}).catch(b=>{s==null||s(b.message),i({type:"error",heading:b.message})}):se({...O,items:u}).then(b=>{a==null||a(b),S("success"),i()}).catch(b=>{s==null||s(b.message),i({type:"error",heading:b.message})}),d(!1)},[S,s,a,i,o,k]);return{order:o,steps:v,loading:h,formsRef:c,attributesList:C,selectedProductList:g,itemsEligibleForReturn:m,handleSelectedProductList:y,handleSetQuantity:E,handleChangeStep:S,onSubmit:Q}},he={success:pe,warning:de,error:ce},ge=()=>{const[a,s]=w({type:"success",heading:""}),i=F(l=>{if(!(l!=null&&l.type)){s({type:"success",heading:""});return}const k=r($,{source:he[l.type]});s({...l,icon:k})},[]);return{inLineAlertProps:a,handleSetInLineAlert:i}},je=({className:a,orderData:s,slots:i,onSuccess:l,onError:k,routeReturnSuccess:L,showConfigurableOptions:o})=>{const R=le({headerText:"Order.CreateReturn.headerText",successTitle:"Order.CreateReturn.success.title",successMessage:"Order.CreateReturn.success.message",sender:"Order.CreateReturn.giftCard.sender",recipient:"Order.CreateReturn.giftCard.recipient",message:"Order.CreateReturn.giftCard.message",outOfStock:"Order.CreateReturn.stockStatus.outOfStock",nextStep:"Order.CreateReturn.buttons.nextStep",backStep:"Order.CreateReturn.buttons.backStep",submit:"Order.CreateReturn.buttons.submit",backStore:"Order.CreateReturn.buttons.backStore",downloadableCount:"Order.CreateReturn.downloadableCount",returnedItems:"Order.CreateReturn.returnedItems",configurationsListQuantity:"Order.CreateReturn.configurationsList.quantity"}),{inLineAlertProps:v,handleSetInLineAlert:x}=ge(),h=J(),{order:d,itemsEligibleForReturn:g,formsRef:f,attributesList:C,steps:t,loading:m,selectedProductList:e,handleSelectedProductList:c,handleSetQuantity:y,handleChangeStep:S,onSubmit:E}=me({orderData:s,onSuccess:l,onError:k,handleSetInLineAlert:x});if(m)return r("div",{children:r(oe,{})});if(!m&&!C.length)return r("div",{});const Q=(h==null?void 0:h.baseMediaUrl)??"",n={products:r(be,{itemsEligibleForReturn:g,placeholderImage:Q,taxConfig:ie((h==null?void 0:h.shoppingCartDisplayPrice)??0),slots:i,translations:R,loading:m,selectedProductList:e,handleSelectedProductList:c,showConfigurableOptions:o,handleSetQuantity:y,handleChangeStep:S}),attributes:r(ke,{placeholderImage:Q,slots:i,formsRef:f,loading:m,fieldsConfig:C,selectedProductList:e,handleChangeStep:S,translations:R,onSubmit:E}),success:r(fe,{translations:R,routeReturnSuccess:L,orderData:d}),error:null};return N("div",{className:B(["order-create-return",a]),children:[r(W,{title:R.headerText}),v.heading?r(j,{className:"order-create-return_notification",variant:"secondary","data-testid":"orderCreateReturnNotification",...v}):null,n[t]]})},fe=({routeReturnSuccess:a,translations:s,orderData:i})=>N("div",{className:"order-return-order-message",children:[r("p",{className:"order-return-order-message__title",children:s.successTitle}),r("p",{className:"order-return-order-message__subtitle",children:s.successMessage}),r(M,{href:(a==null?void 0:a(i))??"#",children:s.backStore})]}),be=({placeholderImage:a,itemsEligibleForReturn:s,slots:i,loading:l,taxConfig:k,translations:L,selectedProductList:o,handleSelectedProductList:R,showConfigurableOptions:v,handleSetQuantity:x,handleChangeStep:h})=>N("ul",{className:"order-return-order-product-list",children:[s==null?void 0:s.map((d,g)=>{const{quantityReturnRequested:f,quantityShipped:C,eligibleForReturn:t}=d,m=o.some(y=>(y==null?void 0:y.productSku)===d.productSku&&d.eligibleForReturn),e=C===f&&t||!t,c=C-f===0?f:C-f;return N("li",{className:B(["order-return-order-product-list__item",["order-return-order-product-list__item--blur",e]]),children:[r(G,{"data-testid":`key_${g}`,name:`key_${g}`,checked:m,disabled:e,onChange:()=>{R({...d,currentReturnOrderQuantity:1})}}),r(ue,{placeholderImage:a,loading:l,product:{...d,totalQuantity:c||1},itemType:"",taxConfig:k,translations:L,showConfigurableOptions:v,disabledIncrementer:!m,onQuantity:c>1?y=>{x(y,d.productSku)}:void 0}),r(H,{"data-testid":"returnOrderItem",name:"ReturnOrderItem",slot:i==null?void 0:i.ReturnOrderItem})]},d.id)}),r("li",{className:"order-return-order-product-list__item",children:r(M,{type:"button",onClick:()=>h("attributes"),disabled:!o.length,children:L.nextStep})})]}),ke=({placeholderImage:a,slots:s,formsRef:i,selectedProductList:l,loading:k,fieldsConfig:L,translations:o,handleChangeStep:R,onSubmit:v})=>{const{formData:x,errors:h,formRef:d,handleChange:g,handleBlur:f,handleSubmit:C}=U({fieldsConfig:ee(L,l==null?void 0:l.length),onSubmit:v});return N("form",{className:"order-return-reason-form",ref:d,onSubmit:C,name:"returnReasonForm",children:[l.map((t,m)=>{var p,O,u,b,T,q;const e=t==null?void 0:t.giftCard,c=t==null?void 0:t.product,y=te(L,m),S=`${t==null?void 0:t.id}_${m}`,E=(t==null?void 0:t.currentReturnOrderQuantity)??1,Q={...t!=null&&t.currentReturnOrderQuantity?{[o.configurationsListQuantity]:E}:{},...t.configurableOptions||{},...t.bundleOptions||{},...e!=null&&e.senderName?{[o.sender]:e==null?void 0:e.senderName}:{},...e!=null&&e.senderEmail?{[o.sender]:e==null?void 0:e.senderEmail}:{},...e!=null&&e.recipientName?{[o.recipient]:e==null?void 0:e.recipientName}:{},...e!=null&&e.recipientEmail?{[o.recipient]:e==null?void 0:e.recipientEmail}:{},...e!=null&&e.message?{[o.message]:e==null?void 0:e.message}:{},...t!=null&&t.downloadableLinks?{[`${(p=t==null?void 0:t.downloadableLinks)==null?void 0:p.count} ${o.downloadableCount}`]:(O=t==null?void 0:t.downloadableLinks)==null?void 0:O.result}:{}},n=(b=(u=c==null?void 0:c.thumbnail)==null?void 0:u.url)!=null&&b.length?c.thumbnail.url:a;return N(X,{children:[r(V,{loading:k,title:r("div",{"data-testid":"product-name",children:(T=t==null?void 0:t.product)==null?void 0:T.name}),sku:r("div",{children:c==null?void 0:c.sku}),image:r(Z,{src:n,alt:((q=c==null?void 0:c.thumbnail)==null?void 0:q.label)??"",loading:"lazy",width:"90",height:"120"}),configurations:Q}),r("form",{name:S,ref:i==null?void 0:i.current[m],"data-quantity":E,children:r(z,{className:"className",loading:k,fields:y,onChange:g,onBlur:f,errors:h,values:x})})]},t.id)}),r(H,{"data-testid":"returnFormActions",name:"ReturnFormActions",slot:s==null?void 0:s.ReturnFormActions,context:{handleChangeStep:R},children:N("div",{className:"order-return-reason-form__actions",children:[r(M,{variant:"secondary",type:"button",onClick:()=>{R("products")},children:o.backStep}),r(M,{children:o.submit})]})})]})};export{je as CreateReturn,je as default}; diff --git a/scripts/__dropins__/storefront-order/containers/OrderCancelForm.js b/scripts/__dropins__/storefront-order/containers/OrderCancelForm.js index a148b2ddf6..0933505eac 100644 --- a/scripts/__dropins__/storefront-order/containers/OrderCancelForm.js +++ b/scripts/__dropins__/storefront-order/containers/OrderCancelForm.js @@ -1,3 +1,3 @@ /*! Copyright 2024 Adobe All Rights Reserved. */ -import{O as C,O as F}from"../chunks/OrderCancelForm.js";import"@dropins/tools/preact-jsx-runtime.js";import"@dropins/tools/components.js";import"../chunks/ShippingStatusCard.js";import"@dropins/tools/preact-hooks.js";import"@dropins/tools/i18n.js";import"@dropins/tools/preact-compat.js";import"@dropins/tools/lib.js";import"@dropins/tools/preact.js";import"@dropins/tools/event-bus.js";import"../chunks/requestGuestOrderCancel.js";import"../chunks/initialize.js";import"../chunks/network-error.js";import"../chunks/fetch-graphql.js";import"@dropins/tools/fetch-graphql.js";import"../chunks/GurestOrderFragment.graphql.js";export{C as OrderCancelForm,F as default}; +import{O as C,O as F}from"../chunks/OrderCancelForm.js";import"@dropins/tools/preact-jsx-runtime.js";import"@dropins/tools/components.js";import"../chunks/ShippingStatusCard.js";import"@dropins/tools/preact-hooks.js";import"@dropins/tools/i18n.js";import"@dropins/tools/preact-compat.js";import"@dropins/tools/lib.js";import"@dropins/tools/preact.js";import"@dropins/tools/event-bus.js";import"../chunks/requestGuestOrderCancel.js";import"../fragments.js";import"../chunks/fetch-graphql.js";import"@dropins/tools/fetch-graphql.js";import"../chunks/initialize.js";import"../chunks/network-error.js";export{C as OrderCancelForm,F as default}; diff --git a/scripts/__dropins__/storefront-order/containers/OrderSearch.js b/scripts/__dropins__/storefront-order/containers/OrderSearch.js index 848af49fd4..e391860b18 100644 --- a/scripts/__dropins__/storefront-order/containers/OrderSearch.js +++ b/scripts/__dropins__/storefront-order/containers/OrderSearch.js @@ -1,3 +1,3 @@ /*! Copyright 2024 Adobe All Rights Reserved. */ -import{jsx as t,jsxs as L}from"@dropins/tools/preact-jsx-runtime.js";import{classes as M}from"@dropins/tools/lib.js";import{Card as V,InLineAlert as k,Icon as C,Button as q}from"@dropins/tools/components.js";import{useState as v,useCallback as F,useEffect as _,useMemo as D}from"@dropins/tools/preact-hooks.js";import{F as H}from"../chunks/ShippingStatusCard.js";import*as w from"@dropins/tools/preact-compat.js";import"@dropins/tools/preact.js";import{events as N}from"@dropins/tools/event-bus.js";import{F as g,g as B}from"../chunks/getFormValues.js";import{r as f}from"../chunks/redirectTo.js";import{g as E}from"../chunks/getQueryParam.js";import{g as x,a as z}from"../chunks/getGuestOrder.js";import{useText as U,Text as T}from"@dropins/tools/i18n.js";import"../chunks/network-error.js";import"../chunks/fetch-graphql.js";import"@dropins/tools/fetch-graphql.js";import"../chunks/GurestOrderFragment.graphql.js";import"../chunks/initialize.js";const X=s=>w.createElement("svg",{width:24,height:24,viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",...s},w.createElement("path",{vectorEffect:"non-scaling-stroke",fillRule:"evenodd",clipRule:"evenodd",d:"M1 20.8953L12.1922 1.5L23.395 20.8953H1ZM13.0278 13.9638L13.25 10.0377V9H11.25V10.0377L11.4722 13.9638H13.0278ZM11.2994 16V17.7509H13.2253V16H11.2994Z",fill:"currentColor"})),Z=({onError:s,isAuth:r,renderSignIn:a,routeCustomerOrder:i,routeGuestOrder:c})=>{const[b,u]=v({text:"",type:"success"}),[y,p]=v(!1),n=U({invalidSearch:"Order.Errors.invalidSearch",email:"Order.OrderSearchForm.email",lastname:"Order.OrderSearchForm.lastname",number:"Order.OrderSearchForm.orderNumber"}),R=F(async e=>{const l=E("orderRef"),o=l&&l.length>20;if(!e&&!l||!(e!=null&&e.number)&&!(e!=null&&e.token)&&!l)return null;if(r){const d=await x();(d==null?void 0:d.email)===e.email?f(i,{orderRef:e==null?void 0:e.number}):o||f(c,{orderRef:e.token})}else o||f(c,{orderRef:e==null?void 0:e.token})},[r,i,c]);_(()=>{const e=N.on("order/data",l=>{R(l)},{eager:!0});return()=>{e==null||e.off()}},[R]),_(()=>{const e=E("orderRef"),l=e&&e.length>20?e:null;e&&(l?f(c,{orderRef:e}):r?f(i,{orderRef:e}):a==null||a({render:!0,formValues:{number:e}}))},[r,i,c,a]);const O=D(()=>[{entityType:"CUSTOMER_ADDRESS",is_unique:!1,label:n.email,options:[],defaultValue:"",fieldType:g.TEXT,className:"",required:!0,orderNumber:1,name:"email",id:"email",code:"email"},{entityType:"CUSTOMER_ADDRESS",is_unique:!1,label:n.lastname,options:[],defaultValue:"",fieldType:g.TEXT,className:"",required:!0,orderNumber:2,name:"lastname",id:"lastname",code:"lastname"},{entityType:"CUSTOMER_ADDRESS",is_unique:!1,label:n.number,options:[],defaultValue:"",fieldType:g.TEXT,className:"",required:!0,orderNumber:3,name:"number",id:"number",code:"number"}],[n]);return{onSubmit:F(async(e,l)=>{if(!l)return null;p(!0);const o=B(e.target);await z(o).then(m=>{m||u({text:n.invalidSearch,type:"warning"}),N.emit("order/data",m)}).catch(async m=>{var S;let d=!0;s==null||s({error:m.message});const h=r?await x():{email:""};(h==null?void 0:h.email)===(o==null?void 0:o.email)?f(i,{orderRef:o.number}):d=a==null?void 0:a({render:h===null||((S=m==null?void 0:m.message)==null?void 0:S.includes("Please login to view the order.")),formValues:o}),d&&u({text:m.message,type:"warning"})}).finally(()=>{p(!1)})},[r,s,a,i,n.invalidSearch]),inLineAlert:b,loading:y,normalizeFieldsConfig:O}},ne=({className:s,isAuth:r,renderSignIn:a,routeCustomerOrder:i,routeGuestOrder:c,onError:b})=>{const{onSubmit:u,loading:y,inLineAlert:p,normalizeFieldsConfig:n}=Z({onError:b,isAuth:r,renderSignIn:a,routeCustomerOrder:i,routeGuestOrder:c});return t("div",{className:M(["order-order-search",s]),children:t(j,{onSubmit:u,loading:y,inLineAlert:p,fieldsConfig:n})})},j=({onSubmit:s,loading:r,inLineAlert:a,fieldsConfig:i})=>L(V,{variant:"secondary",className:"order-order-search-form",children:[t("h2",{className:"order-order-search-form__title",children:t(T,{id:"Order.OrderSearchForm.title"})}),t("p",{children:t(T,{id:"Order.OrderSearchForm.description"})}),a.text?t(k,{"data-testid":"orderAlert",className:"order-order-search-form__alert",type:a.type,variant:"secondary",heading:a.text,icon:t(C,{source:X})}):null,t(H,{className:"order-order-search-form__wrapper",name:"orderSearchForm",loading:r,fieldsConfig:i,onSubmit:s,children:t("div",{className:"order-order-search-form__button-container",children:t(q,{className:"order-order-search-form__button",size:"medium",variant:"primary",type:"submit",disabled:r,children:t(T,{id:"Order.OrderSearchForm.button"})},"logIn")})})]});export{ne as OrderSearch,ne as default}; +import{jsx as t,jsxs as L}from"@dropins/tools/preact-jsx-runtime.js";import{classes as M}from"@dropins/tools/lib.js";import{Card as V,InLineAlert as k,Icon as C,Button as q}from"@dropins/tools/components.js";import{useState as v,useCallback as F,useEffect as _,useMemo as D}from"@dropins/tools/preact-hooks.js";import{F as H}from"../chunks/ShippingStatusCard.js";import*as w from"@dropins/tools/preact-compat.js";import"@dropins/tools/preact.js";import{events as N}from"@dropins/tools/event-bus.js";import{F as g,g as B}from"../chunks/getFormValues.js";import{r as f}from"../chunks/redirectTo.js";import{g as E}from"../chunks/getQueryParam.js";import{g as x,a as z}from"../chunks/getGuestOrder.js";import{useText as U,Text as T}from"@dropins/tools/i18n.js";import"../chunks/network-error.js";import"../chunks/fetch-graphql.js";import"@dropins/tools/fetch-graphql.js";import"../fragments.js";import"../chunks/initialize.js";const X=s=>w.createElement("svg",{width:24,height:24,viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",...s},w.createElement("path",{vectorEffect:"non-scaling-stroke",fillRule:"evenodd",clipRule:"evenodd",d:"M1 20.8953L12.1922 1.5L23.395 20.8953H1ZM13.0278 13.9638L13.25 10.0377V9H11.25V10.0377L11.4722 13.9638H13.0278ZM11.2994 16V17.7509H13.2253V16H11.2994Z",fill:"currentColor"})),Z=({onError:s,isAuth:r,renderSignIn:a,routeCustomerOrder:i,routeGuestOrder:c})=>{const[b,u]=v({text:"",type:"success"}),[y,p]=v(!1),n=U({invalidSearch:"Order.Errors.invalidSearch",email:"Order.OrderSearchForm.email",lastname:"Order.OrderSearchForm.lastname",number:"Order.OrderSearchForm.orderNumber"}),R=F(async e=>{const l=E("orderRef"),o=l&&l.length>20;if(!e&&!l||!(e!=null&&e.number)&&!(e!=null&&e.token)&&!l)return null;if(r){const d=await x();(d==null?void 0:d.email)===e.email?f(i,{orderRef:e==null?void 0:e.number}):o||f(c,{orderRef:e.token})}else o||f(c,{orderRef:e==null?void 0:e.token})},[r,i,c]);_(()=>{const e=N.on("order/data",l=>{R(l)},{eager:!0});return()=>{e==null||e.off()}},[R]),_(()=>{const e=E("orderRef"),l=e&&e.length>20?e:null;e&&(l?f(c,{orderRef:e}):r?f(i,{orderRef:e}):a==null||a({render:!0,formValues:{number:e}}))},[r,i,c,a]);const O=D(()=>[{entityType:"CUSTOMER_ADDRESS",is_unique:!1,label:n.email,options:[],defaultValue:"",fieldType:g.TEXT,className:"",required:!0,orderNumber:1,name:"email",id:"email",code:"email"},{entityType:"CUSTOMER_ADDRESS",is_unique:!1,label:n.lastname,options:[],defaultValue:"",fieldType:g.TEXT,className:"",required:!0,orderNumber:2,name:"lastname",id:"lastname",code:"lastname"},{entityType:"CUSTOMER_ADDRESS",is_unique:!1,label:n.number,options:[],defaultValue:"",fieldType:g.TEXT,className:"",required:!0,orderNumber:3,name:"number",id:"number",code:"number"}],[n]);return{onSubmit:F(async(e,l)=>{if(!l)return null;p(!0);const o=B(e.target);await z(o).then(m=>{m||u({text:n.invalidSearch,type:"warning"}),N.emit("order/data",m)}).catch(async m=>{var S;let d=!0;s==null||s({error:m.message});const h=r?await x():{email:""};(h==null?void 0:h.email)===(o==null?void 0:o.email)?f(i,{orderRef:o.number}):d=a==null?void 0:a({render:h===null||((S=m==null?void 0:m.message)==null?void 0:S.includes("Please login to view the order.")),formValues:o}),d&&u({text:m.message,type:"warning"})}).finally(()=>{p(!1)})},[r,s,a,i,n.invalidSearch]),inLineAlert:b,loading:y,normalizeFieldsConfig:O}},ne=({className:s,isAuth:r,renderSignIn:a,routeCustomerOrder:i,routeGuestOrder:c,onError:b})=>{const{onSubmit:u,loading:y,inLineAlert:p,normalizeFieldsConfig:n}=Z({onError:b,isAuth:r,renderSignIn:a,routeCustomerOrder:i,routeGuestOrder:c});return t("div",{className:M(["order-order-search",s]),children:t(j,{onSubmit:u,loading:y,inLineAlert:p,fieldsConfig:n})})},j=({onSubmit:s,loading:r,inLineAlert:a,fieldsConfig:i})=>L(V,{variant:"secondary",className:"order-order-search-form",children:[t("h2",{className:"order-order-search-form__title",children:t(T,{id:"Order.OrderSearchForm.title"})}),t("p",{children:t(T,{id:"Order.OrderSearchForm.description"})}),a.text?t(k,{"data-testid":"orderAlert",className:"order-order-search-form__alert",type:a.type,variant:"secondary",heading:a.text,icon:t(C,{source:X})}):null,t(H,{className:"order-order-search-form__wrapper",name:"orderSearchForm",loading:r,fieldsConfig:i,onSubmit:s,children:t("div",{className:"order-order-search-form__button-container",children:t(q,{className:"order-order-search-form__button",size:"medium",variant:"primary",type:"submit",disabled:r,children:t(T,{id:"Order.OrderSearchForm.button"})},"logIn")})})]});export{ne as OrderSearch,ne as default}; diff --git a/scripts/__dropins__/storefront-order/containers/OrderStatus.js b/scripts/__dropins__/storefront-order/containers/OrderStatus.js index 3e50d674bb..1e1d15df87 100644 --- a/scripts/__dropins__/storefront-order/containers/OrderStatus.js +++ b/scripts/__dropins__/storefront-order/containers/OrderStatus.js @@ -1,3 +1,3 @@ /*! Copyright 2024 Adobe All Rights Reserved. */ -import{jsx as s,Fragment as S,jsxs as A}from"@dropins/tools/preact-jsx-runtime.js";import{Slot as $,classes as _}from"@dropins/tools/lib.js";import{Button as P,InLineAlert as B,Modal as V,Card as K,Header as Q}from"@dropins/tools/components.js";import{useState as C,useEffect as k,useCallback as T}from"@dropins/tools/preact-hooks.js";import"../chunks/ShippingStatusCard.js";import{useMemo as J}from"@dropins/tools/preact-compat.js";import{u as G}from"../chunks/useGetStoreConfig.js";import"@dropins/tools/preact.js";import{events as I}from"@dropins/tools/event-bus.js";import{a as X,c as Y,r as Z}from"../chunks/confirmCancelOrder.js";import{useText as O,Text as M}from"@dropins/tools/i18n.js";import{C as D}from"../chunks/OrderLoaders.js";import{f as ee}from"../chunks/returnOrdersHelper.js";import{f as w}from"../chunks/formatDateToLocale.js";import{c as b}from"../chunks/capitalizeFirst.js";import{r as U}from"../chunks/redirectTo.js";import{O as te}from"../chunks/OrderCancelForm.js";import"../chunks/getStoreConfig.js";import"../chunks/fetch-graphql.js";import"@dropins/tools/fetch-graphql.js";import"../chunks/network-error.js";import"../chunks/RequestReturnOrderFragment.graphql.js";import"../chunks/GurestOrderFragment.graphql.js";import"../chunks/initialize.js";import"../chunks/getFormValues.js";import"../chunks/requestGuestOrderCancel.js";var y=(t=>(t.CANCEL="CANCEL",t.RETURN="RETURN",t.REORDER="REORDER",t))(y||{});const re=({className:t,orderData:e,slots:n,routeCreateReturn:r,routeOnSuccess:u,onError:i})=>{const d=O({cancel:"Order.OrderStatusContent.actions.cancel",createReturn:"Order.OrderStatusContent.actions.createReturn",createAnotherReturn:"Order.OrderStatusContent.actions.createAnotherReturn",reorder:"Order.OrderStatusContent.actions.reorder"}),l=J(()=>{const c=e==null?void 0:e.availableActions,o=!!(c!=null&&c.length),a=!!(e!=null&&e.returnNumber),m=()=>{U(r,{},e)};return s(S,{children:n!=null&&n.OrderActions?s($,{"data-testid":"OrderActionsSlot",name:"OrderCanceledActions",slot:n==null?void 0:n.OrderActions,context:e}):s("div",{"data-testid":"availableActionsList",className:_(["order-order-actions__wrapper",["order-order-actions__wrapper--empty",!o]]),children:c==null?void 0:c.map(p=>{switch(p){case y.CANCEL:return s(S,{children:a?null:s(ce,{orderRef:(e==null?void 0:e.token)??(e==null?void 0:e.id)})});case y.RETURN:return s(P,{variant:"secondary",onClick:m,children:a?d.createAnotherReturn:d.createReturn});case y.REORDER:return s(S,{children:a?null:s(ie,{orderData:e,onError:i,routeOnSuccess:u,children:d.reorder})})}})})})},[i,e,u,r,n,d]);return s("div",{className:_(["order-order-actions",t]),children:l})},ne=({orderData:t})=>{const[e,n]=C(t),[r,u]=C(t==null?void 0:t.status);return k(()=>{const i=I.on("order/data",d=>{n(d),u(d.status)},{eager:!0});return()=>{i==null||i.off()}},[]),{orderStatus:r,order:e}},H=t=>{const e=new URL(window.location.href);t.forEach(n=>{e.searchParams.has(n)&&e.searchParams.delete(n)}),window.history.replaceState({},document.title,e.toString())},se=({enableOrderCancellation:t})=>{const e=O({cancelOrderHeading:"Order.OrderStatusContent.actions.cancel",confirmGuestReturnHeading:"Order.OrderStatusContent.actions.confirmGuestReturn",orderCancelled:"Order.OrderStatusContent.orderCanceled.message",guestRequestReturnMessage:"Order.OrderStatusContent.actions.confirmGuestReturnMessage"}),[n,r]=C(!1),[u,i]=C(!1),[d,l]=C({heading:"",text:"",status:void 0}),c=T(()=>{r(!0),H(["order_id","confirmation_key","action"])},[]),o=T((a,m,p)=>{l({heading:a,text:m,status:p}),H(["action"])},[]);return k(()=>{const a=new URLSearchParams(window.location.search),m=a.get("order_id")??"",p=a.get("confirmation_key")??"",g=a.get("action")??"";u||!m||!p||!g||(t&&g==="cancel"&&(i(!0),X(m,p).then(()=>{l({heading:e.cancelOrderHeading,text:e.orderCancelled,status:"success"})}).catch(h=>{l({heading:e.cancelOrderHeading,text:h.message,status:"warning"})})),g==="return"&&(i(!0),Y(m,p).then(()=>{l({heading:e.confirmGuestReturnHeading,text:e.guestRequestReturnMessage,status:"success"})}).catch(h=>{l({heading:e.confirmGuestReturnHeading,text:h.message,status:"warning"})})))},[t,e,o,u]),{orderActionStatus:d,isDismissed:n,onDismiss:c}},He=({slots:t,orderData:e,className:n,statusTitle:r,status:u,routeCreateReturn:i,onError:d,routeOnSuccess:l})=>{const{orderStatus:c,order:o}=ne({orderData:e}),a=G(),{orderActionStatus:m,isDismissed:p,onDismiss:g}=se({enableOrderCancellation:a==null?void 0:a.orderCancellationEnabled});return A("div",{className:_(["order-order-status",n]),children:[!p&&(m==null?void 0:m.status)!==void 0?s(B,{style:{marginBottom:"1rem"},heading:m.heading,onDismiss:g,description:m.text,type:m.status}):null,o?s(oe,{title:r,status:u||c,slots:t,orderData:o,routeCreateReturn:i,onError:d,routeOnSuccess:l}):s(D,{withCard:!1})]})},ce=({orderRef:t})=>{const[e,n]=C(!1),r=()=>{n(!0)},u=()=>{n(!1)},i=G(),d=(i==null?void 0:i.orderCancellationReasons)??[],l=c=>c.map((o,a)=>({text:o==null?void 0:o.description,value:a.toString()}));return I.on("order/data",c=>{const o=String(c.status).toLocaleLowerCase();(o==="guest order cancellation requested"||o==="canceled")&&u()}),A(S,{children:[s(P,{variant:"secondary",onClick:r,"data-testid":"cancel-button",children:s(M,{id:"Order.OrderStatusContent.actions.cancel"})}),e&&s(V,{centered:!0,size:"medium",onClose:u,className:"order-order-cancel__modal",title:s("h2",{className:"order-order-cancel__title",children:s(M,{id:"Order.OrderCancelForm.title"})}),"data-testid":"order-cancellation-reasons-modal",children:s(te,{orderRef:t,cancelReasons:l(d)})})]})},N={pending:"orderPending",shiping:"orderShipped",complete:"orderComplete",processing:"orderProcessing","on hold":"orderOnHold",canceled:"orderCanceled","suspected fraud":"orderSuspectedFraud","payment Review":"orderPaymentReview","order received":"orderReceived","guest order cancellation requested":"guestOrderCancellationRequested","pending payment":"orderPendingPayment",rejected:"orderRejected",authorized:"orderAuthorized","paypal canceled reversal":"orderPaypalCanceledReversal","pending paypal":"orderPendingPaypal","paypal reversed":"orderPaypalReversed",closed:"orderClosed"},oe=({slots:t,title:e,status:n,orderData:r,routeCreateReturn:u,onError:i,routeOnSuccess:d})=>{var x,E,L;const l=!!(r!=null&&r.returnNumber),c=String(n).toLocaleLowerCase(),o=(x=r==null?void 0:r.returns)==null?void 0:x[0],a=(o==null?void 0:o.returnStatus)??"",m=(o==null?void 0:o.createdReturnAt)??"",p=O({message:"Order.OrderStatusContent.orderPlaceholder.message",messageWithoutDate:"Order.OrderStatusContent.orderPlaceholder.messageWithoutDate"}),g=O(`Order.OrderStatusContent.${N[c]}.title`),h=O(`Order.OrderStatusContent.${N[c]}.message`),R=O(`Order.OrderStatusContent.${N[c]}.messageWithoutDate`),f=O({title:`Order.OrderStatusContent.returnStatus.${ee(a)}`,returnMessage:"Order.OrderStatusContent.returnMessage"});if(!n)return s("div",{});const q=g!=null&&g.title?g:{title:b(c)},v=h!=null&&h.message?h:p,F=R!=null&&R.messageWithoutDate?R:p,W=r!=null&&r.orderStatusChangeDate?v==null?void 0:v.message.replace("{DATE}",w(r==null?void 0:r.orderStatusChangeDate)):F.messageWithoutDate,j=((L=(E=f==null?void 0:f.returnMessage)==null?void 0:E.replace("{ORDER_CREATE_DATE}",w(r==null?void 0:r.orderDate)))==null?void 0:L.replace("{RETURN_CREATE_DATE}",w(m)))??"",z=l?e??(f.title||b(a)):e??q.title;return A(K,{className:"order-order-status-content",variant:"secondary",children:[s(Q,{title:z}),A("div",{className:"order-order-status-content__wrapper",children:[s("div",{className:_(["order-order-status-content__wrapper-description",["order-order-status-content__wrapper-description--actions-slot",!!(t!=null&&t.OrderActions)]]),children:s("p",{children:l?j:W})}),s(re,{orderData:r,slots:t,routeCreateReturn:u,routeOnSuccess:d,onError:i})]})]})},ie=({onError:t,routeOnSuccess:e,orderData:n,children:r})=>{const[u,i]=C(!1),d=T(()=>{i(!0);const l=n==null?void 0:n.number;Z(l).then(({success:c,userInputErrors:o})=>{c&&U(e,{}),o.length&&(t==null||t(o))}).catch(c=>{t==null||t(c.message)}).finally(()=>{i(!1)})},[n,e,t]);return s(P,{type:"button",disabled:u,variant:"secondary",className:"order-reorder",onClick:d,children:r})};export{He as OrderStatus,He as default}; +import{jsx as s,Fragment as S,jsxs as A}from"@dropins/tools/preact-jsx-runtime.js";import{Slot as $,classes as _}from"@dropins/tools/lib.js";import{Button as P,InLineAlert as B,Modal as V,Card as K,Header as Q}from"@dropins/tools/components.js";import{useState as C,useEffect as k,useCallback as T}from"@dropins/tools/preact-hooks.js";import"../chunks/ShippingStatusCard.js";import{useMemo as J}from"@dropins/tools/preact-compat.js";import{u as G}from"../chunks/useGetStoreConfig.js";import"@dropins/tools/preact.js";import{events as I}from"@dropins/tools/event-bus.js";import{a as X,c as Y,r as Z}from"../chunks/confirmCancelOrder.js";import{useText as O,Text as M}from"@dropins/tools/i18n.js";import{C as D}from"../chunks/OrderLoaders.js";import{f as ee}from"../chunks/returnOrdersHelper.js";import{f as w}from"../chunks/formatDateToLocale.js";import{c as b}from"../chunks/capitalizeFirst.js";import{r as U}from"../chunks/redirectTo.js";import{O as te}from"../chunks/OrderCancelForm.js";import"../chunks/getStoreConfig.js";import"../chunks/fetch-graphql.js";import"@dropins/tools/fetch-graphql.js";import"../chunks/network-error.js";import"../fragments.js";import"../chunks/initialize.js";import"../chunks/getFormValues.js";import"../chunks/requestGuestOrderCancel.js";var y=(t=>(t.CANCEL="CANCEL",t.RETURN="RETURN",t.REORDER="REORDER",t))(y||{});const re=({className:t,orderData:e,slots:n,routeCreateReturn:r,routeOnSuccess:u,onError:i})=>{const d=O({cancel:"Order.OrderStatusContent.actions.cancel",createReturn:"Order.OrderStatusContent.actions.createReturn",createAnotherReturn:"Order.OrderStatusContent.actions.createAnotherReturn",reorder:"Order.OrderStatusContent.actions.reorder"}),l=J(()=>{const c=e==null?void 0:e.availableActions,o=!!(c!=null&&c.length),a=!!(e!=null&&e.returnNumber),m=()=>{U(r,{},e)};return s(S,{children:n!=null&&n.OrderActions?s($,{"data-testid":"OrderActionsSlot",name:"OrderCanceledActions",slot:n==null?void 0:n.OrderActions,context:e}):s("div",{"data-testid":"availableActionsList",className:_(["order-order-actions__wrapper",["order-order-actions__wrapper--empty",!o]]),children:c==null?void 0:c.map(p=>{switch(p){case y.CANCEL:return s(S,{children:a?null:s(ce,{orderRef:(e==null?void 0:e.token)??(e==null?void 0:e.id)})});case y.RETURN:return s(P,{variant:"secondary",onClick:m,children:a?d.createAnotherReturn:d.createReturn});case y.REORDER:return s(S,{children:a?null:s(ie,{orderData:e,onError:i,routeOnSuccess:u,children:d.reorder})})}})})})},[i,e,u,r,n,d]);return s("div",{className:_(["order-order-actions",t]),children:l})},ne=({orderData:t})=>{const[e,n]=C(t),[r,u]=C(t==null?void 0:t.status);return k(()=>{const i=I.on("order/data",d=>{n(d),u(d.status)},{eager:!0});return()=>{i==null||i.off()}},[]),{orderStatus:r,order:e}},H=t=>{const e=new URL(window.location.href);t.forEach(n=>{e.searchParams.has(n)&&e.searchParams.delete(n)}),window.history.replaceState({},document.title,e.toString())},se=({enableOrderCancellation:t})=>{const e=O({cancelOrderHeading:"Order.OrderStatusContent.actions.cancel",confirmGuestReturnHeading:"Order.OrderStatusContent.actions.confirmGuestReturn",orderCancelled:"Order.OrderStatusContent.orderCanceled.message",guestRequestReturnMessage:"Order.OrderStatusContent.actions.confirmGuestReturnMessage"}),[n,r]=C(!1),[u,i]=C(!1),[d,l]=C({heading:"",text:"",status:void 0}),c=T(()=>{r(!0),H(["order_id","confirmation_key","action"])},[]),o=T((a,m,p)=>{l({heading:a,text:m,status:p}),H(["action"])},[]);return k(()=>{const a=new URLSearchParams(window.location.search),m=a.get("order_id")??"",p=a.get("confirmation_key")??"",g=a.get("action")??"";u||!m||!p||!g||(t&&g==="cancel"&&(i(!0),X(m,p).then(()=>{l({heading:e.cancelOrderHeading,text:e.orderCancelled,status:"success"})}).catch(h=>{l({heading:e.cancelOrderHeading,text:h.message,status:"warning"})})),g==="return"&&(i(!0),Y(m,p).then(()=>{l({heading:e.confirmGuestReturnHeading,text:e.guestRequestReturnMessage,status:"success"})}).catch(h=>{l({heading:e.confirmGuestReturnHeading,text:h.message,status:"warning"})})))},[t,e,o,u]),{orderActionStatus:d,isDismissed:n,onDismiss:c}},be=({slots:t,orderData:e,className:n,statusTitle:r,status:u,routeCreateReturn:i,onError:d,routeOnSuccess:l})=>{const{orderStatus:c,order:o}=ne({orderData:e}),a=G(),{orderActionStatus:m,isDismissed:p,onDismiss:g}=se({enableOrderCancellation:a==null?void 0:a.orderCancellationEnabled});return A("div",{className:_(["order-order-status",n]),children:[!p&&(m==null?void 0:m.status)!==void 0?s(B,{style:{marginBottom:"1rem"},heading:m.heading,onDismiss:g,description:m.text,type:m.status}):null,o?s(oe,{title:r,status:u||c,slots:t,orderData:o,routeCreateReturn:i,onError:d,routeOnSuccess:l}):s(D,{withCard:!1})]})},ce=({orderRef:t})=>{const[e,n]=C(!1),r=()=>{n(!0)},u=()=>{n(!1)},i=G(),d=(i==null?void 0:i.orderCancellationReasons)??[],l=c=>c.map((o,a)=>({text:o==null?void 0:o.description,value:a.toString()}));return I.on("order/data",c=>{const o=String(c.status).toLocaleLowerCase();(o==="guest order cancellation requested"||o==="canceled")&&u()}),A(S,{children:[s(P,{variant:"secondary",onClick:r,"data-testid":"cancel-button",children:s(M,{id:"Order.OrderStatusContent.actions.cancel"})}),e&&s(V,{centered:!0,size:"medium",onClose:u,className:"order-order-cancel__modal",title:s("h2",{className:"order-order-cancel__title",children:s(M,{id:"Order.OrderCancelForm.title"})}),"data-testid":"order-cancellation-reasons-modal",children:s(te,{orderRef:t,cancelReasons:l(d)})})]})},N={pending:"orderPending",shiping:"orderShipped",complete:"orderComplete",processing:"orderProcessing","on hold":"orderOnHold",canceled:"orderCanceled","suspected fraud":"orderSuspectedFraud","payment Review":"orderPaymentReview","order received":"orderReceived","guest order cancellation requested":"guestOrderCancellationRequested","pending payment":"orderPendingPayment",rejected:"orderRejected",authorized:"orderAuthorized","paypal canceled reversal":"orderPaypalCanceledReversal","pending paypal":"orderPendingPaypal","paypal reversed":"orderPaypalReversed",closed:"orderClosed"},oe=({slots:t,title:e,status:n,orderData:r,routeCreateReturn:u,onError:i,routeOnSuccess:d})=>{var x,E,L;const l=!!(r!=null&&r.returnNumber),c=String(n).toLocaleLowerCase(),o=(x=r==null?void 0:r.returns)==null?void 0:x[0],a=(o==null?void 0:o.returnStatus)??"",m=(o==null?void 0:o.createdReturnAt)??"",p=O({message:"Order.OrderStatusContent.orderPlaceholder.message",messageWithoutDate:"Order.OrderStatusContent.orderPlaceholder.messageWithoutDate"}),g=O(`Order.OrderStatusContent.${N[c]}.title`),h=O(`Order.OrderStatusContent.${N[c]}.message`),R=O(`Order.OrderStatusContent.${N[c]}.messageWithoutDate`),f=O({title:`Order.OrderStatusContent.returnStatus.${ee(a)}`,returnMessage:"Order.OrderStatusContent.returnMessage"});if(!n)return s("div",{});const q=g!=null&&g.title?g:{title:b(c)},v=h!=null&&h.message?h:p,F=R!=null&&R.messageWithoutDate?R:p,W=r!=null&&r.orderStatusChangeDate?v==null?void 0:v.message.replace("{DATE}",w(r==null?void 0:r.orderStatusChangeDate)):F.messageWithoutDate,j=((L=(E=f==null?void 0:f.returnMessage)==null?void 0:E.replace("{ORDER_CREATE_DATE}",w(r==null?void 0:r.orderDate)))==null?void 0:L.replace("{RETURN_CREATE_DATE}",w(m)))??"",z=l?e??(f.title||b(a)):e??q.title;return A(K,{className:"order-order-status-content",variant:"secondary",children:[s(Q,{title:z}),A("div",{className:"order-order-status-content__wrapper",children:[s("div",{className:_(["order-order-status-content__wrapper-description",["order-order-status-content__wrapper-description--actions-slot",!!(t!=null&&t.OrderActions)]]),children:s("p",{children:l?j:W})}),s(re,{orderData:r,slots:t,routeCreateReturn:u,routeOnSuccess:d,onError:i})]})]})},ie=({onError:t,routeOnSuccess:e,orderData:n,children:r})=>{const[u,i]=C(!1),d=T(()=>{i(!0);const l=n==null?void 0:n.number;Z(l).then(({success:c,userInputErrors:o})=>{c&&U(e,{}),o.length&&(t==null||t(o))}).catch(c=>{t==null||t(c.message)}).finally(()=>{i(!1)})},[n,e,t]);return s(P,{type:"button",disabled:u,variant:"secondary",className:"order-reorder",onClick:d,children:r})};export{be as OrderStatus,be as default}; diff --git a/scripts/__dropins__/storefront-order/containers/ReturnsList.js b/scripts/__dropins__/storefront-order/containers/ReturnsList.js index 0f701a7577..f185864eb6 100644 --- a/scripts/__dropins__/storefront-order/containers/ReturnsList.js +++ b/scripts/__dropins__/storefront-order/containers/ReturnsList.js @@ -1,3 +1,3 @@ /*! Copyright 2024 Adobe All Rights Reserved. */ -import{jsx as f}from"@dropins/tools/preact-jsx-runtime.js";import{classes as $}from"@dropins/tools/lib.js";import"@dropins/tools/components.js";import{useState as o,useEffect as g,useCallback as M}from"@dropins/tools/preact-hooks.js";import"../chunks/ShippingStatusCard.js";import"@dropins/tools/preact-compat.js";import{u as T}from"../chunks/useGetStoreConfig.js";import"@dropins/tools/preact.js";import"@dropins/tools/event-bus.js";import{g as v}from"../chunks/getCustomerOrdersReturn.js";import{u as y}from"../chunks/useIsMobile.js";import{R as A}from"../chunks/ReturnsListContent.js";import{useText as V}from"@dropins/tools/i18n.js";import"../chunks/getStoreConfig.js";import"../chunks/fetch-graphql.js";import"@dropins/tools/fetch-graphql.js";import"../chunks/network-error.js";import"../chunks/initialize.js";import"../chunks/returnOrdersHelper.js";import"../chunks/getFormValues.js";import"../chunks/OrderLoaders.js";import"../chunks/capitalizeFirst.js";const L={totalPages:1,currentPage:1,pageSize:1},k=({returnPageSize:i})=>{const[n,u]=o(!0),[s,a]=o([]),[m,l]=o(L),[t,d]=o(1);g(()=>{v(i,t).then(r=>{a((r==null?void 0:r.ordersReturn)??[]),l((r==null?void 0:r.pageInfo)??L)}).finally(()=>{u(!1)})},[i,t]),g(()=>{window==null||window.scrollTo({top:100,behavior:"smooth"})},[t]);const c=M(r=>{d(r)},[]);return{pageInfo:m,selectedPage:t,loading:n,orderReturns:s,handleSetSelectPage:c}},tr=({slots:i,withReturnsListButton:n,className:u,minifiedView:s,withHeader:a,withThumbnails:m,returnPageSize:l,returnsInMinifiedView:t,routeReturnDetails:d,routeOrderDetails:c,routeTracking:r,routeReturnsList:R,routeProductDetails:O})=>{const p=T(),{pageInfo:b,selectedPage:w,handleSetSelectPage:h,loading:N,orderReturns:P}=k({returnPageSize:l}),S=y(),e=s?"minifiedView":"fullSizeView",I=V({viewAllOrdersButton:`Order.Returns.${e}.returnsList.viewAllOrdersButton`,ariaLabelLink:`Order.Returns.${e}.returnsList.ariaLabelLink`,emptyOrdersListMessage:`Order.Returns.${e}.returnsList.emptyOrdersListMessage`,minifiedViewTitle:`Order.Returns.${e}.returnsList.minifiedViewTitle`,orderNumber:`Order.Returns.${e}.returnsList.orderNumber`,returnNumber:`Order.Returns.${e}.returnsList.returnNumber`,carrier:`Order.Returns.${e}.returnsList.carrier`});return f("div",{className:$(["order-returns-list",u]),children:f(A,{placeholderImage:(p==null?void 0:p.baseMediaUrl)??"",minifiedViewKey:e,withOrderNumber:!0,withReturnNumber:!0,slots:i,selectedPage:w,handleSetSelectPage:h,pageInfo:b,withReturnsListButton:n,isMobile:S,orderReturns:P,translations:I,withHeader:a,returnsInMinifiedView:t,withThumbnails:m,minifiedView:s,routeReturnDetails:d,routeOrderDetails:c,routeTracking:r,routeReturnsList:R,routeProductDetails:O,loading:N})})};export{tr as default}; +import{jsx as f}from"@dropins/tools/preact-jsx-runtime.js";import{classes as $}from"@dropins/tools/lib.js";import"@dropins/tools/components.js";import{useState as o,useEffect as g,useCallback as M}from"@dropins/tools/preact-hooks.js";import"../chunks/ShippingStatusCard.js";import"@dropins/tools/preact-compat.js";import{u as T}from"../chunks/useGetStoreConfig.js";import"@dropins/tools/preact.js";import"@dropins/tools/event-bus.js";import{g as v}from"../chunks/getCustomerOrdersReturn.js";import{u as y}from"../chunks/useIsMobile.js";import{R as A}from"../chunks/ReturnsListContent.js";import{useText as V}from"@dropins/tools/i18n.js";import"../chunks/getStoreConfig.js";import"../chunks/fetch-graphql.js";import"@dropins/tools/fetch-graphql.js";import"../chunks/network-error.js";import"../fragments.js";import"../chunks/initialize.js";import"../chunks/returnOrdersHelper.js";import"../chunks/getFormValues.js";import"../chunks/OrderLoaders.js";import"../chunks/capitalizeFirst.js";const L={totalPages:1,currentPage:1,pageSize:1},k=({returnPageSize:i})=>{const[n,u]=o(!0),[s,a]=o([]),[m,l]=o(L),[t,d]=o(1);g(()=>{v(i,t).then(r=>{a((r==null?void 0:r.ordersReturn)??[]),l((r==null?void 0:r.pageInfo)??L)}).finally(()=>{u(!1)})},[i,t]),g(()=>{window==null||window.scrollTo({top:100,behavior:"smooth"})},[t]);const c=M(r=>{d(r)},[]);return{pageInfo:m,selectedPage:t,loading:n,orderReturns:s,handleSetSelectPage:c}},ir=({slots:i,withReturnsListButton:n,className:u,minifiedView:s,withHeader:a,withThumbnails:m,returnPageSize:l,returnsInMinifiedView:t,routeReturnDetails:d,routeOrderDetails:c,routeTracking:r,routeReturnsList:R,routeProductDetails:O})=>{const p=T(),{pageInfo:b,selectedPage:w,handleSetSelectPage:h,loading:N,orderReturns:P}=k({returnPageSize:l}),S=y(),e=s?"minifiedView":"fullSizeView",I=V({viewAllOrdersButton:`Order.Returns.${e}.returnsList.viewAllOrdersButton`,ariaLabelLink:`Order.Returns.${e}.returnsList.ariaLabelLink`,emptyOrdersListMessage:`Order.Returns.${e}.returnsList.emptyOrdersListMessage`,minifiedViewTitle:`Order.Returns.${e}.returnsList.minifiedViewTitle`,orderNumber:`Order.Returns.${e}.returnsList.orderNumber`,returnNumber:`Order.Returns.${e}.returnsList.returnNumber`,carrier:`Order.Returns.${e}.returnsList.carrier`});return f("div",{className:$(["order-returns-list",u]),children:f(A,{placeholderImage:(p==null?void 0:p.baseMediaUrl)??"",minifiedViewKey:e,withOrderNumber:!0,withReturnNumber:!0,slots:i,selectedPage:w,handleSetSelectPage:h,pageInfo:b,withReturnsListButton:n,isMobile:S,orderReturns:P,translations:I,withHeader:a,returnsInMinifiedView:t,withThumbnails:m,minifiedView:s,routeReturnDetails:d,routeOrderDetails:c,routeTracking:r,routeReturnsList:R,routeProductDetails:O,loading:N})})};export{ir as default}; diff --git a/scripts/__dropins__/storefront-order/fragments.d.ts b/scripts/__dropins__/storefront-order/fragments.d.ts new file mode 100644 index 0000000000..4d0b3af3f9 --- /dev/null +++ b/scripts/__dropins__/storefront-order/fragments.d.ts @@ -0,0 +1 @@ +export * from './api/fragments' diff --git a/scripts/__dropins__/storefront-order/fragments.js b/scripts/__dropins__/storefront-order/fragments.js new file mode 100644 index 0000000000..5b3b46ff34 --- /dev/null +++ b/scripts/__dropins__/storefront-order/fragments.js @@ -0,0 +1,314 @@ +const R = ` + fragment REQUEST_RETURN_ORDER_FRAGMENT on Return { + __typename + uid + status + number + created_at + } +`, e = (`fragment ADDRESS_FRAGMENT on OrderAddress { + city + company + country_code + fax + firstname + lastname + middlename + postcode + prefix + region + region_id + street + suffix + telephone + vat_id +}`), t = ` + fragment PRODUCT_DETAILS_FRAGMENT on ProductInterface { + __typename + canonical_url + url_key + uid + name + sku + only_x_left_in_stock + stock_status + thumbnail { + label + url + } + price_range { + maximum_price { + regular_price { + currency + value + } + } + } + } +`, _ = ` + fragment PRICE_DETAILS_FRAGMENT on OrderItemInterface { + prices { + price_including_tax { + value + currency + } + original_price { + value + currency + } + original_price_including_tax { + value + currency + } + price { + value + currency + } + } + } +`, r = ` + fragment GIFT_CARD_DETAILS_FRAGMENT on GiftCardOrderItem { + ...PRICE_DETAILS_FRAGMENT + gift_message { + message + } + gift_card { + recipient_name + recipient_email + sender_name + sender_email + message + } + } +`, n = ` + fragment ORDER_ITEM_DETAILS_FRAGMENT on OrderItemInterface { + __typename + status + product_sku + eligible_for_return + product_name + product_url_key + id + quantity_ordered + quantity_shipped + quantity_canceled + quantity_invoiced + quantity_refunded + quantity_return_requested + product_sale_price { + value + currency + } + selected_options { + label + value + } + product { + ...PRODUCT_DETAILS_FRAGMENT + } + ...PRICE_DETAILS_FRAGMENT + } +`, a = ` + fragment BUNDLE_ORDER_ITEM_DETAILS_FRAGMENT on BundleOrderItem { + ...PRICE_DETAILS_FRAGMENT + bundle_options { + uid + label + values { + uid + product_name + } + } + } +`, i = ` + fragment ORDER_SUMMARY_FRAGMENT on OrderTotal { + grand_total { + value + currency + } + total_giftcard { + currency + value + } + subtotal_excl_tax { + currency + value + } + subtotal_incl_tax { + currency + value + } + taxes { + amount { + currency + value + } + rate + title + } + total_tax { + currency + value + } + total_shipping { + currency + value + } + discounts { + amount { + currency + value + } + label + } + } +`, E = ` + fragment RETURNS_FRAGMENT on Returns { + __typename + items { + number + status + created_at + shipping { + tracking { + status { + text + type + } + carrier { + uid + label + } + tracking_number + } + } + order { + number + token + } + items { + uid + quantity + status + request_quantity + order_item { + ...ORDER_ITEM_DETAILS_FRAGMENT + ... on GiftCardOrderItem { + ...GIFT_CARD_DETAILS_FRAGMENT + product { + ...PRODUCT_DETAILS_FRAGMENT + } + } + } + } + } + } +`, u = ` + fragment GUEST_ORDER_FRAGMENT on CustomerOrder { + email + id + number + order_date + order_status_change_date + status + token + carrier + shipping_method + printed_card_included + gift_receipt_included + available_actions + is_virtual + items_eligible_for_return { + ...ORDER_ITEM_DETAILS_FRAGMENT + } + returns { + ...RETURNS_FRAGMENT + } + payment_methods { + name + type + } + applied_coupons { + code + } + shipments { + id + tracking { + title + number + carrier + } + comments { + message + timestamp + } + items { + __typename + id + product_sku + product_name + order_item { + ...ORDER_ITEM_DETAILS_FRAGMENT + ... on GiftCardOrderItem { + ...GIFT_CARD_DETAILS_FRAGMENT + product { + ...PRODUCT_DETAILS_FRAGMENT + } + } + } + } + } + payment_methods { + name + type + } + shipping_address { + ...ADDRESS_FRAGMENT + } + billing_address { + ...ADDRESS_FRAGMENT + } + items { + ...ORDER_ITEM_DETAILS_FRAGMENT + ... on BundleOrderItem { + ...BUNDLE_ORDER_ITEM_DETAILS_FRAGMENT + } + ... on GiftCardOrderItem { + ...GIFT_CARD_DETAILS_FRAGMENT + product { + ...PRODUCT_DETAILS_FRAGMENT + } + } + ... on DownloadableOrderItem { + product_name + downloadable_links { + sort_order + title + } + } + } + total { + ...ORDER_SUMMARY_FRAGMENT + } + } + ${t} + ${_} + ${r} + ${n} + ${a} + ${i} + ${e} + ${E} +`; +export { +e as ADDRESS_FRAGMENT, +a as BUNDLE_ORDER_ITEM_DETAILS_FRAGMENT, +r as GIFT_CARD_DETAILS_FRAGMENT, +u as GUEST_ORDER_FRAGMENT, +n as ORDER_ITEM_DETAILS_FRAGMENT, +i as ORDER_SUMMARY_FRAGMENT, +_ as PRICE_DETAILS_FRAGMENT, +t as PRODUCT_DETAILS_FRAGMENT, +R as REQUEST_RETURN_ORDER_FRAGMENT, +E as RETURNS_FRAGMENT +}; \ No newline at end of file diff --git a/scripts/__dropins__/storefront-order/fragments.original.js b/scripts/__dropins__/storefront-order/fragments.original.js new file mode 100644 index 0000000000..5908a7657e --- /dev/null +++ b/scripts/__dropins__/storefront-order/fragments.original.js @@ -0,0 +1,306 @@ +/*! Copyright 2024 Adobe +All Rights Reserved. */ +const R=` + fragment REQUEST_RETURN_ORDER_FRAGMENT on Return { + __typename + uid + status + number + created_at + } +`,e=` + fragment ADDRESS_FRAGMENT on OrderAddress { + city + company + country_code + fax + firstname + lastname + middlename + postcode + prefix + region + region_id + street + suffix + telephone + vat_id + } +`,t=` + fragment PRODUCT_DETAILS_FRAGMENT on ProductInterface { + __typename + canonical_url + url_key + uid + name + sku + only_x_left_in_stock + stock_status + thumbnail { + label + url + } + price_range { + maximum_price { + regular_price { + currency + value + } + } + } + } +`,_=` + fragment PRICE_DETAILS_FRAGMENT on OrderItemInterface { + prices { + price_including_tax { + value + currency + } + original_price { + value + currency + } + original_price_including_tax { + value + currency + } + price { + value + currency + } + } + } +`,r=` + fragment GIFT_CARD_DETAILS_FRAGMENT on GiftCardOrderItem { + ...PRICE_DETAILS_FRAGMENT + gift_message { + message + } + gift_card { + recipient_name + recipient_email + sender_name + sender_email + message + } + } +`,n=` + fragment ORDER_ITEM_DETAILS_FRAGMENT on OrderItemInterface { + __typename + status + product_sku + eligible_for_return + product_name + product_url_key + id + quantity_ordered + quantity_shipped + quantity_canceled + quantity_invoiced + quantity_refunded + quantity_return_requested + product_sale_price { + value + currency + } + selected_options { + label + value + } + product { + ...PRODUCT_DETAILS_FRAGMENT + } + ...PRICE_DETAILS_FRAGMENT + } +`,a=` + fragment BUNDLE_ORDER_ITEM_DETAILS_FRAGMENT on BundleOrderItem { + ...PRICE_DETAILS_FRAGMENT + bundle_options { + uid + label + values { + uid + product_name + } + } + } +`,i=` + fragment ORDER_SUMMARY_FRAGMENT on OrderTotal { + grand_total { + value + currency + } + total_giftcard { + currency + value + } + subtotal_excl_tax { + currency + value + } + subtotal_incl_tax { + currency + value + } + taxes { + amount { + currency + value + } + rate + title + } + total_tax { + currency + value + } + total_shipping { + currency + value + } + discounts { + amount { + currency + value + } + label + } + } +`,E=` + fragment RETURNS_FRAGMENT on Returns { + __typename + items { + number + status + created_at + shipping { + tracking { + status { + text + type + } + carrier { + uid + label + } + tracking_number + } + } + order { + number + token + } + items { + uid + quantity + status + request_quantity + order_item { + ...ORDER_ITEM_DETAILS_FRAGMENT + ... on GiftCardOrderItem { + ...GIFT_CARD_DETAILS_FRAGMENT + product { + ...PRODUCT_DETAILS_FRAGMENT + } + } + } + } + } + } +`,u=` + fragment GUEST_ORDER_FRAGMENT on CustomerOrder { + email + id + number + order_date + order_status_change_date + status + token + carrier + shipping_method + printed_card_included + gift_receipt_included + available_actions + is_virtual + items_eligible_for_return { + ...ORDER_ITEM_DETAILS_FRAGMENT + } + returns { + ...RETURNS_FRAGMENT + } + payment_methods { + name + type + } + applied_coupons { + code + } + shipments { + id + tracking { + title + number + carrier + } + comments { + message + timestamp + } + items { + __typename + id + product_sku + product_name + order_item { + ...ORDER_ITEM_DETAILS_FRAGMENT + ... on GiftCardOrderItem { + ...GIFT_CARD_DETAILS_FRAGMENT + product { + ...PRODUCT_DETAILS_FRAGMENT + } + } + } + } + } + payment_methods { + name + type + } + shipping_address { + ...ADDRESS_FRAGMENT + } + billing_address { + ...ADDRESS_FRAGMENT + } + items { + ...ORDER_ITEM_DETAILS_FRAGMENT + ... on BundleOrderItem { + ...BUNDLE_ORDER_ITEM_DETAILS_FRAGMENT + } + ... on GiftCardOrderItem { + ...GIFT_CARD_DETAILS_FRAGMENT + product { + ...PRODUCT_DETAILS_FRAGMENT + } + } + ... on DownloadableOrderItem { + product_name + downloadable_links { + sort_order + title + } + } + } + total { + ...ORDER_SUMMARY_FRAGMENT + } + } + ${t} + ${_} + ${r} + ${n} + ${a} + ${i} + ${e} + ${E} +`;export{e as ADDRESS_FRAGMENT,a as BUNDLE_ORDER_ITEM_DETAILS_FRAGMENT,r as GIFT_CARD_DETAILS_FRAGMENT,u as GUEST_ORDER_FRAGMENT,n as ORDER_ITEM_DETAILS_FRAGMENT,i as ORDER_SUMMARY_FRAGMENT,_ as PRICE_DETAILS_FRAGMENT,t as PRODUCT_DETAILS_FRAGMENT,R as REQUEST_RETURN_ORDER_FRAGMENT,E as RETURNS_FRAGMENT}; diff --git a/scripts/__dropins__/storefront-pdp/__mocks__/product-mocks.d.ts b/scripts/__dropins__/storefront-pdp/__mocks__/product-mocks.d.ts index 0583bef6fb..a28578fd4f 100644 --- a/scripts/__dropins__/storefront-pdp/__mocks__/product-mocks.d.ts +++ b/scripts/__dropins__/storefront-pdp/__mocks__/product-mocks.d.ts @@ -91,6 +91,7 @@ export declare const MOCK_DATA_BUNDLE: { export declare const MOCK_DATA_BUNDLE_TRANSFORMED: { name: string; sku: string; + isBundle: boolean; addToCartAllowed: boolean; inStock: boolean; shortDescription: string; diff --git a/scripts/__dropins__/storefront-pdp/api.js b/scripts/__dropins__/storefront-pdp/api.js index beedc21372..e03a44ad5d 100644 --- a/scripts/__dropins__/storefront-pdp/api.js +++ b/scripts/__dropins__/storefront-pdp/api.js @@ -1 +1,3 @@ -import{f as s,g as o,c as i,d as c,r as p,s as d,a as h,b as f}from"./chunks/getRefinedProduct.js";import{c as n,i as l}from"./chunks/initialize.js";import"@dropins/tools/fetch-graphql.js";import"@dropins/tools/lib.js";export{n as config,s as fetchGraphQl,o as getConfig,i as getProductData,c as getRefinedProduct,l as initialize,p as removeFetchGraphQlHeader,d as setEndpoint,h as setFetchGraphQlHeader,f as setFetchGraphQlHeaders}; +/*! Copyright 2024 Adobe +All Rights Reserved. */ +import{c as s,f as i,h as d,g as c,d as g,e as n,i as u,k as f,r as h,s as p,a as l,b as P,j as m}from"./chunks/isProductConfigurationValid.js";import{g as F,s as G}from"./chunks/getProductConfigurationValues.js";import{g as V}from"./chunks/getFetchedProductData.js";import"@dropins/tools/lib.js";import"@dropins/tools/event-bus.js";import"@dropins/tools/fetch-graphql.js";export{s as config,i as fetchGraphQl,d as fetchProductData,c as getConfig,V as getFetchedProductData,F as getProductConfigurationValues,g as getProductData,n as getRefinedProduct,u as initialize,f as isProductConfigurationValid,h as removeFetchGraphQlHeader,p as setEndpoint,l as setFetchGraphQlHeader,P as setFetchGraphQlHeaders,m as setProductConfigurationValid,G as setProductConfigurationValues}; diff --git a/scripts/__dropins__/storefront-pdp/api/fetchProductData/fetchProductData.d.ts b/scripts/__dropins__/storefront-pdp/api/fetchProductData/fetchProductData.d.ts new file mode 100644 index 0000000000..20debb6d4e --- /dev/null +++ b/scripts/__dropins__/storefront-pdp/api/fetchProductData/fetchProductData.d.ts @@ -0,0 +1,24 @@ +/** + * ADOBE CONFIDENTIAL + * __________________ + * Copyright 2024 Adobe + * All Rights Reserved. + * __________________ + * NOTICE: All information contained herein is, and remains + * the property of Adobe and its suppliers, if any. The intellectual + * and technical concepts contained herein are proprietary to Adobe + * and its suppliers and are protected by all applicable intellectual + * property laws, including trade secret and copyright laws. + * Dissemination of this information or reproduction of this material + * is strictly forbidden unless prior written permission is obtained + * from Adobe. + */ +export type Options = { + anchors?: string[]; + optionsUIDs?: string[]; + preselectFirstOption?: boolean; + isBundle?: boolean; + skipTransform?: boolean; +}; +export declare const fetchProductData: (sku: string, options?: Options) => Promise; +//# sourceMappingURL=fetchProductData.d.ts.map \ No newline at end of file diff --git a/scripts/__dropins__/storefront-pdp/api/fetchProductData/index.d.ts b/scripts/__dropins__/storefront-pdp/api/fetchProductData/index.d.ts new file mode 100644 index 0000000000..4359f3fa31 --- /dev/null +++ b/scripts/__dropins__/storefront-pdp/api/fetchProductData/index.d.ts @@ -0,0 +1,17 @@ +/** + * ADOBE CONFIDENTIAL + * __________________ + * Copyright 2024 Adobe + * All Rights Reserved. + * __________________ + * NOTICE: All information contained herein is, and remains + * the property of Adobe and its suppliers, if any. The intellectual + * and technical concepts contained herein are proprietary to Adobe + * and its suppliers and are protected by all applicable intellectual + * property laws, including trade secret and copyright laws. + * Dissemination of this information or reproduction of this material + * is strictly forbidden unless prior written permission is obtained + * from Adobe. + */ +export * from './fetchProductData'; +//# sourceMappingURL=index.d.ts.map \ No newline at end of file diff --git a/scripts/__dropins__/storefront-pdp/api/getFetchedProductData/getFetchedProductData.d.ts b/scripts/__dropins__/storefront-pdp/api/getFetchedProductData/getFetchedProductData.d.ts new file mode 100644 index 0000000000..c0578e840c --- /dev/null +++ b/scripts/__dropins__/storefront-pdp/api/getFetchedProductData/getFetchedProductData.d.ts @@ -0,0 +1,4 @@ +import { ProductModel } from '../../data/models/product-model'; + +export declare const getFetchedProductData: () => Promise; +//# sourceMappingURL=getFetchedProductData.d.ts.map \ No newline at end of file diff --git a/scripts/__dropins__/storefront-pdp/api/getFetchedProductData/index.d.ts b/scripts/__dropins__/storefront-pdp/api/getFetchedProductData/index.d.ts new file mode 100644 index 0000000000..fc0b77048a --- /dev/null +++ b/scripts/__dropins__/storefront-pdp/api/getFetchedProductData/index.d.ts @@ -0,0 +1,17 @@ +/** + * ADOBE CONFIDENTIAL + * __________________ + * Copyright 2024 Adobe + * All Rights Reserved. + * __________________ + * NOTICE: All information contained herein is, and remains + * the property of Adobe and its suppliers, if any. The intellectual + * and technical concepts contained herein are proprietary to Adobe + * and its suppliers and are protected by all applicable intellectual + * property laws, including trade secret and copyright laws. + * Dissemination of this information or reproduction of this material + * is strictly forbidden unless prior written permission is obtained + * from Adobe. + */ +export * from './getFetchedProductData'; +//# sourceMappingURL=index.d.ts.map \ No newline at end of file diff --git a/scripts/__dropins__/storefront-pdp/api/getProductConfigurationValues/getProductConfigurationValues.d.ts b/scripts/__dropins__/storefront-pdp/api/getProductConfigurationValues/getProductConfigurationValues.d.ts new file mode 100644 index 0000000000..fd9cc4a6aa --- /dev/null +++ b/scripts/__dropins__/storefront-pdp/api/getProductConfigurationValues/getProductConfigurationValues.d.ts @@ -0,0 +1,4 @@ +import { ValuesModel } from '../../data/models'; + +export declare const getProductConfigurationValues: () => ValuesModel | null; +//# sourceMappingURL=getProductConfigurationValues.d.ts.map \ No newline at end of file diff --git a/scripts/__dropins__/storefront-pdp/api/getProductConfigurationValues/index.d.ts b/scripts/__dropins__/storefront-pdp/api/getProductConfigurationValues/index.d.ts new file mode 100644 index 0000000000..d2af5c5c5e --- /dev/null +++ b/scripts/__dropins__/storefront-pdp/api/getProductConfigurationValues/index.d.ts @@ -0,0 +1,17 @@ +/** + * ADOBE CONFIDENTIAL + * __________________ + * Copyright 2024 Adobe + * All Rights Reserved. + * __________________ + * NOTICE: All information contained herein is, and remains + * the property of Adobe and its suppliers, if any. The intellectual + * and technical concepts contained herein are proprietary to Adobe + * and its suppliers and are protected by all applicable intellectual + * property laws, including trade secret and copyright laws. + * Dissemination of this information or reproduction of this material + * is strictly forbidden unless prior written permission is obtained + * from Adobe. + */ +export * from './getProductConfigurationValues'; +//# sourceMappingURL=index.d.ts.map \ No newline at end of file diff --git a/scripts/__dropins__/storefront-pdp/api/getProductData/getProductData.d.ts b/scripts/__dropins__/storefront-pdp/api/getProductData/getProductData.d.ts index 00cc3fc96a..2cdb94108e 100644 --- a/scripts/__dropins__/storefront-pdp/api/getProductData/getProductData.d.ts +++ b/scripts/__dropins__/storefront-pdp/api/getProductData/getProductData.d.ts @@ -1,4 +1,7 @@ import { ProductModel } from '../../data/models'; -export declare const getProductData: (sku: string) => Promise; +export declare const getProductData: (sku: string, options?: { + preselectFirstOption?: boolean; + optionsUIDs?: string[]; +}, raw?: boolean) => Promise; //# sourceMappingURL=getProductData.d.ts.map \ No newline at end of file diff --git a/scripts/__dropins__/storefront-pdp/api/getRefinedProduct/getRefinedProduct.d.ts b/scripts/__dropins__/storefront-pdp/api/getRefinedProduct/getRefinedProduct.d.ts index 5c7ec9a4d7..6442000fae 100644 --- a/scripts/__dropins__/storefront-pdp/api/getRefinedProduct/getRefinedProduct.d.ts +++ b/scripts/__dropins__/storefront-pdp/api/getRefinedProduct/getRefinedProduct.d.ts @@ -1,4 +1,4 @@ import { ProductModel } from '../../data/models'; -export declare const getRefinedProduct: (sku: string, optionUIDs: string[], anchorOptions?: string[], isBundle?: boolean) => Promise; +export declare const getRefinedProduct: (sku: string, optionUIDs: string[], anchorOptions?: string[], raw?: boolean) => Promise; //# sourceMappingURL=getRefinedProduct.d.ts.map \ No newline at end of file diff --git a/scripts/__dropins__/storefront-pdp/api/index.d.ts b/scripts/__dropins__/storefront-pdp/api/index.d.ts index f3e6257bbf..4afc0b5d31 100644 --- a/scripts/__dropins__/storefront-pdp/api/index.d.ts +++ b/scripts/__dropins__/storefront-pdp/api/index.d.ts @@ -17,4 +17,10 @@ export * from './initialize'; export * from './fetch-graphql'; export * from './getProductData'; export * from './getRefinedProduct'; +export * from './fetchProductData'; +export * from './setProductConfigurationValues'; +export * from './getProductConfigurationValues'; +export * from './setProductConfigurationValid'; +export * from './getFetchedProductData'; +export * from './isProductConfigurationValid'; //# sourceMappingURL=index.d.ts.map \ No newline at end of file diff --git a/scripts/__dropins__/storefront-pdp/api/initialize/initialize.d.ts b/scripts/__dropins__/storefront-pdp/api/initialize/initialize.d.ts index 07b5b62c7e..ae0335fb47 100644 --- a/scripts/__dropins__/storefront-pdp/api/initialize/initialize.d.ts +++ b/scripts/__dropins__/storefront-pdp/api/initialize/initialize.d.ts @@ -5,10 +5,18 @@ import { ProductModel } from '../../data/models'; type ConfigProps = { langDefinitions?: Lang; defaultLocale?: string; + sku?: string; + acdl?: boolean; + anchors?: string[]; + persistURLParams?: boolean; + preselectFirstOption?: boolean; + optionsUIDs?: string[]; models?: { [name: string]: { initialData: any; - transform: (data?: ProductModel) => ProductModel; + /** @deprecated Use "transformer" instead */ + transform?: (data?: ProductModel) => ProductModel; + transformer?: (data?: ProductModel) => ProductModel; fallbackData?: (parentProduct: any, simpleProduct: ProductModel) => ProductModel; }; }; diff --git a/scripts/__dropins__/storefront-pdp/api/isProductConfigurationValid/index.d.ts b/scripts/__dropins__/storefront-pdp/api/isProductConfigurationValid/index.d.ts new file mode 100644 index 0000000000..f06819c6b4 --- /dev/null +++ b/scripts/__dropins__/storefront-pdp/api/isProductConfigurationValid/index.d.ts @@ -0,0 +1,17 @@ +/** + * ADOBE CONFIDENTIAL + * __________________ + * Copyright 2024 Adobe + * All Rights Reserved. + * __________________ + * NOTICE: All information contained herein is, and remains + * the property of Adobe and its suppliers, if any. The intellectual + * and technical concepts contained herein are proprietary to Adobe + * and its suppliers and are protected by all applicable intellectual + * property laws, including trade secret and copyright laws. + * Dissemination of this information or reproduction of this material + * is strictly forbidden unless prior written permission is obtained + * from Adobe. + */ +export * from './isProductConfigurationValid'; +//# sourceMappingURL=index.d.ts.map \ No newline at end of file diff --git a/scripts/__dropins__/storefront-pdp/api/isProductConfigurationValid/isProductConfigurationValid.d.ts b/scripts/__dropins__/storefront-pdp/api/isProductConfigurationValid/isProductConfigurationValid.d.ts new file mode 100644 index 0000000000..15505ef040 --- /dev/null +++ b/scripts/__dropins__/storefront-pdp/api/isProductConfigurationValid/isProductConfigurationValid.d.ts @@ -0,0 +1,17 @@ +/** + * ADOBE CONFIDENTIAL + * __________________ + * Copyright 2024 Adobe + * All Rights Reserved. + * __________________ + * NOTICE: All information contained herein is, and remains + * the property of Adobe and its suppliers, if any. The intellectual + * and technical concepts contained herein are proprietary to Adobe + * and its suppliers and are protected by all applicable intellectual + * property laws, including trade secret and copyright laws. + * Dissemination of this information or reproduction of this material + * is strictly forbidden unless prior written permission is obtained + * from Adobe. + */ +export declare const isProductConfigurationValid: () => boolean | null; +//# sourceMappingURL=isProductConfigurationValid.d.ts.map \ No newline at end of file diff --git a/scripts/__dropins__/storefront-pdp/api/setProductConfigurationValid/index.d.ts b/scripts/__dropins__/storefront-pdp/api/setProductConfigurationValid/index.d.ts new file mode 100644 index 0000000000..0beb9a0a43 --- /dev/null +++ b/scripts/__dropins__/storefront-pdp/api/setProductConfigurationValid/index.d.ts @@ -0,0 +1,17 @@ +/** + * ADOBE CONFIDENTIAL + * __________________ + * Copyright 2024 Adobe + * All Rights Reserved. + * __________________ + * NOTICE: All information contained herein is, and remains + * the property of Adobe and its suppliers, if any. The intellectual + * and technical concepts contained herein are proprietary to Adobe + * and its suppliers and are protected by all applicable intellectual + * property laws, including trade secret and copyright laws. + * Dissemination of this information or reproduction of this material + * is strictly forbidden unless prior written permission is obtained + * from Adobe. + */ +export * from './setProductConfigurationValid'; +//# sourceMappingURL=index.d.ts.map \ No newline at end of file diff --git a/scripts/__dropins__/storefront-pdp/api/setProductConfigurationValid/setProductConfigurationValid.d.ts b/scripts/__dropins__/storefront-pdp/api/setProductConfigurationValid/setProductConfigurationValid.d.ts new file mode 100644 index 0000000000..d3da4f8f3a --- /dev/null +++ b/scripts/__dropins__/storefront-pdp/api/setProductConfigurationValid/setProductConfigurationValid.d.ts @@ -0,0 +1,17 @@ +/** + * ADOBE CONFIDENTIAL + * __________________ + * Copyright 2024 Adobe + * All Rights Reserved. + * __________________ + * NOTICE: All information contained herein is, and remains + * the property of Adobe and its suppliers, if any. The intellectual + * and technical concepts contained herein are proprietary to Adobe + * and its suppliers and are protected by all applicable intellectual + * property laws, including trade secret and copyright laws. + * Dissemination of this information or reproduction of this material + * is strictly forbidden unless prior written permission is obtained + * from Adobe. + */ +export declare const setProductConfigurationValid: (callback: (prev: boolean) => boolean) => void; +//# sourceMappingURL=setProductConfigurationValid.d.ts.map \ No newline at end of file diff --git a/scripts/__dropins__/storefront-pdp/api/setProductConfigurationValues/index.d.ts b/scripts/__dropins__/storefront-pdp/api/setProductConfigurationValues/index.d.ts new file mode 100644 index 0000000000..bd96ba1193 --- /dev/null +++ b/scripts/__dropins__/storefront-pdp/api/setProductConfigurationValues/index.d.ts @@ -0,0 +1,17 @@ +/** + * ADOBE CONFIDENTIAL + * __________________ + * Copyright 2024 Adobe + * All Rights Reserved. + * __________________ + * NOTICE: All information contained herein is, and remains + * the property of Adobe and its suppliers, if any. The intellectual + * and technical concepts contained herein are proprietary to Adobe + * and its suppliers and are protected by all applicable intellectual + * property laws, including trade secret and copyright laws. + * Dissemination of this information or reproduction of this material + * is strictly forbidden unless prior written permission is obtained + * from Adobe. + */ +export * from './setProductConfigurationValues'; +//# sourceMappingURL=index.d.ts.map \ No newline at end of file diff --git a/scripts/__dropins__/storefront-pdp/api/setProductConfigurationValues/setProductConfigurationValues.d.ts b/scripts/__dropins__/storefront-pdp/api/setProductConfigurationValues/setProductConfigurationValues.d.ts new file mode 100644 index 0000000000..8adf840fa9 --- /dev/null +++ b/scripts/__dropins__/storefront-pdp/api/setProductConfigurationValues/setProductConfigurationValues.d.ts @@ -0,0 +1,4 @@ +import { ValuesModel } from '../../data/models'; + +export declare const setProductConfigurationValues: (callback: (prev: ValuesModel) => ValuesModel) => void; +//# sourceMappingURL=setProductConfigurationValues.d.ts.map \ No newline at end of file diff --git a/scripts/__dropins__/storefront-pdp/chunks/PriceRange.js b/scripts/__dropins__/storefront-pdp/chunks/PriceRange.js new file mode 100644 index 0000000000..cc5535a55d --- /dev/null +++ b/scripts/__dropins__/storefront-pdp/chunks/PriceRange.js @@ -0,0 +1,3 @@ +/*! Copyright 2024 Adobe +All Rights Reserved. */ +import{jsx as r,Fragment as h,jsxs as l}from"@dropins/tools/preact-jsx-runtime.js";/* empty css */import{Price as s}from"@dropins/tools/components.js";const o=({amount:e,currency:p,locale:d,variant:g,sale:t,minimumAmount:i,maximumAmount:n,className:a,...c})=>r(h,{children:e||i===n?r("div",{className:"pdp-price-range",...c,children:r(s,{amount:e||i,currency:p,locale:d,variant:g,sale:t,className:a})}):l("div",{className:"pdp-price-range",...c,children:[r(s,{amount:i,currency:p,locale:d,className:a}),r("span",{className:"pdp-price-range__label",children:"-"}),r(s,{amount:n,currency:p,locale:d,className:a})]})});export{o as P}; diff --git a/scripts/__dropins__/storefront-pdp/chunks/Swatches.js b/scripts/__dropins__/storefront-pdp/chunks/Swatches.js new file mode 100644 index 0000000000..cf3c448f42 --- /dev/null +++ b/scripts/__dropins__/storefront-pdp/chunks/Swatches.js @@ -0,0 +1,3 @@ +/*! Copyright 2024 Adobe +All Rights Reserved. */ +import{jsx as h,jsxs as J}from"@dropins/tools/preact-jsx-runtime.js";import{useState as M,useEffect as P,useMemo as R,useCallback as _}from"@dropins/tools/preact-compat.js";import{classes as N}from"@dropins/tools/lib.js";import{Picker as z,ColorSwatch as A,ImageSwatch as y,TextSwatch as B}from"@dropins/tools/components.js";/* empty css */import{useText as C}from"@dropins/tools/i18n.js";const D=["text","image","color","dropdown"],F=d=>d.map(s=>({...s,text:s.label,disabled:!s.inStock}));function G(d,s){return d.reduce((x,i)=>{const n=s==null?void 0:s.find(f=>f.items.find(w=>w.id===i));if(!n)return x;const b=n.items.find(f=>f.id===i);return{...x,[n.id]:{label:b.label,value:b.id}}},{})}const E=({options:d,hideSelectedValue:s,disablePreselections:x,selectedUIDs:i,onValues:n,onErrors:b,defaultOptions:f,selectionsToUpdate:w,className:L,children:H,...O})=>{const q=C("PDP.Swatches.Required.label").label,k=C("PDP.Swatches.ChooseOption.label").label,[S,m]=M(()=>d==null?void 0:d.reduce((r,e)=>{const{items:a}=e,t=a==null?void 0:a.find(c=>f==null?void 0:f.includes(c.id)),u=a==null?void 0:a.find(c=>c.selected);return t?{...r,[e.id]:{label:t.label,value:t.id}}:u?{...r,[e.id]:{label:u.label,value:u.id}}:r},{}));P(()=>{if(i){const l=G(i,d);if(JSON.stringify(l)===JSON.stringify(S))return;m(r=>{let e={...r,...l};return n==null||n(e),e})}},[i]),P(()=>{w==null||w.forEach(l=>{m(r=>{var t;const e=(t=l==null?void 0:l.items)==null?void 0:t.find(u=>u.selected);return e?{...r,[l.id]:{label:e==null?void 0:e.label,value:e==null?void 0:e.id}}:r})})},[w,m]),R(()=>{const l=d==null?void 0:d.reduce((r,e)=>{var t;let a=!1;return(t=e==null?void 0:e.items)==null||t.forEach(u=>{var v;((v=S[e.id])==null?void 0:v.value)===u.id&&(a=!0)}),e.required&&!a&&(r[e.id]=q),r},{});return b==null||b(l),l},[S]);const g=_((l,r,e)=>{m(a=>{let t={...a,...l&&{[l]:{label:r,value:e}}};return r===k&&delete t[l],n==null||n(t,e),t})},[n]),$=_((l,r)=>{var a;const e=((a=r.selectedOptions[0])==null?void 0:a.label)??"";g(l,e,r.value)},[g]),j=_(({items:l,id:r,required:e,type:a,selected:t,label:u})=>(l==null?void 0:l.length)>0&&h("div",{className:N(["pdp-swatches__options"]),children:(a==null?void 0:a.toLowerCase())==="dropdown"?h(z,{"aria-label":u,placeholder:x?k:void 0,handleSelect:c=>$(r,c.target),options:F(l),value:t}):l==null?void 0:l.map(c=>{const v={key:c.id,id:c.id,name:r,value:c.value,label:c.label,groupAriaLabel:u,selected:t===c.id,outOfStock:!c.inStock,required:e===null?!0:e,onValue:()=>{g(r,c.label,c.id)}};switch(a){case"text":return h(B,{...v,label:c.label});case"image":return h(y,{...v,src:c.value,alt:c.label});case"color":return h(A,{...v,size:"large",color:c.value});default:return console.warn(`Invalid swatch type ${a}`),null}})}),[k,g,$]);return h("div",{...O,className:N(["pdp-swatches",L]),children:d==null?void 0:d.map(({type:l,label:r,id:e,multiple:a,required:t,items:u})=>{var c;return D.includes(l)||console.warn(`Invalid swatch type ${l}`),a&&console.warn("Multiple selection swatches are not currently supported."),J("div",{id:`swatch-item-${e}`,"data-slot-key":`product-swatch--${e}`,className:"pdp-swatches__field",children:[h("div",{className:"pdp-swatches__field__label",children:S[e]?s?`${r}`:`${r}: ${S[e].label}`:r}),h(j,{id:e,type:l,required:t,items:u,label:r,selected:(c=S[e])==null?void 0:c.value})]},`swatch-item-${e}`)})})};export{E as S}; diff --git a/scripts/__dropins__/storefront-pdp/chunks/Zoom.js b/scripts/__dropins__/storefront-pdp/chunks/Zoom.js new file mode 100644 index 0000000000..d1e726a1e4 --- /dev/null +++ b/scripts/__dropins__/storefront-pdp/chunks/Zoom.js @@ -0,0 +1,3 @@ +/*! Copyright 2024 Adobe +All Rights Reserved. */ +import{jsxs as z,jsx as L,Fragment as _e}from"@dropins/tools/preact-jsx-runtime.js";import*as I from"@dropins/tools/preact-compat.js";import{useState as k,Children as R,useRef as le,useMemo as be,useEffect as B,useCallback as V}from"@dropins/tools/preact-compat.js";import{debounce as ve,classes as M}from"@dropins/tools/lib.js";import{Button as he,Icon as Ne}from"@dropins/tools/components.js";/* empty css */import{useText as S}from"@dropins/tools/i18n.js";import{cloneElement as Ee}from"@dropins/tools/preact.js";const We=i=>I.createElement("svg",{width:24,height:24,viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",...i},I.createElement("path",{d:"M7.74512 9.87701L12.0001 14.132L16.2551 9.87701",stroke:"currentColor",strokeWidth:1.5,strokeLinecap:"square",strokeLinejoin:"round"})),Le=i=>I.createElement("svg",{width:24,height:24,viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",...i},I.createElement("path",{vectorEffect:"non-scaling-stroke",d:"M18.3599 5.64001L5.62988 18.37",stroke:"currentColor"}),I.createElement("path",{vectorEffect:"non-scaling-stroke",d:"M18.3599 18.37L5.62988 5.64001",stroke:"currentColor"})),ke=24,ye=16,H=2,De="32";var Ce=(i=>(i[i.small=16]="small",i[i.medium=24]="medium",i[i.large=64]="large",i))(Ce||{});const He=({show:i=1,scrollbar:y=!1,peak:v=!1,arrows:p=!1,controls:l="dots",arrowsOnMainImage:W=!1,loop:n=!1,gap:C=null,direction:P="horizontal",width:N="100%",height:X="100%",defaultIndex:D=0,className:ae,children:E,thumbnails:Y=null,isZoomed:J,...Q})=>{const G=S("PDP.Carousel.label").label,ee=S("PDP.Carousel.Slide.label").label,te=S("PDP.Carousel.Previous.label").label,re=S("PDP.Carousel.Next.label").label,ce=S("PDP.Carousel.Controls.label").label,oe=S("PDP.Carousel.Controls.Button.label").label,[d,ie]=k(()=>we(i)),r=Math.ceil(R.count(E)/d),h=v?ke:0,m=C?Ce[C]:0,x=R.count(E)%d,[a,O]=k(n?w()?D-1:D+1:D),$=le([]),[Z,ue]=k(0),[j,Me]=k(0),fe=be(()=>R.toArray(Y),[Y]),g=be(()=>{const e=R.toArray(E).reduce((t,s,o)=>o%d===0?[...t,[s]]:[...t.slice(0,-1),[...t[t.length-1],s]],[]);return!n||e.length===1?e:n&&R.count(E)%d===0?[e[r-1]].concat(e).concat([e[0],e[1]]):[R.toArray(E).slice(-d)].concat(e).concat([e[0],e[1]])},[E,d,r,n]),F=le(null),pe=le(null),_=l==="thumbnailsRow"||l==="thumbnailsColumn";B(()=>{const e=F.current;if(!e)return;const t=ve(()=>{ue(e.offsetWidth??0),Me(e.offsetHeight??0);const o=window.innerWidth,u=we(i,o);u!==d&&ie(u)},50),s=new ResizeObserver(t);return s.observe(e),()=>{s.unobserve(e)}},[d,i]);const K=V(e=>{const t=n?e-1:e,s=$==null?void 0:$.current[0],o=(s==null?void 0:s.offsetWidth)+ye,u=(s==null?void 0:s.offsetHeight)+ye,c=pe.current,T=l==="thumbnailsRow",ne=l==="thumbnailsColumn",A=T?c==null?void 0:c.offsetWidth:c==null?void 0:c.offsetHeight,f=T?o:u;(T||ne)&&A&&(f*(t+1)>A&&(c.style.scrollBehavior="smooth",T?c.scrollLeft=w()?c.scrollWidth-c.clientWidth-(t+H)*f:(t+H)*f:c.scrollTop=(t+H)*f),(w()&&(T?c.scrollLeft:c.scrollTop)<=-f*t||!w()&&(T?c.scrollLeft:c.scrollTop)>f*t)&&(c.style.scrollBehavior="smooth",T?c.scrollLeft=w()?-(t-H)*f:(t-H)*f:c.scrollTop=(t-H)*f))},[l,n]);B(()=>{K(a)},[a,K]);const b=V((e,t,s)=>{_&&K(e);const o=F.current,u=h?o.offsetWidth-h:o.offsetWidth-h+m;if(!Array.from(o.querySelectorAll("[data-index]")).filter(A=>{const f=Number(A.getAttribute("data-index"));return!isNaN(f)&&f>-1})[e])return;if(s){const A=e===0?r:0,f=u*(r+(x||d)/d);if(w()){if(o.scrollLeft<=0&&o.scrollLeft>-(u-5)){b(1,!0);return}if(o.scrollLeft=-f){b(r,!0);return}o.style.scrollBehavior="auto",o.scrollLeft=A===0?0:-f,b(A===0?1:r,!0)}else{if(o.scrollLeft>=0&&o.scrollLeftf-u&&o.scrollLeft<=f){b(r,!0);return}o.style.scrollBehavior="auto",o.scrollLeft=A===0?0:f,b(A===0?1:r,!0);return}}const ne=(o.offsetWidth-m)/d*g[e].length-h;o.style.scrollBehavior=t?"smooth":"auto",o.scrollLeft=w()?-(g[e].length===d?u*e:u*(e-1)-ne):g[e].length===d?u*e:u*(e-1)+ne},[m,r,h,d,x,g,K,l]),q=V(()=>{if(n){const t=a-1;b(t,!0,w()?a===r-1:a===1);return}const e=a<=0?0:a-1;b(e,!0)},[a,b,n]),U=V(()=>{const e=g.length-1;if(n){const s=a+1;b(s,!0,w()?a===0:a===r);return}const t=a>=e?e:a+1;b(t,!0)},[g.length,n,a,b,r]);B(()=>{const e=t=>{t.key==="ArrowLeft"&&(t.preventDefault(),w()?U():q()),t.key==="ArrowRight"&&(t.preventDefault(),w()?q():U())};return window.addEventListener("keydown",e),()=>{window.removeEventListener("keydown",e)}},[U,q]),B(()=>{b(n?D+1:D,!1)},[D,b,n]);const de=ve(()=>{const e=F.current,t=h?e.offsetWidth-h:e.offsetWidth-h+m,s=Math.abs(e.scrollLeft)/t,o=Math.abs(Math.round(s)-s<1?Math.round(s):Math.ceil(s));if(_&&K(o),n){const u=t*(r+(x||d)/d),c=w()?-e.scrollLeft:e.scrollLeft;if(Math.ceil(Math.abs(c))>=Math.ceil(u)-5){e.style.scrollBehavior="auto",e.scrollLeft=w()?-e.offsetWidth+(Math.ceil(c)-Math.ceil(u)-h):e.offsetWidth+(Math.ceil(c)-Math.ceil(u)-h);return}if(Math.abs(c)===0){e.style.scrollBehavior="auto",e.scrollLeft=w()?-(u-e.offsetWidth+h):u-e.offsetWidth+h;return}}a!==o&&O(o)},100);B(()=>{const e=F.current;return e==null||e.addEventListener("scroll",de),()=>{e==null||e.removeEventListener("scroll",de)}},[de]);const se=(e,t,s)=>L(he,{className:M([["pdp-carousel__button",!e],[`pdp-carousel__button--${t}`,!e],[`pdp-carousel__button--${l}`,e]]),style:{"--height":`${j}px`},variant:"tertiary","aria-label":t==="next"?re:te,onClick:s,disabled:n?!1:t==="next"?a>=g.length-1:a<1,children:L(Ne,{className:M([["pdp-carousel__button__icon",!e],[`pdp-carousel__button__icon--${t}`,!e],[`pdp-carousel__button__icon--${l}--${t}`,e]]),size:De,source:We})}),me=p&&g.length!=1&&se(_,"prev",q),ge=p&&g.length!=1&&se(_,"next",U),Pe=p&&g.length!=1&&se(!1,"prev",q),xe=p&&g.length!=1&&se(!1,"next",U);return z("div",{role:"region","aria-roledescription":G,className:M(["pdp-carousel",["pdp-carousel--main-image-controls",W],["pdp-carousel--arrows",p&&!_],[`pdp-carousel--${l}`,_],ae]),style:{"--flex-carousel":l==="thumbnailsColumn"?"row-reverse":"column","--gap":_?"0":"var(--spacing-small)","--width":N},...Q,children:[L("div",{ref:F,className:M(["pdp-carousel__wrapper",`pdp-carousel__wrapper--${P}`,["pdp-carousel__wrapper--scrollbar",y],["pdp-carousel__wrapper--peak",v]]),style:{"--total-width":l==="thumbnailsColumn"?"81.6%":"100%","--height":l==="thumbnailsColumn"?"auto":X,"--gap":C?`var(--spacing-${C})`:"0px","--per-page":d},tabIndex:0,children:g.map((e,t)=>{const s=e.length{const s=n?r:g.length,o=n?a-1===t:a===t;return _?z("label",{className:M(["pdp-carousel__thumbnail__container"]),ref:u=>{u&&($.current[t]=u)},children:[L("input",{type:"radio",name:"carousel-thumbnails","aria-label":oe.replace("{key}",String(t+1)).replace("{total}",String(s)),checked:o&&Z!==0,onChange:()=>{b(n?t+1:t,!0)},...Q,className:M(["pdp-carousel__thumbnail",["pdp-carousel__thumbnail--selected",o&&Z!==0]])}),L("span",{className:M(["pdp-carousel__thumbnail__span"]),children:fe[t]})]},t):L("button",{"aria-label":oe.replace("{key}",String(t+1)).replace("{total}",String(s)),onClick:()=>{b(n?t+1:t,!0)},className:M(["pdp-carousel__controls__button",["pdp-carousel__controls__button--active",o]])},t)})})}),(_||J)&&!W&&ge]})]})};function we(i,y=0){if(typeof i=="number")return i;const{small:v,medium:p,large:l}=i,n=[{breakpoint:1024,value:l},{breakpoint:786,value:p},{breakpoint:0,value:v}].find(({breakpoint:C})=>y>C);return n?n.value:v}function w(){return document.documentElement.dir==="rtl"}const Xe=({centered:i,onClose:y,className:v,children:p,...l})=>{const W=S("PDP.Overlay.Close.label").label,n=le(null),C=V(()=>{y==null||y()},[y]);return B(()=>{const P=N=>{N.key==="Escape"&&C()};return document.addEventListener("keydown",P),()=>{document.removeEventListener("keydown",P)}},[C]),B(()=>{const P=n.current;P==null||P.focus();const N=document.scrollingElement,X=N.style.overflow;return N.style.overflow="hidden",()=>{N.style.overflow=X}},[]),z("div",{...l,className:M(["pdp-overlay",["pdp-overlay--centered",i],v]),ref:n,role:"dialog","aria-describedby":"overlay-content",tabindex:0,children:[L("div",{className:"pdp-overlay__content",id:"overlay-content",children:p}),L(he,{"aria-label":W,variant:"tertiary",className:"pdp-overlay__close-button",onClick:C,icon:L(Le,{})})]})},Ye=({children:i,scale:y=2,closeButton:v=!0})=>{const[p,l]=k(!1),[W,n]=k("pdp-zoom"),[C,P]=k(!1),[N,X]=k({x:0,y:0}),[D,ae]=k({x:0,y:0}),[E,Y]=k({x:0,y:0}),J=r=>{!p||r.type!=="touchstart"||(X({x:r.touches[0].clientX,y:r.touches[0].clientY}),ae({x:E.x,y:E.y}),P(!0))},Q=r=>{var j;if(!C||r.type!=="touchmove")return;const h=(j=r.currentTarget)==null?void 0:j.getBoundingClientRect(),m=(100-100/y)/2,x=r.touches[0].clientX-N.x,a=r.touches[0].clientY-N.y,O=x*100/(h.width*y),$=a*100/(h.height*y),Z=D.x+O,ue=D.y+$;Y({x:Math.max(-m,Math.min(Z,m))||0,y:Math.max(-m,Math.min(ue,m))||0}),r.preventDefault()},G=r=>{var $;const h=($=r.currentTarget)==null?void 0:$.getBoundingClientRect(),m=(100-100/y)/2;let x;if("touches"in r)x=r.touches[0];else if(r instanceof MouseEvent)x=r;else return;const a=m-(x.clientX-h.left)/h.width*100,O=m-(x.clientY-h.top)/h.height*100;Y({x:Math.max(-m,Math.min(a,m))||0,y:Math.max(-m,Math.min(O,m))||0})},ee=r=>{if(!C){if(p){if(v&&"touches"in r){J(r);return}v||l(!1)}else l(!0),G(r);r.preventDefault()}},te=r=>{if(v&&"touches"in r){Q(r);return}p&&G(r)},re=()=>{if(v){P(!1);return}l(!1)},ce=r=>{l(!1),r.stopPropagation()},oe=p?`scale(${y}) translateX(${E.x}%) translateY(${E.y}%)`:"none",d=S("PDP.Zoom.Close.label").label,ie=Ee(R.only(i),{draggable:!1,style:{"--transform":oe}});return B(()=>{n(p?`pdp-zoom ${v?"pdp-zoom--no-effects":"pdp-zoom--zoomed"}`:"pdp-zoom")},[p,v]),z("figure",{className:W,onClick:ee,onMouseMove:te,onMouseLeave:re,onTouchStart:ee,onTouchMove:te,onTouchEnd:re,children:[ie,v&&p&&L(he,{"aria-label":d,variant:"tertiary",className:"pdp-zoom__close-button",icon:L(Le,{}),onClick:ce})]})};export{He as C,Xe as O,Ye as Z}; diff --git a/scripts/__dropins__/storefront-pdp/chunks/date.js b/scripts/__dropins__/storefront-pdp/chunks/date.js new file mode 100644 index 0000000000..629d21dbd1 --- /dev/null +++ b/scripts/__dropins__/storefront-pdp/chunks/date.js @@ -0,0 +1,3 @@ +/*! Copyright 2024 Adobe +All Rights Reserved. */ +import{toLanguageTag as n}from"@dropins/tools/lib.js";function a(t,d="en_US"){if(!o(t))throw Error("Invalid date string");return t.split(" ")[1]||(t=`${t} 00:00:00`),new Date(t).toLocaleDateString(n(d)).toString()}function o(t){if(![/^\d{4}-\d{2}-\d{2}$/,/^\d{1,2}\/\d{1,2}\/\d{4}$/,/^\d{2}\/\d{2}\/\d{4}$/,/^\d{4}\/\d{2}\/\d{2}$/,/^\d{1,2}\.\d{1,2}\.\d{4}$/,/^\d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2}$/].some(i=>i.test(t)))return!1;const e=new Date(t);return!isNaN(e.getTime())}export{o as i,a as t}; diff --git a/scripts/__dropins__/storefront-pdp/chunks/getFetchedProductData.js b/scripts/__dropins__/storefront-pdp/chunks/getFetchedProductData.js new file mode 100644 index 0000000000..3b8bfea59e --- /dev/null +++ b/scripts/__dropins__/storefront-pdp/chunks/getFetchedProductData.js @@ -0,0 +1,3 @@ +/*! Copyright 2024 Adobe +All Rights Reserved. */ +import{events as e}from"@dropins/tools/event-bus.js";const s=async()=>e._lastEvent["pdp/data"]?Promise.resolve(e._lastEvent["pdp/data"].payload):new Promise(a=>{const t=e.on("pdp/data",r=>{a(r),t==null||t.off()},{eager:!0})});export{s as g}; diff --git a/scripts/__dropins__/storefront-pdp/chunks/getProductConfigurationValues.js b/scripts/__dropins__/storefront-pdp/chunks/getProductConfigurationValues.js new file mode 100644 index 0000000000..1a47041364 --- /dev/null +++ b/scripts/__dropins__/storefront-pdp/chunks/getProductConfigurationValues.js @@ -0,0 +1,3 @@ +/*! Copyright 2024 Adobe +All Rights Reserved. */ +import{events as o}from"@dropins/tools/event-bus.js";import"@dropins/tools/lib.js";const a=t=>{const s=e(),n=t(s);JSON.stringify(s)!==JSON.stringify(n)&&o.emit("pdp/values",{...n})},e=()=>{var t;return((t=o._lastEvent["pdp/values"])==null?void 0:t.payload)??null};export{e as g,a as s}; diff --git a/scripts/__dropins__/storefront-pdp/chunks/getRefinedProduct.js b/scripts/__dropins__/storefront-pdp/chunks/getRefinedProduct.js deleted file mode 100644 index fb71cf4b8e..0000000000 --- a/scripts/__dropins__/storefront-pdp/chunks/getRefinedProduct.js +++ /dev/null @@ -1,185 +0,0 @@ -import{c as B}from"./initialize.js";import{FetchGraphQL as et}from"@dropins/tools/fetch-graphql.js";const{setEndpoint:gt,setFetchGraphQlHeader:ht,removeFetchGraphQlHeader:wt,setFetchGraphQlHeaders:xt,fetchGraphQl:q,getConfig:_t}=new et().getMethods();function K(e,r){var i,u,o;const n=e?{name:e.name,sku:e.sku,addToCartAllowed:e.addToCartAllowed,inStock:e.inStock,shortDescription:e.shortDescription,metaDescription:e.metaDescription,metaKeyword:e.metaKeyword,metaTitle:e.metaTitle,description:e.description,images:rt(e),prices:mt(e,!!r),attributes:nt(e),options:ut(e),optionUIDs:at(e),url:e.url,urlKey:e.urlKey,externalId:e.externalId,externalParentId:e.externalParentId,variantSku:e.variantSku}:null,t=(o=(u=(i=B.getConfig())==null?void 0:i.models)==null?void 0:u.ProductDetails)==null?void 0:o.transform;return t&&n?t(n):n}function rt(e){var r;return(r=e.images)==null?void 0:r.map(n=>(n.url=n.url.replace(/^https?:/,""),n))}function nt(e){var r,n;return(n=(r=e.attributes)==null?void 0:r.filter(({roles:t})=>(t==null?void 0:t.indexOf("visible_in_pdp"))!==-1))==null?void 0:n.map(({label:t,value:i,name:u})=>({id:u,label:t,value:i.toString().split(",").join(", ")}))}function ut(e){const{options:r,optionUIDs:n}=e;return r==null?void 0:r.map(({id:t,title:i,required:u,multi:o,values:m})=>{var d,s;const a=(d=m==null?void 0:m[0])==null?void 0:d.__typename;let l=m==null?void 0:m[0].type;const c=((s=m==null?void 0:m[0])==null?void 0:s.__typename)==="ProductViewOptionValueProduct";return l?l=l.replace("COLOR_HEX","color").replace("TEXT","text").replace("IMAGE","image"):l="dropdown",{id:t,type:l,typename:a,label:i,required:u,multiple:o,items:c?it(m,n):ot(m,n,l)}})}function it(e,r){return e==null?void 0:e.map(({id:n,title:t,inStock:i,isDefault:u,product:o})=>({id:n,inStock:i,label:t,selected:(r==null?void 0:r.indexOf(n))>-1||u,value:n,product:o}))}function ot(e,r,n){return e==null?void 0:e.map(({id:t,title:i,inStock:u,value:o})=>({id:t,inStock:u,label:i,selected:(r==null?void 0:r.indexOf(t))>-1,value:(n==null?void 0:n.toLowerCase())==="dropdown"?t:o==null?void 0:o.replace(/^https?:/,"")}))}function mt(e,r){var E,x,H,I,L;const{price:n,priceRange:t,options:i,optionUIDs:u}=e;let{__typename:o}=e;function m(){var g;const P=n.regular.amount.value,f=((g=n.final)==null?void 0:g.amount.value)??n.regular.amount.value,y=n.regular.amount.currency==="NONE"?"USD":n==null?void 0:n.regular.amount.currency;return[P,f,f,y]}function a(){var _,b,S,V,T,C,D,A,F,$,G,M;const P=(_=t==null?void 0:t.minimum)==null?void 0:_.final.amount.value,f=(b=t==null?void 0:t.maximum)==null?void 0:b.final.amount.value;let y;((V=(S=t==null?void 0:t.minimum)==null?void 0:S.regular)==null?void 0:V.amount.value)===((C=(T=t==null?void 0:t.maximum)==null?void 0:T.regular)==null?void 0:C.amount.value)&&(y=(A=(D=t==null?void 0:t.minimum)==null?void 0:D.regular)==null?void 0:A.amount.value);const g=(($=(F=t==null?void 0:t.minimum)==null?void 0:F.final)==null?void 0:$.amount.currency)==="NONE"?"USD":(M=(G=t==null?void 0:t.minimum)==null?void 0:G.final)==null?void 0:M.amount.currency;return[y,P,f,g]}function l(){var S,V,T,C,D,A,F,$,G,M,X,Y;let P=0,f=0;i==null||i.forEach(k=>{var z;const j=k==null?void 0:k.values;if(j&&Array.isArray(j)){const h=j.map(p=>{var Q,N,J,W;return(W=(J=(N=(Q=p==null?void 0:p.product)==null?void 0:Q.price)==null?void 0:N.regular)==null?void 0:J.amount)==null?void 0:W.value}).filter(p=>p!==void 0),v=h.length>0?Math.max(...h):0;P+=v}else P+=0;(z=k==null?void 0:k.values)==null||z.forEach(h=>{var v,p,Q,N;u!=null&&u.includes(h.id)&&(f+=(N=(Q=(p=(v=h==null?void 0:h.product)==null?void 0:v.price)==null?void 0:p.final)==null?void 0:Q.amount)==null?void 0:N.value)})});const y=(S=t==null?void 0:t.minimum)==null?void 0:S.final.amount.value,g=(V=t==null?void 0:t.maximum)==null?void 0:V.final.amount.value;let _;((C=(T=t==null?void 0:t.minimum)==null?void 0:T.regular)==null?void 0:C.amount.value)===((A=(D=t==null?void 0:t.maximum)==null?void 0:D.regular)==null?void 0:A.amount.value)&&(_=($=(F=t==null?void 0:t.minimum)==null?void 0:F.regular)==null?void 0:$.amount.value);const b=((M=(G=t==null?void 0:t.minimum)==null?void 0:G.final)==null?void 0:M.amount.currency)==="NONE"?"USD":(Y=(X=t==null?void 0:t.minimum)==null?void 0:X.final)==null?void 0:Y.amount.currency;return r&&!u?[_,y,g,b]:P===(t==null?void 0:t.maximum.regular.amount.value)?[f,f,f,b]:[_,y,g,b]}const[c,d,s,w]=o==="SimpleProductView"?m():r?l():a(),O=o==="SimpleProductView"?(E=n==null?void 0:n.roles)==null?void 0:E.includes("visible"):((H=(x=t==null?void 0:t.maximum)==null?void 0:x.roles)==null?void 0:H.includes("visible"))&&((L=(I=t==null?void 0:t.minimum)==null?void 0:I.roles)==null?void 0:L.includes("visible"));return s&&d===s?{regular:{amount:c,currency:w,variant:c&&d!==c?"strikethrough":"default"},final:{amount:s,currency:w,variant:"default"},visible:O}:{final:{minimumAmount:d,maximumAmount:s,currency:w},visible:O}}function at(e){var n;let{optionUIDs:r}=e;return(n=e==null?void 0:e.options)==null||n.map(({values:t})=>{var u;((u=t==null?void 0:t[0])==null?void 0:u.__typename)==="ProductViewOptionValueProduct"&&!r&&(r=[],t==null||t.map(({id:o,isDefault:m})=>{m&&(r==null?void 0:r.indexOf(o))===-1&&r.push(o)}))}),r}const lt=` -fragment ProductOptionFragment on ProductViewOption { - id - title - required - multi - values { - id - title - inStock - __typename - ... on ProductViewOptionValueProduct { - title - quantity - isDefault - __typename - product { - sku - shortDescription - metaDescription - metaKeyword - metaTitle - name - price { - final { - amount { - value - currency - } - } - regular { - amount { - value - currency - } - } - roles - } - } - } - ... on ProductViewOptionValueSwatch { - id - title - type - value - inStock - } - } - } -`,R=` -fragment ProductFragment on ProductView { - __typename - id - sku - name - shortDescription - metaDescription - metaKeyword - metaTitle - description - inStock - addToCartAllowed - url - urlKey - externalId - - images(roles: []) { - url - label - roles - } - - attributes(roles: []) { - name - label - value - roles - } - -... on SimpleProductView { - price { - roles - - regular { - amount { - value - currency - } - } - - final { - amount { - value - currency - } - } - } -} - - - ... on ComplexProductView { - options { - ...ProductOptionFragment - } - - priceRange { - maximum { - final { - amount { - value - currency - } - } - regular { - amount { - value - currency - } - } - roles - } - minimum { - final { - amount { - value - currency - } - } - regular { - amount { - value - currency - } - } - roles - } - } - } -} - -${lt} -`,tt=` -query GET_PRODUCT_DATA($skus: [String]) { - products(skus: $skus) { - ...ProductFragment - } -} - -${R} -`;function Z(e){return e.some(r=>(r==null?void 0:r.__typename)==="ProductViewOptionValueProduct")}const bt=async e=>{var u,o,m,a,l,c,d;const r=(a=(m=(o=(u=B)==null?void 0:u.getConfig())==null?void 0:o.models)==null?void 0:m.ProductDetails)==null?void 0:a.initialData;let n=(l=r==null?void 0:r.options)==null?void 0:l.some(s=>Z(s.values));if(r)return K(r,!!n);const{data:t}=await q(tt,{method:"GET",variables:{skus:[e]}}),i=(c=t==null?void 0:t.products)==null?void 0:c[0];return n=(d=i==null?void 0:i.options)==null?void 0:d.some(s=>Z(s.values)),K(i,!!n)},ct=` -query REFINE_PRODUCT_QUERY( - $optionIds: [String!]! - $sku: String! -) { - # Refined Product - refineProduct( - optionIds: $optionIds - sku: $sku - ) { - ...ProductFragment - } - - # Parent Product - products(skus: [$sku]) { - ...ProductFragment - } - - # %extendedPlaceholder% -} - -${R} -`;async function U(e,r,n){var m;if(n)return{...(m=(await q(tt,{method:"GET",variables:{skus:[e]}})).data)==null?void 0:m.products[0],optionUIDs:r};const t=st(r),i=dt(t,e),u=ct.replace("# %extendedPlaceholder%",i),{data:o}=await q(u,{method:"GET",variables:{optionIds:r,sku:e}});return o}const kt=async(e,r,n,t)=>{var s,w,O,E;let i;if(i=await U(e,r,t),!i)return null;if(t)return K({...i,optionUIDs:r},!0);let{products:u,refineProduct:o,...m}=i;const a=u==null?void 0:u[0],l=ft(Object.values(m),a.options,n);if(n!=null&&n.length&&o===null){r=Pt(l,r,n);const x=await U(e,r);o=x==null?void 0:x.refineProduct}const c=K({...o||a,sku:a.sku,name:a.name,externalParentId:a==null?void 0:a.externalId,options:l,optionUIDs:r,variantSku:(o==null?void 0:o.__typename)==="SimpleProductView"?o==null?void 0:o.sku:void 0}),d=(E=(O=(w=(s=B)==null?void 0:s.getConfig())==null?void 0:w.models)==null?void 0:O.ProductDetails)==null?void 0:E.fallbackData;return d?d(a,c):c};function st(e){if(e.length<2)return[e];const r=[];return e.forEach(n=>{const t=[];e.forEach(i=>{n!==i&&t.push(i)}),r.push(t)}),r}function dt(e,r){return e.map((n,t)=>` - ProductOption${t}: refineProduct( - optionIds: [ - ${n.map(i=>`"${i}"`).join(", ")} - ] - sku: "${r}" - ) { - ... on ComplexProductView { - options { - ...ProductOptionFragment - } - } - } - `).join("")}function ft(e,r,n){const t=Object.values(e).filter(u=>!!u).reduce((u,o)=>o.options?[...u,...o.options]:[...u],[]),i=new Map(r.map(u=>[u.id,u]));return t.forEach(u=>{n!=null&&n.includes(u.id)||i.set(u.id,u)}),[...i.values()]}function Pt(e,r,n){const t=[];let i;return e.forEach(u=>{var o,m,a,l;n.includes(u.id)?i=((m=(o=u.values)==null?void 0:o.find(c=>r.includes(c==null?void 0:c.id)))==null?void 0:m.id)||((a=u.values[0])==null?void 0:a.id):i=(l=u.values[0])==null?void 0:l.id,t.push(i)}),t}export{ht as a,xt as b,bt as c,kt as d,q as f,_t as g,wt as r,gt as s}; diff --git a/scripts/__dropins__/storefront-pdp/chunks/initialize.js b/scripts/__dropins__/storefront-pdp/chunks/initialize.js deleted file mode 100644 index ee6ee5ce63..0000000000 --- a/scripts/__dropins__/storefront-pdp/chunks/initialize.js +++ /dev/null @@ -1 +0,0 @@ -import{Initializer as t}from"@dropins/tools/lib.js";const i=new t({init:async n=>{const o={defaultLocale:"en-US"};i.config.setConfig({...o,...n})},listeners:()=>[]}),c=i.config;export{c,i}; diff --git a/scripts/__dropins__/storefront-pdp/chunks/isProductConfigurationValid.js b/scripts/__dropins__/storefront-pdp/chunks/isProductConfigurationValid.js new file mode 100644 index 0000000000..8494ef8de8 --- /dev/null +++ b/scripts/__dropins__/storefront-pdp/chunks/isProductConfigurationValid.js @@ -0,0 +1,187 @@ +/*! Copyright 2024 Adobe +All Rights Reserved. */ +import{merge as se,Initializer as ae}from"@dropins/tools/lib.js";import{events as N}from"@dropins/tools/event-bus.js";import{FetchGraphQL as ue}from"@dropins/tools/fetch-graphql.js";import{s as le}from"./getProductConfigurationValues.js";function Me(e){const n=new URLSearchParams(window.location.search);Object.entries(e).forEach(([r,t])=>{t===null?n.delete(r):n.set(r,String(t))});let i=window.location.pathname;i+=`?${n.toString()}`,i+=window.location.hash,window.history.replaceState({},"",i)}function me(){const e=new URLSearchParams(window.location.search),n={};return e.forEach((i,r)=>{n[r]=i}),n}function ce(e){var n,i,r,t,o,a,l,s,m,u,c,f;return{productId:Number(e==null?void 0:e.externalId),name:e==null?void 0:e.name,sku:(e==null?void 0:e.variantSku)||(e==null?void 0:e.sku),topLevelSku:e==null?void 0:e.sku,specialToDate:void 0,specialFromDate:void 0,newToDate:void 0,newFromDate:void 0,createdAt:void 0,updatedAt:void 0,manufacturer:void 0,countryOfManufacture:void 0,categories:void 0,productType:e==null?void 0:e.productType,pricing:{regularPrice:((i=(n=e==null?void 0:e.prices)==null?void 0:n.regular)==null?void 0:i.amount)||0,minimalPrice:(t=(r=e==null?void 0:e.prices)==null?void 0:r.final)==null?void 0:t.minimumAmount,maximalPrice:(a=(o=e==null?void 0:e.prices)==null?void 0:o.final)==null?void 0:a.maximumAmount,specialPrice:(s=(l=e==null?void 0:e.prices)==null?void 0:l.final)==null?void 0:s.amount,tierPricing:void 0,currencyCode:((u=(m=e==null?void 0:e.prices)==null?void 0:m.final)==null?void 0:u.currency)||"USD"},canonicalUrl:e==null?void 0:e.url,mainImageUrl:(f=(c=e==null?void 0:e.images)==null?void 0:c[0])==null?void 0:f.url}}const fe={PRODUCT_CONTEXT:"productContext"},de={PRODUCT_PAGE_VIEW:"product-page-view"};function ne(){return window.adobeDataLayer=window.adobeDataLayer||[],window.adobeDataLayer}function Pe(e,n){const i=ne();i.push({[e]:null}),i.push({[e]:n})}function ge(e,n){ne().push(r=>{const t=r.getState?r.getState():{};r.push({event:e,eventInfo:{...t,...n}})})}function we(e){const n=ce(e);Pe(fe.PRODUCT_CONTEXT,n),ge(de.PRODUCT_PAGE_VIEW)}var K=(e=>(e.ComplexProduct="complex",e.SimpleProduct="simple",e))(K||{}),re=(e=>(e.ComplexProductView="ComplexProductView",e.SimpleProductView="SimpleProductView",e))(re||{});function H(e,n){var a,l,s,m,u,c,f,P,g,y,d,b;const i=((m=(s=(l=(a=e==null?void 0:e.options)==null?void 0:a[0])==null?void 0:l.values)==null?void 0:s[0])==null?void 0:m.__typename)==="ProductViewOptionValueProduct",r=Ce(e,i,n==null?void 0:n.preselectFirstOption),t=(e==null?void 0:e.__typename)===re.SimpleProductView?K.SimpleProduct:K.ComplexProduct,o=e?{name:e.name,sku:e.sku,isBundle:i,addToCartAllowed:e.addToCartAllowed,inStock:e.inStock,shortDescription:e.shortDescription,metaDescription:e.metaDescription,metaKeyword:e.metaKeyword,metaTitle:e.metaTitle,description:e.description,images:ye(e),prices:Se(e,i,r),attributes:he(e),options:pe(e,i),optionUIDs:r,url:e.url,urlKey:e.urlKey,externalId:e.externalId,externalParentId:e.externalParentId,variantSku:e.variantSku,productType:t}:null;return se(o,((P=(f=(c=(u=k.getConfig())==null?void 0:u.models)==null?void 0:c.ProductDetails)==null?void 0:f.transformer)==null?void 0:P.call(f,e))??((b=(d=(y=(g=k.getConfig())==null?void 0:g.models)==null?void 0:y.ProductDetails)==null?void 0:d.transform)==null?void 0:b.call(d,e)))}function ye(e){var n,i;return(i=(n=e.images)==null?void 0:n.filter(r=>{var t;return!((t=r.roles)!=null&&t.includes("hide_from_pdp"))}))==null?void 0:i.map(r=>(r.url=r.url.replace(/^https?:/,""),r))}function he(e){var n,i;return(i=(n=e.attributes)==null?void 0:n.filter(({roles:r})=>(r==null?void 0:r.indexOf("visible_in_pdp"))!==-1))==null?void 0:i.map(({label:r,value:t,name:o})=>({id:o,label:r,value:t.toString().split(",").join(", ")}))}function pe(e,n){const{options:i,optionUIDs:r}=e;return i==null?void 0:i.map(({id:t,title:o,required:a,multi:l,values:s})=>{var c;const m=(c=s==null?void 0:s[0])==null?void 0:c.__typename;let u=s==null?void 0:s[0].type;return u?u=u.replace("COLOR_HEX","color").replace("TEXT","text").replace("IMAGE","image"):u="dropdown",{id:t,type:u,typename:m,label:o,required:a,multiple:l,items:n?De(s,r):xe(s,r,u)}})}function De(e,n){return e==null?void 0:e.map(({id:i,title:r,inStock:t,isDefault:o,product:a})=>({id:i,inStock:t,label:r,selected:(n==null?void 0:n.indexOf(i))>-1||o,value:i,product:a}))}function xe(e,n,i){return e==null?void 0:e.map(({id:r,title:t,inStock:o,value:a})=>({id:r,inStock:o,label:t,selected:(n==null?void 0:n.indexOf(r))>-1,value:(i==null?void 0:i.toLowerCase())==="dropdown"?r:a==null?void 0:a.replace(/^https?:/,"")}))}function Se(e,n,i){var d,b,X,B,z;const{price:r,priceRange:t,options:o,optionUIDs:a=i}=e;let{__typename:l}=e;function s(){var x;const p=r.regular.amount.value,w=((x=r.final)==null?void 0:x.amount.value)??r.regular.amount.value,D=r.regular.amount.currency==="NONE"?"USD":r==null?void 0:r.regular.amount.currency;return[p,w,w,D]}function m(){var C,v,E,T,_,V,I,F,U,A,$,L;const p=(C=t==null?void 0:t.minimum)==null?void 0:C.final.amount.value,w=(v=t==null?void 0:t.maximum)==null?void 0:v.final.amount.value;let D;((T=(E=t==null?void 0:t.minimum)==null?void 0:E.regular)==null?void 0:T.amount.value)===((V=(_=t==null?void 0:t.maximum)==null?void 0:_.regular)==null?void 0:V.amount.value)&&(D=(F=(I=t==null?void 0:t.minimum)==null?void 0:I.regular)==null?void 0:F.amount.value);const x=((A=(U=t==null?void 0:t.minimum)==null?void 0:U.final)==null?void 0:A.amount.currency)==="NONE"?"USD":(L=($=t==null?void 0:t.minimum)==null?void 0:$.final)==null?void 0:L.amount.currency;return[D,p,w,x]}function u(){var E,T,_,V,I,F,U,A,$,L,W,Y;let p=0,w=0;o==null||o.forEach(O=>{var J;const j=O==null?void 0:O.values;if(j&&Array.isArray(j)){const S=j.map(h=>{var G,M,Z,R;return(R=(Z=(M=(G=h==null?void 0:h.product)==null?void 0:G.price)==null?void 0:M.regular)==null?void 0:Z.amount)==null?void 0:R.value}).filter(h=>h!==void 0),Q=S.length>0?Math.max(...S):0;p+=Q}(J=O==null?void 0:O.values)==null||J.forEach(S=>{var Q,h,G,M;a!=null&&a.includes(S.id)&&(w+=(M=(G=(h=(Q=S==null?void 0:S.product)==null?void 0:Q.price)==null?void 0:h.final)==null?void 0:G.amount)==null?void 0:M.value)})});const D=(E=t==null?void 0:t.minimum)==null?void 0:E.final.amount.value,x=(T=t==null?void 0:t.maximum)==null?void 0:T.final.amount.value;let C;((V=(_=t==null?void 0:t.minimum)==null?void 0:_.regular)==null?void 0:V.amount.value)===((F=(I=t==null?void 0:t.maximum)==null?void 0:I.regular)==null?void 0:F.amount.value)&&(C=(A=(U=t==null?void 0:t.minimum)==null?void 0:U.regular)==null?void 0:A.amount.value);const v=((L=($=t==null?void 0:t.minimum)==null?void 0:$.final)==null?void 0:L.amount.currency)==="NONE"?"USD":(Y=(W=t==null?void 0:t.minimum)==null?void 0:W.final)==null?void 0:Y.amount.currency;return n&&(a==null?void 0:a.length)<1?[C,D,x,v]:p===(t==null?void 0:t.maximum.regular.amount.value)?[w,w,w,v]:[C,D,x,v]}const[c,f,P,g]=l==="SimpleProductView"?s():n?u():m(),y=l==="SimpleProductView"?(d=r==null?void 0:r.roles)==null?void 0:d.includes("visible"):((X=(b=t==null?void 0:t.maximum)==null?void 0:b.roles)==null?void 0:X.includes("visible"))&&((z=(B=t==null?void 0:t.minimum)==null?void 0:B.roles)==null?void 0:z.includes("visible"));return P&&f===P?{regular:{amount:c,currency:g,variant:c&&f!==c?"strikethrough":"default"},final:{amount:P,currency:g,variant:"default"},visible:y}:{final:{minimumAmount:f,maximumAmount:P,currency:g},visible:y}}function Ce(e,n,i){var r;return n?((r=e==null?void 0:e.options)==null?void 0:r.map(({values:o})=>{var s;const a=((s=o==null?void 0:o.find(({isDefault:m})=>m))==null?void 0:s.id)??null,l=i?o[0].id:null;return a||l})).filter(o=>o!==null):e==null?void 0:e.optionUIDs}const q=new ae({init:async e=>{var o,a,l;const n=(a=(o=e==null?void 0:e.models)==null?void 0:o.ProductDetails)==null?void 0:a.initialData,t={...{defaultLocale:"en-US",persistURLParams:!1,acdl:!1,optionsUIDs:((l=me().optionsUIDs)==null?void 0:l.split(","))||(n==null?void 0:n.optionsUIDs)},...e};if(q.config.setConfig({...t}),t!=null&&t.sku){const s=n?H(n):await te(t.sku,{preselectFirstOption:t.preselectFirstOption});N.emit("pdp/data",s);const m={sku:t.sku,quantity:1,optionsUIDs:s==null?void 0:s.optionUIDs};le(()=>({...m})),Fe(()=>{var u;return s!=null&&s.options?s.options.length===((u=s==null?void 0:s.optionUIDs)==null?void 0:u.length):!0}),t.acdl&&s&&we(s)}},listeners:()=>[N.on("locale",async()=>{const{sku:e}=q.config.getConfig();if(e){const n=await te(e);N.emit("pdp/data",n)}})]}),k=q.config,{setEndpoint:Ne,setFetchGraphQlHeader:Qe,removeFetchGraphQlHeader:je,setFetchGraphQlHeaders:Ke,fetchGraphQl:ie,getConfig:qe}=new ue().getMethods(),ve=` +fragment ProductOptionFragment on ProductViewOption { + id + title + required + multi + values { + id + title + inStock + __typename + ... on ProductViewOptionValueProduct { + title + quantity + isDefault + __typename + product { + sku + shortDescription + metaDescription + metaKeyword + metaTitle + name + price { + final { + amount { + value + currency + } + } + regular { + amount { + value + currency + } + } + roles + } + } + } + ... on ProductViewOptionValueSwatch { + id + title + type + value + inStock + } + } + } +`,oe=` +fragment ProductFragment on ProductView { + __typename + id + sku + name + shortDescription + metaDescription + metaKeyword + metaTitle + description + inStock + addToCartAllowed + url + urlKey + externalId + + images(roles: []) { + url + label + roles + } + + attributes(roles: []) { + name + label + value + roles + } + +... on SimpleProductView { + price { + roles + + regular { + amount { + value + currency + } + } + + final { + amount { + value + currency + } + } + } +} + + + ... on ComplexProductView { + options { + ...ProductOptionFragment + } + + priceRange { + maximum { + final { + amount { + value + currency + } + } + regular { + amount { + value + currency + } + } + roles + } + minimum { + final { + amount { + value + currency + } + } + regular { + amount { + value + currency + } + } + roles + } + } + } +} + +${ve} +`,Oe=` +query GET_PRODUCT_DATA($skus: [String]) { + products(skus: $skus) { + ...ProductFragment + } +} + +${oe} +`,ke=async(e,n,i)=>{var o;const{data:r}=await ie(Oe,{method:"GET",variables:{skus:[e]}}),t=(o=r==null?void 0:r.products)==null?void 0:o[0];return n!=null&&n.optionsUIDs&&(t.optionUIDs=n.optionsUIDs),i?t:H(t,{preselectFirstOption:n==null?void 0:n.preselectFirstOption})},be=` +query REFINE_PRODUCT_QUERY( + $optionIds: [String!]! + $sku: String! +) { + # Refined Product + refineProduct( + optionIds: $optionIds + sku: $sku + ) { + ...ProductFragment + } + + # Parent Product + products(skus: [$sku]) { + ...ProductFragment + } + + # %extendedPlaceholder% +} + +${oe} +`;async function ee(e,n){const i=Te(n),r=_e(i,e),t=be.replace("# %extendedPlaceholder%",r),{data:o}=await ie(t,{method:"GET",variables:{optionIds:n,sku:e}});return o}const Ee=async(e,n,i,r)=>{var P,g,y;const t=await ee(e,n);if(!t)return null;let{products:o,refineProduct:a,...l}=t;const s=o==null?void 0:o[0],m=Ve(Object.values(l),s.options,i);if(i!=null&&i.length&&a===null){n=Ie(m,n,i);const d=await ee(e,n);a=d==null?void 0:d.refineProduct}const u={...a||s,sku:s.sku,name:s.name,externalParentId:s==null?void 0:s.externalId,options:m,optionUIDs:n,variantSku:(a==null?void 0:a.__typename)==="SimpleProductView"?a==null?void 0:a.sku:void 0},c=r?u:H(u),f=(y=(g=(P=k==null?void 0:k.getConfig())==null?void 0:P.models)==null?void 0:g.ProductDetails)==null?void 0:y.fallbackData;return f?f(s,c):c};function Te(e){if(e.length<2)return[e];const n=[];return e.forEach(i=>{const r=[];e.forEach(t=>{i!==t&&r.push(t)}),n.push(r)}),n}function _e(e,n){return e.map((i,r)=>` + ProductOption${r}: refineProduct( + optionIds: [ + ${i.map(t=>`"${t}"`).join(", ")} + ] + sku: "${n}" + ) { + ... on ComplexProductView { + options { + ...ProductOptionFragment + } + } + } + `).join("")}function Ve(e,n=[],i){const r=Object.values(e).filter(o=>!!o).reduce((o,a)=>a.options?[...o,...a.options]:[...o],[]),t=new Map(n.map(o=>[o.id,o]));return r.forEach(o=>{i!=null&&i.includes(o.id)||t.set(o.id,o)}),[...t.values()]}function Ie(e,n,i){const r=[];let t;return e.forEach(o=>{var a,l,s,m;i.includes(o.id)?t=((l=(a=o.values)==null?void 0:a.find(u=>n.includes(u==null?void 0:u.id)))==null?void 0:l.id)||((s=o.values[0])==null?void 0:s.id):t=(m=o.values[0])==null?void 0:m.id,r.push(t)}),r}const te=async(e,n)=>{const{anchors:i,optionsUIDs:r}=k.getConfig(),{optionsUIDs:t=r,anchors:o=i,preselectFirstOption:a,isBundle:l,skipTransform:s}=n??{};return!l&&t?await Ee(e,t,o,s):await ke(e,{preselectFirstOption:a,optionsUIDs:t},s)},Fe=e=>{const n=Ue(),i=e(n);n!==i&&N.emit("pdp/valid",i)},Ue=()=>{var e;return((e=N._lastEvent["pdp/valid"])==null?void 0:e.payload)??null};export{Qe as a,Ke as b,k as c,ke as d,Ee as e,ie as f,qe as g,te as h,q as i,Fe as j,Ue as k,Me as l,we as p,je as r,Ne as s,H as t}; diff --git a/scripts/__dropins__/storefront-pdp/components/Header/Header.d.ts b/scripts/__dropins__/storefront-pdp/components/Header/Header.d.ts new file mode 100644 index 0000000000..268d5a9d24 --- /dev/null +++ b/scripts/__dropins__/storefront-pdp/components/Header/Header.d.ts @@ -0,0 +1,10 @@ +import { FunctionComponent, VNode } from 'preact'; +import { HTMLAttributes } from 'preact/compat'; + +export interface HeaderProps extends Omit, 'title'> { + title: VNode; + sku: VNode; + hideSku?: boolean; +} +export declare const Header: FunctionComponent; +//# sourceMappingURL=Header.d.ts.map \ No newline at end of file diff --git a/scripts/__dropins__/storefront-pdp/components/Header/index.d.ts b/scripts/__dropins__/storefront-pdp/components/Header/index.d.ts new file mode 100644 index 0000000000..f56ed8ed6a --- /dev/null +++ b/scripts/__dropins__/storefront-pdp/components/Header/index.d.ts @@ -0,0 +1,18 @@ +/** + * ADOBE CONFIDENTIAL + * __________________ + * Copyright 2024 Adobe + * All Rights Reserved. + * __________________ + * NOTICE: All information contained herein is, and remains + * the property of Adobe and its suppliers, if any. The intellectual + * and technical concepts contained herein are proprietary to Adobe + * and its suppliers and are protected by all applicable intellectual + * property laws, including trade secret and copyright laws. + * Dissemination of this information or reproduction of this material + * is strictly forbidden unless prior written permission is obtained + * from Adobe. + */ +export * from './Header'; +export { Header as default } from './Header'; +//# sourceMappingURL=index.d.ts.map \ No newline at end of file diff --git a/scripts/__dropins__/storefront-pdp/components/Price/Price.d.ts b/scripts/__dropins__/storefront-pdp/components/Price/Price.d.ts new file mode 100644 index 0000000000..dc7f7da99e --- /dev/null +++ b/scripts/__dropins__/storefront-pdp/components/Price/Price.d.ts @@ -0,0 +1,9 @@ +import { FunctionComponent, VNode } from 'preact'; +import { HTMLAttributes } from 'preact/compat'; + +export interface PriceProps extends HTMLAttributes { + price?: VNode; + specialPrice?: VNode; +} +export declare const Price: FunctionComponent; +//# sourceMappingURL=Price.d.ts.map \ No newline at end of file diff --git a/scripts/__dropins__/storefront-pdp/components/Price/index.d.ts b/scripts/__dropins__/storefront-pdp/components/Price/index.d.ts new file mode 100644 index 0000000000..7fe872098b --- /dev/null +++ b/scripts/__dropins__/storefront-pdp/components/Price/index.d.ts @@ -0,0 +1,18 @@ +/** + * ADOBE CONFIDENTIAL + * __________________ + * Copyright 2024 Adobe + * All Rights Reserved. + * __________________ + * NOTICE: All information contained herein is, and remains + * the property of Adobe and its suppliers, if any. The intellectual + * and technical concepts contained herein are proprietary to Adobe + * and its suppliers and are protected by all applicable intellectual + * property laws, including trade secret and copyright laws. + * Dissemination of this information or reproduction of this material + * is strictly forbidden unless prior written permission is obtained + * from Adobe. + */ +export * from './Price'; +export { Price as default } from './Price'; +//# sourceMappingURL=index.d.ts.map \ No newline at end of file diff --git a/scripts/__dropins__/storefront-pdp/components/Swatches/Swatches.d.ts b/scripts/__dropins__/storefront-pdp/components/Swatches/Swatches.d.ts index fb5fd5efef..b888e4909e 100644 --- a/scripts/__dropins__/storefront-pdp/components/Swatches/Swatches.d.ts +++ b/scripts/__dropins__/storefront-pdp/components/Swatches/Swatches.d.ts @@ -26,6 +26,7 @@ type Selection = { export interface SwatchesProps extends HTMLAttributes { options: Array