PluginProbe
FluentCart A New Era of eCommerce – Faster, Lighter, and Simpler / 1.6.4
FluentCart A New Era of eCommerce – Faster, Lighter, and Simpler v1.6.4
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 trunk 1.2.0 All 47 releases
fluent-cart / assets / PriceRangeBlockEditor.js

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

2 lines 4.8 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 import{j as t}from"./chunks/jsx-runtime.js?ver=1.6.4";import{a as S}from"./chunks/index5.js?ver=1.6.4";import{S as N}from"./chunks/SelectProductModal.js?ver=1.6.4";import{C as b}from"./chunks/CustomSelect.js?ver=1.6.4";import{E as d}from"./chunks/EditorPanel.js?ver=1.6.4";import{E as u}from"./chunks/EditorPanelRow.js?ver=1.6.4";import{b as a}from"./chunks/BlockEditorTranslator.js?ver=1.6.4";import{u as w}from"./chunks/SingleProductContext.js?ver=1.6.4";import{l as v}from"./chunks/Icons.js?ver=1.6.4";import{a as E}from"./chunks/add-query-args.js?ver=1.6.4";import"./chunks/ProductListItem.js?ver=1.6.4";import"./chunks/index6.js?ver=1.6.4";const{InspectorControls:F}=wp.blockEditor,I=({attributes:o,setAttributes:i,selectedProduct:e,setSelectedProduct:l})=>t.jsx(F,{children:t.jsx("div",{className:"fct-inspector-control-wrap fct-inspector-control-wrap--product-card",children:t.jsx("div",{className:"fct-inspector-control-group",children:t.jsxs("div",{className:"fct-inspector-control-body",children:[t.jsx(d,{title:a("Product"),children:t.jsxs(u,{className:"flex-col",children:[t.jsx(N,{onModalClosed:r=>{i({product_id:r!=null&&r.ID?String(r.ID):""}),l(r)},selectedProduct:e,setSelectedProduct:l,isMultiple:!1}),(e==null?void 0:e.post_title)&&t.jsxs("div",{className:"fct-selected-products",children:[t.jsx("span",{className:"fct-selected-products__label",children:a("Selected Product")}),t.jsx("div",{className:"fct-selected-products__list",children:t.jsx("div",{className:"fct-product-chip-group",children:t.jsx("span",{className:"fct-product-chip fct-product-chip--parent",children:e.post_title})})}),(e==null?void 0:e.detail)&&t.jsxs("div",{className:"fct-selected-products__preview",children:[t.jsxs("strong",{children:[a("Price"),":"]})," ",t.jsx("span",{dangerouslySetInnerHTML:{__html:e.detail.formatted_min_price}}),e.detail.min_price!==e.detail.max_price&&t.jsxs(t.Fragment,{children:[" - ",t.jsx("span",{dangerouslySetInnerHTML:{__html:e.detail.formatted_max_price}})]})]})]})]})}),t.jsx(d,{title:a("Settings"),children:t.jsx(u,{children:t.jsx("div",{className:"fct-block-editor-control-item",children:t.jsxs("div",{className:"fct-inspector-control-row",children:[t.jsx("span",{className:"label",children:a("Price Format")}),t.jsx("div",{className:"actions",children:t.jsx(b,{customKeys:{key:"value",label:"label"},defaultValue:o.price_format,options:[{label:a("Starts From"),value:"starts_from"},{label:a("Range"),value:"range"}],onChange:function(r){i({price_format:r})}})})]})})})})]})})})}),{useBlockProps:T}=wp.blockEditor,{registerBlockType:C,createBlock:M}=wp.blocks,{useEffect:f,useState:B}=wp.element,{useSelect:H}=wp.data,{store:L}=wp.blockEditor,s=window.fluent_cart_price_range_data;s.placeholder_image;const _=window.fluentCartRestVars.rest;C(s.slug+"/"+s.name,{apiVersion:3,title:s.title,description:s.description,icon:{src:v},category:"fluent-cart",attributes:{product_id:{type:["string","number"],default:""},query_type:{type:"string",default:"default"},inside_product_info:{type:"string",default:"-"},price_format:{type:"string",default:"starts_from"}},edit:({attributes:o,setAttributes:i,clientId:e})=>{const l=T(),[r,p]=B({}),h=_.url+"/products/"+o.product_id,n=w(),c=H(m=>{const{getBlockParents:g,getBlockName:j}=m(L);return g(e).some(y=>{const k=j(y);return["fluent-cart/product-info","fluent-cart/products","fluent-cart/shopapp-product-container","fluent-cart/shopapp-product-loop","fluent-cart/product-carousel"].includes(k)})},[e]);f(()=>{i({inside_product_info:c?"yes":"no",...c?{}:{query_type:"custom"}})},[c]);const x=()=>{S({path:E(h,{with:["block_product_detail"]}),headers:{"X-WP-Nonce":_.nonce}}).then(m=>{p(m.product||{})}).finally(()=>{})};return f(()=>{n!=null&&n.product&&p(n.product),!c&&o.product_id&&x()},[o.product_id,n==null?void 0:n.product]),t.jsxs("div",{...l,children:[c?"":t.jsx(I,{attributes:o,setAttributes:i,selectedProduct:r,setSelectedProduct:p}),r!=null&&r.detail?t.jsxs("div",{className:"fct-product-price-range",children:[t.jsx("span",{className:"price-min",dangerouslySetInnerHTML:{__html:r.detail.formatted_min_price}}),r.detail.min_price!==r.detail.max_price&&t.jsxs(t.Fragment,{children:[" - ",t.jsx("span",{className:"price-max",dangerouslySetInnerHTML:{__html:r.detail.formatted_max_price}})]})]}):"$0.00"]})},save:function(o){return null},transforms:{from:[{type:"block",blocks:["fluent-cart/shopapp-product-price"],transform:()=>M(s.slug+"/"+s.name)}]},supports:{html:!1,align:["left","center","right"],typography:{fontSize:!0,lineHeight:!0,__experimentalFontFamily:!0,__experimentalFontWeight:!0,__experimentalFontStyle:!0,__experimentalTextTransform:!0,__experimentalTextDecoration:!0,__experimentalLetterSpacing:!0,__experimentalDefaultControls:{fontSize:!0,lineHeight:!0,fontWeight:!0}},color:{text:!0,background:!0,link:!0,gradients:!0},spacing:{margin:!0,padding:!0},__experimentalBorder:{color:!0,radius:!0,style:!0,width:!0},shadow:!0}});
2