@gem-sdk/components 12.0.0-dev.75 → 12.0.0-dev.76

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1 +1 @@
1
- "use strict";var core=require("@gem-sdk/core"),useDynamicProduct=require("../../../hooks/useDynamicProduct.js"),React=require("react"),index=require("../../../helpers/index.js"),ProductOfferPlaceholder=require("../../../constants/ProductOfferPlaceholder.js");const useProductOfferData=()=>{let e=core.usePageStore(e=>e.productOffers),o=core.usePageStore(e=>e.publicStoreFrontData),{isDynamicProduct:r}=useDynamicProduct.useDynamicProduct(),t=core.usePageStore(e=>e.dynamicDiscountOffer),c=React.useMemo(()=>r?t?.appliedProductCount:e?.length,[t?.appliedProductCount,r,e?.length]),u=React.useMemo(()=>e?.sort((e,o)=>e?.node?.position&&o?.node?.position?e.node.position-o.node.position:0).map(e=>e?.node?.objectBaseID).filter(Boolean),[e]),{isLoading:a,isValidating:d,data:n}=core.useProductOffersQuery(u||[],{revalidateOnMount:!0},{allStatus:!0,fetcher:index.hasPublicStoreFrontData(o)?index.createStoreFrontFetcher(o):void 0}),s=React.useMemo(()=>a||d,[a,d]),i=React.useMemo(()=>core.flattenConnection(n?.products),[n?.products]),l=React.useMemo(()=>r&&t?.appliedProductCount?Array(t.appliedProductCount).fill(ProductOfferPlaceholder.productOfferPlaceholder):u?.map(e=>i?.find(o=>o?.baseID===e)).filter(Boolean),[r,t?.appliedProductCount,u,i]);return{isLoading:s,productSortedById:l,totalProduct:c}};exports.useProductOfferData=useProductOfferData;
1
+ "use strict";var core=require("@gem-sdk/core"),useDynamicProduct=require("../../../hooks/useDynamicProduct.js"),React=require("react"),index=require("../../../helpers/index.js"),ProductOfferPlaceholder=require("../../../constants/ProductOfferPlaceholder.js");const useProductOfferData=()=>{let e=core.usePageStore(e=>e.productOffers),o=core.usePageStore(e=>e.publicStoreFrontData),{isDynamicProduct:t}=useDynamicProduct.useDynamicProduct(),r=core.usePageStore(e=>e.dynamicDiscountOffer),{isEditMode:c}=core.useRenderMode(),u=React.useMemo(()=>t?r?.appliedProductCount:e?.length,[r?.appliedProductCount,t,e?.length]),a=React.useMemo(()=>e?.sort((e,o)=>e?.node?.position&&o?.node?.position?e.node.position-o.node.position:0).map(e=>e?.node?.objectBaseID).filter(Boolean),[e]),{isLoading:n,isValidating:d,data:s}=core.useProductOffersQuery(a||[],{revalidateOnMount:!0},{allStatus:!0,fetcher:index.hasPublicStoreFrontData(o)?index.createStoreFrontFetcher(o):void 0}),i=React.useMemo(()=>n||d,[n,d]),l=React.useMemo(()=>core.flattenConnection(s?.products),[s?.products]),f=React.useMemo(()=>t&&r?.appliedProductCount?Array(r.appliedProductCount).fill(ProductOfferPlaceholder.productOfferPlaceholder):a?.map(e=>l?.find(o=>o?.baseID===e)).filter(Boolean),[t,r?.appliedProductCount,a,l]);return React.useEffect(()=>{if(i||!c)return;let e=new CustomEvent("editor:toolbar:force-active-component",{bubbles:!0,detail:{}});window.dispatchEvent(e)},[i,c]),{isLoading:i,productSortedById:f,totalProduct:u}};exports.useProductOfferData=useProductOfferData;
@@ -1 +1 @@
1
- import{usePageStore as o,useProductOffersQuery as t,flattenConnection as e}from"@gem-sdk/core";import{useDynamicProduct as r}from"../../../hooks/useDynamicProduct.js";import{useMemo as i}from"react";import{hasPublicStoreFrontData as d,createStoreFrontFetcher as n}from"../../../helpers/index.js";import{productOfferPlaceholder as a}from"../../../constants/ProductOfferPlaceholder.js";let useProductOfferData=()=>{let p=o(o=>o.productOffers),u=o(o=>o.publicStoreFrontData),{isDynamicProduct:s}=r(),c=o(o=>o.dynamicDiscountOffer),l=i(()=>s?c?.appliedProductCount:p?.length,[c?.appliedProductCount,s,p?.length]),f=i(()=>p?.sort((o,t)=>o?.node?.position&&t?.node?.position?o.node.position-t.node.position:0).map(o=>o?.node?.objectBaseID).filter(Boolean),[p]),{isLoading:m,isValidating:P,data:D}=t(f||[],{revalidateOnMount:!0},{allStatus:!0,fetcher:d(u)?n(u):void 0}),h=i(()=>m||P,[m,P]),O=i(()=>e(D?.products),[D?.products]),C=i(()=>s&&c?.appliedProductCount?Array(c.appliedProductCount).fill(a):f?.map(o=>O?.find(t=>t?.baseID===o)).filter(Boolean),[s,c?.appliedProductCount,f,O]);return{isLoading:h,productSortedById:C,totalProduct:l}};export{useProductOfferData};
1
+ import{usePageStore as o,useRenderMode as t,useProductOffersQuery as e,flattenConnection as r}from"@gem-sdk/core";import{useDynamicProduct as i}from"../../../hooks/useDynamicProduct.js";import{useMemo as n,useEffect as d}from"react";import{hasPublicStoreFrontData as a,createStoreFrontFetcher as p}from"../../../helpers/index.js";import{productOfferPlaceholder as u}from"../../../constants/ProductOfferPlaceholder.js";let useProductOfferData=()=>{let s=o(o=>o.productOffers),c=o(o=>o.publicStoreFrontData),{isDynamicProduct:l}=i(),f=o(o=>o.dynamicDiscountOffer),{isEditMode:m}=t(),P=n(()=>l?f?.appliedProductCount:s?.length,[f?.appliedProductCount,l,s?.length]),b=n(()=>s?.sort((o,t)=>o?.node?.position&&t?.node?.position?o.node.position-t.node.position:0).map(o=>o?.node?.objectBaseID).filter(Boolean),[s]),{isLoading:h,isValidating:D,data:C}=e(b||[],{revalidateOnMount:!0},{allStatus:!0,fetcher:a(c)?p(c):void 0}),O=n(()=>h||D,[h,D]),v=n(()=>r(C?.products),[C?.products]),g=n(()=>l&&f?.appliedProductCount?Array(f.appliedProductCount).fill(u):b?.map(o=>v?.find(t=>t?.baseID===o)).filter(Boolean),[l,f?.appliedProductCount,b,v]);return d(()=>{if(O||!m)return;let o=new CustomEvent("editor:toolbar:force-active-component",{bubbles:!0,detail:{}});window.dispatchEvent(o)},[O,m]),{isLoading:O,productSortedById:g,totalProduct:P}};export{useProductOfferData};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gem-sdk/components",
3
- "version": "12.0.0-dev.75",
3
+ "version": "12.0.0-dev.76",
4
4
  "license": "MIT",
5
5
  "sideEffects": false,
6
6
  "main": "dist/cjs/index.js",