@gem-sdk/core 1.21.12 → 1.22.0-hotfix.2

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.
@@ -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);
@@ -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);
@@ -171,7 +171,7 @@ type HyperlinkInfo = {
171
171
  link?: string;
172
172
  modal?: CommonModalApp;
173
173
  };
174
- type Mapped$4<K, T> = NonNullable<T> extends ObjectDevices<infer U> ? {
174
+ type Mapped$5<K, T> = NonNullable<T> extends ObjectDevices<infer U> ? {
175
175
  id: K;
176
176
  label?: string;
177
177
  info?: string;
@@ -237,7 +237,7 @@ type Mapped$4<K, T> = NonNullable<T> extends ObjectDevices<infer U> ? {
237
237
  default?: T;
238
238
  };
239
239
  type SharedControlType<T> = {
240
- [K in keyof T]-?: Mapped$4<K, T[K]>;
240
+ [K in keyof T]-?: Mapped$5<K, T[K]>;
241
241
  }[keyof T];
242
242
 
243
243
  type AngleControlType<T> = SharedControlType<T> & {
@@ -254,7 +254,7 @@ type Option$3<T> = {
254
254
  text: string | number;
255
255
  desc?: any;
256
256
  };
257
- type Mapped$3<K, T> = NonNullable<T> extends ObjectDevices<infer U> ? {
257
+ type Mapped$4<K, T> = NonNullable<T> extends ObjectDevices<infer U> ? {
258
258
  id: K;
259
259
  label: string;
260
260
  hideOnMode?: {
@@ -292,7 +292,7 @@ type Mapped$3<K, T> = NonNullable<T> extends ObjectDevices<infer U> ? {
292
292
  default?: T;
293
293
  };
294
294
  type CheckboxControlType<T> = {
295
- [K in keyof T]-?: Mapped$3<K, T[K]>;
295
+ [K in keyof T]-?: Mapped$4<K, T[K]>;
296
296
  }[keyof T];
297
297
 
298
298
  type ChildrensControlType = {
@@ -428,7 +428,7 @@ type Option$2<T> = {
428
428
  type?: string;
429
429
  icon?: string;
430
430
  };
431
- type Mapped$2<K, T> = NonNullable<T> extends ObjectDevices<infer U> ? {
431
+ type Mapped$3<K, T> = NonNullable<T> extends ObjectDevices<infer U> ? {
432
432
  id: K;
433
433
  label?: string;
434
434
  info?: string;
@@ -472,7 +472,7 @@ type Mapped$2<K, T> = NonNullable<T> extends ObjectDevices<infer U> ? {
472
472
  default?: T;
473
473
  };
474
474
  type SegmentControlType<T> = {
475
- [K in keyof T]-?: Mapped$2<K, T[K]>;
475
+ [K in keyof T]-?: Mapped$3<K, T[K]>;
476
476
  }[keyof T];
477
477
 
478
478
  type Option$1<T> = {
@@ -480,7 +480,7 @@ type Option$1<T> = {
480
480
  label: string | number;
481
481
  hideOnPage?: string[];
482
482
  };
483
- type Mapped$1<K, T> = NonNullable<T> extends ObjectDevices<infer U> ? {
483
+ type Mapped$2<K, T> = NonNullable<T> extends ObjectDevices<infer U> ? {
484
484
  id: K;
485
485
  label?: string;
486
486
  info?: string;
@@ -522,7 +522,7 @@ type Mapped$1<K, T> = NonNullable<T> extends ObjectDevices<infer U> ? {
522
522
  default?: T;
523
523
  };
524
524
  type SelectControlType<T> = {
525
- [K in keyof T]-?: Mapped$1<K, T[K]>;
525
+ [K in keyof T]-?: Mapped$2<K, T[K]>;
526
526
  }[keyof T];
527
527
 
528
528
  type TextareaControlType<T> = SharedControlType<T> & {
@@ -729,7 +729,7 @@ type Option<T> = {
729
729
  type?: string;
730
730
  icon?: string;
731
731
  };
732
- type Mapped<K, T> = NonNullable<T> extends ObjectDevices<infer U> ? {
732
+ type Mapped$1<K, T> = NonNullable<T> extends ObjectDevices<infer U> ? {
733
733
  id: K;
734
734
  label: string;
735
735
  info?: string;
@@ -775,7 +775,7 @@ type Mapped<K, T> = NonNullable<T> extends ObjectDevices<infer U> ? {
775
775
  default?: T;
776
776
  };
777
777
  type LayoutSegmentControlType<T> = {
778
- [K in keyof T]-?: Mapped<K, T[K]>;
778
+ [K in keyof T]-?: Mapped$1<K, T[K]>;
779
779
  }[keyof T];
780
780
 
781
781
  type InputSpacing<T> = SharedControlType<T> & {
@@ -858,7 +858,36 @@ type SyncProductPropertiesControlType<T> = SharedControlType<T> & {
858
858
  type: 'sync-product-properties';
859
859
  };
860
860
 
861
- type ControlProp<T> = AngleControlType<T> | CheckboxControlType<T> | ColorPickerControlType<T> | GroupControlType<T> | IconControlType<T> | InputFixContentControlType<T> | InputNumberControlType<T> | InputUnitControlType<T> | InputUnitSpacingControlType<T> | InputUnitWidthControlType<T> | InputControlType<T> | MarginControlType<T> | PaddingControlType<T> | PositionControlType<T> | RadioGroupControlType | RangeControlType<T> | SegmentControlType<T> | SelectControlType<T> | TextareaControlType<T> | ToggleControlType<T> | ImageControlType<T> | ChildrensControlType | GridControlType<T> | FlexControlType<T> | TextEditorControlType<T> | ProductControlType<T> | TypographyControlType<T> | TypographyV2ControlType<T> | MenuControlType<T> | BehaviorStateControlType<T> | PickLinkControlType<T> | BoxShadowControlType<T> | TextShadowControlType<T> | BorderControlType<T> | BorderRadiusControlType<T> | RadiusPresetControlType<T> | SizeControlType<T> | ChildItemType<T> | PickMultiProductControlType<T> | CollectionControlType<T> | BackgroundControlType<T> | VisibilityControlType<T> | SelectVariantControlType | CountdownEvergreenType | Timezone<T> | CustomContentControlType<T> | DateTimePickerControlType | CountdownDailyType | KlaviyoCodes | YotpoLoyaltyCodes | InputWidthControlType<T> | LayoutSegmentControlType<T> | InputSpacing<T> | UniqueIdControlType<T> | PositionSquareControlType<T> | CustomCodeEditor | LayoutControlType<T> | SwatchesLinkControlType<T> | ProductListControlType<T> | CollectionBannerControlType<T> | Ratio<T> | StickyDisplayControlType<T> | SyncProductPropertiesControlType<T>;
861
+ type Steps<T> = {
862
+ label?: string | number;
863
+ type?: string;
864
+ icon?: string;
865
+ value: T;
866
+ actions?: Actions[];
867
+ };
868
+ type Actions = {
869
+ label?: string | number;
870
+ type?: 'tertiary' | 'primary';
871
+ size?: 'large' | 'medium' | 'small';
872
+ icon?: string;
873
+ iconPosition?: 'left' | 'right';
874
+ buttonType?: 'link' | 'action';
875
+ actionHandle?: string;
876
+ link?: string;
877
+ };
878
+ type Mapped<K, T> = {
879
+ id: K;
880
+ label: string;
881
+ info?: string;
882
+ type: 'steps-guide';
883
+ steps?: Steps<T>[];
884
+ default?: T;
885
+ };
886
+ type StepsGuide<T> = {
887
+ [K in keyof T]-?: Mapped<K, T[K]>;
888
+ }[keyof T];
889
+
890
+ type ControlProp<T> = AngleControlType<T> | CheckboxControlType<T> | ColorPickerControlType<T> | GroupControlType<T> | IconControlType<T> | InputFixContentControlType<T> | InputNumberControlType<T> | InputUnitControlType<T> | InputUnitSpacingControlType<T> | InputUnitWidthControlType<T> | InputControlType<T> | MarginControlType<T> | PaddingControlType<T> | PositionControlType<T> | RadioGroupControlType | RangeControlType<T> | SegmentControlType<T> | SelectControlType<T> | TextareaControlType<T> | ToggleControlType<T> | ImageControlType<T> | ChildrensControlType | GridControlType<T> | FlexControlType<T> | TextEditorControlType<T> | ProductControlType<T> | TypographyControlType<T> | TypographyV2ControlType<T> | MenuControlType<T> | BehaviorStateControlType<T> | PickLinkControlType<T> | BoxShadowControlType<T> | TextShadowControlType<T> | BorderControlType<T> | BorderRadiusControlType<T> | RadiusPresetControlType<T> | SizeControlType<T> | ChildItemType<T> | PickMultiProductControlType<T> | CollectionControlType<T> | BackgroundControlType<T> | VisibilityControlType<T> | SelectVariantControlType | CountdownEvergreenType | Timezone<T> | CustomContentControlType<T> | DateTimePickerControlType | CountdownDailyType | KlaviyoCodes | YotpoLoyaltyCodes | InputWidthControlType<T> | LayoutSegmentControlType<T> | InputSpacing<T> | UniqueIdControlType<T> | PositionSquareControlType<T> | CustomCodeEditor | LayoutControlType<T> | SwatchesLinkControlType<T> | ProductListControlType<T> | CollectionBannerControlType<T> | Ratio<T> | StickyDisplayControlType<T> | SyncProductPropertiesControlType<T> | StepsGuide<T>;
862
891
  type Setting<P extends BaseProps> = {
863
892
  id: 'setting';
864
893
  note?: string;
@@ -948,6 +977,7 @@ type ControlUI = {
948
977
  };
949
978
  hideOnPages?: PageType[];
950
979
  };
980
+ isMoreSetting?: boolean;
951
981
  };
952
982
  type PageType = 'ARTICLE' | 'BLOG' | 'COLLECTION' | 'GP_ARTICLE' | 'GP_BLOG' | 'GP_COLLECTION' | 'GP_INDEX' | 'GP_PRODUCT' | 'GP_STATIC' | 'PRODUCT' | 'STATIC';
953
983
  type ComponentPreset = {
@@ -9435,6 +9465,7 @@ type FetchProductsParams = {
9435
9465
  ids: string[];
9436
9466
  isSample?: boolean;
9437
9467
  isStorefront?: boolean;
9468
+ defaultSelectedProductCount?: number;
9438
9469
  };
9439
9470
 
9440
9471
  declare const generateProductQueryKey: (args: FetchProductParams) => ['query/product', FetchProductParams];
@@ -9523,7 +9554,7 @@ declare const useCollectionsQuery: (variable: CollectionsQueryVariables, options
9523
9554
 
9524
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>;
9525
9556
 
9526
- 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>;
9527
9558
 
9528
9559
  declare const useCurrentDevice: () => NameDevices;
9529
9560
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gem-sdk/core",
3
- "version": "1.21.12",
3
+ "version": "1.22.0-hotfix.2",
4
4
  "license": "MIT",
5
5
  "sideEffects": false,
6
6
  "main": "dist/cjs/index.js",