@gem-sdk/components 2.0.0-dev.833 → 2.0.0-dev.834
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";Object.defineProperty(exports,"__esModule",{value:!0});var jsxRuntime=require("react/jsx-runtime"),core=require("@gem-sdk/core"),ChildrenDroppable=require("../../../grid/components/ChildrenDroppable.js"),react=require("react"),Row=require("../../../grid/components/Row.js"),Loading=require("../../../common/components/Loading.js"),ProductVariant=require("./ProductVariant.js"),helper=require("../../utils/helper.js");const PostPurchaseProductOffer=({styles:e,builderAttrs:t,builderProps:
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var jsxRuntime=require("react/jsx-runtime"),core=require("@gem-sdk/core"),ChildrenDroppable=require("../../../grid/components/ChildrenDroppable.js"),react=require("react"),Row=require("../../../grid/components/Row.js"),Loading=require("../../../common/components/Loading.js"),ProductVariant=require("./ProductVariant.js"),helper=require("../../utils/helper.js"),index=require("../helpers/index.js");const PostPurchaseProductOffer=({styles:e,builderAttrs:t,builderProps:r,children:o,setting:i})=>{let s=core.useEditorMode(),{productSetting:n,productOfferLayout:a,inlineAlignment:d,...c}=i||{},{productOfferColumnGap:l,productOfferVerticalGutter:u,productOfferWidth:p,...m}=e||{},j=core.usePageStore(e=>e.productOffers),g=core.usePageStore(e=>e.publicStoreFrontData),x=react.useMemo(()=>j?.length,[j?.length]),h=react.useMemo(()=>j?.sort((e,t)=>e?.node?.position&&t?.node?.position?e.node.position-t.node.position:0).map(e=>e?.node?.objectBaseID).filter(Boolean),[j]),P=core.useProductsQuery(h||[],{revalidateOnMount:!0},{allStatus:!0,fetcher:index.hasPublicStoreFrontData(g)?index.createStoreFrontFetcher(g):void 0}),f=react.useMemo(()=>P.isLoading||P.isValidating,[P.isLoading,P.isValidating]),R=react.useMemo(()=>core.flattenConnection(P.data?.products),[P.data?.products]),b=h?.map(e=>R?.find(t=>t?.baseID===e)).filter(Boolean),v=()=>({...core.makeStyleResponsive("cg",l),...core.makeStyleResponsive("rg",{desktop:helper.postPurchaseViewSpacing[u||"base"]}),...core.makeStyleResponsive("w",core.makeWidth(p))}),y=e=>{let t="";return ProductVariant.DEVICES.map(r=>{let o="desktop"===r?"":`${r}:`;(a?.[r]==="1col"&&e%3==0||1>=(x||0))&&(t+=` ${o}gp-col-span-2`)}),t};return jsxRuntime.jsxs(jsxRuntime.Fragment,{children:[jsxRuntime.jsx("div",{className:" mobile:gp-col-span-2 tablet:gp-col-span-2 gp-col-span-2 hidden"}),f?jsxRuntime.jsx(Loading.default,{}):b?.length?jsxRuntime.jsx("div",{...t,className:core.cls(r?.uid,"gp-flex w-auto"),style:{...core.makeStyle({pc:d})},children:jsxRuntime.jsx("div",{className:"gp-grid gp-grid-cols-2",style:v(),children:b?.map((e,i)=>jsxRuntime.jsx("div",{className:y(i),children:jsxRuntime.jsx(core.ProductProvider,{product:e,readOnly:!0,initialVariantId:"Latest",children:jsxRuntime.jsx("div",{..."edit"===s?{"data-uid":r?.uid,"data-component-type":"component","data-component-tag":"Product","data-component-label":"Product","data-component-no-setting":!0,"data-product-id":e?.baseID?.replace("gid://shopify/Product/","")}:{},children:jsxRuntime.jsx(Row.default,{builderAttrs:t,setting:c,styles:m,children:core.isEmptyChildren(o)?jsxRuntime.jsx(ChildrenDroppable.default,{}):o})})})},`uid-${e?.id}`))})}):jsxRuntime.jsx("div",{children:"Products not found"})]})};exports.default=PostPurchaseProductOffer;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";const getPostPurchaseAlignClasses=
|
|
1
|
+
"use strict";const getPostPurchaseAlignClasses=t=>"left"===t?"gp-justify-start":"right"===t?"gp-justify-end":"gp-justify-center",createStoreFrontFetcher=t=>async e=>{let[r,o,s]=e,n={"Content-Type":"application/json","X-GemX-Shop-Token":t.token};return fetch(t.endpoint,{method:"POST",headers:n,body:JSON.stringify({query:r,variables:o,operationName:s})}).then(t=>t.json()).then(t=>t.errors?Promise.reject(t.errors):t.data)},hasPublicStoreFrontData=t=>!!(t&&t.token&&t.endpoint);exports.createStoreFrontFetcher=createStoreFrontFetcher,exports.getPostPurchaseAlignClasses=getPostPurchaseAlignClasses,exports.hasPublicStoreFrontData=t=>!!(t&&t.token&&t.endpoint);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{jsxs as t,Fragment as o,jsx as e}from"react/jsx-runtime";import{useEditorMode as i,usePageStore as
|
|
1
|
+
import{jsxs as t,Fragment as o,jsx as e}from"react/jsx-runtime";import{useEditorMode as i,usePageStore as r,useProductsQuery as a,flattenConnection as d,cls as n,makeStyle as s,ProductProvider as l,isEmptyChildren as p,makeStyleResponsive as c,makeWidth as m}from"@gem-sdk/core";import u from"../../../grid/components/ChildrenDroppable.js";import{useMemo as g}from"react";import f from"../../../grid/components/Row.js";import h from"../../../common/components/Loading.js";import{DEVICES as P}from"./ProductVariant.js";import{postPurchaseViewSpacing as b}from"../../utils/helper.js";import{hasPublicStoreFrontData as j,createStoreFrontFetcher as v}from"../helpers/index.js";let PostPurchaseProductOffer=({styles:y,builderAttrs:D,builderProps:O,children:x,setting:I})=>{let L=i(),{productSetting:N,productOfferLayout:V,inlineAlignment:k,...w}=I||{},{productOfferColumnGap:B,productOfferVerticalGutter:$,productOfferWidth:S,...A}=y||{},C=r(t=>t.productOffers),F=r(t=>t.publicStoreFrontData),M=g(()=>C?.length,[C?.length]),R=g(()=>C?.sort((t,o)=>t?.node?.position&&o?.node?.position?t.node.position-o.node.position:0).map(t=>t?.node?.objectBaseID).filter(Boolean),[C]),q=a(R||[],{revalidateOnMount:!0},{allStatus:!0,fetcher:j(F)?v(F):void 0}),z=g(()=>q.isLoading||q.isValidating,[q.isLoading,q.isValidating]),E=g(()=>d(q.data?.products),[q.data?.products]),G=R?.map(t=>E?.find(o=>o?.baseID===t)).filter(Boolean),H=()=>({...c("cg",B),...c("rg",{desktop:b[$||"base"]}),...c("w",m(S))}),J=t=>{let o="";return P.map(e=>{let i="desktop"===e?"":`${e}:`;(V?.[e]==="1col"&&t%3==0||1>=(M||0))&&(o+=` ${i}gp-col-span-2`)}),o};return t(o,{children:[e("div",{className:" mobile:gp-col-span-2 tablet:gp-col-span-2 gp-col-span-2 hidden"}),z?e(h,{}):G?.length?e("div",{...D,className:n(O?.uid,"gp-flex w-auto"),style:{...s({pc:k})},children:e("div",{className:"gp-grid gp-grid-cols-2",style:H(),children:G?.map((t,o)=>e("div",{className:J(o),children:e(l,{product:t,readOnly:!0,initialVariantId:"Latest",children:e("div",{..."edit"===L?{"data-uid":O?.uid,"data-component-type":"component","data-component-tag":"Product","data-component-label":"Product","data-component-no-setting":!0,"data-product-id":t?.baseID?.replace("gid://shopify/Product/","")}:{},children:e(f,{builderAttrs:D,setting:w,styles:A,children:p(x)?e(u,{}):x})})})},`uid-${t?.id}`))})}):e("div",{children:"Products not found"})]})};export{PostPurchaseProductOffer as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
let getPostPurchaseAlignClasses=
|
|
1
|
+
let getPostPurchaseAlignClasses=t=>"left"===t?"gp-justify-start":"right"===t?"gp-justify-end":"gp-justify-center",createStoreFrontFetcher=t=>async e=>{let[r,o,n]=e,s={"Content-Type":"application/json","X-GemX-Shop-Token":t.token};return fetch(t.endpoint,{method:"POST",headers:s,body:JSON.stringify({query:r,variables:o,operationName:n})}).then(t=>t.json()).then(t=>t.errors?Promise.reject(t.errors):t.data)},hasPublicStoreFrontData=t=>!!(t&&t.token&&t.endpoint);export{createStoreFrontFetcher,getPostPurchaseAlignClasses,hasPublicStoreFrontData};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@gem-sdk/components",
|
|
3
|
-
"version": "2.0.0-dev.
|
|
3
|
+
"version": "2.0.0-dev.834",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"sideEffects": false,
|
|
6
6
|
"main": "dist/cjs/index.js",
|
|
@@ -21,7 +21,7 @@
|
|
|
21
21
|
"format": "prettier --write \"./src/**/*.{ts,tsx}\""
|
|
22
22
|
},
|
|
23
23
|
"devDependencies": {
|
|
24
|
-
"@gem-sdk/core": "2.0.0-dev.
|
|
24
|
+
"@gem-sdk/core": "2.0.0-dev.834",
|
|
25
25
|
"@gem-sdk/styles": "1.14.0-dev.831",
|
|
26
26
|
"@types/react-transition-group": "^4.4.5"
|
|
27
27
|
},
|