@gem-sdk/components 12.0.0-dev.74 → 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,2 +1,2 @@
1
1
  'use client';
2
- "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var jsxRuntime=require("react/jsx-runtime"),Text=require("../../../text/components/Text.js"),system=require("@gem-sdk/system"),classes=require("./common/classes.js"),attrs=require("./common/attrs.js"),helpers=require("./common/helpers.js"),useGpPrice=require("./hooks/useGpPrice.js"),core=require("@gem-sdk/core");const ProductPrice=e=>{let{style:s,children:r}=e,t=core.useEditorMode(),i="edit"===t,{elementRef:c,moneyFormatted:u,currentProductId:o,isNoComparePrice:a,isNoComparePriceILP:m,shouldHiddenComparePrice:l,emitNoDataSignal:n}=useGpPrice.useGpPrice(e),x=system.createClass(classes.getWrapperClasses(e)),d=system.createAttr(attrs.getAttrs(e,{isILP:!i,productId:o,shouldHiddenComparePrice:l})),p=helpers.getTextProps(e,u),j={visibility:"hidden",opacity:0,maxWidth:0,maxHeight:0},g=m?j:s;return jsxRuntime.jsxs("div",{ref:c,...d,className:x,style:g,"aria-hidden":"true",onClick:n,children:[a&&i?jsxRuntime.jsx(jsxRuntime.Fragment,{children:jsxRuntime.jsx("div",{className:"gp-flex-col gp-flex gp-justify-between gp-p-2",children:jsxRuntime.jsx("p",{className:"gp-text-[#212121] gp-text-[12px] gp-leading-3 ",children:"No compare price"})})}):jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(Text.default,{...p}),r]}),core.filterToolbarPreview(r,!0)]})};exports.default=ProductPrice;
2
+ "use strict";Object.defineProperty(exports,"__esModule",{value:!0});var jsxRuntime=require("react/jsx-runtime"),Text=require("../../../text/components/Text.js"),system=require("@gem-sdk/system"),classes=require("./common/classes.js"),attrs=require("./common/attrs.js"),helpers=require("./common/helpers.js"),useGpPrice=require("./hooks/useGpPrice.js"),core=require("@gem-sdk/core");const ProductPrice=e=>{let{style:s,children:r}=e,t=core.useEditorMode(),{t:i}=core.useI18nStore(),c="edit"===t,{elementRef:o,moneyFormatted:u,currentProductId:a,isNoComparePrice:m,isNoComparePriceILP:n,shouldHiddenComparePrice:l,emitNoDataSignal:x}=useGpPrice.useGpPrice(e),d=system.createClass(classes.getWrapperClasses(e)),p=system.createAttr(attrs.getAttrs(e,{isILP:!c,productId:a,shouldHiddenComparePrice:l})),j=helpers.getTextProps(e,u),g={visibility:"hidden",opacity:0,maxWidth:0,maxHeight:0},h=n?g:s;return jsxRuntime.jsxs("div",{ref:o,...p,className:d,style:h,"aria-hidden":"true",onClick:x,children:[m&&c?jsxRuntime.jsx(jsxRuntime.Fragment,{children:jsxRuntime.jsx("div",{className:"gp-flex-col gp-flex gp-justify-between gp-p-2",children:jsxRuntime.jsx("p",{className:"gp-text-[#212121] gp-text-[12px] gp-leading-3 ",children:i("No compare price")})})}):jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx(Text.default,{...j}),r]}),core.filterToolbarPreview(r,!0)]})};exports.default=ProductPrice;
@@ -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};
@@ -1,2 +1,2 @@
1
1
  'use client';
2
- import{jsxs as e,jsx as r,Fragment as o}from"react/jsx-runtime";import t from"../../../text/components/Text.js";import{createClass as i,createAttr as m}from"@gem-sdk/system";import{getWrapperClasses as s}from"./common/classes.js";import{getAttrs as c}from"./common/attrs.js";import{getTextProps as p}from"./common/helpers.js";import{useGpPrice as d}from"./hooks/useGpPrice.js";import{useEditorMode as l,filterToolbarPreview as a}from"@gem-sdk/core";let ProductPrice=n=>{let{style:f,children:h}=n,g=l(),x="edit"===g,{elementRef:u,moneyFormatted:j,currentProductId:P,isNoComparePrice:y,isNoComparePriceILP:k,shouldHiddenComparePrice:N,emitNoDataSignal:v}=d(n),b=i(s(n)),C=m(c(n,{isILP:!x,productId:P,shouldHiddenComparePrice:N})),H=p(n,j),I={visibility:"hidden",opacity:0,maxWidth:0,maxHeight:0},w=k?I:f;return e("div",{ref:u,...C,className:b,style:w,"aria-hidden":"true",onClick:v,children:[y&&x?r(o,{children:r("div",{className:"gp-flex-col gp-flex gp-justify-between gp-p-2",children:r("p",{className:"gp-text-[#212121] gp-text-[12px] gp-leading-3 ",children:"No compare price"})})}):e(o,{children:[r(t,{...H}),h]}),a(h,!0)]})};export{ProductPrice as default};
2
+ import{jsxs as e,jsx as r,Fragment as o}from"react/jsx-runtime";import t from"../../../text/components/Text.js";import{createClass as i,createAttr as m}from"@gem-sdk/system";import{getWrapperClasses as s}from"./common/classes.js";import{getAttrs as c}from"./common/attrs.js";import{getTextProps as p}from"./common/helpers.js";import{useGpPrice as d}from"./hooks/useGpPrice.js";import{useEditorMode as l,useI18nStore as a,filterToolbarPreview as n}from"@gem-sdk/core";let ProductPrice=f=>{let{style:h,children:g}=f,x=l(),{t:u}=a(),j="edit"===x,{elementRef:P,moneyFormatted:y,currentProductId:k,isNoComparePrice:N,isNoComparePriceILP:v,shouldHiddenComparePrice:b,emitNoDataSignal:C}=d(f),H=i(s(f)),I=m(c(f,{isILP:!j,productId:k,shouldHiddenComparePrice:b})),w=p(f,y),G={visibility:"hidden",opacity:0,maxWidth:0,maxHeight:0},L=v?G:h;return e("div",{ref:P,...I,className:H,style:L,"aria-hidden":"true",onClick:C,children:[N&&j?r(o,{children:r("div",{className:"gp-flex-col gp-flex gp-justify-between gp-p-2",children:r("p",{className:"gp-text-[#212121] gp-text-[12px] gp-leading-3 ",children:u("No compare price")})})}):e(o,{children:[r(t,{...w}),g]}),n(g,!0)]})};export{ProductPrice as default};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gem-sdk/components",
3
- "version": "12.0.0-dev.74",
3
+ "version": "12.0.0-dev.76",
4
4
  "license": "MIT",
5
5
  "sideEffects": false,
6
6
  "main": "dist/cjs/index.js",