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.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
← All changes | assets/chunks/SelectProductModal.js +1 -1 1.3.21 → 1.6.5 View file →
@@ -1 +1 @@
1 -import{j as s,b as o}from"./BlockEditorTranslator.js?ver=1.3.21";import{f as D}from"./Icons.js?ver=1.3.21";import{a as w}from"./index5.js?ver=1.3.21";import{I as C,L as A,E}from"./ProductListItem.js?ver=1.3.21";import"./index6.js?ver=1.3.21";import{a as _}from"./add-query-args.js?ver=1.3.21";const{useEffect:S,useState:h}=wp.element,v=window.fluentCartRestVars.rest,F=({prevSelectedProduct:i,onProductSelectionUpdated:a,isMultiple:c=!1})=>{const d=v.url+"/products",[x,u]=h(!1),[p,f]=h({}),[n,j]=h(c?null:i||null),[y,k]=h(c?i||[]:[]),I=(e,t)=>{if(c){k(l=>{const m=Array.isArray(l)?l:[],N=t?[...m,e]:m.filter(P=>P.ID!==e.ID);return a==null||a(N),N});return}const r=t?e:null;j(r),a==null||a(r)},b=(e=null)=>{u(!0),f({}),w({path:_(d,{...{with:["detail","variants"],active_view:"publish",per_page:10,page:1,order_by:"ID",order_type:"DESC",search:e}}),headers:{"X-WP-Nonce":v.nonce}}).then(r=>{let l=r.products.data;f(l)}).finally(()=>{u(!1)})};S(()=>{b()},[]);const g=e=>{b(e)};return s.jsxs(s.Fragment,{children:[s.jsx("div",{className:"fct-popup-search-wrap",children:s.jsx(C,{icon:!0,name:"search",placeholder:o("Type to search for products, then hit Enter"),onKeyDown:e=>{const t=e.target.value;e.key==="Enter"&&g(t)}})}),s.jsx("div",{className:"fct-popup-body-inner",children:x?s.jsx("div",{className:"fct-skeleton-container",children:[...Array(9)].map((e,t)=>s.jsx("div",{className:"skeleton skeleton-item"},t))}):Object.keys(p).length>0?s.jsx("div",{className:"fct-popup-product-list-container",children:s.jsx("ul",{className:"fct-collapsible-list",children:p.map((e,t)=>{var r,l;return s.jsx("li",{className:"fct-collapsible-list-item",children:s.jsx("div",{className:"fct-collapsible-list-item-inner",children:s.jsx(A,{variant:e,title:e==null?void 0:e.post_title,media:(l=(r=e==null?void 0:e.detail)==null?void 0:r.featured_media)==null?void 0:l.url,isMultiple:c,checked:c?Array.isArray(y)&&y.some(m=>m.ID===e.ID):(n==null?void 0:n.ID)===e.ID,updateSelectedVariations:I})})},t)})})}):s.jsx(E,{text:o("We couldn't find any products matching your search")})})]})},{useState:L}=wp.element,K=({onModalClosed:i,buttonLabel:a=o("Add Product"),selectedProduct:c=null,setSelectedProduct:d=()=>{},isMultiple:x=!1})=>{const[u,p]=L(!1),f=()=>{p(!0)},n=()=>{p(!1),typeof i=="function"&&i(c)};return s.jsxs(s.Fragment,{children:[s.jsx("button",{className:"fct-button fct-button-secondary",onClick:f,children:o("Select Product")}),u&&s.jsxs("div",{className:"fct-popup-container",children:[s.jsx("div",{className:"fct-popup-overlay",onClick:n}),s.jsxs("div",{className:"fct-popup-inner-container",children:[s.jsxs("div",{className:"fct-popup-head",children:[s.jsx("h4",{className:"fct-popup-head-title",children:o("Select Product")}),s.jsx("button",{type:"button",className:"fct-popup-close",onClick:n,children:s.jsx(D,{})})]}),s.jsx("div",{className:"fct-popup-body",children:s.jsx(F,{prevSelectedProduct:c,onProductSelectionUpdated:j=>{d(j)},isMultiple:x})}),s.jsxs("div",{className:"fct-popup-footer",children:[s.jsx("button",{className:"fct-button fct-button-info-soft",onClick:n,children:o("Cancel")}),s.jsx("button",{className:"fct-button fct-button-primary",onClick:()=>{n()},children:a})]})]})]})]})};export{K as S};
1 +import{j as s}from"./jsx-runtime.js?ver=1.6.5";import{f as D}from"./Icons.js?ver=1.6.5";import{b as o}from"./BlockEditorTranslator.js?ver=1.6.5";import{a as w}from"./index5.js?ver=1.6.5";import{I as C,L as _,E as A}from"./ProductListItem.js?ver=1.6.5";import"./index6.js?ver=1.6.5";import{a as E}from"./add-query-args.js?ver=1.6.5";const{useEffect:S,useState:h}=wp.element,v=window.fluentCartRestVars.rest,F=({prevSelectedProduct:i,onProductSelectionUpdated:a,isMultiple:c=!1})=>{const d=v.url+"/products",[x,u]=h(!1),[p,f]=h({}),[r,j]=h(c?null:i||null),[y,k]=h(c?i||[]:[]),I=(e,t)=>{if(c){k(l=>{const m=Array.isArray(l)?l:[],N=t?[...m,e]:m.filter(P=>P.ID!==e.ID);return a==null||a(N),N});return}const n=t?e:null;j(n),a==null||a(n)},b=(e=null)=>{u(!0),f({}),w({path:E(d,{...{with:["block_picker"],active_view:"publish",per_page:10,page:1,order_by:"ID",order_type:"DESC",search:e}}),headers:{"X-WP-Nonce":v.nonce}}).then(n=>{let l=n.products.data;f(l)}).finally(()=>{u(!1)})};S(()=>{b()},[]);const g=e=>{b(e)};return s.jsxs(s.Fragment,{children:[s.jsx("div",{className:"fct-popup-search-wrap",children:s.jsx(C,{icon:!0,name:"search",placeholder:o("Type to search for products, then hit Enter"),onKeyDown:e=>{const t=e.target.value;e.key==="Enter"&&g(t)}})}),s.jsx("div",{className:"fct-popup-body-inner",children:x?s.jsx("div",{className:"fct-skeleton-container",children:[...Array(9)].map((e,t)=>s.jsx("div",{className:"skeleton skeleton-item"},t))}):Object.keys(p).length>0?s.jsx("div",{className:"fct-popup-product-list-container",children:s.jsx("ul",{className:"fct-collapsible-list",children:p.map((e,t)=>{var n,l;return s.jsx("li",{className:"fct-collapsible-list-item",children:s.jsx("div",{className:"fct-collapsible-list-item-inner",children:s.jsx(_,{variant:e,title:e==null?void 0:e.post_title,media:(l=(n=e==null?void 0:e.detail)==null?void 0:n.featured_media)==null?void 0:l.url,isMultiple:c,checked:c?Array.isArray(y)&&y.some(m=>m.ID===e.ID):(r==null?void 0:r.ID)===e.ID,updateSelectedVariations:I})})},t)})})}):s.jsx(A,{text:o("We couldn't find any products matching your search")})})]})},{useState:L}=wp.element,Q=({onModalClosed:i,buttonLabel:a=o("Add Product"),selectedProduct:c=null,setSelectedProduct:d=()=>{},isMultiple:x=!1})=>{const[u,p]=L(!1),f=()=>{p(!0)},r=()=>{p(!1),typeof i=="function"&&i(c)};return s.jsxs(s.Fragment,{children:[s.jsx("button",{className:"fct-button fct-button-secondary",onClick:f,children:o("Select Product")}),u&&s.jsxs("div",{className:"fct-popup-container",children:[s.jsx("div",{className:"fct-popup-overlay",onClick:r}),s.jsxs("div",{className:"fct-popup-inner-container",children:[s.jsxs("div",{className:"fct-popup-head",children:[s.jsx("h4",{className:"fct-popup-head-title",children:o("Select Product")}),s.jsx("button",{type:"button",className:"fct-popup-close",onClick:r,children:s.jsx(D,{})})]}),s.jsx("div",{className:"fct-popup-body",children:s.jsx(F,{prevSelectedProduct:c,onProductSelectionUpdated:j=>{d(j)},isMultiple:x})}),s.jsxs("div",{className:"fct-popup-footer",children:[s.jsx("button",{className:"fct-button fct-button-info-soft",onClick:r,children:o("Cancel")}),s.jsx("button",{className:"fct-button fct-button-primary",onClick:()=>{r()},children:a})]})]})]})]})};export{Q as S};