4 lines
20 KiB
JavaScript
4 lines
20 KiB
JavaScript
|
(()=>{var e={4184:(e,t)=>{var r;!function(){"use strict";var s={}.hasOwnProperty;function o(){for(var e=[],t=0;t<arguments.length;t++){var r=arguments[t];if(r){var n=typeof r;if("string"===n||"number"===n)e.push(r);else if(Array.isArray(r)){if(r.length){var i=o.apply(null,r);i&&e.push(i)}}else if("object"===n)if(r.toString===Object.prototype.toString)for(var a in r)s.call(r,a)&&r[a]&&e.push(a);else e.push(r.toString())}}return e.join(" ")}e.exports?(o.default=o,e.exports=o):void 0===(r=function(){return o}.apply(t,[]))||(e.exports=r)}()},4578:()=>{},7349:()=>{},8204:()=>{},4093:()=>{},8543:()=>{}},t={};function r(s){var o=t[s];if(void 0!==o)return o.exports;var n=t[s]={exports:{}};return e[s](n,n.exports,r),n.exports}r.n=e=>{var t=e&&e.__esModule?()=>e.default:()=>e;return r.d(t,{a:t}),t},r.d=(e,t)=>{for(var s in t)r.o(t,s)&&!r.o(e,s)&&Object.defineProperty(e,s,{enumerable:!0,get:t[s]})},r.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),(()=>{"use strict";const e=window.React,t=window.wp.element;function s(e){return s="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},s(e)}function o(e,t,r){return(t=function(e){var t=function(e,t){if("object"!==s(e)||null===e)return e;var r=e[Symbol.toPrimitive];if(void 0!==r){var o=r.call(e,"string");if("object"!==s(o))return o;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(e)}(e);return"symbol"===s(t)?t:String(t)}(t))in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}const n=window.wp.i18n,i=window.wc.wcSettings;var a,l,c,d,p,u,w,m,g,h;const v=(0,i.getSetting)("wcBlocksConfig",{buildPhase:1,pluginUrl:"",productCount:0,defaultAvatar:"",restApiRoutes:{},wordCountType:"words"}),b=v.pluginUrl+"images/",y=(v.pluginUrl,v.buildPhase,null===(a=i.STORE_PAGES.shop)||void 0===a||a.permalink,null===(l=i.STORE_PAGES.checkout)||void 0===l||l.id,null===(c=i.STORE_PAGES.checkout)||void 0===c||c.permalink,null===(d=i.STORE_PAGES.privacy)||void 0===d||d.permalink,null===(p=i.STORE_PAGES.privacy)||void 0===p||p.title,null===(u=i.STORE_PAGES.terms)||void 0===u||u.permalink,null===(w=i.STORE_PAGES.terms)||void 0===w||w.title,null===(m=i.STORE_PAGES.cart)||void 0===m||m.id,null===(g=i.STORE_PAGES.cart)||void 0===g||g.permalink,null!==(h=i.STORE_PAGES.myaccount)&&void 0!==h&&h.permalink?i.STORE_PAGES.myaccount.permalink:(0,i.getSetting)("wpLoginUrl","/wp-login.php"),(0,i.getSetting)("localPickupEnabled",!1),(0,i.getSetting)("countries",{})),_=(0,i.getSetting)("countryData",{}),f=(Object.fromEntries(Object.keys(_).filter((e=>!0===_[e].allowBilling)).map((e=>[e,y[e]||""]))),Object.fromEntries(Object.keys(_).filter((e=>!0===_[e].allowBilling)).map((e=>[e,_[e].states||[]]))),Object.fromEntries(Object.keys(_).filter((e=>!0===_[e].allowShipping)).map((e=>[e,y[e]||""]))),Object.fromEntries(Object.keys(_).filter((e=>!0===_[e].allowShipping)).map((e=>[e,_[e].states||[]]))),Object.fromEntries(Object.keys(_).map((e=>[e,_[e].locale||[]]))),({imageUrl:t=`${b}/block-error.svg`,header:r=(0,n.__)("Oops!","woocommerce"),text:s=(0,n.__)("There was an error loading the content.","woocommerce"),errorMessage:o,errorMessagePrefix:i=(0,n.__)("Error:","woocommerce"),button:a,showErrorBlock:l=!0})=>l?(0,e.createElement)("div",{className:"wc-block-error wc-block-components-error"},t&&(0,e.createElement)("img",{className:"wc-block-error__image wc-block-components-error__image",src:t,alt:""}),(0,e.createElement)("div",{className:"wc-block-error__content wc-block-components-error__content"},r&&(0,e.createElement)("p",{className:"wc-block-error__header wc-block-components-error__header"},r),s&&(0,e.createElement)("p",{className:"wc-block-error__text wc-block-components-error__text"},s),o&&(0,e.createElement)("p",{className:"wc-block-error__message wc-block-components-error__message"},i?i+" ":"",o),a&&(0,e.createElement)("p",{className:"wc-block-error__button wc-block-components-error__button"},a))):null);r(457
|
||
|
(0,n.__)("Rated %f out of 5","woocommerce"),r),i={__html:(0,n.sprintf)(/* translators: %s is referring to the average rating value */
|
||
|
(0,n.__)("Rated %s out of 5","woocommerce"),(0,n.sprintf)('<strong class="rating">%f</strong>',r))};return(0,e.createElement)("div",{className:"wc-block-review-list-item__rating wc-block-components-review-list-item__rating"},(0,e.createElement)("div",{className:"wc-block-review-list-item__rating__stars wc-block-components-review-list-item__rating__stars",role:"img","aria-label":o},(0,e.createElement)("span",{style:s,dangerouslySetInnerHTML:i})))}(r),d&&function(t){return(0,e.createElement)("div",{className:"wc-block-review-list-item__product wc-block-components-review-list-item__product"},(0,e.createElement)("a",{href:t.product_permalink,dangerouslySetInnerHTML:{__html:t.product_name}}))}(r),i&&function(t){const{reviewer:r=""}=t;return(0,e.createElement)("div",{className:"wc-block-review-list-item__author wc-block-components-review-list-item__author"},r)}(r),o&&function(t){const{date_created:r,formatted_date_created:s}=t;return(0,e.createElement)("time",{className:"wc-block-review-list-item__published-date wc-block-components-review-list-item__published-date",dateTime:r},s)}(r))),c&&function(t){return(0,e.createElement)(U,{maxLines:10,moreText:(0,n.__)("Read full review","woocommerce"),lessText:(0,n.__)("Hide full review","woocommerce"),className:"wc-block-review-list-item__text wc-block-components-review-list-item__text"},(0,e.createElement)("div",{dangerouslySetInnerHTML:{__html:t.review||""}}))}(r))};r(4093);const q=({attributes:t,reviews:r})=>{const s=(0,i.getSetting)("showAvatars",!0),o=(0,i.getSetting)("reviewRatingsEnabled",!0),n=(s||"product"===t.imageType)&&t.showReviewImage,a=o&&t.showReviewRating,l={...t,showReviewImage:n,showReviewRating:a};return(0,e.createElement)("ul",{className:"wc-block-review-list wc-block-components-review-list"},0===r.length?(0,e.createElement)(F,{attributes:l}):r.map(((t,r)=>(0,e.createElement)(F,{key:t.id||r,attributes:l,review:t}))))},V=window.wp.isShallowEqual;var W=r.n(V);const $=(r=>{class s extends t.Component{constructor(...e){super(...e),o(this,"isPreview",!!this.props.attributes.previewReviews),o(this,"delayedAppendReviews",this.props.delayFunction(this.appendReviews)),o(this,"isMounted",!1),o(this,"state",{error:null,loading:!0,reviews:this.isPreview?this.props.attributes.previewReviews:[],totalReviews:this.isPreview?this.props.attributes.previewReviews.length:0}),o(this,"setError",(async e=>{if(!this.isMounted)return;const{onReviewsLoadError:t}=this.props,r=await(async e=>{if(!("json"in e))return{message:e.message,type:e.type||"general"};try{const t=await e.json();return{message:t.message,type:t.type||"api"}}catch(e){return{message:e.message,type:"general"}}})(e);this.setState({reviews:[],loading:!1,error:r}),t(r)}))}componentDidMount(){this.isMounted=!0,this.replaceReviews()}componentDidUpdate(e){e.reviewsToDisplay<this.props.reviewsToDisplay?this.delayedAppendReviews():this.shouldReplaceReviews(e,this.props)&&this.replaceReviews()}shouldReplaceReviews(e,t){return e.orderby!==t.orderby||e.order!==t.order||e.productId!==t.productId||!W()(e.categoryIds,t.categoryIds)}componentWillUnmount(){this.isMounted=!1,this.delayedAppendReviews.cancel&&this.delayedAppendReviews.cancel()}getArgs(e){const{categoryIds:t,order:r,orderby:s,productId:o,reviewsToDisplay:n}=this.props,i={order:r,orderby:s,per_page:n-e,offset:e};if(t){const e=Array.isArray(t)?t:JSON.parse(t);i.category_id=Array.isArray(e)?e.join(","):e}return o&&(i.product_id=o),i}replaceReviews(){if(this.isPreview)return;const{onReviewsReplaced:e}=this.props;this.updateListOfReviews().then(e)}appendReviews(){if(this.isPreview)return;const{onReviewsAppended:e,reviewsToDisplay:t}=this.props,{reviews:r}=this.state;t<=r.length||this.updateListOfReviews(r).then(e)}updateListOfReviews(e=[]){const{reviewsToDisplay:t}=this.props,{totalReviews:r}=this.state,s=Math.min(r,t)-e.length;return this.setState({loading:!0,reviews:e.concat(Array(s).fill({}))}),(o=this.getArgs(e.length),L()({path:"/wc/store/v1/products/reviews?"+Object.entries(o).map((e=>e.join("="))).join("&"),parse:!1}).then((e=>e.json().then((t=>({reviews:t,totalReviews:pars
|
||
|
(0,n._n)("%d review loaded.","%d reviews loaded.",e.length,"woocommerce"),e.length))}onReviewsReplaced(){(0,O.speak)((0,n.__)("Reviews list updated.","woocommerce"))}onReviewsLoadError(){(0,O.speak)((0,n.__)("There was an error loading the reviews.","woocommerce"))}render(){const{attributes:t}=this.props,{categoryIds:r,productId:s}=t,{reviewsToDisplay:o}=this.state,{order:n,orderby:a}=(e=>{if((0,i.getSetting)("reviewRatingsEnabled",!0)){if("lowest-rating"===e)return{order:"asc",orderby:"rating"};if("highest-rating"===e)return{order:"desc",orderby:"rating"}}return{order:"desc",orderby:"date_gmt"}})(this.state.orderby);return(0,e.createElement)($,{attributes:t,categoryIds:r,onAppendReviews:this.onAppendReviews,onChangeOrderby:this.onChangeOrderby,onReviewsAppended:this.onReviewsAppended,onReviewsLoadError:this.onReviewsLoadError,onReviewsReplaced:this.onReviewsReplaced,order:n,orderby:a,productId:s,reviewsToDisplay:o,sortSelectValue:this.state.orderby})}}(e=>{const t=document.body.querySelectorAll(R.join(",")),{Block:r,getProps:s,getErrorBoundaryProps:o,selector:n}=e;(({Block:e,getProps:t,getErrorBoundaryProps:r,selector:s,wrappers:o})=>{const n=document.body.querySelectorAll(s);o&&o.length>0&&Array.prototype.filter.call(n,(e=>!((e,t)=>Array.prototype.some.call(t,(t=>t.contains(e)&&!t.isSameNode(e))))(e,o))),S({Block:e,containers:n,getProps:t,getErrorBoundaryProps:r})})({Block:r,getProps:s,getErrorBoundaryProps:o,selector:n,wrappers:t}),Array.prototype.forEach.call(t,(t=>{t.addEventListener("wc-blocks_render_blocks_frontend",(()=>{(({Block:e,getProps:t,getErrorBoundaryProps:r,selector:s,wrapper:o})=>{const n=o.querySelectorAll(s);S({Block:e,containers:n,getProps:t,getErrorBoundaryProps:r})})({...e,wrapper:t})}))}))})({selector:"\n\t.wp-block-woocommerce-all-reviews,\n\t.wp-block-woocommerce-reviews-by-product,\n\t.wp-block-woocommerce-reviews-by-category\n",Block:z,getProps:e=>({attributes:{showOrderby:"true"===e.dataset.showOrderby,showLoadMore:"true"===e.dataset.showLoadMore,showReviewDate:e.classList.contains("has-date"),showReviewerName:e.classList.contains("has-name"),showReviewImage:e.classList.contains("has-image"),showReviewRating:e.classList.contains("has-rating"),showReviewContent:e.classList.contains("has-content"),showProductName:e.classList.contains("has-product-name")}})})})()})();
|