FileMaster
Search
Toggle Dark Mode
Home
/
.
/
wp-content
/
plugins
/
surecart
/
dist
/
components
/
components
Edit File: sc-line-items.js
import{proxyCustomElement,HTMLElement,h}from"@stencil/core/internal/client";import{s as state}from"./mutations2.js";import{u as updateCheckoutLineItem,r as removeCheckoutLineItem}from"./mutations4.js";import{f as formBusy}from"./getters3.js";import{g as getMaxStockQuantity}from"./quantity.js";import{d as defineCustomElement$b}from"./sc-button2.js";import{d as defineCustomElement$a}from"./sc-icon2.js";import{d as defineCustomElement$9}from"./sc-line-item2.js";import{d as defineCustomElement$8}from"./sc-product-line-item2.js";import{d as defineCustomElement$7}from"./sc-product-line-item-note2.js";import{d as defineCustomElement$6}from"./sc-quantity-select2.js";import{d as defineCustomElement$5}from"./sc-skeleton2.js";import{d as defineCustomElement$4}from"./sc-spinner2.js";import{d as defineCustomElement$3}from"./sc-swap2.js";import{d as defineCustomElement$2}from"./sc-switch2.js";const scLineItemsCss=":host{display:block}:slotted(*~*){margin-top:20px}.line-items{display:grid;gap:var(--sc-form-row-spacing)}.line-item{display:grid;gap:var(--sc-spacing-small)}.line-item--has-swap{border:1px solid var(--sc-input-border-color);background:var(--sc-card-background-color, var(--sc-color-white));border-radius:var(--sc-border-radius-medium);gap:0;border-radius:var(--sc-input-border-radius-medium);overflow:hidden}.line-item--has-swap sc-product-line-item{padding:var(--sc-spacing-medium);border-bottom:solid var(--sc-input-border-width) var(--sc-input-border-color)}.line-item--has-swap sc-swap{padding:var(--sc-spacing-medium);background:var(--sc-card-background-color, var(--sc-color-gray-50))}sc-swap{font-size:var(--sc-font-size-small);line-height:var(--sc-line-height-dense);color:var(--sc-input-label-color)}.fee__description{opacity:0.75}",ScLineItemsStyle0=scLineItemsCss,ScLineItems$1=proxyCustomElement(class extends HTMLElement{constructor(){super(),this.__registerHost(),this.__attachShadow(),this.editable=void 0,this.removable=void 0}isEditable(e){var t;return!((null===(t=null==e?void 0:e.price)||void 0===t?void 0:t.ad_hoc)||(null==e?void 0:e.bump_amount)||(null==e?void 0:e.locked))&&this.editable}render(){var e,t,i,s,n;if(formBusy()&&!(null===(i=null===(t=null===(e=null==state?void 0:state.checkout)||void 0===e?void 0:e.line_items)||void 0===t?void 0:t.data)||void 0===i?void 0:i.length))return h("sc-line-item",null,h("sc-skeleton",{style:{width:"50px",height:"50px","--border-radius":"0"},slot:"image"}),h("sc-skeleton",{slot:"title",style:{width:"120px",display:"inline-block"}}),h("sc-skeleton",{slot:"description",style:{width:"60px",display:"inline-block"}}),h("sc-skeleton",{style:{width:"120px",display:"inline-block"},slot:"price"}),h("sc-skeleton",{style:{width:"60px",display:"inline-block"},slot:"price-description"}));const o=((null===(n=null===(s=null==state?void 0:state.checkout)||void 0===s?void 0:s.line_items)||void 0===n?void 0:n.data)||[]).sort(((e,t)=>{const i=(null==e?void 0:e.is_swappable)?1:0;return((null==t?void 0:t.is_swappable)?1:0)-i}));return h("div",{class:"line-items",part:"base",tabindex:"0"},o.map((e=>{var t,i,s,n,o,l,a,m;const c=getMaxStockQuantity(null===(t=null==e?void 0:e.price)||void 0===t?void 0:t.product,null==e?void 0:e.variant);return h("div",{class:"line-item "+((null==e?void 0:e.is_swappable)?"line-item--has-swap":"")},h("sc-product-line-item",{key:e.id,image:null==e?void 0:e.image,name:null===(s=null===(i=null==e?void 0:e.price)||void 0===i?void 0:i.product)||void 0===s?void 0:s.name,price:null===(n=null==e?void 0:e.price)||void 0===n?void 0:n.name,variant:null==e?void 0:e.variant_display_options,fees:null===(o=null==e?void 0:e.fees)||void 0===o?void 0:o.data,amount:e.ad_hoc_display_amount?e.ad_hoc_display_amount:e.subtotal_display_amount,scratch:e.ad_hoc_display_amount?null:null==e?void 0:e.scratch_display_amount,trial:null===(l=null==e?void 0:e.price)||void 0===l?void 0:l.trial_text,interval:`${null===(a=null==e?void 0:e.price)||void 0===a?void 0:a.short_interval_text} ${null===(m=null==e?void 0:e.price)||void 0===m?void 0:m.short_interval_count_text}`,quantity:e.quantity,purchasableStatus:null==e?void 0:e.purchasable_status_display,note:null==e?void 0:e.display_note,...c?{max:c}:{},editable:this.isEditable(e),removable:!(null==e?void 0:e.locked)&&this.removable,onScUpdateQuantity:t=>updateCheckoutLineItem({id:e.id,data:{quantity:t.detail}}),onScRemove:()=>removeCheckoutLineItem(null==e?void 0:e.id),exportparts:"base:line-item, product-line-item, image:line-item__image, placeholder__image: line-item__placeholder-image, text:line-item__text, title:line-item__title, suffix:line-item__suffix, price:line-item__price, price__amount:line-item__price-amount, price__description:line-item__price-description, price__scratch:line-item__price-scratch, static-quantity:line-item__static-quantity, remove-icon__base:line-item__remove-icon, quantity:line-item__quantity, quantity__minus:line-item__quantity-minus, quantity__minus-icon:line-item__quantity-minus-icon, quantity__plus:line-item__quantity-plus, quantity__plus-icon:line-item__quantity-plus-icon, quantity__input:line-item__quantity-input, line-item__price-description:line-item__price-description"}),h("sc-swap",{lineItem:e}))})))}static get style(){return ScLineItemsStyle0}},[1,"sc-line-items",{editable:[4],removable:[4]}]);function defineCustomElement$1(){"undefined"!=typeof customElements&&["sc-line-items","sc-button","sc-icon","sc-line-item","sc-product-line-item","sc-product-line-item-note","sc-quantity-select","sc-skeleton","sc-spinner","sc-swap","sc-switch"].forEach((e=>{switch(e){case"sc-line-items":customElements.get(e)||customElements.define(e,ScLineItems$1);break;case"sc-button":customElements.get(e)||defineCustomElement$b();break;case"sc-icon":customElements.get(e)||defineCustomElement$a();break;case"sc-line-item":customElements.get(e)||defineCustomElement$9();break;case"sc-product-line-item":customElements.get(e)||defineCustomElement$8();break;case"sc-product-line-item-note":customElements.get(e)||defineCustomElement$7();break;case"sc-quantity-select":customElements.get(e)||defineCustomElement$6();break;case"sc-skeleton":customElements.get(e)||defineCustomElement$5();break;case"sc-spinner":customElements.get(e)||defineCustomElement$4();break;case"sc-swap":customElements.get(e)||defineCustomElement$3();break;case"sc-switch":customElements.get(e)||defineCustomElement$2()}}))}const ScLineItems=ScLineItems$1,defineCustomElement=defineCustomElement$1;export{ScLineItems,defineCustomElement};
Save
Back