PluginProbe
FluentCart A New Era of eCommerce – Faster, Lighter, and Simpler / 1.6.5
FluentCart A New Era of eCommerce – Faster, Lighter, and Simpler v1.6.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
← All changes | assets/ProductCarouselBlockEditor.js +1 -1 1.5.2 → 1.6.5 View file →
@@ -1 +1 @@
1 -import{j as e,b as m}from"./chunks/BlockEditorTranslator.js?ver=1.5.2";import{h as O}from"./chunks/Icons.js?ver=1.5.2";import{a as U}from"./chunks/index5.js?ver=1.5.2";import{E as k}from"./chunks/EditorPanel.js?ver=1.5.2";import{E as u}from"./chunks/EditorPanelRow.js?ver=1.5.2";import"./chunks/CustomSelect.js?ver=1.5.2";import{S as V}from"./chunks/SelectProductModal.js?ver=1.5.2";import"./chunks/SingleProductContext.js?ver=1.5.2";import{P as H}from"./chunks/ProductContext.js?ver=1.5.2";import{a as Q}from"./chunks/add-query-args.js?ver=1.5.2";import"./chunks/index6.js?ver=1.5.2";import"./chunks/ProductListItem.js?ver=1.5.2";const{InspectorControls:W}=wp.blockEditor,{CheckboxControl:X}=wp.components,{RangeControl:I}=wp.components,{SelectControl:N,ToggleControl:E}=wp.components,$=({attributes:o,setAttributes:n,selectedProduct:i,setSelectedProduct:g,isInsideProductInfo:c})=>{const{carousel_settings:s}=o,{useEffect:y,useState:M}=wp.element;return y(()=>{},[o,i]),e.jsx(W,{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.jsx(k,{title:m("Product"),children:!c&&e.jsxs(u,{className:"flex-col",children:[e.jsx(V,{onModalClosed:t=>{const x=Array.isArray(t)?t.filter(a=>a==null?void 0:a.ID):[],v=x.map(a=>a.ID);n({product_ids:v}),g(x)},selectedProduct:i,setSelectedProduct:g,isMultiple:!0}),Array.isArray(o.product_ids)&&o.product_ids.length>0&&i&&i.length>0&&e.jsxs("div",{className:"fct-selected-products",children:[e.jsx("span",{className:"fct-selected-products__label",children:m("Selected products")}),e.jsx("div",{className:"fct-selected-products__list",children:i.map(t=>e.jsx("span",{className:"fct-product-chip",children:t.post_title},t.ID))})]})]})}),e.jsx(k,{title:m("Layout"),children:e.jsxs(u,{children:[e.jsx("span",{className:"fct-inspector-control-label",children:m("Slides per view")}),e.jsx(I,{value:s.slidesToShow,onChange:t=>n({carousel_settings:{...s,slidesToShow:t}}),min:1,max:6})]})}),e.jsxs(k,{title:m("Behavior"),children:[e.jsx("p",{className:"fct-panel-subtitle",children:m("Carousel interaction & animation")}),e.jsx(u,{children:e.jsx(N,{label:"Autoplay",value:s.autoplay,options:[{label:"Disabled",value:"no"},{label:"Always",value:"yes"},{label:"On Hover",value:"hover"}],onChange:t=>{n({carousel_settings:{...s,autoplay:t}})}})}),["yes","hover"].includes(s.autoplay)&&e.jsx(u,{className:"fct-nested-control",children:e.jsx(I,{label:"Autoplay Delay (ms)",help:"Time between slides in milliseconds",value:s.autoplayDelay||3e3,min:300,max:1e4,step:100,onChange:t=>n({carousel_settings:{...s,autoplayDelay:t}})})}),e.jsx("div",{className:"fct-inspector-divider"}),e.jsx(u,{children:e.jsx(E,{label:"Show arrows",checked:s.arrows==="yes",onChange:t=>n({carousel_settings:{...s,arrows:t?"yes":"no"}})})}),s.arrows==="yes"&&e.jsx(u,{className:"fct-nested-control",children:e.jsx(N,{label:"Arrow Size",value:s.arrowsSize,options:[{label:"Small",value:"sm"},{label:"Medium",value:"md"},{label:"Large",value:"lg"}],onChange:t=>n({carousel_settings:{...s,arrowsSize:t}})})}),e.jsx("div",{className:"fct-inspector-divider"}),e.jsx(u,{children:e.jsx(E,{label:"Show Pagination",checked:s.pagination==="yes",onChange:t=>n({carousel_settings:{...s,pagination:t?"yes":"no"}})})}),s.pagination==="yes"&&e.jsx(u,{className:"fct-nested-control",children:e.jsx(N,{label:"Pagination Type",value:s.paginationType,options:[{label:"Bullets",value:"bullets"},{label:"Fraction",value:"fraction"},{label:"Progress Bar",value:"progress"},{label:"Segmented (Modern)",value:"segmented"}],onChange:t=>n({carousel_settings:{...s,paginationType:t}})})}),e.jsx("div",{className:"fct-inspector-divider"}),e.jsx(u,{children:e.jsx(X,{label:m("Infinite loop"),checked:s.infinite==="yes",onChange:t=>n({carousel_settings:{...s,infinite:t?"yes":"no"}})})})]})]})})})})},q=""+new URL("assets/ProductGallery.png",import.meta.url).href,{InnerBlocks:T,useBlockProps:D,useInnerBlocksProps:he,__experimentalUseBlockPreview:fe,BlockContextProvider:ge}=wp.blockEditor,{registerBlockType:J}=wp.blocks,{useEffect:h,useState:f,useRef:K}=wp.element,{useSelect:b}=wp.data,{store:Y}=wp.blockEditor,j=window.fluent_cart_product_carousel_block_editor_data,A=window.fluentCartRestVars.rest,Z=[["fluent-cart/product-carousel-loop",{className:"fluent-cart-product-carousel-loop",layout:{type:"constrained"},metadata:{name:"Product Carousel Loop"}},[["fluent-cart/product-image"],["fluent-cart/product-title"],["fluent-cart/excerpt"],["fluent-cart/price-range"],["fluent-cart/shopapp-product-buttons"]]],["fluent-cart/product-carousel-controls"],["fluent-cart/product-carousel-pagination"]];J(j.slug+"/"+j.name,{apiVersion:3,title:j.title,description:j.description,example:{attributes:{},innerBlocks:[{name:"core/image",attributes:{url:q,alt:"Product Carousel Preview",style:{width:"100%",height:"auto"}}}]},icon:{src:O},category:"fluent-cart",supports:{html:!1,reusable:!1,innerBlocks:!0},attributes:{product_ids:{type:"array",default:[]},inside_product_info:{type:"string",default:"-"},carousel_settings:{type:"object",default:{slidesToShow:3,autoplay:"yes",autoplayDelay:3e3,arrows:"yes",arrowsSize:"md",pagination:"yes",paginationType:"bullets",infinite:"no"}},has_controls:{type:"string",default:"yes"},has_pagination:{type:"string",default:"yes"}},provides_context:{"fluent-cart/carousel_settings":"carousel_settings","fluent-cart/product_ids":"product_ids","fluent-cart/has_controls":"has_controls","fluent-cart/has_pagination":"has_pagination"},edit:({attributes:o,setAttributes:n,clientId:i})=>{const g=D({className:"fluent-cart-product-carousel-block"}),[c,s]=f([]),y=K(!1),[M,t]=f([]),[x,v]=f(!1),a=Math.max(1,Number(o.carousel_settings.slidesToShow||4)),L=o.carousel_settings.infinite==="yes",{has_controls:_,has_pagination:w}=b(r=>{const d=r("core/block-editor").getBlocks(i);return{has_controls:d.some(p=>p.name==="fluent-cart/product-carousel-controls"),has_pagination:d.some(p=>p.name==="fluent-cart/product-carousel-pagination")}},[i]);h(()=>{if(!y.current){if(!_&&!w)return;y.current=!0}n({has_controls:_?"yes":"no",has_pagination:w?"yes":"no"})},[_,w]);const P=b(r=>{const{getBlockParents:d,getBlockName:p}=r(Y);return d(i).some(l=>p(l)==="fluent-cart/product-info")},[i]);h(()=>{const r=P?"yes":"no";o.inside_product_info!==r&&n({inside_product_info:r})},[P]);const R=()=>{if(!(Array.isArray(o.product_ids)&&o.product_ids.length>0))return;v(!0);const d=A.url+"/products/fetchProductsByIds",p={productIds:o.product_ids,with:["detail","variants"]};U({path:Q(d,p),headers:{"X-WP-Nonce":A.nonce}}).then(l=>{var B;const G=Array.isArray((B=l==null?void 0:l.products)==null?void 0:B.data)?l.products.data:Array.isArray(l==null?void 0:l.products)?l.products:Array.isArray(l)?l:[];s(G),console.log("api response",c)}).finally(()=>{v(!1)})};h(()=>{R()},[o.product_ids]),h(()=>{},[c]);const z=(()=>{if(!c.length)return Array.from({length:a}).map((p,l)=>({ID:`placeholder-${l}`,isPlaceholder:!0}));if(!L||c.length>=a)return c.slice(0,a);const r=[...c];let d=0;for(;r.length<a;)r.push(c[d%c.length]),d++;return r.slice(0,a)})();Math.ceil((c.length||a)/a);const C=b(r=>r("core/block-editor").getBlock(i),[i]),[S,F]=f(1);h(()=>{if(S>1){new Date().toISOString();return}F(S+1)},[C]),C.innerBlocks;const[ee,se]=f();return e.jsxs("div",{...g,children:[e.jsx($,{attributes:o,setAttributes:n,selectedProduct:c,setSelectedProduct:s}),e.jsx("div",{className:"fct-product-gallery-wrapper is-editor-preview",children:e.jsx("div",{className:"fct-product-gallery-carousel editor-carousel-preview",style:{display:"grid",gap:"16px"},children:x||!c.length?e.jsx(e.Fragment,{children:e.jsxs("div",{className:"fluent-cart-empty",children:[e.jsxs("div",{className:"fct-loading-header",children:[e.jsx("div",{className:"fct-loading-spinner"}),e.jsx("span",{children:m("Loading products...")})]}),e.jsx("div",{className:"dummy-grid",style:{"--fct-slides-per-view":a},children:Array.from({length:a}).map((r,d)=>e.jsxs("div",{className:"dummy-card",style:{"--card-index":d},children:[e.jsx("div",{className:"dummy-image skeleton"}),e.jsxs("div",{className:"dummy-content",children:[e.jsx("div",{className:"dummy-title skeleton"}),e.jsx("div",{className:"dummy-excerpt skeleton"}),e.jsx("div",{className:"dummy-price skeleton"})]}),e.jsx("div",{className:"dummy-btn-wrap",children:e.jsx("div",{className:"dummy-btn"})})]},d))})]})}):e.jsx(H,{value:{products:z},children:e.jsx(T,{template:Z})})})})]})},save:()=>{const o=D.save({className:"fluent-cart-product-carousel-block"});return e.jsx("div",{...o,children:e.jsx(T.Content,{})})}});
1 +import{j as e}from"./chunks/jsx-runtime.js?ver=1.6.5";import{h as O}from"./chunks/Icons.js?ver=1.6.5";import{a as U}from"./chunks/index5.js?ver=1.6.5";import{E as k}from"./chunks/EditorPanel.js?ver=1.6.5";import{E as p}from"./chunks/EditorPanelRow.js?ver=1.6.5";import{b as s}from"./chunks/BlockEditorTranslator.js?ver=1.6.5";import"./chunks/CustomSelect.js?ver=1.6.5";import{S as V}from"./chunks/SelectProductModal.js?ver=1.6.5";import"./chunks/SingleProductContext.js?ver=1.6.5";import{P as H}from"./chunks/ProductContext.js?ver=1.6.5";import{a as Q}from"./chunks/add-query-args.js?ver=1.6.5";import"./chunks/index6.js?ver=1.6.5";import"./chunks/ProductListItem.js?ver=1.6.5";const{InspectorControls:W}=wp.blockEditor,{CheckboxControl:X}=wp.components,{RangeControl:I}=wp.components,{SelectControl:N,ToggleControl:E}=wp.components,$=({attributes:a,setAttributes:c,selectedProduct:d,setSelectedProduct:g,isInsideProductInfo:i})=>{const{carousel_settings:t}=a,{useEffect:y,useState:M}=wp.element;return y(()=>{},[a,d]),e.jsx(W,{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.jsx(k,{title:s("Product"),children:!i&&e.jsxs(p,{className:"flex-col",children:[e.jsx(V,{onModalClosed:o=>{const x=Array.isArray(o)?o.filter(r=>r==null?void 0:r.ID):[],v=x.map(r=>r.ID);c({product_ids:v}),g(x)},selectedProduct:d,setSelectedProduct:g,isMultiple:!0}),Array.isArray(a.product_ids)&&a.product_ids.length>0&&d&&d.length>0&&e.jsxs("div",{className:"fct-selected-products",children:[e.jsx("span",{className:"fct-selected-products__label",children:s("Selected products")}),e.jsx("div",{className:"fct-selected-products__list",children:d.map(o=>e.jsx("span",{className:"fct-product-chip",children:o.post_title},o.ID))})]})]})}),e.jsx(k,{title:s("Layout"),children:e.jsxs(p,{children:[e.jsx("span",{className:"fct-inspector-control-label",children:s("Slides per view")}),e.jsx(I,{value:t.slidesToShow,onChange:o=>c({carousel_settings:{...t,slidesToShow:o}}),min:1,max:6})]})}),e.jsxs(k,{title:s("Behavior"),children:[e.jsx("p",{className:"fct-panel-subtitle",children:s("Carousel interaction & animation")}),e.jsx(p,{children:e.jsx(N,{label:s("Autoplay"),value:t.autoplay,options:[{label:s("Disabled"),value:"no"},{label:s("Always"),value:"yes"},{label:s("On Hover"),value:"hover"}],onChange:o=>{c({carousel_settings:{...t,autoplay:o}})}})}),["yes","hover"].includes(t.autoplay)&&e.jsx(p,{className:"fct-nested-control",children:e.jsx(I,{label:"Autoplay Delay (ms)",help:s("Time between slides in milliseconds"),value:t.autoplayDelay||3e3,min:300,max:1e4,step:100,onChange:o=>c({carousel_settings:{...t,autoplayDelay:o}})})}),e.jsx("div",{className:"fct-inspector-divider"}),e.jsx(p,{children:e.jsx(E,{label:s("Show arrows"),checked:t.arrows==="yes",onChange:o=>c({carousel_settings:{...t,arrows:o?"yes":"no"}})})}),t.arrows==="yes"&&e.jsx(p,{className:"fct-nested-control",children:e.jsx(N,{label:s("Arrow Size"),value:t.arrowsSize,options:[{label:s("Small"),value:"sm"},{label:s("Medium"),value:"md"},{label:s("Large"),value:"lg"}],onChange:o=>c({carousel_settings:{...t,arrowsSize:o}})})}),e.jsx("div",{className:"fct-inspector-divider"}),e.jsx(p,{children:e.jsx(E,{label:s("Show Pagination"),checked:t.pagination==="yes",onChange:o=>c({carousel_settings:{...t,pagination:o?"yes":"no"}})})}),t.pagination==="yes"&&e.jsx(p,{className:"fct-nested-control",children:e.jsx(N,{label:s("Pagination Type"),value:t.paginationType,options:[{label:s("Bullets"),value:"bullets"},{label:s("Fraction"),value:"fraction"},{label:s("Progress Bar"),value:"progress"},{label:s("Segmented (Modern)"),value:"segmented"}],onChange:o=>c({carousel_settings:{...t,paginationType:o}})})}),e.jsx("div",{className:"fct-inspector-divider"}),e.jsx(p,{children:e.jsx(X,{label:s("Infinite loop"),checked:t.infinite==="yes",onChange:o=>c({carousel_settings:{...t,infinite:o?"yes":"no"}})})})]})]})})})})},q=""+new URL("assets/ProductGallery.png",import.meta.url).href,{InnerBlocks:T,useBlockProps:D,useInnerBlocksProps:fe,__experimentalUseBlockPreview:ge,BlockContextProvider:ye}=wp.blockEditor,{registerBlockType:J}=wp.blocks,{useEffect:h,useState:f,useRef:K}=wp.element,{useSelect:b}=wp.data,{store:Y}=wp.blockEditor,j=window.fluent_cart_product_carousel_block_editor_data,A=window.fluentCartRestVars.rest,Z=[["fluent-cart/product-carousel-loop",{className:"fluent-cart-product-carousel-loop",layout:{type:"constrained"},metadata:{name:"Product Carousel Loop"}},[["fluent-cart/product-image"],["fluent-cart/product-title"],["fluent-cart/excerpt"],["fluent-cart/price-range"],["fluent-cart/shopapp-product-buttons"]]],["fluent-cart/product-carousel-controls"],["fluent-cart/product-carousel-pagination"]];J(j.slug+"/"+j.name,{apiVersion:3,title:j.title,description:j.description,example:{attributes:{},innerBlocks:[{name:"core/image",attributes:{url:q,alt:"Product Carousel Preview",style:{width:"100%",height:"auto"}}}]},icon:{src:O},category:"fluent-cart",supports:{html:!1,reusable:!1,innerBlocks:!0},attributes:{product_ids:{type:"array",default:[]},inside_product_info:{type:"string",default:"-"},carousel_settings:{type:"object",default:{slidesToShow:3,autoplay:"yes",autoplayDelay:3e3,arrows:"yes",arrowsSize:"md",pagination:"yes",paginationType:"bullets",infinite:"no"}},has_controls:{type:"string",default:"yes"},has_pagination:{type:"string",default:"yes"}},provides_context:{"fluent-cart/carousel_settings":"carousel_settings","fluent-cart/product_ids":"product_ids","fluent-cart/has_controls":"has_controls","fluent-cart/has_pagination":"has_pagination"},edit:({attributes:a,setAttributes:c,clientId:d})=>{const g=D({className:"fluent-cart-product-carousel-block"}),[i,t]=f([]),y=K(!1),[M,o]=f([]),[x,v]=f(!1),r=Math.max(1,Number(a.carousel_settings.slidesToShow||4)),L=a.carousel_settings.infinite==="yes",{has_controls:_,has_pagination:w}=b(l=>{const u=l("core/block-editor").getBlocks(d);return{has_controls:u.some(m=>m.name==="fluent-cart/product-carousel-controls"),has_pagination:u.some(m=>m.name==="fluent-cart/product-carousel-pagination")}},[d]);h(()=>{if(!y.current){if(!_&&!w)return;y.current=!0}c({has_controls:_?"yes":"no",has_pagination:w?"yes":"no"})},[_,w]);const P=b(l=>{const{getBlockParents:u,getBlockName:m}=l(Y);return u(d).some(n=>m(n)==="fluent-cart/product-info")},[d]);h(()=>{const l=P?"yes":"no";a.inside_product_info!==l&&c({inside_product_info:l})},[P]);const R=()=>{if(!(Array.isArray(a.product_ids)&&a.product_ids.length>0))return;v(!0);const u=A.url+"/products/fetchProductsByIds",m={productIds:a.product_ids,with:["detail","variants"]};U({path:Q(u,m),headers:{"X-WP-Nonce":A.nonce}}).then(n=>{var B;const G=Array.isArray((B=n==null?void 0:n.products)==null?void 0:B.data)?n.products.data:Array.isArray(n==null?void 0:n.products)?n.products:Array.isArray(n)?n:[];t(G),console.log("api response",i)}).finally(()=>{v(!1)})};h(()=>{R()},[a.product_ids]),h(()=>{},[i]);const z=(()=>{if(!i.length)return Array.from({length:r}).map((m,n)=>({ID:`placeholder-${n}`,isPlaceholder:!0}));if(!L||i.length>=r)return i.slice(0,r);const l=[...i];let u=0;for(;l.length<r;)l.push(i[u%i.length]),u++;return l.slice(0,r)})();Math.ceil((i.length||r)/r);const C=b(l=>l("core/block-editor").getBlock(d),[d]),[S,F]=f(1);h(()=>{if(S>1){new Date().toISOString();return}F(S+1)},[C]),C.innerBlocks;const[ee,se]=f();return e.jsxs("div",{...g,children:[e.jsx($,{attributes:a,setAttributes:c,selectedProduct:i,setSelectedProduct:t}),e.jsx("div",{className:"fct-product-gallery-wrapper is-editor-preview",children:e.jsx("div",{className:"fct-product-gallery-carousel editor-carousel-preview",style:{display:"grid",gap:"16px"},children:x||!i.length?e.jsx(e.Fragment,{children:e.jsxs("div",{className:"fluent-cart-empty",children:[e.jsxs("div",{className:"fct-loading-header",children:[e.jsx("div",{className:"fct-loading-spinner"}),e.jsx("span",{children:s("Loading products...")})]}),e.jsx("div",{className:"dummy-grid",style:{"--fct-slides-per-view":r},children:Array.from({length:r}).map((l,u)=>e.jsxs("div",{className:"dummy-card",style:{"--card-index":u},children:[e.jsx("div",{className:"dummy-image skeleton"}),e.jsxs("div",{className:"dummy-content",children:[e.jsx("div",{className:"dummy-title skeleton"}),e.jsx("div",{className:"dummy-excerpt skeleton"}),e.jsx("div",{className:"dummy-price skeleton"})]}),e.jsx("div",{className:"dummy-btn-wrap",children:e.jsx("div",{className:"dummy-btn"})})]},u))})]})}):e.jsx(H,{value:{products:z},children:e.jsx(T,{template:Z})})})})]})},save:()=>{const a=D.save({className:"fluent-cart-product-carousel-block"});return e.jsx("div",{...a,children:e.jsx(T.Content,{})})}});