17 lines
No EOL
42 KiB
JavaScript
17 lines
No EOL
42 KiB
JavaScript
(()=>{var e,t={5585:(e,t,r)=>{"use strict";r.r(t);var o=r(9196),n=r(5736);const s=window.wp.blocks;var a=r(1984),i=r(7286);r(6990);const l=window.wp.blockEditor,c=window.wp.components;var d=r(4184),u=r.n(d),m=r(9307);function p(e,t,r){const o=new Set(t.map((e=>e[r])));return e.filter((e=>!o.has(e[r])))}const w=window.wp.htmlEntities,g={clear:(0,n.__)("Clear all selected items","woocommerce"),noItems:(0,n.__)("No items found.","woocommerce"),
|
||
/* Translators: %s search term */
|
||
noResults:(0,n.__)("No results for %s","woocommerce"),search:(0,n.__)("Search for items","woocommerce"),selected:e=>(0,n.sprintf)(/* translators: Number of items selected from list. */
|
||
(0,n._n)("%d item selected","%d items selected",e,"woocommerce"),e),updated:(0,n.__)("Search results updated.","woocommerce")},h=(e,t=e)=>{const r=e.reduce(((e,t)=>{const r=t.parent||0;return e[r]||(e[r]=[]),e[r].push(t),e}),{}),o=("id",t.reduce(((e,t)=>(e[String(t.id)]=t,e)),{}));const n=["0"],s=(e={})=>e.parent?[...s(o[e.parent]),e.name]:e.name?[e.name]:[],a=e=>e.map((e=>{const t=r[e.id];return n.push(""+e.id),{...e,breadcrumbs:s(o[e.parent]),children:t&&t.length?a(t):[]}})),i=a(r[0]||[]);return Object.entries(r).forEach((([e,t])=>{n.includes(e)||i.push(...a(t||[]))})),i},b=(e,t)=>{if(!t)return e;const r=new RegExp(`(${t.replace(/[-\/\\^$*+?.()|[\]{}]/g,"\\$&")})`,"ig");return e.split(r).map(((e,t)=>r.test(e)?(0,o.createElement)("strong",{key:t},e):(0,o.createElement)(m.Fragment,{key:t},e)))},v=({label:e})=>(0,o.createElement)("span",{className:"woocommerce-search-list__item-count"},e),_=e=>{const{item:t,search:r}=e,n=t.breadcrumbs&&t.breadcrumbs.length;return(0,o.createElement)("span",{className:"woocommerce-search-list__item-label"},n?(0,o.createElement)("span",{className:"woocommerce-search-list__item-prefix"},1===(s=t.breadcrumbs).length?s.slice(0,1).toString():2===s.length?s.slice(0,1).toString()+" › "+s.slice(-1).toString():s.slice(0,1).toString()+" … "+s.slice(-1).toString()):null,(0,o.createElement)("span",{className:"woocommerce-search-list__item-name"},b((0,w.decodeEntities)(t.name),r)));var s},E=({countLabel:e,className:t,depth:r=0,controlId:n="",item:s,isSelected:a,isSingle:i,onSelect:l,search:d="",selected:g,useExpandedPanelId:h,...E})=>{var k,y;const[f,R]=h,S=null!=e&&void 0!==s.count&&null!==s.count,C=!(null===(k=s.breadcrumbs)||void 0===k||!k.length),N=!(null===(y=s.children)||void 0===y||!y.length),P=f===s.id,I=u()(["woocommerce-search-list__item",`depth-${r}`,t],{"has-breadcrumbs":C,"has-children":N,"has-count":S,"is-expanded":P,"is-radio-button":i}),L=E.name||`search-list-item-${n}`,x=`${L}-${s.id}`,O=(0,m.useCallback)((()=>{R(P?-1:Number(s.id))}),[P,s.id,R]);return N?(0,o.createElement)("div",{className:I,onClick:O,onKeyDown:e=>"Enter"===e.key||" "===e.key?O():null,role:"treeitem",tabIndex:0},i?(0,o.createElement)(o.Fragment,null,(0,o.createElement)("input",{type:"radio",id:x,name:L,value:s.value,onChange:l(s),onClick:e=>e.stopPropagation(),checked:a,className:"woocommerce-search-list__item-input",...E}),(0,o.createElement)(_,{item:s,search:d}),S?(0,o.createElement)(v,{label:e||s.count}):null):(0,o.createElement)(o.Fragment,null,(0,o.createElement)(c.CheckboxControl,{className:"woocommerce-search-list__item-input",checked:a,...!a&&s.children.some((e=>g.find((t=>t.id===e.id))))?{indeterminate:!0}:{},label:b((0,w.decodeEntities)(s.name),d),onChange:()=>{a?l(p(g,s.children,"id"))():l(function(e,t,r){const o=p(t,e,"id");return[...e,...o]}(g,s.children))()},onClick:e=>e.stopPropagation()}),S?(0,o.createElement)(v,{label:e||s.count}):null)):(0,o.createElement)("label",{htmlFor:x,className:I},i?(0,o.createElement)(o.Fragment,null,(0,o.createElement)("input",{...E,type:"radio",id:x,name:L,value:s.value,onChange:l(s),checked:a,className:"woocommerce-search-list__item-input"}),(0,o.createElement)(_,{item:s,search:d})):(0,o.createElement)(c.CheckboxControl,{...E,id:x,name:L,className:"woocommerce-search-list__item-input",value:(0,w.decodeEntities)(s.value),label:b((0,w.decodeEntities)(s.name),d),onChange:l(s),checked:a}),S?(0,o.createElement)(v,{label:e||s.count}):null)},k=E;var y=r(5430),f=r(4333),R=r(906);r(5932);const S=({id:e,label:t,popoverContents:r,remove:s,screenReaderLabel:i,className:l=""})=>{const[d,p]=(0,m.useState)(!1),g=(0,f.useInstanceId)(S);if(i=i||t,!t)return null;t=(0,w.decodeEntities)(t);const h=u()("woocommerce-tag",l,{"has-remove":!!s}),b=`woocommerce-tag__label-${g}`,v=(0,o.createElement)(o.Fragment,null,(0,o.createElement)("span",{className:"screen-reader-text"},i),(0,o.createElement)("span",{"aria-hidden":"true"},t));return(0,o.createElement)("span",{className:h},r?(0,o.createElement)(c.Button,{className:"woocommerce-tag__text",id:b,onClick:()=>p(!0)},v):(0,o.createElement)("span",{className:"woocommerce-tag__text",id:b},v),r&&d&&(0,o.createElement)(c.Popover,{onClose:()=>p(!1)},r),s&&(0,o.createElement)(c.Button,{className:"woocommerce-tag__remove",onClick:s(e),label:(0,n.sprintf)(
|
||
// Translators: %s label.
|
||
(0,n.__)("Remove %s","woocommerce"),t),"aria-describedby":b},(0,o.createElement)(a.Z,{icon:R.Z,size:20,className:"clear-icon",role:"img"})))},C=S;r(8462);const N=e=>(0,o.createElement)(k,{...e}),P=e=>{const{list:t,selected:r,renderItem:n,depth:s=0,onSelect:a,instanceId:i,isSingle:l,search:c,useExpandedPanelId:d}=e,[u]=d;return t?(0,o.createElement)(m.Fragment,null,t.map((t=>{var p,w;const g=null!==(p=t.children)&&void 0!==p&&p.length&&!l?t.children.every((({id:e})=>r.find((t=>t.id===e)))):!!r.find((({id:e})=>e===t.id)),h=(null===(w=t.children)||void 0===w?void 0:w.length)&&u===t.id;return(0,o.createElement)(m.Fragment,{key:t.id},(0,o.createElement)("li",null,n({item:t,isSelected:g,onSelect:a,isSingle:l,selected:r,search:c,depth:s,useExpandedPanelId:d,controlId:i})),h?(0,o.createElement)(P,{...e,list:t.children,depth:s+1}):null)}))):null},I=({isLoading:e,isSingle:t,selected:r,messages:s,onChange:a,onRemove:i})=>{if(e||t||!r)return null;const l=r.length;return(0,o.createElement)("div",{className:"woocommerce-search-list__selected"},(0,o.createElement)("div",{className:"woocommerce-search-list__selected-header"},(0,o.createElement)("strong",null,s.selected(l)),l>0?(0,o.createElement)(c.Button,{isLink:!0,isDestructive:!0,onClick:()=>a([]),"aria-label":s.clear},(0,n.__)("Clear all","woocommerce")):null),l>0?(0,o.createElement)("ul",null,r.map(((e,t)=>(0,o.createElement)("li",{key:t},(0,o.createElement)(C,{label:e.name,id:e.id,remove:i}))))):null)},L=({filteredList:e,search:t,onSelect:r,instanceId:s,useExpandedPanelId:i,...l})=>{const{messages:c,renderItem:d,selected:u,isSingle:m}=l,p=d||N;return 0===e.length?(0,o.createElement)("div",{className:"woocommerce-search-list__list is-not-found"},(0,o.createElement)("span",{className:"woocommerce-search-list__not-found-icon"},(0,o.createElement)(a.Z,{icon:y.Z,role:"img"})),(0,o.createElement)("span",{className:"woocommerce-search-list__not-found-text"},t?(0,n.sprintf)(c.noResults,t):c.noItems)):(0,o.createElement)("ul",{className:"woocommerce-search-list__list"},(0,o.createElement)(P,{useExpandedPanelId:i,list:e,selected:u,renderItem:p,onSelect:r,instanceId:s,isSingle:m,search:t}))},x=e=>{const{className:t="",isCompact:r,isHierarchical:s,isLoading:a,isSingle:i,list:l,messages:d=g,onChange:p,onSearch:w,selected:b,type:v="text",debouncedSpeak:_}=e,[E,k]=(0,m.useState)(""),y=(0,m.useState)(-1),R=(0,f.useInstanceId)(x),S=(0,m.useMemo)((()=>({...g,...d})),[d]),C=(0,m.useMemo)((()=>((e,t,r)=>{if(!t)return r?h(e):e;const o=new RegExp(t.replace(/[-\/\\^$*+?.()|[\]{}]/g,"\\$&"),"i"),n=e.map((e=>!!o.test(e.name)&&e)).filter(Boolean);return r?h(n,e):n})(l,E,s)),[l,E,s]);(0,m.useEffect)((()=>{_&&_(S.updated)}),[_,S]),(0,m.useEffect)((()=>{"function"==typeof w&&w(E)}),[E,w]);const N=(0,m.useCallback)((e=>()=>{i&&p([]);const t=b.findIndex((({id:t})=>t===e));p([...b.slice(0,t),...b.slice(t+1)])}),[i,b,p]),P=(0,m.useCallback)((e=>()=>{Array.isArray(e)?p(e):-1===b.findIndex((({id:t})=>t===e.id))?p(i?[e]:[...b,e]):N(e.id)()}),[i,N,p,b]),O=(0,m.useCallback)((e=>{const[t]=b.filter((t=>!e.find((e=>t.id===e.id))));N(t.id)()}),[N,b]);return(0,o.createElement)("div",{className:u()("woocommerce-search-list",t,{"is-compact":r,"is-loading":a,"is-token":"token"===v})},"text"===v&&(0,o.createElement)(I,{...e,onRemove:N,messages:S}),(0,o.createElement)("div",{className:"woocommerce-search-list__search"},"text"===v?(0,o.createElement)(c.TextControl,{label:S.search,type:"search",value:E,onChange:e=>k(e)}):(0,o.createElement)(c.FormTokenField,{disabled:a,label:S.search,onChange:O,onInputChange:e=>k(e),suggestions:[],__experimentalValidateInput:()=>!1,value:a?[(0,n.__)("Loading…","woocommerce")]:b.map((e=>({...e,value:e.name}))),__experimentalShowHowTo:!1})),a?(0,o.createElement)("div",{className:"woocommerce-search-list__list"},(0,o.createElement)(c.Spinner,null)):(0,o.createElement)(L,{...e,search:E,filteredList:C,messages:S,onSelect:P,instanceId:R,useExpandedPanelId:y}))},O=((0,c.withSpokenMessages)(x),e=>t=>{let{selected:r}=t;r=void 0===r?null:r;const n=null===r;return Array.isArray(r)?(0,o.createElement)(e,{...t}):(0,o.createElement)(e,{...t,selected:n?[]:[r]})}),T=window.wc.wcSettings;var A,M,j,D,Z,$,B,F,H,G;const V=(0,T.getSetting)("wcBlocksConfig",{buildPhase:1,pluginUrl:"",productCount:0,defaultAvatar:"",restApiRoutes:{},wordCountType:"words"}),U=(V.pluginUrl,V.pluginUrl,V.buildPhase,null===(A=T.STORE_PAGES.shop)||void 0===A||A.permalink,null===(M=T.STORE_PAGES.checkout)||void 0===M||M.id,null===(j=T.STORE_PAGES.checkout)||void 0===j||j.permalink,null===(D=T.STORE_PAGES.privacy)||void 0===D||D.permalink,null===(Z=T.STORE_PAGES.privacy)||void 0===Z||Z.title,null===($=T.STORE_PAGES.terms)||void 0===$||$.permalink,null===(B=T.STORE_PAGES.terms)||void 0===B||B.title,null===(F=T.STORE_PAGES.cart)||void 0===F||F.id,null===(H=T.STORE_PAGES.cart)||void 0===H||H.permalink,null!==(G=T.STORE_PAGES.myaccount)&&void 0!==G&&G.permalink?T.STORE_PAGES.myaccount.permalink:(0,T.getSetting)("wpLoginUrl","/wp-login.php"),(0,T.getSetting)("localPickupEnabled",!1),(0,T.getSetting)("countries",{})),W=(0,T.getSetting)("countryData",{}),q=(Object.fromEntries(Object.keys(W).filter((e=>!0===W[e].allowBilling)).map((e=>[e,U[e]||""]))),Object.fromEntries(Object.keys(W).filter((e=>!0===W[e].allowBilling)).map((e=>[e,W[e].states||[]]))),Object.fromEntries(Object.keys(W).filter((e=>!0===W[e].allowShipping)).map((e=>[e,U[e]||""]))),Object.fromEntries(Object.keys(W).filter((e=>!0===W[e].allowShipping)).map((e=>[e,W[e].states||[]]))),Object.fromEntries(Object.keys(W).map((e=>[e,W[e].locale||[]]))),window.wp.url),J=window.wp.apiFetch;var z=r.n(J);const Q=({selected:e=[],search:t="",queryArgs:r={}})=>{const o=(({selected:e=[],search:t="",queryArgs:r={}})=>{const o=V.productCount>100,n={per_page:o?100:0,catalog_visibility:"any",search:t,orderby:"title",order:"asc"},s=[(0,q.addQueryArgs)("/wc/store/v1/products",{...n,...r})];return o&&e.length&&s.push((0,q.addQueryArgs)("/wc/store/v1/products",{catalog_visibility:"any",include:e,per_page:0})),s})({selected:e,search:t,queryArgs:r});return Promise.all(o.map((e=>z()({path:e})))).then((e=>{const t=((e,t)=>{const r=new Map;return e.filter((e=>{const o=t(e);return!r.has(o)&&(r.set(o,e),!0)}))})(e.flat(),(e=>e.id));return t.map((e=>({...e,parent:0})))})).catch((e=>{throw e}))};var K=r(4697);const Y=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"}}};var X=r(4942),ee=r(9127),te=r.n(ee);const re=(0,f.createHigherOrderComponent)((e=>{class t extends m.Component{constructor(...e){super(...e),(0,X.Z)(this,"state",{error:null,loading:!1,variations:{}}),(0,X.Z)(this,"loadVariations",(()=>{const{products:e}=this.props,{loading:t,variations:r}=this.state;if(t)return;const o=this.getExpandedProduct();if(!o||r[o])return;const n=e.find((e=>e.id===o));var s;n.variations&&0!==n.variations.length?(this.setState({loading:!0}),(s=o,z()({path:(0,q.addQueryArgs)("wc/store/v1/products",{per_page:0,type:"variation",parent:s})})).then((e=>{const t=e.map((e=>({...e,parent:o})));this.setState({variations:{...this.state.variations,[o]:t},loading:!1,error:null})})).catch((async e=>{const t=await Y(e);this.setState({variations:{...this.state.variations,[o]:null},loading:!1,error:t})}))):this.setState({variations:{...this.state.variations,[o]:null},loading:!1,error:null})}))}componentDidMount(){const{selected:e,showVariations:t}=this.props;e&&t&&this.loadVariations()}componentDidUpdate(e){const{isLoading:t,selected:r,showVariations:o}=this.props;o&&(!te()(e.selected,r)||e.isLoading&&!t)&&this.loadVariations()}isProductId(e){const{products:t}=this.props;return t.some((t=>t.id===e))}findParentProduct(e){var t;const{products:r}=this.props;return null===(t=r.filter((t=>t.variations&&t.variations.find((({id:t})=>t===e))))[0])||void 0===t?void 0:t.id}getExpandedProduct(){const{isLoading:e,selected:t,showVariations:r}=this.props;if(!r)return null;let o=t&&t.length?t[0]:null;return o?this.prevSelectedItem=o:this.prevSelectedItem&&(e||this.isProductId(this.prevSelectedItem)||(o=this.prevSelectedItem)),!e&&o?this.isProductId(o)?o:this.findParentProduct(o):null}render(){const{error:t,isLoading:r}=this.props,{error:n,loading:s,variations:a}=this.state;return(0,o.createElement)(e,{...this.props,error:n||t,expandedProduct:this.getExpandedProduct(),isLoading:r,variations:a,variationsLoading:s})}}return(0,X.Z)(t,"defaultProps",{selected:[],showVariations:!1}),t}),"withProductVariations"),oe=e=>{const{id:t,name:r,parent:o}=e;return{id:t,name:r,parent:o,breadcrumbs:[],children:[],details:e,value:e.slug}},ne=window.wp.escapeHtml,se=({error:e})=>(0,o.createElement)("div",{className:"wc-block-error-message"},(({message:e,type:t})=>e?"general"===t?(0,o.createElement)("span",null,(0,n.__)("The following error was returned","woocommerce"),(0,o.createElement)("br",null),(0,o.createElement)("code",null,(0,ne.escapeHTML)(e))):"api"===t?(0,o.createElement)("span",null,(0,n.__)("The following error was returned from the API","woocommerce"),(0,o.createElement)("br",null),(0,o.createElement)("code",null,(0,ne.escapeHTML)(e))):e:(0,n.__)("An error has prevented the block from being updated.","woocommerce"))(e)),ae=({className:e,item:t,isSelected:r,isLoading:n,onSelect:s,disabled:a,...i})=>(0,o.createElement)(o.Fragment,null,(0,o.createElement)(E,{...i,key:t.id,className:e,isSelected:r,item:t,onSelect:s,disabled:a}),r&&n&&(0,o.createElement)("div",{key:"loading",className:u()("woocommerce-search-list__item","woocommerce-product-attributes__item","depth-1","is-loading","is-not-active")},(0,o.createElement)(c.Spinner,null)));r(5301);const ie={list:(0,n.__)("Products","woocommerce"),noItems:(0,n.__)("Your store doesn't have any products.","woocommerce"),search:(0,n.__)("Search for a product to display","woocommerce"),updated:(0,n.__)("Product search results updated.","woocommerce")},le=O((ce=re((0,f.withInstanceId)((e=>{const{expandedProduct:t=null,error:r,instanceId:s,isCompact:a=!1,isLoading:i,onChange:l,onSearch:c,products:d,renderItem:m,selected:p=[],showVariations:w=!1,variations:g,variationsLoading:h}=e;if(r)return(0,o.createElement)(se,{error:r});const b=[...d,...g&&t&&g[t]?g[t]:[]].map(oe);return(0,o.createElement)(x,{className:"woocommerce-products",list:b,isCompact:a,isLoading:i,isSingle:!0,selected:b.filter((({id:e})=>p.includes(Number(e)))),onChange:l,renderItem:m||(w?e=>{var t,r,a,l;const{item:c,search:d,depth:m=0,isSelected:p,onSelect:w}=e,g=null!==(t=c.details)&&void 0!==t&&t.variations&&Array.isArray(c.details.variations)?c.details.variations.length:0,b=u()("woocommerce-search-product__item","woocommerce-search-list__item",`depth-${m}`,"has-count",{"is-searching":d.length>0,"is-skip-level":0===m&&0!==c.parent,"is-variable":g>0});if(!c.breadcrumbs.length){var v,_,k,y,f;const t=(null===(v=c.details)||void 0===v?void 0:v.variations)&&c.details.variations.length>0;return(0,o.createElement)(ae,{...e,className:u()(b,{"is-selected":p}),isSelected:p,item:c,onSelect:()=>()=>{w(c)()},isLoading:i||h,countLabel:t?(0,n.sprintf)(/* translators: %1$d is the number of variations of a product product. */
|
||
(0,n.__)("%1$d variations","woocommerce"),null===(_=c.details)||void 0===_?void 0:_.variations.length):null,name:`products-${s}`,"aria-label":t?(0,n.sprintf)(/* translators: %1$s is the product name, %2$d is the number of variations of that product. */
|
||
(0,n._n)("%1$s, has %2$d variation","%1$s, has %2$d variations",null===(k=c.details)||void 0===k||null===(y=k.variations)||void 0===y?void 0:y.length,"woocommerce"),c.name,null===(f=c.details)||void 0===f?void 0:f.variations.length):void 0})}const R=null==(S=null===(r=c.details)||void 0===r?void 0:r.variation)||"object"==typeof S&&0===Object.keys(S).length||"string"==typeof S&&0===S.trim().length?e:{...e,item:{...e.item,name:null===(a=c.details)||void 0===a?void 0:a.variation},"aria-label":`${c.breadcrumbs[0]}: ${null===(l=c.details)||void 0===l?void 0:l.variation}`};var S;return(0,o.createElement)(E,{...R,className:b,name:`variations-${s}`})}:()=>null),onSearch:c,messages:ie,isHierarchical:!0})}))),({selected:e,...t})=>{const[r,n]=(0,m.useState)(!0),[s,a]=(0,m.useState)(null),[i,l]=(0,m.useState)([]),c=V.productCount>100,d=async e=>{const t=await Y(e);a(t),n(!1)},u=(0,m.useRef)(e);(0,m.useEffect)((()=>{Q({selected:u.current}).then((e=>{l(e),n(!1)})).catch(d)}),[u]);const p=(0,K.y1)((t=>{Q({selected:e,search:t}).then((e=>{l(e),n(!1)})).catch(d)}),400),w=(0,m.useCallback)((e=>{n(!0),p(e)}),[n,p]);return(0,o.createElement)(ce,{...t,selected:e,error:s,products:i,isLoading:r,onSearch:c?w:null})}));var ce,de=r(7329);r(2513);const ue=({className:e="",error:t,isLoading:r=!1,onRetry:s})=>(0,o.createElement)(c.Placeholder,{icon:(0,o.createElement)(a.Z,{icon:de.Z}),label:(0,n.__)("Sorry, an error occurred","woocommerce"),className:u()("wc-block-api-error",e)},(0,o.createElement)(se,{error:t}),s&&(0,o.createElement)(o.Fragment,null,r?(0,o.createElement)(c.Spinner,null):(0,o.createElement)(c.Button,{isSecondary:!0,onClick:s},(0,n.__)("Retry","woocommerce"))));r(7349);const me=({label:e,screenReaderLabel:t,wrapperElement:r,wrapperProps:n={}})=>{let s;const a=null!=e,i=null!=t;return!a&&i?(s=r||"span",n={...n,className:u()(n.className,"screen-reader-text")},(0,o.createElement)(s,{...n},t)):(s=r||m.Fragment,a&&i&&e!==t?(0,o.createElement)(s,{...n},(0,o.createElement)("span",{"aria-hidden":"true"},e),(0,o.createElement)("span",{className:"screen-reader-text"},t)):(0,o.createElement)(s,{...n},e))},pe=({onClick:e,label:t=(0,n.__)("Load more","woocommerce"),screenReaderLabel:r=(0,n.__)("Load more","woocommerce")})=>(0,o.createElement)("div",{className:"wp-block-button wc-block-load-more wc-block-components-load-more"},(0,o.createElement)("button",{className:"wp-block-button__link",onClick:e},(0,o.createElement)(me,{label:t,screenReaderLabel:r}))),we=window.wc.blocksComponents;r(8543);const ge=({onChange:e,readOnly:t,value:r})=>(0,o.createElement)(we.SortSelect,{className:"wc-block-review-sort-select wc-block-components-review-sort-select",label:(0,n.__)("Order by","woocommerce"),onChange:e,options:[{key:"most-recent",label:(0,n.__)("Most recent","woocommerce")},{key:"highest-rating",label:(0,n.__)("Highest rating","woocommerce")},{key:"lowest-rating",label:(0,n.__)("Lowest rating","woocommerce")}],readOnly:t,screenReaderLabel:(0,n.__)("Order reviews by","woocommerce"),value:r});function he(e){let t,r,o,n=[];for(let s=0;s<e.length;s++)t=e.substring(s),r=t.match(/^&[a-z0-9#]+;/),r?(o=r[0],n.push(o),s+=o.length-1):n.push(e[s]);return n}const be=(e,t,r="...")=>{const o=function(e,t){const r=(t=t||{}).limit||100,o=void 0===t.preserveTags||t.preserveTags,n=void 0!==t.wordBreak&&t.wordBreak,s=t.suffix||"...",a=t.moreLink||"",i=t.moreText||"»",l=t.preserveWhiteSpace||!1,c=e.replace(/</g,"\n<").replace(/>/g,">\n").replace(/\n\n/g,"\n").replace(/^\n/g,"").replace(/\n$/g,"").split("\n");let d,u,m,p,w,g,h=0,b=[],v=!1;for(let e=0;e<c.length;e++){if(d=c[e],p=l?d:d.replace(/[ ]+/g," "),!d.length)continue;const t=he(p);if("<"!==d[0])if(h>=r)d="";else if(h+t.length>=r){if(u=r-h," "===t[u-1])for(;u&&(u-=1," "===t[u-1]););else m=t.slice(u).indexOf(" "),n||(-1!==m?u+=m:u=d.length);d=t.slice(0,u).join("")+s,a&&(d+='<a href="'+a+'" style="display:inline">'+i+"</a>"),h=r,v=!0}else h+=t.length;else if(o){if(h>=r)if(w=d.match(/[a-zA-Z]+/),g=w?w[0]:"",g)if("</"!==d.substring(0,2))b.push(g),d="";else{for(;b[b.length-1]!==g&&b.length;)b.pop();b.length&&(d=""),b.pop()}else d=""}else d="";c[e]=d}return{html:c.join("\n").replace(/\n/g,""),more:v}}(e,{suffix:r,limit:t});return o.html},ve=(e,t,r)=>(t<=r?e.start=e.middle+1:e.end=e.middle-1,e),_e=(e,t,r,o)=>{const n=((e,t,r)=>{let o={start:0,middle:0,end:e.length};for(;o.start<=o.end;)o.middle=Math.floor((o.start+o.end)/2),t.innerHTML=be(e,o.middle),o=ve(o,t.clientHeight,r);return o.middle})(e,t,r);return be(e,n-o.length,o)},Ee={className:"read-more-content",ellipsis:"…",lessText:(0,n.__)("Read less","woocommerce"),maxLines:3,moreText:(0,n.__)("Read more","woocommerce")};class ke extends m.Component{constructor(e){super(e),(0,X.Z)(this,"reviewSummary",void 0),(0,X.Z)(this,"reviewContent",void 0),this.state={isExpanded:!1,clampEnabled:null,content:e.children,summary:"."},this.reviewContent=(0,m.createRef)(),this.reviewSummary=(0,m.createRef)(),this.getButton=this.getButton.bind(this),this.onClick=this.onClick.bind(this)}componentDidMount(){this.setSummary()}componentDidUpdate(e){e.maxLines===this.props.maxLines&&e.children===this.props.children||this.setState({clampEnabled:null,summary:"."},this.setSummary)}setSummary(){if(this.props.children){const{maxLines:e,ellipsis:t}=this.props;if(!this.reviewSummary.current||!this.reviewContent.current)return;const r=(this.reviewSummary.current.clientHeight+1)*e+1,o=this.reviewContent.current.clientHeight+1>r;this.setState({clampEnabled:o}),o&&this.setState({summary:_e(this.reviewContent.current.innerHTML,this.reviewSummary.current,r,t)})}}getButton(){const{isExpanded:e}=this.state,{className:t,lessText:r,moreText:n}=this.props,s=e?r:n;if(s)return(0,o.createElement)("a",{href:"#more",className:t+"__read_more",onClick:this.onClick,"aria-expanded":!e,role:"button"},s)}onClick(e){e.preventDefault();const{isExpanded:t}=this.state;this.setState({isExpanded:!t})}render(){const{className:e}=this.props,{content:t,summary:r,clampEnabled:n,isExpanded:s}=this.state;return t?!1===n?(0,o.createElement)("div",{className:e},(0,o.createElement)("div",{ref:this.reviewContent},t)):(0,o.createElement)("div",{className:e},(!s||null===n)&&(0,o.createElement)("div",{ref:this.reviewSummary,"aria-hidden":s,dangerouslySetInnerHTML:{__html:r}}),(s||null===n)&&(0,o.createElement)("div",{ref:this.reviewContent,"aria-hidden":!s},t),this.getButton()):null}}(0,X.Z)(ke,"defaultProps",Ee);const ye=ke;r(8204);const fe=({attributes:e,review:t={}})=>{const{imageType:r,showReviewDate:s,showReviewerName:a,showReviewImage:i,showReviewRating:l,showReviewContent:c,showProductName:d}=e,{rating:m}=t,p=!(Object.keys(t).length>0),w=Number.isFinite(m)&&l;return(0,o.createElement)("li",{className:u()("wc-block-review-list-item__item","wc-block-components-review-list-item__item",{"is-loading":p,"wc-block-components-review-list-item__item--has-image":i}),"aria-hidden":p},(d||s||a||i||w)&&(0,o.createElement)("div",{className:"wc-block-review-list-item__info wc-block-components-review-list-item__info"},i&&function(e,t,r){var s,a;return r||!e?(0,o.createElement)("div",{className:"wc-block-review-list-item__image wc-block-components-review-list-item__image"}):(0,o.createElement)("div",{className:"wc-block-review-list-item__image wc-block-components-review-list-item__image"},"product"===t?(0,o.createElement)("img",{"aria-hidden":"true",alt:(null===(s=e.product_image)||void 0===s?void 0:s.alt)||"",src:(null===(a=e.product_image)||void 0===a?void 0:a.thumbnail)||""}):(0,o.createElement)("img",{"aria-hidden":"true",alt:"",src:e.reviewer_avatar_urls[96]||""}),e.verified&&(0,o.createElement)("div",{className:"wc-block-review-list-item__verified wc-block-components-review-list-item__verified",title:(0,n.__)("Verified buyer","woocommerce")},(0,n.__)("Verified buyer","woocommerce")))}(t,r,p),(d||a||w||s)&&(0,o.createElement)("div",{className:"wc-block-review-list-item__meta wc-block-components-review-list-item__meta"},w&&function(e){const{rating:t}=e,r={width:t/5*100+"%"},s=(0,n.sprintf)(/* translators: %f is referring to the average rating value */
|
||
(0,n.__)("Rated %f out of 5","woocommerce"),t),a={__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>',t))};return(0,o.createElement)("div",{className:"wc-block-review-list-item__rating wc-block-components-review-list-item__rating"},(0,o.createElement)("div",{className:"wc-block-review-list-item__rating__stars wc-block-components-review-list-item__rating__stars",role:"img","aria-label":s},(0,o.createElement)("span",{style:r,dangerouslySetInnerHTML:a})))}(t),d&&function(e){return(0,o.createElement)("div",{className:"wc-block-review-list-item__product wc-block-components-review-list-item__product"},(0,o.createElement)("a",{href:e.product_permalink,dangerouslySetInnerHTML:{__html:e.product_name}}))}(t),a&&function(e){const{reviewer:t=""}=e;return(0,o.createElement)("div",{className:"wc-block-review-list-item__author wc-block-components-review-list-item__author"},t)}(t),s&&function(e){const{date_created:t,formatted_date_created:r}=e;return(0,o.createElement)("time",{className:"wc-block-review-list-item__published-date wc-block-components-review-list-item__published-date",dateTime:t},r)}(t))),c&&function(e){return(0,o.createElement)(ye,{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,o.createElement)("div",{dangerouslySetInnerHTML:{__html:e.review||""}}))}(t))};r(4093);const Re=({attributes:e,reviews:t})=>{const r=(0,T.getSetting)("showAvatars",!0),n=(0,T.getSetting)("reviewRatingsEnabled",!0),s=(r||"product"===e.imageType)&&e.showReviewImage,a=n&&e.showReviewRating,i={...e,showReviewImage:s,showReviewRating:a};return(0,o.createElement)("ul",{className:"wc-block-review-list wc-block-components-review-list"},0===t.length?(0,o.createElement)(fe,{attributes:i}):t.map(((e,t)=>(0,o.createElement)(fe,{key:e.id||t,attributes:i,review:e}))))},Se=e=>{const{className:t,categoryIds:r,productId:o,showReviewDate:n,showReviewerName:s,showReviewContent:a,showProductName:i,showReviewImage:l,showReviewRating:c}=e;let d="wc-block-all-reviews";return o&&(d="wc-block-reviews-by-product"),Array.isArray(r)&&(d="wc-block-reviews-by-category"),u()(d,t,{"has-image":l,"has-name":s,"has-date":n,"has-rating":c,"has-content":a,"has-product-name":i})},Ce=e=>{const{categoryIds:t,imageType:r,orderby:o,productId:n,reviewsOnPageLoad:s,reviewsOnLoadMore:a,showLoadMore:i,showOrderby:l}=e,c={"data-image-type":r,"data-orderby":o,"data-reviews-on-page-load":s,"data-reviews-on-load-more":a,"data-show-load-more":i,"data-show-orderby":l};return n&&(c["data-product-id"]=n),Array.isArray(t)&&(c["data-category-ids"]=t.join(",")),c};class Ne extends m.Component{render(){const{attributes:e,error:t,isLoading:r,noReviewsPlaceholder:s,reviews:a,totalReviews:i}=this.props;if(t)return(0,o.createElement)(ue,{className:"wc-block-featured-product-error",error:t,isLoading:r});if(0===a.length&&!r)return(0,o.createElement)(s,{attributes:e});const l=(0,T.getSetting)("reviewRatingsEnabled",!0);return(0,o.createElement)(c.Disabled,null,e.showOrderby&&l&&(0,o.createElement)(ge,{readOnly:!0,value:e.orderby,onChange:()=>null}),(0,o.createElement)(Re,{attributes:e,reviews:a}),e.showLoadMore&&i>a.length&&(0,o.createElement)(pe,{screenReaderLabel:(0,n.__)("Load more reviews","woocommerce")}))}}const Pe=(e=>{class t extends m.Component{constructor(...e){super(...e),(0,X.Z)(this,"isPreview",!!this.props.attributes.previewReviews),(0,X.Z)(this,"delayedAppendReviews",this.props.delayFunction(this.appendReviews)),(0,X.Z)(this,"isMounted",!1),(0,X.Z)(this,"state",{error:null,loading:!0,reviews:this.isPreview?this.props.attributes.previewReviews:[],totalReviews:this.isPreview?this.props.attributes.previewReviews.length:0}),(0,X.Z)(this,"setError",(async e=>{if(!this.isMounted)return;const{onReviewsLoadError:t}=this.props,r=await Y(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||!te()(e.categoryIds,t.categoryIds)}componentWillUnmount(){this.isMounted=!1,this.delayedAppendReviews.cancel&&this.delayedAppendReviews.cancel()}getArgs(e){const{categoryIds:t,order:r,orderby:o,productId:n,reviewsToDisplay:s}=this.props,a={order:r,orderby:o,per_page:s-e,offset:e};if(t){const e=Array.isArray(t)?t:JSON.parse(t);a.category_id=Array.isArray(e)?e.join(","):e}return n&&(a.product_id=n),a}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,o=Math.min(r,t)-e.length;return this.setState({loading:!0,reviews:e.concat(Array(o).fill({}))}),(n=this.getArgs(e.length),z()({path:"/wc/store/v1/products/reviews?"+Object.entries(n).map((e=>e.join("="))).join("&"),parse:!1}).then((e=>e.json().then((t=>({reviews:t,totalReviews:parseInt(e.headers.get("x-wp-total"),10)})))))).then((({reviews:t,totalReviews:r})=>(this.isMounted&&this.setState({reviews:e.filter((e=>Object.keys(e).length)).concat(t),totalReviews:r,loading:!1,error:null}),{newReviews:t}))).catch(this.setError);var n}render(){const{reviewsToDisplay:t}=this.props,{error:r,loading:n,reviews:s,totalReviews:a}=this.state;return(0,o.createElement)(e,{...this.props,error:r,isLoading:n,reviews:s.slice(0,t),totalReviews:a})}}(0,X.Z)(t,"defaultProps",{delayFunction:e=>e,onReviewsAppended:()=>{},onReviewsLoadError:()=>{},onReviewsReplaced:()=>{}});const{displayName:r=e.name||"Component"}=e;return t.displayName=`WithReviews( ${r} )`,t})(Ne),Ie=({attributes:e,icon:t,name:r,noReviewsPlaceholder:s})=>{const{categoryIds:a,productId:i,reviewsOnPageLoad:d,showProductName:u,showReviewDate:m,showReviewerName:p,showReviewContent:w,showReviewImage:g,showReviewRating:h}=e,{order:b,orderby:v}=(e=>{if((0,T.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"}})(e.orderby),_=!(w||h||m||p||g||u),E=(0,l.useBlockProps)({className:Se(e)});return _?(0,o.createElement)(c.Placeholder,{icon:t,label:r},(0,n.__)("The content for this block is hidden due to block settings.","woocommerce")):(0,o.createElement)("div",{...E},(0,o.createElement)(Pe,{attributes:e,categoryIds:a,delayFunction:e=>((e,t,r)=>{let o,n=null;const s=(...t)=>{n=t,o&&clearTimeout(o),o=setTimeout((()=>{o=null,n&&e(...n)}),400)};return s.flush=()=>{o&&n&&(e(...n),clearTimeout(o),o=null)},s})(e),noReviewsPlaceholder:s,orderby:v,order:b,productId:i,reviewsToDisplay:d}))},Le=(0,f.createHigherOrderComponent)((e=>class extends m.Component{constructor(...e){super(...e),(0,X.Z)(this,"state",{error:null,loading:!1,product:"preview"===this.props.attributes.productId?this.props.attributes.previewProduct:null}),(0,X.Z)(this,"loadProduct",(()=>{const{productId:e}=this.props.attributes;"preview"!==e&&(e?(this.setState({loading:!0}),(e=>z()({path:`/wc/store/v1/products/${e}`}))(e).then((e=>{this.setState({product:e,loading:!1,error:null})})).catch((async e=>{const t=await Y(e);this.setState({product:null,loading:!1,error:t})}))):this.setState({product:null,loading:!1,error:null}))}))}componentDidMount(){this.loadProduct()}componentDidUpdate(e){e.attributes.productId!==this.props.attributes.productId&&this.loadProduct()}render(){const{error:t,loading:r,product:n}=this.state;return(0,o.createElement)(e,{...this.props,error:t,getProduct:this.loadProduct,isLoading:r,product:n})}}),"withProduct")((({error:e,getProduct:t,isLoading:r,product:s})=>{if(e)return(0,o.createElement)(ue,{className:"wc-block-featured-product-error",error:e,isLoading:r,onRetry:t});const l=!s||r?(0,o.createElement)(c.Spinner,null):(0,n.sprintf)(/* translators: %s is the product name. */
|
||
(0,n.__)("This block lists reviews for a selected product. %s doesn't have any reviews yet, but they will show up here when it does.","woocommerce"),(0,w.decodeEntities)(s.name));return(0,o.createElement)(c.Placeholder,{className:"wc-block-reviews-by-product",icon:(0,o.createElement)(a.Z,{icon:i.Z,className:"block-editor-block-icon"}),label:(0,n.__)("Reviews by Product","woocommerce")},l)})),xe=(0,c.withSpokenMessages)((({attributes:e,debouncedSpeak:t,setAttributes:r})=>{const{editMode:s,productId:d}=e,u=e=>{const{item:t=0}=e;return(0,o.createElement)(E,{...e,countLabel:(0,n.sprintf)(/* translators: %d is the review count. */
|
||
(0,n._n)("%d review","%d reviews",t.review_count,"woocommerce"),t.review_count),"aria-label":(0,n.sprintf)(/* translators: %1$s is the item name, and %2$d is the number of reviews for the item. */
|
||
(0,n._n)("%1$s, has %2$d review","%1$s, has %2$d reviews",t.review_count,"woocommerce"),t.name,t.review_count)})};if(!d||s)return(0,o.createElement)(c.Placeholder,{icon:(0,o.createElement)(a.Z,{icon:i.Z,className:"block-editor-block-icon"}),label:(0,n.__)("Reviews by Product","woocommerce"),className:"wc-block-reviews-by-product"},(0,n.__)("Show reviews of your product to build trust","woocommerce"),(0,o.createElement)("div",{className:"wc-block-reviews__selection"},(0,o.createElement)(le,{selected:e.productId||0,onChange:(e=[])=>{const t=e[0]?e[0].id:0;r({productId:t})},queryArgs:{orderby:"comment_count",order:"desc"},renderItem:u}),(0,o.createElement)(c.Button,{isPrimary:!0,onClick:()=>{r({editMode:!1}),t((0,n.__)("Showing Reviews by Product block preview.","woocommerce"))}},(0,n.__)("Done","woocommerce"))));const p=(0,n.__)("Edit selected product","woocommerce");return(0,o.createElement)(o.Fragment,null,((e,t,r)=>(0,o.createElement)(l.BlockControls,null,(0,o.createElement)(c.ToolbarGroup,{controls:[{icon:"edit",title:r,onClick:()=>t({editMode:!e}),isActive:e}]})))(s,r,p),(0,o.createElement)(l.InspectorControls,{key:"inspector"},(0,o.createElement)(c.PanelBody,{title:(0,n.__)("Product","woocommerce"),initialOpen:!1},(0,o.createElement)(le,{selected:e.productId||0,onChange:(e=[])=>{const t=e[0]?e[0].id:0;r({productId:t})},renderItem:u,isCompact:!0})),(0,o.createElement)(c.PanelBody,{title:(0,n.__)("Content","woocommerce")},((e,t)=>{const r=(0,T.getSetting)("showAvatars",!0),s=(0,T.getSetting)("reviewRatingsEnabled",!0);return(0,o.createElement)(o.Fragment,null,(0,o.createElement)(c.ToggleControl,{label:(0,n.__)("Product rating","woocommerce"),checked:e.showReviewRating,onChange:()=>t({showReviewRating:!e.showReviewRating})}),e.showReviewRating&&!s&&(0,o.createElement)(c.Notice,{className:"wc-block-base-control-notice",isDismissible:!1},(0,m.createInterpolateElement)((0,n.__)("Product rating is disabled in your <a>store settings</a>.","woocommerce"),{a:(0,o.createElement)("a",{href:(0,T.getAdminLink)("admin.php?page=wc-settings&tab=products"),target:"_blank",rel:"noopener noreferrer"})})),(0,o.createElement)(c.ToggleControl,{label:(0,n.__)("Reviewer name","woocommerce"),checked:e.showReviewerName,onChange:()=>t({showReviewerName:!e.showReviewerName})}),(0,o.createElement)(c.ToggleControl,{label:(0,n.__)("Image","woocommerce"),checked:e.showReviewImage,onChange:()=>t({showReviewImage:!e.showReviewImage})}),(0,o.createElement)(c.ToggleControl,{label:(0,n.__)("Review date","woocommerce"),checked:e.showReviewDate,onChange:()=>t({showReviewDate:!e.showReviewDate})}),(0,o.createElement)(c.ToggleControl,{label:(0,n.__)("Review content","woocommerce"),checked:e.showReviewContent,onChange:()=>t({showReviewContent:!e.showReviewContent})}),e.showReviewImage&&(0,o.createElement)(o.Fragment,null,(0,o.createElement)(c.__experimentalToggleGroupControl,{label:(0,n.__)("Review image","woocommerce"),value:e.imageType,onChange:e=>t({imageType:e})},(0,o.createElement)(c.__experimentalToggleGroupControlOption,{value:"reviewer",label:(0,n.__)("Reviewer photo","woocommerce")}),(0,o.createElement)(c.__experimentalToggleGroupControlOption,{value:"product",label:(0,n.__)("Product","woocommerce")})),"reviewer"===e.imageType&&!r&&(0,o.createElement)(c.Notice,{className:"wc-block-base-control-notice",isDismissible:!1},(0,m.createInterpolateElement)((0,n.__)("Reviewer photo is disabled in your <a>site settings</a>.","woocommerce"),{a:(0,o.createElement)("a",{href:(0,T.getAdminLink)("options-discussion.php"),target:"_blank",rel:"noopener noreferrer"})}))))})(e,r)),(0,o.createElement)(c.PanelBody,{title:(0,n.__)("List Settings","woocommerce")},((e,t)=>(0,o.createElement)(o.Fragment,null,(0,o.createElement)(c.ToggleControl,{label:(0,n.__)("Order by","woocommerce"),checked:e.showOrderby,onChange:()=>t({showOrderby:!e.showOrderby})}),(0,o.createElement)(c.SelectControl,{label:(0,n.__)("Order Product Reviews by","woocommerce"),value:e.orderby,options:[{label:"Most recent",value:"most-recent"},{label:"Highest Rating",value:"highest-rating"},{label:"Lowest Rating",value:"lowest-rating"}],onChange:e=>t({orderby:e})}),(0,o.createElement)(c.RangeControl,{label:(0,n.__)("Starting Number of Reviews","woocommerce"),value:e.reviewsOnPageLoad,onChange:e=>t({reviewsOnPageLoad:e}),max:20,min:1}),(0,o.createElement)(c.ToggleControl,{label:(0,n.__)("Load more","woocommerce"),checked:e.showLoadMore,onChange:()=>t({showLoadMore:!e.showLoadMore})}),e.showLoadMore&&(0,o.createElement)(c.RangeControl,{label:(0,n.__)("Load More Reviews","woocommerce"),value:e.reviewsOnLoadMore,onChange:e=>t({reviewsOnLoadMore:e}),max:20,min:1})))(e,r))),(0,o.createElement)(Ie,{attributes:e,icon:(0,o.createElement)(a.Z,{icon:i.Z,className:"block-editor-block-icon"}),name:(0,n.__)("Reviews by Product","woocommerce"),noReviewsPlaceholder:Le}))})),Oe={attributes:{editMode:!1,imageType:"reviewer",orderby:"most-recent",reviewsOnLoadMore:10,reviewsOnPageLoad:10,showLoadMore:!0,showOrderby:!0,showReviewDate:!0,showReviewerName:!0,showReviewImage:!0,showReviewRating:!0,showReviewContent:!0,previewReviews:[{id:1,date_created:"2019-07-15T17:05:04",formatted_date_created:(0,n.__)("July 15, 2019","woocommerce"),date_created_gmt:"2019-07-15T15:05:04",product_id:0,product_name:(0,n.__)("WordPress Pennant","woocommerce"),product_permalink:"#",
|
||
/* translators: An example person name used for the block previews. */
|
||
reviewer:(0,n.__)("Alice","woocommerce"),review:`<p>${(0,n.__)("I bought this product last week and I'm very happy with it.","woocommerce")}</p>\n`,reviewer_avatar_urls:{48:V.defaultAvatar,96:V.defaultAvatar},rating:5,verified:!0},{id:2,date_created:"2019-07-12T12:39:39",formatted_date_created:(0,n.__)("July 12, 2019","woocommerce"),date_created_gmt:"2019-07-12T10:39:39",product_id:0,product_name:(0,n.__)("WordPress Pennant","woocommerce"),product_permalink:"#",
|
||
/* translators: An example person name used for the block previews. */
|
||
reviewer:(0,n.__)("Bob","woocommerce"),review:`<p>${(0,n.__)("This product is awesome, I love it!","woocommerce")}</p>\n`,reviewer_avatar_urls:{48:V.defaultAvatar,96:V.defaultAvatar},rating:null,verified:!1}]}};(0,s.registerBlockType)("woocommerce/reviews-by-product",{apiVersion:2,title:(0,n.__)("Reviews by Product","woocommerce"),icon:{src:(0,o.createElement)(a.Z,{icon:i.Z,className:"wc-block-editor-components-block-icon"})},category:"woocommerce",keywords:[(0,n.__)("WooCommerce","woocommerce")],description:(0,n.__)("Display reviews for your products.","woocommerce"),supports:{html:!1,color:{background:!1},typography:{fontSize:!0}},example:{...Oe,attributes:{...Oe.attributes,productId:1}},attributes:{editMode:{type:"boolean",default:!0},imageType:{type:"string",default:"reviewer"},orderby:{type:"string",default:"most-recent"},reviewsOnLoadMore:{type:"number",default:10},reviewsOnPageLoad:{type:"number",default:10},showLoadMore:{type:"boolean",default:!0},showOrderby:{type:"boolean",default:!0},showReviewDate:{type:"boolean",default:!0},showReviewerName:{type:"boolean",default:!0},showReviewImage:{type:"boolean",default:!0},showReviewRating:{type:"boolean",default:!0},showReviewContent:{type:"boolean",default:!0},previewReviews:{type:"array",default:null},productId:{type:"number"}},edit:e=>(0,o.createElement)(xe,{...e}),save:({attributes:e})=>(0,o.createElement)("div",{...l.useBlockProps.save({className:Se(e)}),...Ce(e)})})},7349:()=>{},8204:()=>{},4093:()=>{},8543:()=>{},6990:()=>{},2513:()=>{},5301:()=>{},8462:()=>{},5932:()=>{},9196:e=>{"use strict";e.exports=window.React},4333:e=>{"use strict";e.exports=window.wp.compose},9307:e=>{"use strict";e.exports=window.wp.element},5736:e=>{"use strict";e.exports=window.wp.i18n},9127:e=>{"use strict";e.exports=window.wp.isShallowEqual},444:e=>{"use strict";e.exports=window.wp.primitives}},r={};function o(e){var n=r[e];if(void 0!==n)return n.exports;var s=r[e]={exports:{}};return t[e].call(s.exports,s,s.exports,o),s.exports}o.m=t,e=[],o.O=(t,r,n,s)=>{if(!r){var a=1/0;for(d=0;d<e.length;d++){for(var[r,n,s]=e[d],i=!0,l=0;l<r.length;l++)(!1&s||a>=s)&&Object.keys(o.O).every((e=>o.O[e](r[l])))?r.splice(l--,1):(i=!1,s<a&&(a=s));if(i){e.splice(d--,1);var c=n();void 0!==c&&(t=c)}}return t}s=s||0;for(var d=e.length;d>0&&e[d-1][2]>s;d--)e[d]=e[d-1];e[d]=[r,n,s]},o.n=e=>{var t=e&&e.__esModule?()=>e.default:()=>e;return o.d(t,{a:t}),t},o.d=(e,t)=>{for(var r in t)o.o(t,r)&&!o.o(e,r)&&Object.defineProperty(e,r,{enumerable:!0,get:t[r]})},o.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),o.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},o.j=7874,(()=>{var e={7874:0};o.O.j=t=>0===e[t];var t=(t,r)=>{var n,s,[a,i,l]=r,c=0;if(a.some((t=>0!==e[t]))){for(n in i)o.o(i,n)&&(o.m[n]=i[n]);if(l)var d=l(o)}for(t&&t(r);c<a.length;c++)s=a[c],o.o(e,s)&&e[s]&&e[s][0](),e[s]=0;return o.O(d)},r=self.webpackChunkwebpackWcBlocksJsonp=self.webpackChunkwebpackWcBlocksJsonp||[];r.forEach(t.bind(null,0)),r.push=t.bind(null,r.push.bind(r))})();var n=o.O(void 0,[2869],(()=>o(5585)));n=o.O(n),((this.wc=this.wc||{}).blocks=this.wc.blocks||{})["reviews-by-product"]=n})(); |