admin
1 year ago
blocks
1 year ago
components
1 year ago
icon-assets
1 year ago
store
1 year ago
styles
1 year ago
templates
1 year ago
1012.js
1 year ago
1013.js
1 year ago
1071.js
1 year ago
1222.js
1 year ago
1279.js
1 year ago
1375.js
1 year ago
1418.js
1 year ago
1467.js
1 year ago
1567.js
1 year ago
1712.js
1 year ago
1782.js
1 year ago
1897.js
1 year ago
1935.js
1 year ago
1936.js
1 year ago
1972.js
1 year ago
2023.js
1 year ago
2074.js
1 year ago
2107.js
1 year ago
2120.js
1 year ago
2179.js
1 year ago
2321.js
1 year ago
2393.js
1 year ago
2461.js
1 year ago
2518.js
1 year ago
2529.js
1 year ago
253.js
1 year ago
2654.js
1 year ago
2655.js
1 year ago
2837.js
1 year ago
2850.js
1 year ago
2865.js
1 year ago
2878.js
1 year ago
2885.js
1 year ago
2894.js
1 year ago
2932.js
1 year ago
294.js
1 year ago
2948.js
1 year ago
3093.js
1 year ago
3139.js
1 year ago
3291.js
1 year ago
3328.js
1 year ago
3346.js
1 year ago
3396.js
1 year ago
3419.js
1 year ago
348.js
1 year ago
3590.js
1 year ago
3684.js
1 year ago
3787.js
1 year ago
3789.js
1 year ago
3829.js
1 year ago
3877.js
1 year ago
3928.js
1 year ago
393.js
1 year ago
3998.js
1 year ago
4006.js
1 year ago
4009.js
1 year ago
4086.js
1 year ago
4127.js
1 year ago
4179.js
1 year ago
4264.js
1 year ago
4372.js
1 year ago
4495.js
1 year ago
4498.js
1 year ago
4527.js
1 year ago
475.js
1 year ago
476.js
1 year ago
4869.js
1 year ago
4917.js
1 year ago
5093.js
1 year ago
515.js
1 year ago
5230.js
1 year ago
5254.js
1 year ago
5397.js
1 year ago
5471.js
1 year ago
5503.js
1 year ago
5585.js
1 year ago
5611.js
1 year ago
5668.js
1 year ago
5703.js
1 year ago
5733.js
1 year ago
5812.js
1 year ago
5825.js
1 year ago
6000.js
1 year ago
6008.js
1 year ago
6021.js
1 year ago
6034.js
1 year ago
6087.js
1 year ago
610.js
1 year ago
6241.js
1 year ago
6274.js
1 year ago
6325.js
1 year ago
6387.js
1 year ago
6453.js
1 year ago
648.js
1 year ago
6653.js
1 year ago
6755.js
1 year ago
6756.js
1 year ago
686.js
1 year ago
6886.js
1 year ago
6912.js
1 year ago
6932.js
1 year ago
7245.js
1 year ago
7254.js
1 year ago
7291.js
1 year ago
7313.js
1 year ago
7349.js
1 year ago
7435.js
1 year ago
75.js
1 year ago
7513.js
1 year ago
7578.js
1 year ago
758.js
1 year ago
7624.js
1 year ago
7725.js
1 year ago
7851.js
1 year ago
7893.js
1 year ago
8053.js
1 year ago
8095.js
1 year ago
8148.js
1 year ago
8207.js
1 year ago
821.js
1 year ago
8229.js
1 year ago
8270.js
1 year ago
829.js
1 year ago
8360.js
1 year ago
839.js
1 year ago
8516.js
1 year ago
8532.js
1 year ago
854.js
1 year ago
8676.js
1 year ago
868.js
1 year ago
8695.js
1 year ago
8739.js
1 year ago
8923.js
1 year ago
8925.js
1 year ago
8935.js
1 year ago
8942.js
1 year ago
8979.js
1 year ago
9008.js
1 year ago
9017.js
1 year ago
9023.js
1 year ago
903.js
1 year ago
9049.js
1 year ago
9063.js
1 year ago
9093.js
1 year ago
9140.js
1 year ago
9173.js
1 year ago
9210.js
1 year ago
9367.js
1 year ago
9372.js
1 year ago
9433.js
1 year ago
9459.js
1 year ago
9537.js
1 year ago
9607.js
1 year ago
9626.js
1 year ago
9640.js
1 year ago
9643.js
1 year ago
965.js
1 year ago
9687.js
1 year ago
9688.js
1 year ago
9691.js
1 year ago
9797.js
1 year ago
9804.js
1 year ago
9846.js
1 year ago
9881.js
1 year ago
9897.js
1 year ago
9969.js
1 year ago
7893.js
1 lines
| 1 | "use strict";(self.webpackChunk_surecart_surecart=self.webpackChunk_surecart_surecart||[]).push([[7893],{581:function(e,i,t){t.d(i,{o:function(){return o}});var n=t(1346),o=function(e,i,t){void 0===t&&(t=!0);var o="Function"===e.constructor.name?e.prototype:e,s=o.componentWillLoad;o.componentWillLoad=function(){var e,o=this,l=(0,n.a)(this),u={promise:new Promise((function(i){e=i})),resolve:e},c=new CustomEvent("openWormhole",{bubbles:!0,composed:!0,detail:{consumer:this,fields:i,updater:function(e,i){(e in l?l:o)[e]=i},onOpen:u}});l.dispatchEvent(c);var a=function(){if(s)return s.call(o)};return t?u.promise.then((function(){return a()})):a()}}},7893:function(e,i,t){t.r(i),t.d(i,{sc_donation_choices:function(){return r}});var n=t(467),o=t(3029),s=t(2901),l=t(9280),u=t.n(l),c=t(1346),a=t(581),r=function(){return(0,s.A)((function e(i){(0,o.A)(this,e),(0,c.r)(this,i),this.scRemoveLineItem=(0,c.c)(this,"scRemoveLineItem",7),this.scUpdateLineItem=(0,c.c)(this,"scUpdateLineItem",7),this.scAddLineItem=(0,c.c)(this,"scAddLineItem",7),this.priceId=void 0,this.defaultAmount=void 0,this.currencyCode="usd",this.lineItems=[],this.loading=void 0,this.busy=void 0,this.removeInvalid=!0,this.label=void 0,this.lineItem=void 0,this.error=void 0,this.showCustomAmount=void 0}),[{key:"reportValidity",value:(e=(0,n.A)(u().mark((function e(){return u().wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(this.input){e.next=2;break}return e.abrupt("return",!0);case 2:return e.abrupt("return",this.input.shadowRoot.querySelector("sc-input").reportValidity());case 3:case"end":return e.stop()}}),e,this)}))),function(){return e.apply(this,arguments)})},{key:"handleChange",value:function(){var e=Array.from(this.getChoices()).find((function(e){return e.checked}));this.showCustomAmount="ad_hoc"===e.value,isNaN(parseInt(e.value))||this.scUpdateLineItem.emit({price_id:this.priceId,quantity:1,ad_hoc_amount:parseInt(e.value)})}},{key:"handleCustomAmountToggle",value:function(e){var i=this;e&&setTimeout((function(){var e,t;null===(t=null===(e=i.input)||void 0===e?void 0:e.triggerFocus)||void 0===t||t.call(e)}),50)}},{key:"handleLineItemsChange",value:function(){var e,i=this;(null===(e=this.lineItems)||void 0===e?void 0:e.length)&&(this.lineItem=(this.lineItems||[]).find((function(e){return e.price.id===i.priceId})))}},{key:"handleLineItemChange",value:function(e){this.removeInvalid&&this.removeInvalidPrices();var i=this.getChoices(),t=!1;i.forEach((function(i){isNaN(parseInt(i.value))||i.disabled||(parseInt(i.value)===(null==e?void 0:e.ad_hoc_amount)?(i.checked=!0,t=!0):i.checked=!1)})),this.showCustomAmount=!t,t||(this.el.querySelector('sc-choice[value="ad_hoc"]').checked=!0)}},{key:"componentWillLoad",value:function(){this.handleLineItemsChange()}},{key:"selectDefaultChoice",value:function(){var e=this.getChoices();e.length&&(e[0].checked=!0)}},{key:"getChoices",value:function(){return this.el.querySelectorAll("sc-choice")||[]}},{key:"removeInvalidPrices",value:function(){var e=this;this.lineItem&&this.getChoices().forEach((function(i){var t,n,o,s,l,u,c,a;return(null===(n=null===(t=e.lineItem)||void 0===t?void 0:t.price)||void 0===n?void 0:n.ad_hoc_max_amount)&&parseInt(i.value)>(null===(s=null===(o=e.lineItem)||void 0===o?void 0:o.price)||void 0===s?void 0:s.ad_hoc_max_amount)||(null===(u=null===(l=e.lineItem)||void 0===l?void 0:l.price)||void 0===u?void 0:u.ad_hoc_min_amount)&&parseInt(i.value)<(null===(a=null===(c=e.lineItem)||void 0===c?void 0:c.price)||void 0===a?void 0:a.ad_hoc_min_amount)?(i.style.display="none",void(i.disabled=!0)):(i.style.display="flex",void(i.disabled=!1))}))}},{key:"updateCustomAmount",value:function(){var e,i,t;this.input.value!==(null===(t=null===(i=null===(e=this.lineItem)||void 0===e?void 0:e.ad_hoc_amount)||void 0===i?void 0:i.toString)||void 0===t?void 0:t.call(i))&&(this.input.value?this.scUpdateLineItem.emit({price_id:this.priceId,quantity:1,ad_hoc_amount:parseInt(this.input.value)}):this.scRemoveLineItem.emit({price_id:this.priceId,quantity:1}))}},{key:"render",value:function(){var e,i,t,n=this;return this.loading?(0,c.h)("div",{class:"sc-donation-choices"},(0,c.h)("sc-skeleton",{style:{width:"20%",display:"inline-block"}}),(0,c.h)("sc-skeleton",{style:{width:"60%",display:"inline-block"}}),(0,c.h)("sc-skeleton",{style:{width:"40%",display:"inline-block"}})):(0,c.h)("div",{class:"sc-donation-choices"},(0,c.h)("sc-choices",{label:this.label,"auto-width":!0},(0,c.h)("slot",null)),this.showCustomAmount&&(0,c.h)("div",{class:"sc-donation-choices__form"},(0,c.h)("sc-price-input",{ref:function(e){return n.input=e},required:!0,currencyCode:this.currencyCode,label:"Enter an amount",value:null===(t=null===(i=null===(e=this.lineItem)||void 0===e?void 0:e.ad_hoc_amount)||void 0===i?void 0:i.toString)||void 0===t?void 0:t.call(i)}),(0,c.h)("sc-button",{type:"primary",onClick:function(){return n.updateCustomAmount()},full:!0,busy:this.busy},wp.i18n.__("Update","surecart"))),this.busy&&(0,c.h)("sc-block-ui",{style:{zIndex:"9"}}))}},{key:"el",get:function(){return(0,c.a)(this)}}],[{key:"watchers",get:function(){return{showCustomAmount:["handleCustomAmountToggle"],lineItems:["handleLineItemsChange"],lineItem:["handleLineItemChange"]}}}]);var e}();(0,a.o)(r,["lineItems","loading","busy","currencyCode"],!1),r.style=":host{display:block}.sc-donation-choices{display:grid;gap:var(--sc-spacing-small);position:relative}.sc-donation-choices__form{display:grid;gap:var(--sc-spacing-small)}"}}]); |