PluginProbe
FluentCart A New Era of eCommerce – Faster, Lighter, and Simpler / 1.3.27
FluentCart A New Era of eCommerce – Faster, Lighter, and Simpler v1.3.27
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 trunk All 48 releases
fluent-cart / assets / SoldOutBadgeBlockEditor.js

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

2 lines 3.4 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 import{j as t,b as o}from"./chunks/BlockEditorTranslator.js?ver=1.3.27";import{E as u}from"./chunks/EditorPanel.js?ver=1.3.27";import{E as g}from"./chunks/EditorPanelRow.js?ver=1.3.27";import{u as m}from"./chunks/SingleProductContext.js?ver=1.3.27";import{m as x}from"./chunks/Icons.js?ver=1.3.27";import{E as h}from"./chunks/ErrorBoundary.js?ver=1.3.27";const{InspectorControls:_}=wp.blockEditor,{TextControl:y,SelectControl:b}=wp.components,j=({attributes:l,setAttributes:s,isOutOfStock:r})=>t.jsx(_,{children:t.jsx("div",{className:"fct-inspector-control-wrap fct-inspector-control-wrap--sold-out-badge",children:t.jsx("div",{className:"fct-inspector-control-group",children:t.jsxs("div",{className:"fct-inspector-control-body",children:[t.jsx(u,{title:o("Badge Settings"),children:t.jsxs(g,{className:"flex-col",children:[t.jsx(y,{label:o("Badge Text"),value:l.badge_text,onChange:e=>s({badge_text:e}),help:o("Text displayed on the badge.")}),typeof r=="boolean"&&t.jsx("div",{className:`fct-sold-out-badge-status ${r?"fct-sold-out-badge-status--out-of-stock":"fct-sold-out-badge-status--in-stock"}`,children:r?o("Product is out of stock"):o("Product is in stock")})]})}),t.jsx(u,{title:o("Position & Style"),children:t.jsxs(g,{className:"flex-col",children:[t.jsx(b,{label:o("Badge Style"),value:l.badge_style,options:[{label:o("Badge"),value:"badge"},{label:o("Ribbon"),value:"ribbon"},{label:o("Tag"),value:"tag"}],onChange:e=>s({badge_style:e})}),t.jsx(b,{label:o("Position"),value:l.badge_position,options:[{label:o("Top Left"),value:"top-left"},{label:o("Top Right"),value:"top-right"},{label:o("Bottom Left"),value:"bottom-left"},{label:o("Bottom Right"),value:"bottom-right"}],onChange:e=>s({badge_position:e})})]})})]})})})}),{useBlockProps:v}=wp.blockEditor,{registerBlockType:k}=wp.blocks,{useEffect:S,useState:w,useMemo:B}=wp.element,n=window.fluent_cart_sold_out_badge_data;k(n.slug+"/"+n.name,{apiVersion:3,title:n.title,description:n.description,icon:{src:x},category:"fluent-cart",parent:["fluent-cart/products","fluent-cart/product-carousel","fluent-cart/product-image","fluent-cart/shopapp-product-image"],attributes:{badge_text:{type:"string",default:"Sold Out"},badge_style:{type:"string",default:"badge"},badge_position:{type:"string",default:"top-left"}},edit:({attributes:l,setAttributes:s})=>{const r=v(),[e,c]=w({}),a=m();S(()=>{a!=null&&a.product?c(a.product):c({})},[a==null?void 0:a.product]);const i=B(()=>{var p;return((p=e==null?void 0:e.detail)==null?void 0:p.stock_availability)==="out-of-stock"},[e]),f=["fct-sold-out-badge",`fct-sold-out-badge--${l.badge_style||"badge"}`,l.badge_position?`fct-sold-out-badge--${l.badge_position}`:""].filter(Boolean).join(" "),d=(e==null?void 0:e.ID)||(e==null?void 0:e.detail);return t.jsx("div",{...r,children:t.jsxs(h,{children:[t.jsx(j,{attributes:l,setAttributes:s,isOutOfStock:i}),t.jsx("span",{className:f,style:d&&!i?{opacity:.4}:{},children:l.badge_text||"Sold Out"}),d&&!i&&t.jsx("small",{style:{display:"block",color:"#999",fontSize:"11px",marginTop:"4px"},children:o("Product is in stock")})]})})},save:function(){return null},supports:{html:!1,align:["left","center","right"],color:{text:!0,background:!0,gradients:!0},typography:{fontSize:!0,__experimentalFontWeight:!0,__experimentalLetterSpacing:!0,__experimentalTextTransform:!0,__experimentalDefaultControls:{fontSize:!0}},spacing:{margin:!0,padding:!0},__experimentalBorder:{color:!0,radius:!0,style:!0,width:!0},shadow:!0}});
2