PluginProbe
FluentCart A New Era of eCommerce – Faster, Lighter, and Simpler / 1.5.5
FluentCart A New Era of eCommerce – Faster, Lighter, and Simpler v1.5.5
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 / ProductGalleryBlockEditor.js

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

2 lines 5.3 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 import{j as e,b as o}from"./chunks/BlockEditorTranslator.js?ver=1.5.5";import{h as k}from"./chunks/Icons.js?ver=1.5.5";import"./chunks/SelectVariationModal.js?ver=1.5.5";import{a as C}from"./chunks/index5.js?ver=1.5.5";import{E as j}from"./chunks/EditorPanel.js?ver=1.5.5";import{E as i}from"./chunks/EditorPanelRow.js?ver=1.5.5";import{C as y}from"./chunks/CustomSelect.js?ver=1.5.5";import{S as E}from"./chunks/SelectProductModal.js?ver=1.5.5";import{u as S}from"./chunks/SingleProductContext.js?ver=1.5.5";import{a as I}from"./chunks/add-query-args.js?ver=1.5.5";import"./chunks/ProductListItem.js?ver=1.5.5";import"./chunks/index6.js?ver=1.5.5";const{InspectorControls:T}=wp.blockEditor,{CheckboxControl:g,__experimentalNumberControl:P}=wp.components,B=({attributes:s,setAttributes:a,selectedProduct:c,setSelectedProduct:u,isInsideProductInfo:t})=>e.jsx(T,{children:e.jsx("div",{className:"fct-inspector-control-wrap fct-inspector-control-wrap--product-card",children:e.jsx("div",{className:"fct-inspector-control-group",children:e.jsxs("div",{className:"fct-inspector-control-body",children:[e.jsxs(j,{title:o("Product"),children:[!t&&e.jsxs(e.Fragment,{children:[e.jsxs(i,{children:[e.jsx("span",{className:"fct-inspector-control-label",children:o("Query type")}),e.jsx("div",{className:"actions",children:e.jsx(y,{customKeys:{key:"value",label:"label"},defaultValue:s.query_type,options:[{label:o("Default"),value:"default"},{label:o("Custom"),value:"custom"}],onChange:function(l){a({query_type:l})}})})]}),s.query_type==="custom"&&e.jsxs(i,{className:"flex-col",children:[e.jsx(E,{onModalClosed:l=>{a({product_id:l.ID||""}),u(l)},selectedProduct:c,setSelectedProduct:u,isMultiple:!1}),c&&e.jsxs("div",{className:"fct-selected-variation-info w-full",children:[e.jsx("strong",{children:o("Selected product:")}),e.jsx("p",{children:c.post_title})]})]})]}),e.jsxs(i,{children:[e.jsx("span",{className:"fct-inspector-control-label",children:o("Enable image zoom")}),e.jsx("div",{className:"actions",children:e.jsx(g,{checked:s.enableImageZoom==="yes",onChange:l=>{a({enableImageZoom:l?"yes":"no"})}})})]})]}),e.jsxs(j,{title:o("Thumbnail Settings"),children:[e.jsxs(i,{children:[e.jsx("span",{className:"fct-inspector-control-label",children:o("Thumbnail position")}),e.jsx("div",{className:"actions",children:e.jsx(y,{customKeys:{key:"value",label:"label"},defaultValue:s.thumbPosition,options:[{label:o("Bottom"),value:"bottom"},{label:o("Top"),value:"top"},{label:o("Left"),value:"left"},{label:o("Right"),value:"right"}],onChange:function(l){a({thumbPosition:l})}})})]}),e.jsxs(i,{children:[e.jsx("span",{className:"fct-inspector-control-label",children:o("Scrollable thumbnails")}),e.jsx("div",{className:"actions",children:e.jsx(g,{checked:s.scrollableThumbs==="yes",onChange:l=>{a({scrollableThumbs:l?"yes":"no"})}})})]}),e.jsxs(i,{children:[e.jsx("span",{className:"fct-inspector-control-label",children:o("Max thumbnails")}),e.jsx("div",{className:"actions",children:e.jsx(P,{value:s.maxThumbnails,onChange:l=>{a({maxThumbnails:l??""})},min:1,max:50,placeholder:o("No limit")})})]})]})]})})})}),R=""+new URL("assets/ProductGallery.png",import.meta.url).href,{useBlockProps:q}=wp.blockEditor,{registerBlockType:G}=wp.blocks,{useEffect:h,useState:M}=wp.element,p=window.fluent_cart_product_gallery_data,v=p.placeholder_image,N=window.fluentCartRestVars.rest,{useSelect:V}=wp.data,{store:Z}=wp.blockEditor;G(p.slug+"/"+p.name,{apiVersion:3,title:p.title,parent:["fluent-cart/product-info"],description:p.description,example:{attributes:{},innerBlocks:[{name:"core/image",attributes:{url:R,alt:"Product Gallery Preview",style:{width:"100%",height:"auto"}}}]},icon:{src:k},category:"fluent-cart",attributes:{product_id:{type:["string","number"],default:""},query_type:{type:"string",default:"default"},inside_product_info:{type:"string",default:"-"},enableImageZoom:{type:"string",default:"yes"},thumbPosition:{type:"string",default:"bottom"},scrollableThumbs:{type:"string",default:"no"},maxThumbnails:{type:"string",default:""}},edit:({attributes:s,setAttributes:a,clientId:c})=>{var f,x,b;const u=q(),[t,l]=M(null),d=V(n=>{const{getBlockParents:m,getBlockName:_}=n(Z);return m(c).some(w=>_(w)==="fluent-cart/product-info")},[c]);h(()=>{a({inside_product_info:d?"yes":"no"})},[d]);const r=S();return h(()=>{r!=null&&r.product&&l(r.product)},[r==null?void 0:r.product]),h(()=>{if(d)return;const n=s.product_id;if(!n){l(null);return}C({path:I(N.url+"/products/"+n,{with:["detail","variants"]}),headers:{"X-WP-Nonce":N.nonce}}).then(m=>{l(m.product||null)})},[s.product_id,d]),e.jsxs("div",{...u,children:[e.jsx(B,{attributes:s,setAttributes:a,selectedProduct:t,setSelectedProduct:l,isInsideProductInfo:d}),t!=null&&t.ID?e.jsxs("div",{className:"fct-product-gallery-wrapper",children:[e.jsx("div",{className:"fct-product-gallery-thumb",children:e.jsx("img",{src:((x=(f=t==null?void 0:t.detail)==null?void 0:f.featured_media)==null?void 0:x.url)??v,alt:""})}),e.jsx("div",{className:"fct-gallery-thumb-controls",children:(b=t==null?void 0:t.variants)==null?void 0:b.map((n,m)=>e.jsx("div",{className:"fct-gallery-thumb-control-button",children:e.jsx("img",{src:n.thumbnail??v,alt:n.variation_title??""})},n.id||m))})]}):e.jsx("div",{className:"fluent-cart-empty",children:e.jsx("div",{className:"fluent-cart-empty-message",children:o("No product gallery")})})]})},save:function(s){return null}});
2