@gem-sdk/core 1.22.0-hotfix.0 → 1.22.0-hotfix.3

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.
@@ -183,7 +183,7 @@ const RenderChildren = (props)=>{
183
183
  if (Math.ceil(size / 1024) >= 180) {
184
184
  const fileName = `gp-section-snippet-${props.uid}`;
185
185
  props.customProps.extraFiles[fileName] = data.liquid;
186
- return `{% render '${fileName}', product: product, variant: variant, product_form_id: product_form_id %}`;
186
+ return `{% render '${fileName}', product: product, variant: variant, product_form_id: product_form_id, productSelectedVariant: productSelectedVariant %}`;
187
187
  }
188
188
  return data.liquid;
189
189
  };
@@ -200,7 +200,7 @@ const WrapRenderChildren = ({ uid, customProps }, codes)=>{
200
200
  if (Math.ceil(size / 1024) >= 180) {
201
201
  const fileName = `gp-section-snippet-${uid + i}`;
202
202
  customProps.extraFiles[fileName] = code;
203
- liquid += `{% render '${fileName}', product: product, variant: variant, product_form_id: product_form_id %}`;
203
+ liquid += `{% render '${fileName}', product: product, variant: variant, product_form_id: product_form_id, productSelectedVariant: productSelectedVariant %}`;
204
204
  } else {
205
205
  liquid += code;
206
206
  }
@@ -4,11 +4,12 @@ var products_generated = require('../../graphql/queries/products.generated.js');
4
4
  var getCollection = require('./get-collection.js');
5
5
  var getProduct = require('./get-product.js');
6
6
 
7
- const getProducts = async (fetcher, { ids, isSample, isStorefront })=>{
7
+ const getProducts = async (fetcher, { ids, isSample, isStorefront, defaultSelectedProductCount })=>{
8
8
  const products = await loopFetchProducts(fetcher, {
9
9
  ids,
10
10
  isSample,
11
- isStorefront
11
+ isStorefront,
12
+ defaultSelectedProductCount
12
13
  });
13
14
  if (!products) {
14
15
  throw new Error('Product not found');
@@ -61,8 +62,9 @@ const fetchProducts = async (fetcher, variables)=>{
61
62
  variables
62
63
  ]);
63
64
  };
64
- const loopFetchProducts = async (fetcher, { ids, isSample, isStorefront })=>{
65
- const numberOfProducts = (ids?.length == 0 ? 4 : ids?.length) ?? 4;
65
+ const loopFetchProducts = async (fetcher, { ids, isSample, isStorefront, defaultSelectedProductCount })=>{
66
+ const defaultNumberOfProducts = defaultSelectedProductCount || 4;
67
+ const numberOfProducts = (ids?.length == 0 ? defaultNumberOfProducts : ids?.length) ?? defaultNumberOfProducts;
66
68
  const productsPerPage = 8; // number of products per page
67
69
  let variables; // variables of collection query
68
70
  let productAfterFetcher; // product after of collection query
@@ -6,14 +6,15 @@ var query = require('../../helpers/query.js');
6
6
  var shop = require('../shop.js');
7
7
  var useFetchHandle = require('../useFetchHandle.js');
8
8
 
9
- const useProductsQuery = (ids, options)=>{
9
+ const useProductsQuery = (ids, options, defaultSelectedProductCount)=>{
10
10
  const fetcher = useFetchHandle.useFetchHandle();
11
11
  const isSample = shop.useIsSampleProduct();
12
12
  const isStorefront = shop.useIsStorefrontProduct();
13
13
  return useSWR(ids ? query.generateProductsQueryKey({
14
14
  ids,
15
15
  isSample,
16
- isStorefront
16
+ isStorefront,
17
+ defaultSelectedProductCount
17
18
  }) : null, async ([, arg])=>{
18
19
  return getProducts.getProducts(fetcher, arg);
19
20
  }, options);
@@ -179,7 +179,7 @@ const RenderChildren = (props)=>{
179
179
  if (Math.ceil(size / 1024) >= 180) {
180
180
  const fileName = `gp-section-snippet-${props.uid}`;
181
181
  props.customProps.extraFiles[fileName] = data.liquid;
182
- return `{% render '${fileName}', product: product, variant: variant, product_form_id: product_form_id %}`;
182
+ return `{% render '${fileName}', product: product, variant: variant, product_form_id: product_form_id, productSelectedVariant: productSelectedVariant %}`;
183
183
  }
184
184
  return data.liquid;
185
185
  };
@@ -196,7 +196,7 @@ const WrapRenderChildren = ({ uid, customProps }, codes)=>{
196
196
  if (Math.ceil(size / 1024) >= 180) {
197
197
  const fileName = `gp-section-snippet-${uid + i}`;
198
198
  customProps.extraFiles[fileName] = code;
199
- liquid += `{% render '${fileName}', product: product, variant: variant, product_form_id: product_form_id %}`;
199
+ liquid += `{% render '${fileName}', product: product, variant: variant, product_form_id: product_form_id, productSelectedVariant: productSelectedVariant %}`;
200
200
  } else {
201
201
  liquid += code;
202
202
  }
@@ -2,11 +2,12 @@ import { ProductsDocument } from '../../graphql/queries/products.generated.js';
2
2
  import { calculateFirstProduct } from './get-collection.js';
3
3
  import { fetchVariants, fetchMedias } from './get-product.js';
4
4
 
5
- const getProducts = async (fetcher, { ids, isSample, isStorefront })=>{
5
+ const getProducts = async (fetcher, { ids, isSample, isStorefront, defaultSelectedProductCount })=>{
6
6
  const products = await loopFetchProducts(fetcher, {
7
7
  ids,
8
8
  isSample,
9
- isStorefront
9
+ isStorefront,
10
+ defaultSelectedProductCount
10
11
  });
11
12
  if (!products) {
12
13
  throw new Error('Product not found');
@@ -59,8 +60,9 @@ const fetchProducts = async (fetcher, variables)=>{
59
60
  variables
60
61
  ]);
61
62
  };
62
- const loopFetchProducts = async (fetcher, { ids, isSample, isStorefront })=>{
63
- const numberOfProducts = (ids?.length == 0 ? 4 : ids?.length) ?? 4;
63
+ const loopFetchProducts = async (fetcher, { ids, isSample, isStorefront, defaultSelectedProductCount })=>{
64
+ const defaultNumberOfProducts = defaultSelectedProductCount || 4;
65
+ const numberOfProducts = (ids?.length == 0 ? defaultNumberOfProducts : ids?.length) ?? defaultNumberOfProducts;
64
66
  const productsPerPage = 8; // number of products per page
65
67
  let variables; // variables of collection query
66
68
  let productAfterFetcher; // product after of collection query
@@ -4,14 +4,15 @@ import { generateProductsQueryKey } from '../../helpers/query.js';
4
4
  import { useIsSampleProduct, useIsStorefrontProduct } from '../shop.js';
5
5
  import { useFetchHandle } from '../useFetchHandle.js';
6
6
 
7
- const useProductsQuery = (ids, options)=>{
7
+ const useProductsQuery = (ids, options, defaultSelectedProductCount)=>{
8
8
  const fetcher = useFetchHandle();
9
9
  const isSample = useIsSampleProduct();
10
10
  const isStorefront = useIsStorefrontProduct();
11
11
  return useSWR(ids ? generateProductsQueryKey({
12
12
  ids,
13
13
  isSample,
14
- isStorefront
14
+ isStorefront,
15
+ defaultSelectedProductCount
15
16
  }) : null, async ([, arg])=>{
16
17
  return getProducts(fetcher, arg);
17
18
  }, options);
@@ -9465,6 +9465,7 @@ type FetchProductsParams = {
9465
9465
  ids: string[];
9466
9466
  isSample?: boolean;
9467
9467
  isStorefront?: boolean;
9468
+ defaultSelectedProductCount?: number;
9468
9469
  };
9469
9470
 
9470
9471
  declare const generateProductQueryKey: (args: FetchProductParams) => ['query/product', FetchProductParams];
@@ -9553,7 +9554,7 @@ declare const useCollectionsQuery: (variable: CollectionsQueryVariables, options
9553
9554
 
9554
9555
  declare const useProductQuery: (productId?: string, options?: SWRConfiguration<ProductSelectFragment>) => swr__internal.SWRResponse<ProductSelectFragment, any, Partial<swr__internal.PublicConfiguration<ProductSelectFragment, any, (arg: ["query/product", FetchProductParams]) => swr__internal.FetcherResponse<ProductSelectFragment>>> | undefined>;
9555
9556
 
9556
- declare const useProductsQuery: (ids?: string[], options?: SWRConfiguration<ProductsQueryResponse>) => swr__internal.SWRResponse<ProductsQueryResponse, any, Partial<swr__internal.PublicConfiguration<ProductsQueryResponse, any, (arg: ["query/products", FetchProductsParams]) => swr__internal.FetcherResponse<ProductsQueryResponse>>> | undefined>;
9557
+ declare const useProductsQuery: (ids?: string[], options?: SWRConfiguration<ProductsQueryResponse>, defaultSelectedProductCount?: number) => swr__internal.SWRResponse<ProductsQueryResponse, any, Partial<swr__internal.PublicConfiguration<ProductsQueryResponse, any, (arg: ["query/products", FetchProductsParams]) => swr__internal.FetcherResponse<ProductsQueryResponse>>> | undefined>;
9557
9558
 
9558
9559
  declare const useCurrentDevice: () => NameDevices;
9559
9560
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gem-sdk/core",
3
- "version": "1.22.0-hotfix.0",
3
+ "version": "1.22.0-hotfix.3",
4
4
  "license": "MIT",
5
5
  "sideEffects": false,
6
6
  "main": "dist/cjs/index.js",