PluginProbe
FluentCart A New Era of eCommerce – Faster, Lighter, and Simpler / trunk
FluentCart A New Era of eCommerce – Faster, Lighter, and Simpler vtrunk
1.6.6 1.6.5 1.6.4 1.6.3 1.6.2 1.6.1 1.6.0 1.5.4 1.5.5 1.5.3 1.5.2 1.5.1 1.5.0 1.4.2 1.4.1 1.4.0 1.3.28 1.3.27 1.3.26 1.3.25 1.3.23 1.3.22 1.3.21 1.3.20 1.3.19 All 49 releases
fluent-cart / assets / ProductReviewListBlockEditor.js

ProductReviewListBlockEditor.js in FluentCart A New Era of eCommerce – Faster, Lighter, and Simpler trunk, at assets/ProductReviewListBlockEditor.js

3 lines 12.1 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 import{j as e}from"./chunks/jsx-runtime.js?ver=1.7.0";import{b as t}from"./chunks/BlockEditorTranslator.js?ver=1.7.0";import{E as S}from"./chunks/EditorPanel.js?ver=1.7.0";import{E as p}from"./chunks/EditorPanelRow.js?ver=1.7.0";import{R as L,u as D,a as M}from"./chunks/reviewBlockShared.js?ver=1.7.0";import{t as I}from"./chunks/Icons.js?ver=1.7.0";import"./chunks/SelectProductModal.js?ver=1.7.0";import"./chunks/index6.js?ver=1.7.0";import"./chunks/ProductListItem.js?ver=1.7.0";import"./chunks/index5.js?ver=1.7.0";import"./chunks/add-query-args.js?ver=1.7.0";import"./chunks/SingleProductContext.js?ver=1.7.0";const{InspectorControls:T}=wp.blockEditor,{Notice:O,RangeControl:R,SelectControl:y,ToggleControl:_,__experimentalToggleGroupControl:W,__experimentalToggleGroupControlOption:b}=wp.components,{useState:E}=wp.element,A={autoplay:"no",autoplayDelay:3e3,arrows:"yes",arrowsSize:"md",arrowsPosition:"overlap",pagination:"no",paginationType:"bullets",infinite:"no"},G=i=>i==="grid"?t("Grid"):i==="masonry"?t("Masonry"):t("Slider"),F=({attributes:i,setAttributes:u,selectedProduct:o,setSelectedProduct:h,insideParent:n})=>{const l={...A,...i.sliderSettings||{}},a=s=>u({sliderSettings:{...l,...s}}),c=!!(window.fluent_cart_product_review_list_data||{}).is_pro,[f,w]=E(""),[x,g]=E(0),v=i.viewMode||"list",d=c?v:"list",m=s=>{if(!c&&s!=="list"){w(G(s)),g(r=>r+1);return}w(""),u({viewMode:s})};return e.jsx(T,{children:e.jsx("div",{className:"fct-inspector-control-wrap fct-inspector-control-wrap--product-card fct-inspector-control-wrap--review-list",children:e.jsx("div",{className:"fct-inspector-control-group",children:e.jsxs("div",{className:"fct-inspector-control-body",children:[!n&&e.jsx(L,{attributes:i,setAttributes:u,selectedProduct:o,setSelectedProduct:h}),e.jsxs(S,{title:t("Layout"),children:[e.jsx(p,{children:e.jsxs(W,{isBlock:!0,label:t("View Mode"),value:d,onChange:m,children:[e.jsx(b,{value:"list",label:t("List")}),e.jsx(b,{value:"grid",label:t("Grid")}),e.jsx(b,{value:"masonry",label:t("Masonry")}),e.jsx(b,{value:"slider",label:t("Slider")})]},x)}),f&&e.jsx("div",{className:"fct-view-mode-notice",children:e.jsx(O,{status:"warning",isDismissible:!0,onRemove:()=>w(""),children:t("%s view is a Pro feature. The list stays as a single column without FluentCart Pro.",f)})}),["grid","masonry","slider"].includes(d)&&e.jsx(p,{children:e.jsx(R,{label:d==="slider"?t("Reviews Per Slide"):t("Reviews Per Row"),help:d==="slider"?t("Narrow screens always show one per slide"):t("Reviews per page is rounded down to whole rows. Narrow screens always show one per row."),value:i.gridColumns||2,onChange:s=>u({gridColumns:s}),min:2,max:4,step:1})})]}),d==="slider"&&e.jsxs(S,{title:t("Behavior"),children:[e.jsx("p",{className:"fct-panel-subtitle",children:t("Slider interaction & animation")}),e.jsx(p,{children:e.jsx(y,{label:t("Autoplay"),value:l.autoplay,options:[{label:t("Disabled"),value:"no"},{label:t("Always"),value:"yes"},{label:t("On Hover"),value:"hover"}],onChange:s=>a({autoplay:s})})}),["yes","hover"].includes(l.autoplay)&&e.jsx(p,{className:"fct-nested-control",children:e.jsx(R,{label:t("Autoplay Delay (ms)"),help:t("Time between slides in milliseconds"),value:l.autoplayDelay,min:300,max:1e4,step:100,onChange:s=>a({autoplayDelay:s})})}),e.jsx("div",{className:"fct-inspector-divider"}),e.jsx(p,{children:e.jsx(_,{label:t("Show arrows"),checked:l.arrows==="yes",onChange:s=>a({arrows:s?"yes":"no"})})}),l.arrows==="yes"&&e.jsx(p,{className:"fct-nested-control",children:e.jsx(y,{label:t("Arrow Size"),value:l.arrowsSize,options:[{label:t("Small"),value:"sm"},{label:t("Medium"),value:"md"},{label:t("Large"),value:"lg"}],onChange:s=>a({arrowsSize:s})})}),l.arrows==="yes"&&e.jsx(p,{className:"fct-nested-control",children:e.jsx(y,{label:t("Arrow Placement"),help:t("On the reviews saves space. Beside the reviews keeps every review clear. Below the reviews works well in narrow columns where side arrows have less room."),value:l.arrowsPosition,options:[{label:t("On the reviews"),value:"overlap"},{label:t("Beside the reviews"),value:"outside"},{label:t("Below the reviews"),value:"bottom"}],onChange:s=>a({arrowsPosition:s})})}),e.jsx("div",{className:"fct-inspector-divider"}),e.jsx(p,{children:e.jsx(_,{label:t("Show pagination"),checked:l.pagination==="yes",onChange:s=>a({pagination:s?"yes":"no"})})}),l.pagination==="yes"&&e.jsx(p,{className:"fct-nested-control",children:e.jsx(y,{label:t("Pagination Type"),value:l.paginationType,options:[{label:t("Dots"),value:"bullets"},{label:t("Fraction"),value:"fraction"},{label:t("Progress Bar"),value:"progressbar"},{label:t("Segmented"),value:"segmented"}],onChange:s=>a({paginationType:s})})}),e.jsx("div",{className:"fct-inspector-divider"}),e.jsx(p,{children:e.jsx(_,{label:t("Infinite loop"),checked:l.infinite==="yes",onChange:s=>a({infinite:s?"yes":"no"})})})]})]})})})})},V=({hasProductData:i,reviewCount:u,showHeader:o=!0,showSortControls:h,showReviewerName:n,showReviewDate:l,rows:a=null,viewMode:c="list",gridColumns:f=2,sliderSettings:w={}})=>{const x=n||l,g=["grid","masonry","slider"].includes(c),v=w.paginationType||"bullets",d=c==="slider"&&w.pagination==="yes",m=e.jsxs("div",{className:"fct-reviews-block-skeleton-review",children:[n&&e.jsx("div",{className:"fct-reviews-block-skeleton-avatar"}),e.jsxs("div",{className:"fct-reviews-block-skeleton-lines",children:[x&&e.jsx("div",{className:"fct-reviews-block-skeleton-line is-short"}),e.jsx("div",{className:"fct-reviews-block-skeleton-line is-wide"}),e.jsx("div",{className:"fct-reviews-block-skeleton-line"})]})]}),s=e.jsxs("div",{className:`fct-reviews-block-skeleton-list${g?` is-${c}`:""}`,style:g?{"--fct-review-columns":f}:void 0,children:[o&&i&&e.jsxs("div",{className:"fct-reviews-block-real-count",children:[u," ",t("Reviews")]}),o&&h&&(i?e.jsxs("div",{className:"fct-reviews-block-real-controls",children:[e.jsxs("div",{className:"fct-reviews-block-real-chips",children:[e.jsx("span",{className:"fct-reviews-block-real-chip is-active",children:t("All")}),[5,4,3,2,1].map(r=>e.jsxs("span",{className:"fct-reviews-block-real-chip",children:[r," �
2 "]},r))]}),e.jsxs("span",{className:"fct-reviews-block-real-sort",children:[t("Newest")," ▾"]})]}):e.jsxs("div",{className:"fct-reviews-block-skeleton-chips",children:[e.jsx("div",{className:"fct-reviews-block-skeleton-line is-short"}),e.jsx("div",{className:"fct-reviews-block-skeleton-chip"}),e.jsx("div",{className:"fct-reviews-block-skeleton-chip"}),e.jsx("div",{className:"fct-reviews-block-skeleton-chip"})]})),a||e.jsxs(e.Fragment,{children:[m,m]})]});return d?e.jsxs(e.Fragment,{children:[s,e.jsxs("div",{className:`fct-reviews-block-slider-pagination is-${v}`,children:[v==="bullets"&&[0,1,2].map(r=>e.jsx("span",{className:`fct-reviews-block-slider-dot${r===0?" is-active":""}`},r)),v==="fraction"&&e.jsx("span",{className:"fct-reviews-block-slider-fraction",children:"1 / 3"}),v==="progressbar"&&e.jsx("span",{className:"fct-reviews-block-slider-progress",children:e.jsx("span",{className:"fct-reviews-block-slider-progress-fill"})}),v==="segmented"&&e.jsxs(e.Fragment,{children:[[0,1,2].map(r=>e.jsx("span",{className:`fct-reviews-block-slider-segment${r===0?" is-active":""}`},r)),e.jsx("span",{className:"fct-reviews-block-slider-counter",children:"1 / 3"})]})]})]}):s},{useBlockProps:z,InnerBlocks:C}=wp.blockEditor,{registerBlockType:H}=wp.blocks,{useEffect:K}=wp.element,{useSelect:P}=wp.data,$=["fluent-cart/review-list-count","fluent-cart/review-list-filter","fluent-cart/review-list-sorting"],k=window.fluent_cart_product_review_list_data,q=()=>!!(window.fluent_cart_product_review_list_data||{}).is_pro,U=[["core/group",{className:"fct-reviews-header-blocks",layout:{type:"flex",flexWrap:"wrap",justifyContent:"space-between",verticalAlignment:"center"},style:{spacing:{blockGap:"12px"}},metadata:{name:"Review List Header"}},[["fluent-cart/review-list-count"],["core/group",{className:"fct-reviews-controls",layout:{type:"flex",flexWrap:"wrap",justifyContent:"space-between",verticalAlignment:"center"},style:{spacing:{blockGap:"10px"}},metadata:{name:"Review Controls"}},[["fluent-cart/review-list-filter"],["fluent-cart/review-list-sorting"]]]]],["fluent-cart/review-item",{style:{spacing:{blockGap:"0px"}},metadata:{name:"Review Item"}},[["core/group",{className:"fct-review-item-header-left",layout:{type:"flex",flexWrap:"nowrap",verticalAlignment:"center"},style:{spacing:{blockGap:"10px",margin:{bottom:"10px"}}},metadata:{name:"Review Item Header"}},[["fluent-cart/review-item-avatar",{metadata:{name:"Review Author"}}],["core/group",{className:"fct-review-item-meta-text",layout:{type:"flex",orientation:"vertical"},style:{spacing:{blockGap:"2px"}},metadata:{name:"Review Meta"}},[["core/group",{className:"fct-review-item-name-line",layout:{type:"flex",flexWrap:"wrap"},style:{spacing:{blockGap:{top:"4px",left:"8px"}}},metadata:{name:"Review Name Line"}},[["fluent-cart/review-item-author-name"],["fluent-cart/review-item-rating"],["fluent-cart/review-item-verified-badge"],["fluent-cart/review-item-variation-title"]]],["fluent-cart/review-item-date"]]]]],["fluent-cart/review-item-title"],["fluent-cart/review-item-content"],["fluent-cart/review-item-photos"],["core/group",{className:"fct-review-footer",layout:{type:"flex",flexWrap:"wrap",justifyContent:"space-between"},style:{spacing:{blockGap:"10px"}},metadata:{name:"Review Item Footer"}},[["fluent-cart/review-item-reply"],["fluent-cart/review-item-votes"]]]]],["fluent-cart/review-list-pagination"]],B=["fluent-cart/review-item","fluent-cart/review-list-count","fluent-cart/review-list-filter","fluent-cart/review-list-sorting","fluent-cart/review-list-pagination","core/group","core/columns"],J=B.filter(i=>i!=="fluent-cart/review-item");H(k.slug+"/"+k.name,{apiVersion:3,providesContext:{"fluent-cart/review_view_mode":"viewMode","fluent-cart/review_grid_columns":"gridColumns","fluent-cart/review_slider_settings":"sliderSettings"},title:k.title,description:k.description,icon:{src:I},category:"fluent-cart",attributes:{query_type:{type:"string",default:"default"},product_id:{type:["string","number"],default:""},viewMode:{type:"string",default:"list"},gridColumns:{type:"number",default:2},hasMedia:{type:"boolean",default:!1},sliderSettings:{type:"object",default:{autoplay:"no",autoplayDelay:3e3,arrows:"yes",arrowsSize:"md",arrowsPosition:"overlap",pagination:"no",paginationType:"bullets",infinite:"no"}},showSortControls:{type:"boolean",default:!0},defaultSortBy:{type:"string",default:"created_at"},defaultSortOrder:{type:"string",default:"DESC"},perPage:{type:"number",default:0}},edit:({attributes:i,setAttributes:u,clientId:o})=>{var m;const h=z({className:"fct-review-list-block-editor"}),n=D(o),{selectedProduct:l,setSelectedProduct:a,reviewSummary:c,effectiveProductId:f}=M(i,n,!0);K(()=>{n&&i.query_type!=="default"&&u({query_type:"default"})},[n,i.query_type]);const w=P(s=>{const{getClientIdsOfDescendants:r,getBlockName:j}=s("core/block-editor");return r(o).some(N=>j(N)==="fluent-cart/review-item")},[o]),x=P(s=>{const{getClientIdsOfDescendants:r,getBlockName:j}=s("core/block-editor");return r(o).some(N=>$.includes(j(N)))},[o]),g=((m=l==null?void 0:l.detail)==null?void 0:m.other_info)||{},v=parseInt((c==null?void 0:c.total)??g.review_count,10)||0,d=!!f&&!!(l!=null&&l.ID);return e.jsxs("div",{...h,children:[e.jsx(F,{attributes:i,setAttributes:u,selectedProduct:l,setSelectedProduct:a,insideParent:n}),e.jsxs("div",{className:"fct-reviews-block-skeleton",children:[e.jsx("div",{className:"fct-reviews-block-skeleton-columns is-single",children:e.jsx(V,{viewMode:q()&&i.viewMode||"list",gridColumns:i.gridColumns||2,sliderSettings:i.sliderSettings||{},hasProductData:d,reviewCount:v,showHeader:!x&&!w,showSortControls:!0,showReviewerName:!0,showReviewDate:!0,rows:e.jsx(C,{allowedBlocks:w?J:B,template:U,templateInsertUpdatesSelection:!1,renderAppender:C.ButtonBlockAppender})})}),!d&&!n&&e.jsx("div",{className:"fct-reviews-block-skeleton-caption",children:t("Reviews will be displayed for the current product")})]})]})},save:function(){return e.jsx(C.Content,{})},supports:{html:!1,align:!0,typography:{fontSize:!0,lineHeight:!0,__experimentalFontFamily:!0,__experimentalFontWeight:!0,__experimentalDefaultControls:{fontSize:!0}},color:{text:!0,background:!0},spacing:{margin:!0,padding:!0},__experimentalBorder:{color:!0,radius:!0,style:!0,width:!0}}});
3