File "shipping-address-frontend.js"
Full Path: /home/siazco/grocery.siazco.se/wp-content/plugins/woocommerce/assets/client/blocks/checkout-blocks/shipping-address-frontend.js
File size: 5.72 KB
MIME-type: text/plain
Charset: utf-8
(self.webpackChunkwebpackWcBlocksCartCheckoutFrontendJsonp=self.webpackChunkwebpackWcBlocksCartCheckoutFrontendJsonp||[]).push([[636],{3127:(e,s,t)=>{"use strict";t.d(s,{A:()=>l});var r=t(1609),n=t(7723),d=t(3993),i=t(5703),a=t(6398),o=t(9155);t(1094);const l=({address:e,onEdit:s,target:t,fieldConfig:l,isExpanded:c})=>{const p=(0,i.getSetting)("countryData",{});let m=(0,i.getSetting)("defaultAddressFormat","{name}\n{company}\n{address_1}\n{address_2}\n{city}\n{state}\n{postcode}\n{country}");(0,d.objectHasProp)(p,null==e?void 0:e.country)&&(0,d.objectHasProp)(p[e.country],"format")&&(0,d.isString)(p[e.country].format)&&(m=p[e.country].format);const{name:u,address:h}=(0,a.M0)(e,m),g="shipping"===t?(0,n.__)("Edit shipping address","woocommerce"):(0,n.__)("Edit billing address","woocommerce");return(0,r.createElement)("div",{className:"wc-block-components-address-card"},(0,r.createElement)("address",null,(0,r.createElement)("span",{className:"wc-block-components-address-card__address-section"},u),(0,r.createElement)("div",{className:"wc-block-components-address-card__address-section"},h.filter((e=>!!e)).map(((e,s)=>(0,r.createElement)("span",{key:"address-"+s},e)))),e.phone&&!l.phone.hidden?(0,r.createElement)("div",{key:"address-phone",className:"wc-block-components-address-card__address-section"},e.phone):""),s&&(0,r.createElement)(o.$,{render:(0,r.createElement)("span",null),className:"wc-block-components-address-card__edit","aria-controls":t,"aria-expanded":c,"aria-label":g,onClick:e=>{e.preventDefault(),s()},type:"button"},(0,n.__)("Edit","woocommerce")))}},8202:(e,s,t)=>{"use strict";t.d(s,{A:()=>d});var r=t(1609),n=t(851);t(7259);const d=({isEditing:e=!1,addressCard:s,addressForm:t})=>{const d=(0,n.A)("wc-block-components-address-address-wrapper",{"is-editing":e});return(0,r.createElement)("div",{className:d},(0,r.createElement)("div",{className:"wc-block-components-address-card-wrapper"},s()),(0,r.createElement)("div",{className:"wc-block-components-address-form-wrapper"},t()))}},9017:(e,s,t)=>{"use strict";t.d(s,{A:()=>n});var r=t(7723);const n=({defaultTitle:e=(0,r.__)("Step","woocommerce"),defaultDescription:s=(0,r.__)("Step description text.","woocommerce"),defaultShowStepNumber:t=!0})=>({title:{type:"string",default:e},description:{type:"string",default:s},showStepNumber:{type:"boolean",default:t}})},7275:(e,s,t)=>{"use strict";t.r(s),t.d(s,{default:()=>v});var r=t(1609),n=t(851),d=t(1616),i=t(4656),a=t(5251),o=t(7143),l=t(7594),c=t(7723),p=t(6087),m=t(4375),u=t(2663),h=t(2379),g=t(3494),E=t(5703),w=t(5683),_=t(3505),f=t(3603),b=t(812),C=t(8202),S=t(3127);const A=({addressFieldsConfig:e})=>{const{shippingAddress:s,setShippingAddress:t,setBillingAddress:n,useShippingAsBilling:d,editingShippingAddress:i,setEditingShippingAddress:c}=(0,a.C)(),{dispatchCheckoutEvent:m}=(0,f.y)(),{hasValidationErrors:u,invalidProps:h}=(0,o.useSelect)((e=>{const t=e(l.VALIDATION_STORE_KEY);return{hasValidationErrors:t.hasValidationErrors(),invalidProps:Object.keys(s).filter((e=>void 0!==t.getValidationError("shipping_"+e))).filter(Boolean)}}));(0,p.useEffect)((()=>{h.length>0&&!1===i&&c(!0)}),[i,u,h.length,c]);const g=(0,p.useCallback)((e=>{t(e),d&&(n(e),m("set-billing-address")),m("set-shipping-address")}),[m,n,t,d]),E=(0,p.useCallback)((()=>(0,r.createElement)(S.A,{address:s,target:"shipping",onEdit:()=>{c(!0)},fieldConfig:e,isExpanded:i})),[s,e,i,c]),w=(0,p.useCallback)((()=>(0,r.createElement)(_.l,{id:"shipping",addressType:"shipping",onChange:g,values:s,fields:b.Hw,fieldConfig:e,isEditing:i})),[e,g,s,i]);return(0,r.createElement)(C.A,{isEditing:i,addressCard:E,addressForm:w})},k=({showCompanyField:e=!1,requireCompanyField:s=!1,showApartmentField:t=!1,requireApartmentField:n=!1,showPhoneField:d=!1,requirePhoneField:_=!1})=>{const{setBillingAddress:f,shippingAddress:b,billingAddress:C,useShippingAsBilling:S,setUseShippingAsBilling:k,setEditingBillingAddress:F}=(0,a.C)(),{isEditor:y}=(0,u.m)(),v=0===(0,E.getSetting)("currentUserId"),N=()=>{const s={...b};d||delete s.phone,e&&delete s.company,f(s)};(0,m.Su)((()=>{S&&N()}));const P=(0,p.useMemo)((()=>({company:{hidden:!e,required:s},address_2:{hidden:!t,required:n},phone:{hidden:!d,required:_}})),[e,s,t,n,d,_]),D=y?g.A:p.Fragment,q=S?[h.tG.SHIPPING_ADDRESS,h.tG.BILLING_ADDRESS]:[h.tG.SHIPPING_ADDRESS],{cartDataLoaded:B}=(0,o.useSelect)((e=>({cartDataLoaded:e(l.CART_STORE_KEY).hasFinishedResolution("getCartData")})));return(0,r.createElement)(p.Fragment,null,(0,r.createElement)(i.StoreNoticesContainer,{context:q}),(0,r.createElement)(D,null,B?(0,r.createElement)(A,{addressFieldsConfig:P}):null),(0,r.createElement)(i.CheckboxControl,{className:"wc-block-checkout__use-address-for-billing",label:(0,c.__)("Use same address for billing","woocommerce"),checked:S,onChange:e=>{k(e),e?N():(F(!0),(e=>{if(!e||!v)return;const s=(0,w.ln)(e);f(s)})(C))}}))},F={...(0,t(9017).A)({defaultTitle:(0,c.__)("Shipping address","woocommerce"),defaultDescription:(0,c.__)("Enter the address where you want your order delivered.","woocommerce")}),className:{type:"string",default:""},lock:{type:"object",default:{move:!0,remove:!0}}};var y=t(9292);const v=(0,d.withFilteredAttributes)(F)((({title:e,description:s,children:t,className:d})=>{const c=(0,o.useSelect)((e=>e(l.CHECKOUT_STORE_KEY).isProcessing())),{showShippingFields:p}=(0,a.C)(),{showCompanyField:m,requireCompanyField:u,showApartmentField:h,requireApartmentField:g,showPhoneField:E,requirePhoneField:w,showFormStepNumbers:_}=(0,y.Oy)();return p?(0,r.createElement)(i.FormStep,{id:"shipping-fields",disabled:c,className:(0,n.A)("wc-block-checkout__shipping-fields",d),title:e,description:s,showStepNumber:_},(0,r.createElement)(k,{showCompanyField:m,requireCompanyField:u,showApartmentField:h,requireApartmentField:g,showPhoneField:E,requirePhoneField:w}),t):null}))},1094:()=>{},7259:()=>{}}]);