1 line
7.0 KiB
JavaScript
1 line
7.0 KiB
JavaScript
(self.webpackChunkwebpackWcBlocksFrontendJsonp=self.webpackChunkwebpackWcBlocksFrontendJsonp||[]).push([[9319],{4845:(e,t,o)=>{"use strict";o.d(t,{A:()=>m});var i=o(1609),c=o(8165),n=o(6087),r=o(9019),s=o.n(r),a=o(4040),p=o.n(a),l=(o(2080),o(8730));const m=(0,n.forwardRef)(((e,t)=>{"showSpinner"in e&&p()("showSpinner prop",{version:"8.9.0",alternative:"Render a spinner in the button children instead.",plugin:"WooCommerce"});const{className:o,showSpinner:n=!1,children:r,variant:a="contained",removeTextWrap:m=!1,...d}=e,h=s()("wc-block-components-button","wp-element-button",o,a,{"wc-block-components-button--loading":n});if("href"in e)return(0,i.createElement)(c.$,{render:(0,i.createElement)("a",{ref:t,href:e.href},n&&(0,i.createElement)(l.A,null),(0,i.createElement)("span",{className:"wc-block-components-button__text"},r)),className:h,...d});const u=m?e.children:(0,i.createElement)("span",{className:"wc-block-components-button__text"},e.children);return(0,i.createElement)(c.$,{ref:t,className:h,...d},n&&(0,i.createElement)(l.A,null),u)}))},9017:(e,t,o)=>{"use strict";o.d(t,{A:()=>c});var i=o(7723);const c=({defaultTitle:e=(0,i.__)("Step","woocommerce"),defaultDescription:t=(0,i.__)("Step description text.","woocommerce"),defaultShowStepNumber:o=!0})=>({title:{type:"string",default:e},description:{type:"string",default:t},showStepNumber:{type:"boolean",default:o}})},5239:(e,t,o)=>{"use strict";o.r(t),o.d(t,{default:()=>R});var i=o(1609),c=o(9019),n=o.n(c),r=o(1616),s=o(4656),a=o(7143),p=o(7594),l=o(4958),m=o(812),d=o(9292),h=o(7723),u=o(7104),g=o(3705),_=o(1176),k=o(6087),w=o(8531),E=o(5703),v=o(8529);const b=({minRate:e,maxRate:t,multiple:o=!1})=>{if(void 0===e||void 0===t)return null;const c=(0,E.getSetting)("displayCartPricesIncludingTax",!1)?parseInt(e.price,10)+parseInt(e.taxes,10):parseInt(e.price,10),n=(0,E.getSetting)("displayCartPricesIncludingTax",!1)?parseInt(t.price,10)+parseInt(t.taxes,10):parseInt(t.price,10),r=0===c?(0,i.createElement)("em",null,(0,h.__)("free","woocommerce")):(0,i.createElement)(s.FormattedMonetaryAmount,{currency:(0,v.getCurrencyFromPriceResponse)(e),value:c});return(0,i.createElement)("span",{className:"wc-block-checkout__shipping-method-option-price"},c!==n||o?(0,k.createInterpolateElement)(0===c&&0===n?"<price />":(0,h.__)("from <price />","woocommerce"),{price:r}):r)};function f(e){return e?{min:e.reduce(((e,t)=>(0,w.jV)(t.method_id)?e:void 0===e||parseInt(t.price,10)<parseInt(e.price,10)?t:e),void 0),max:e.reduce(((e,t)=>(0,w.jV)(t.method_id)?e:void 0===e||parseInt(t.price,10)>parseInt(e.price,10)?t:e),void 0)}:{min:void 0,max:void 0}}function x(e){return e?{min:e.reduce(((e,t)=>(0,w.jV)(t.method_id)&&(void 0===e||t.price<e.price)?t:e),void 0),max:e.reduce(((e,t)=>(0,w.jV)(t.method_id)&&(void 0===e||t.price>e.price)?t:e),void 0)}:{min:void 0,max:void 0}}const C=(0,h.__)("Pickup","woocommerce"),T=(0,h.__)("Ship","woocommerce");o(3832);var S=o(4845);const I={hidden:!0,message:(0,h.__)("Shipping options are not available","woocommerce")},N=({checked:e,rate:t,showPrice:o,showIcon:c,toggleText:r,multiple:s,onClick:a})=>(0,i.createElement)(S.A,{role:"radio",removeTextWrap:!0,onClick:a,className:n()("wc-block-checkout__shipping-method-option",{"wc-block-checkout__shipping-method-option--selected":"pickup"===e})},!0===c&&(0,i.createElement)(u.A,{icon:g.A,size:28,className:"wc-block-checkout__shipping-method-option-icon"}),(0,i.createElement)("span",{className:"wc-block-checkout__shipping-method-option-title"},r),!0===o&&(0,i.createElement)(b,{multiple:s,minRate:t.min,maxRate:t.max})),y=({checked:e,rate:t,showPrice:o,showIcon:c,toggleText:r,onClick:s,shippingCostRequiresAddress:l=!1})=>{const m=(0,a.useSelect)((e=>e(p.CART_STORE_KEY).getShippingRates().some((({shipping_rates:e})=>!e.every(w.J_))))),d=l&&(()=>{const e=(0,a.select)("wc/store/validation"),t=e.getValidationError("shipping_state"),o=e.getValidationError("shipping_address_1"),i=e.getValidationError("shipping_country"),c=e.getValidationError("shipping_postcode");return[e.getValidationError("shipping_city"),t,o,i,c].some((e=>void 0!==e))})()&&!m,g=void 0!==t.min&&void 0!==t.max,{setValidationErrors:E,clearValidationError:v}=(0,a.useDispatch)(p.VALIDATION_STORE_KEY);(0,k.useEffect)((()=>{"shipping"!==e||g?v("shipping-rates-error"):E({"shipping-rates-error":I})}),[e,v,g,E]);const f=void 0===t.min||d?(0,i.createElement)("span",{className:"wc-block-checkout__shipping-method-option-price"},(0,h.__)("calculated with an address","woocommerce")):(0,i.createElement)(b,{minRate:t.min,maxRate:t.max});return(0,i.createElement)(S.A,{role:"radio",onClick:s,removeTextWrap:!0,className:n()("wc-block-checkout__shipping-method-option",{"wc-block-checkout__shipping-method-option--selected":"shipping"===e})},!0===c&&(0,i.createElement)(u.A,{icon:_.A,size:28,className:"wc-block-checkout__shipping-method-option-icon"}),(0,i.createElement)("span",{className:"wc-block-checkout__shipping-method-option-title"},r),!0===o&&f)},P=({checked:e,onChange:t,showPrice:o,showIcon:c,localPickupText:n,shippingText:r})=>{var s,a;const{shippingRates:p}=(0,l.m)(),m=(0,E.getSetting)("shippingCostRequiresAddress",!1),d=(0,E.getSetting)("localPickupText",n||C);return(0,i.createElement)("div",{id:"shipping-method",className:"components-button-group wc-block-checkout__shipping-method-container",role:"radiogroup"},(0,i.createElement)(y,{checked:e,onClick:()=>{t("shipping")},rate:f(null===(s=p[0])||void 0===s?void 0:s.shipping_rates),showPrice:o,showIcon:c,shippingCostRequiresAddress:m,toggleText:r||T}),(0,i.createElement)(N,{checked:e,onClick:()=>{t("pickup")},rate:x(null===(a=p[0])||void 0===a?void 0:a.shipping_rates),multiple:p.length>1,showPrice:o,showIcon:c,toggleText:d}))},A={...(0,o(9017).A)({defaultTitle:(0,h.__)("Delivery","woocommerce"),defaultDescription:(0,h.__)("Select how you would like to receive your order.","woocommerce")}),className:{type:"string",default:""},showIcon:{type:"boolean",default:!0},showPrice:{type:"boolean",default:!1},localPickupText:{type:"string",default:C},shippingText:{type:"string",default:T},lock:{type:"object",default:{move:!0,remove:!0}}},R=(0,r.withFilteredAttributes)(A)((({title:e,description:t,children:o,className:c,showPrice:r,showIcon:h,shippingText:u,localPickupText:g})=>{const{showFormStepNumbers:_}=(0,d.Oy)(),{checkoutIsProcessing:k,prefersCollection:w}=(0,a.useSelect)((e=>{const t=e(p.CHECKOUT_STORE_KEY);return{checkoutIsProcessing:t.isProcessing(),prefersCollection:t.prefersCollection()}})),{setPrefersCollection:E}=(0,a.useDispatch)(p.CHECKOUT_STORE_KEY),{shippingRates:v,needsShipping:b,hasCalculatedShipping:f,isCollectable:x}=(0,l.m)();return b&&f&&v&&x&&m.F7?(0,i.createElement)(s.FormStep,{id:"shipping-method",disabled:k,className:n()("wc-block-checkout__shipping-method",c),title:e,description:t,showStepNumber:_},(0,i.createElement)(P,{checked:w?"pickup":"shipping",onChange:e=>{E("pickup"===e)},showPrice:r,showIcon:h,localPickupText:g,shippingText:u}),o):null}))},8730:(e,t,o)=>{"use strict";o.d(t,{A:()=>c});var i=o(1609);o(7791);const c=()=>(0,i.createElement)("span",{className:"wc-block-components-spinner","aria-hidden":"true"})},2080:()=>{},7791:()=>{}}]); |