FileMaster
Search
Toggle Dark Mode
Home
/
.
/
wp-content
/
plugins
/
surecart
/
dist
/
components
/
components
Edit File: sc-order-shipping-address2.js
import{proxyCustomElement,HTMLElement,h}from"@stencil/core/internal/client";import{s as state,o as onChange}from"./mutations2.js";import{l as lockCheckout,b as unLockCheckout}from"./mutations4.js";import{d as createOrUpdateCheckout}from"./index4.js";import{f as fullShippingAddressRequired,s as shippingAddressRequired}from"./getters2.js";import{a as formLoading}from"./getters3.js";import{d as defineCustomElement$d}from"./sc-address2.js";import{d as defineCustomElement$c}from"./sc-block-ui2.js";import{d as defineCustomElement$b}from"./sc-compact-address2.js";import{d as defineCustomElement$a}from"./dropdown.js";import{d as defineCustomElement$9}from"./sc-form-control2.js";import{d as defineCustomElement$8}from"./sc-icon2.js";import{d as defineCustomElement$7}from"./sc-input2.js";import{d as defineCustomElement$6}from"./sc-menu2.js";import{d as defineCustomElement$5}from"./sc-menu-item2.js";import{d as defineCustomElement$4}from"./sc-menu-label2.js";import{d as defineCustomElement$3}from"./sc-select2.js";import{d as defineCustomElement$2}from"./sc-spinner2.js";import{d as defineCustomElement$1}from"./sc-visually-hidden2.js";const scOrderShippingAddressCss=":host{display:block}.sc-order-shipping__loading{display:flex;flex-direction:column;gap:0.5em}",ScOrderShippingAddressStyle0=scOrderShippingAddressCss,ScOrderShippingAddress=proxyCustomElement(class extends HTMLElement{constructor(){super(),this.__registerHost(),this.__attachShadow(),this.names={name:"shipping_name",country:"shipping_country",city:"shipping_city",line_1:"shipping_line_1",line_2:"shipping_line_2",postal_code:"shipping_postal_code",state:"shipping_state"},this.label=void 0,this.required=!1,this.full=void 0,this.showName=void 0,this.defaultCountry=void 0,this.showLine2=void 0,this.requireName=!1,this.address={country:null,city:null,line_1:null,line_2:null,postal_code:null,state:null}}async updateAddressState(e){var s;if(JSON.stringify(e)!==JSON.stringify(this.address)){this.address=e;try{lockCheckout("shipping-address"),state.checkout=await createOrUpdateCheckout({id:null===(s=state.checkout)||void 0===s?void 0:s.id,data:{shipping_address:this.address}})}catch(e){console.error(e)}finally{unLockCheckout("shipping-address")}}}async reportValidity(){var e,s;return!this.input||(null===(s=null===(e=this.input)||void 0===e?void 0:e.reportValidity)||void 0===s?void 0:s.call(e))}prefillAddress(){var e;const s=Object.keys(this.address).filter((e=>"country"!==e));s.filter((e=>!this.address[e])).length===s.length&&(this.address={...this.address,...null===(e=state.checkout)||void 0===e?void 0:e.shipping_address})}componentWillLoad(){var e;this.defaultCountry&&!(null===(e=this.address)||void 0===e?void 0:e.country)&&(this.address.country=this.defaultCountry),this.prefillAddress(),onChange("checkout",(()=>this.prefillAddress()))}render(){return fullShippingAddressRequired()||this.full||this.requireName||this.showName?h("sc-address",{exportparts:"label, help-text, form-control, input__base, select__base, columns, search__base, menu__base",ref:e=>this.input=e,label:this.label||wp.i18n.__("Shipping Address","surecart"),names:this.names,required:this.required||shippingAddressRequired(),loading:formLoading(),address:this.address,"show-name":this.showName,"require-name":this.requireName,"show-line-2":this.showLine2,onScChangeAddress:e=>this.updateAddressState(e.detail)}):h("sc-compact-address",{ref:e=>this.input=e,required:this.required||shippingAddressRequired(),loading:formLoading(),address:this.address,names:this.names,label:this.label,onScChangeAddress:e=>this.updateAddressState(e.detail)})}static get style(){return ScOrderShippingAddressStyle0}},[1,"sc-order-shipping-address",{label:[1],required:[1540],full:[1028],showName:[516,"show-name"],defaultCountry:[1,"default-country"],showLine2:[516,"show-line-2"],requireName:[516,"require-name"],address:[32],reportValidity:[64]}]);function defineCustomElement(){"undefined"!=typeof customElements&&["sc-order-shipping-address","sc-address","sc-block-ui","sc-compact-address","sc-dropdown","sc-form-control","sc-icon","sc-input","sc-menu","sc-menu-item","sc-menu-label","sc-select","sc-spinner","sc-visually-hidden"].forEach((e=>{switch(e){case"sc-order-shipping-address":customElements.get(e)||customElements.define(e,ScOrderShippingAddress);break;case"sc-address":customElements.get(e)||defineCustomElement$d();break;case"sc-block-ui":customElements.get(e)||defineCustomElement$c();break;case"sc-compact-address":customElements.get(e)||defineCustomElement$b();break;case"sc-dropdown":customElements.get(e)||defineCustomElement$a();break;case"sc-form-control":customElements.get(e)||defineCustomElement$9();break;case"sc-icon":customElements.get(e)||defineCustomElement$8();break;case"sc-input":customElements.get(e)||defineCustomElement$7();break;case"sc-menu":customElements.get(e)||defineCustomElement$6();break;case"sc-menu-item":customElements.get(e)||defineCustomElement$5();break;case"sc-menu-label":customElements.get(e)||defineCustomElement$4();break;case"sc-select":customElements.get(e)||defineCustomElement$3();break;case"sc-spinner":customElements.get(e)||defineCustomElement$2();break;case"sc-visually-hidden":customElements.get(e)||defineCustomElement$1()}}))}export{ScOrderShippingAddress as S,defineCustomElement as d};
Save
Back