FileMaster
Search
Toggle Dark Mode
Home
/
.
/
wp-content
/
plugins
/
surecart
/
dist
/
components
/
components
Edit File: sc-swap2.js
import{proxyCustomElement,HTMLElement,h}from"@stencil/core/internal/client";import{s as state}from"./mutations2.js";import{t as toggleSwap}from"./index4.js";import{u as updateFormState}from"./mutations5.js";import{c as createErrorNotice}from"./mutations3.js";import{d as defineCustomElement$1}from"./sc-switch2.js";const scSwapCss=".swap{display:flex;align-items:baseline;justify-content:space-between}.swap__price{color:var(--sc-swap-price-color, var(--sc-input-label-color));line-height:var(--sc-line-height-dense);font-size:var(--sc-font-size-small);white-space:nowrap}",ScSwapStyle0=scSwapCss,ScSwap=proxyCustomElement(class extends HTMLElement{constructor(){super(),this.__registerHost(),this.__attachShadow(),this.lineItem=void 0}async onSwapToggleChange(e){var t;try{updateFormState("FETCH"),state.checkout=await toggleSwap({id:null===(t=this.lineItem)||void 0===t?void 0:t.id,action:e.target.checked?"swap":"unswap"}),updateFormState("RESOLVE")}catch(e){updateFormState("REJECT"),createErrorNotice(e.message),console.error(e)}}render(){var e,t,s,i,o;if(!(null===(e=null==this?void 0:this.lineItem)||void 0===e?void 0:e.is_swappable))return null;const a=(null===(t=null==this?void 0:this.lineItem)||void 0===t?void 0:t.swap)||(null===(i=null===(s=null==this?void 0:this.lineItem)||void 0===s?void 0:s.price)||void 0===i?void 0:i.current_swap),n=(null==a?void 0:a.swap_price)||this.lineItem.price;return h("div",{class:"swap"},h("sc-switch",{checked:!!(null===(o=null==this?void 0:this.lineItem)||void 0===o?void 0:o.swap),onScChange:e=>this.onSwapToggleChange(e)},null==a?void 0:a.description),!!(null==n?void 0:n.display_amount)&&h("div",{class:"swap__price"},null==n?void 0:n.display_amount," ",null==n?void 0:n.short_interval_text," ",null==n?void 0:n.short_interval_count_text))}static get style(){return ScSwapStyle0}},[1,"sc-swap",{lineItem:[16]}]);function defineCustomElement(){"undefined"!=typeof customElements&&["sc-swap","sc-switch"].forEach((e=>{switch(e){case"sc-swap":customElements.get(e)||customElements.define(e,ScSwap);break;case"sc-switch":customElements.get(e)||defineCustomElement$1()}}))}export{ScSwap as S,defineCustomElement as d};
Save
Back