@gem-sdk/core 1.41.3 → 1.42.0-dev.60

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.
Files changed (78) hide show
  1. package/dist/cjs/components/ComponentToolbarPreview.js +54 -6
  2. package/dist/cjs/components/ComponentWrapperPreview.js +44 -1
  3. package/dist/cjs/components/Render.liquid.js +2 -0
  4. package/dist/cjs/components/RenderCustomCode.js +2 -0
  5. package/dist/cjs/components/ai-generator/AIContentGenerator.js +205 -0
  6. package/dist/cjs/components/ai-generator/AIGenContentLoading.js +85 -0
  7. package/dist/cjs/components/ai-generator/components/PickProduct.js +218 -0
  8. package/dist/cjs/components/ai-generator/components/ToneAndVoice.js +77 -0
  9. package/dist/cjs/components/ai-generator/hooks/useCheckingProductInside.js +47 -0
  10. package/dist/cjs/components/ai-generator/hooks/useFlipPopup.js +110 -0
  11. package/dist/cjs/components/ai-generator/hooks/useGettingGenerateRequest.js +37 -0
  12. package/dist/cjs/components/ai-generator/hooks/useListenEventGenerate.js +63 -0
  13. package/dist/cjs/components/ai-generator/icons/AIIcon.js +67 -0
  14. package/dist/cjs/components/ai-generator/icons/CloseIcon.js +19 -0
  15. package/dist/cjs/components/ai-generator/icons/DropdownIcon.js +37 -0
  16. package/dist/cjs/components/ai-generator/icons/SearchIcon.js +21 -0
  17. package/dist/cjs/components/ai-generator/icons/ShowMoreIcon.js +21 -0
  18. package/dist/cjs/components/constant.js +19 -2
  19. package/dist/cjs/components/resize/Spacing.js +2 -0
  20. package/dist/cjs/components/theme-section/CreateThemeSection.js +2 -0
  21. package/dist/cjs/contexts/ArticleContext.js +39 -0
  22. package/dist/cjs/contexts/ArticleListContext.js +32 -0
  23. package/dist/cjs/contexts/BuilderPreviewContext.js +11 -6
  24. package/dist/cjs/contexts/SectionContext.js +1 -0
  25. package/dist/cjs/graphql/fragments/product-little.generated.js +9 -0
  26. package/dist/cjs/graphql/fragments/product.generated.js +9 -0
  27. package/dist/cjs/graphql/queries/products.generated.js +9 -0
  28. package/dist/cjs/helpers/align.js +19 -0
  29. package/dist/cjs/helpers/carousel.js +7 -10
  30. package/dist/cjs/helpers/colors.js +1 -1
  31. package/dist/cjs/helpers/queries/get-products.js +47 -0
  32. package/dist/cjs/helpers/typography.js +4 -4
  33. package/dist/cjs/hooks/articles/useArticlesQuery.js +152 -0
  34. package/dist/cjs/hooks/shop/use-products-query.js +39 -0
  35. package/dist/cjs/hooks/useAnimations.js +2 -0
  36. package/dist/cjs/hooks/useInitialSwatchesOptions.js +2 -0
  37. package/dist/cjs/hooks/useProduct.js +2 -0
  38. package/dist/cjs/index.js +12 -0
  39. package/dist/esm/components/ComponentToolbarPreview.js +54 -6
  40. package/dist/esm/components/ComponentWrapperPreview.js +44 -1
  41. package/dist/esm/components/Render.liquid.js +2 -0
  42. package/dist/esm/components/RenderCustomCode.js +2 -0
  43. package/dist/esm/components/ai-generator/AIContentGenerator.js +203 -0
  44. package/dist/esm/components/ai-generator/AIGenContentLoading.js +83 -0
  45. package/dist/esm/components/ai-generator/components/PickProduct.js +216 -0
  46. package/dist/esm/components/ai-generator/components/ToneAndVoice.js +75 -0
  47. package/dist/esm/components/ai-generator/hooks/useCheckingProductInside.js +45 -0
  48. package/dist/esm/components/ai-generator/hooks/useFlipPopup.js +108 -0
  49. package/dist/esm/components/ai-generator/hooks/useGettingGenerateRequest.js +35 -0
  50. package/dist/esm/components/ai-generator/hooks/useListenEventGenerate.js +61 -0
  51. package/dist/esm/components/ai-generator/icons/AIIcon.js +65 -0
  52. package/dist/esm/components/ai-generator/icons/CloseIcon.js +17 -0
  53. package/dist/esm/components/ai-generator/icons/DropdownIcon.js +34 -0
  54. package/dist/esm/components/ai-generator/icons/SearchIcon.js +19 -0
  55. package/dist/esm/components/ai-generator/icons/ShowMoreIcon.js +19 -0
  56. package/dist/esm/components/constant.js +19 -3
  57. package/dist/esm/components/resize/Spacing.js +2 -0
  58. package/dist/esm/components/theme-section/CreateThemeSection.js +2 -0
  59. package/dist/esm/contexts/ArticleContext.js +36 -0
  60. package/dist/esm/contexts/ArticleListContext.js +28 -0
  61. package/dist/esm/contexts/BuilderPreviewContext.js +11 -6
  62. package/dist/esm/contexts/SectionContext.js +1 -0
  63. package/dist/esm/graphql/fragments/product-little.generated.js +9 -0
  64. package/dist/esm/graphql/fragments/product.generated.js +9 -0
  65. package/dist/esm/graphql/queries/products.generated.js +9 -0
  66. package/dist/esm/helpers/align.js +17 -0
  67. package/dist/esm/helpers/carousel.js +7 -10
  68. package/dist/esm/helpers/colors.js +1 -1
  69. package/dist/esm/helpers/queries/get-products.js +46 -1
  70. package/dist/esm/helpers/typography.js +4 -4
  71. package/dist/esm/hooks/articles/useArticlesQuery.js +149 -0
  72. package/dist/esm/hooks/shop/use-products-query.js +39 -2
  73. package/dist/esm/hooks/useAnimations.js +2 -0
  74. package/dist/esm/hooks/useInitialSwatchesOptions.js +2 -0
  75. package/dist/esm/hooks/useProduct.js +2 -0
  76. package/dist/esm/index.js +5 -1
  77. package/dist/types/index.d.ts +176 -21
  78. package/package.json +5 -3
@@ -0,0 +1,19 @@
1
+ import { jsx } from 'react/jsx-runtime';
2
+
3
+ const SearchIcon = ()=>{
4
+ return /*#__PURE__*/ jsx("svg", {
5
+ width: "20",
6
+ height: "20",
7
+ viewBox: "0 0 20 20",
8
+ fill: "none",
9
+ xmlns: "http://www.w3.org/2000/svg",
10
+ children: /*#__PURE__*/ jsx("path", {
11
+ fillRule: "evenodd",
12
+ clipRule: "evenodd",
13
+ d: "M8.75 2.5C5.29822 2.5 2.5 5.29822 2.5 8.75C2.5 12.2018 5.29822 15 8.75 15C10.2508 15 11.628 14.471 12.7055 13.5893L16.4775 17.3614C16.7216 17.6054 17.1173 17.6054 17.3614 17.3614C17.6054 17.1173 17.6054 16.7216 17.3614 16.4775L13.5893 12.7055C14.471 11.628 15 10.2508 15 8.75C15 5.29822 12.2018 2.5 8.75 2.5ZM3.75 8.75C3.75 5.98858 5.98858 3.75 8.75 3.75C11.5114 3.75 13.75 5.98858 13.75 8.75C13.75 11.5114 11.5114 13.75 8.75 13.75C5.98858 13.75 3.75 11.5114 3.75 8.75Z",
14
+ fill: "#AAAAAA"
15
+ })
16
+ });
17
+ };
18
+
19
+ export { SearchIcon };
@@ -0,0 +1,19 @@
1
+ import { jsx } from 'react/jsx-runtime';
2
+
3
+ const ShowMoreIcon = ()=>{
4
+ return /*#__PURE__*/ jsx("svg", {
5
+ width: "17",
6
+ height: "16",
7
+ viewBox: "0 0 17 16",
8
+ fill: "none",
9
+ xmlns: "http://www.w3.org/2000/svg",
10
+ children: /*#__PURE__*/ jsx("path", {
11
+ fillRule: "evenodd",
12
+ clipRule: "evenodd",
13
+ d: "M4.60651 6.09763C4.74852 5.96746 4.97876 5.96746 5.12077 6.09763L8.5 9.19526L11.8792 6.09763C12.0212 5.96746 12.2515 5.96746 12.3935 6.09763C12.5355 6.22781 12.5355 6.43886 12.3935 6.56904L8.75713 9.90237C8.61512 10.0325 8.38488 10.0325 8.24287 9.90237L4.60651 6.56904C4.4645 6.43886 4.4645 6.22781 4.60651 6.09763Z",
14
+ fill: "#F9F9F9"
15
+ })
16
+ });
17
+ };
18
+
19
+ export { ShowMoreIcon };
@@ -34,7 +34,10 @@ const disableWrap = [
34
34
  'ProductImagesV2',
35
35
  'PostPurchaseProductImages',
36
36
  'Sticky',
37
- 'Heading'
37
+ 'Heading',
38
+ 'ProductBadge',
39
+ 'Marquee',
40
+ 'MarqueeItem'
38
41
  ];
39
42
  const customRenderChildren = [
40
43
  'Accordion',
@@ -45,7 +48,8 @@ const customRenderChildren = [
45
48
  ];
46
49
  const excludeApplyStyle = [
47
50
  'IconListV2',
48
- 'IconList'
51
+ 'IconList',
52
+ 'ProductBadge'
49
53
  ];
50
54
  const postPurchaseRequiredElements = [
51
55
  'PostPurchaseProductOffer',
@@ -64,5 +68,17 @@ const postPurchaseWrapElements = [
64
68
  'PostPurchaseCalloutBox',
65
69
  'PostPurchaseProductOffer'
66
70
  ];
71
+ const ableGenerateContentElements = [
72
+ 'Section',
73
+ 'Row',
74
+ 'Text',
75
+ 'Heading',
76
+ 'Accordion',
77
+ 'Product',
78
+ 'HeroBanner',
79
+ 'IconList',
80
+ 'IconListV2',
81
+ 'AdvancedList'
82
+ ];
67
83
 
68
- export { customRenderChildren, disableWrap, excludeApplyStyle, postPurchaseRequiredElements, postPurchaseWrapElements };
84
+ export { ableGenerateContentElements, customRenderChildren, disableWrap, excludeApplyStyle, postPurchaseRequiredElements, postPurchaseWrapElements };
@@ -6,10 +6,12 @@ import 'swr';
6
6
  import '@gem-sdk/adapter-shopify';
7
7
  import 'swr/mutation';
8
8
  import { usePageType } from '../../hooks/shop.js';
9
+ import 'swr/infinite';
9
10
  import 'vanilla-lazyload';
10
11
  import '../../hooks/useCartUI.js';
11
12
  import 'react-transition-group';
12
13
  import '@gem-sdk/core';
14
+ import 'classnames';
13
15
  import '../../helpers/convert.js';
14
16
 
15
17
  function Spacing(props) {
@@ -6,8 +6,10 @@ import { useShopStore } from '../../contexts/ShopContext.js';
6
6
  import '@gem-sdk/adapter-shopify';
7
7
  import 'swr';
8
8
  import 'swr/mutation';
9
+ import 'swr/infinite';
9
10
  import 'vanilla-lazyload';
10
11
  import '../../hooks/useCartUI.js';
12
+ import 'classnames';
11
13
  import '../../helpers/convert.js';
12
14
 
13
15
  const SHOW_TOOLTIP_TIMEOUT = 600;
@@ -0,0 +1,36 @@
1
+ import { jsx, Fragment } from 'react/jsx-runtime';
2
+ import { useStore, createStore } from 'zustand';
3
+ import { useId, useMemo, useContext, createContext } from 'react';
4
+
5
+ // const { Provider, useStore } = createContext<StoreApi<ProductContextProps>>();
6
+ const ArticleContext = /*#__PURE__*/ createContext(null);
7
+ const createArticleStoreProvider = (data)=>createStore(()=>({
8
+ ...data
9
+ }));
10
+ const ArticleProvider = ({ children, article })=>{
11
+ const uniqueId = useId();
12
+ const store = useMemo(()=>{
13
+ return createArticleStoreProvider({
14
+ article,
15
+ uniqueId
16
+ });
17
+ }, [
18
+ article,
19
+ uniqueId
20
+ ]);
21
+ return /*#__PURE__*/ jsx(ArticleContext.Provider, {
22
+ value: store,
23
+ children: /*#__PURE__*/ jsx(Fragment, {
24
+ children: children
25
+ })
26
+ });
27
+ };
28
+ const useArticleStore = (selector, equalityFn)=>{
29
+ const store = useContext(ArticleContext);
30
+ if (!store) {
31
+ throw new Error('Element of article must be used inside a Article');
32
+ }
33
+ return useStore(store, selector, equalityFn);
34
+ };
35
+
36
+ export { ArticleProvider, useArticleStore };
@@ -0,0 +1,28 @@
1
+ import { jsx } from 'react/jsx-runtime';
2
+ import { useContext, createContext } from 'react';
3
+ import { useStore, createStore } from 'zustand';
4
+
5
+ const ArticleListContext = /*#__PURE__*/ createContext(null);
6
+ const createArticleListProvider = (data)=>createStore(()=>({
7
+ ...data
8
+ }));
9
+ const ArticleListProvider = ({ articles, blogs, children, styles, settings })=>{
10
+ return /*#__PURE__*/ jsx(ArticleListContext.Provider, {
11
+ value: createArticleListProvider({
12
+ articles,
13
+ styles,
14
+ settings,
15
+ blogs
16
+ }),
17
+ children: children
18
+ });
19
+ };
20
+ const useArticleListStore = (selector, equalityFn)=>{
21
+ const store = useContext(ArticleListContext);
22
+ if (!store) {
23
+ throw new Error('useArticleListStore must be used within a useArticleListStore');
24
+ }
25
+ return useStore(store, selector, equalityFn);
26
+ };
27
+
28
+ export { ArticleListContext, ArticleListProvider, useArticleListStore };
@@ -251,7 +251,11 @@ const createBuilderPreviewProvider = (args, isThemeSectionEditor)=>createStore((
251
251
  }
252
252
  },
253
253
  getItem: (id)=>{
254
- return get().state[id];
254
+ const item = get().state[id];
255
+ return {
256
+ ...item,
257
+ rawChildrens: item?.childrens?.map((v)=>get().state[v])
258
+ };
255
259
  },
256
260
  removeItem: (id)=>{
257
261
  if (id === 'ROOT') {
@@ -426,15 +430,16 @@ const createBuilderPreviewProvider = (args, isThemeSectionEditor)=>createStore((
426
430
  updateItemAttribute: (id, value, attr)=>{
427
431
  if (!attr || ![
428
432
  'label',
429
- 'customLabel'
433
+ 'customLabel',
434
+ 'isShopifyVisibility'
430
435
  ].includes(attr)) return;
431
436
  const state = get().state;
432
437
  const item = state[id];
433
- // Ignore section
434
- if (item?.type === 'section') return;
435
438
  if (item) {
436
- const dateModified = Date.now();
437
- item.dateModified = dateModified;
439
+ if (item.type !== 'section') {
440
+ const dateModified = Date.now();
441
+ item.dateModified = dateModified;
442
+ }
438
443
  const updatedItem = {
439
444
  ...item,
440
445
  [attr]: value
@@ -8,6 +8,7 @@ const SectionContext = /*#__PURE__*/ createContext(null);
8
8
  const createSectionProvider = (data)=>createStore((set, get)=>({
9
9
  data: data ?? {},
10
10
  getSection: (id)=>{
11
+ console.log('get().data', get().data);
11
12
  const section = get().data[id];
12
13
  return section ?? undefined;
13
14
  },
@@ -17,6 +17,15 @@
17
17
  featuredImage {
18
18
  ...MediaSelect
19
19
  }
20
+ collections {
21
+ edges {
22
+ node {
23
+ id
24
+ title
25
+ }
26
+ }
27
+ }
28
+ tags
20
29
  }
21
30
  `;
22
31
 
@@ -1,6 +1,15 @@
1
1
  /* eslint-disable */ const ProductSelect = `
2
2
  fragment ProductSelect on Product {
3
3
  ...ProductLittleSelect
4
+ collections {
5
+ edges {
6
+ node {
7
+ id
8
+ title
9
+ }
10
+ }
11
+ }
12
+ tags
4
13
  medias(first: $firstMedia, after: $afterMedia, orderBy: $orderByMedia) {
5
14
  edges {
6
15
  cursor
@@ -11,6 +11,15 @@ const ProductsEdgeDetail = `
11
11
  cursor
12
12
  node {
13
13
  ...ProductSelect
14
+ tags
15
+ collections {
16
+ edges {
17
+ node {
18
+ id
19
+ title
20
+ }
21
+ }
22
+ }
14
23
  }
15
24
  }
16
25
  `;
@@ -0,0 +1,17 @@
1
+ const convertTextAlignToJustify = (align)=>{
2
+ const devices = [
3
+ 'desktop',
4
+ 'tablet',
5
+ 'mobile'
6
+ ];
7
+ const result = {};
8
+ devices.forEach((device)=>{
9
+ const deviceType = device === 'desktop' ? '' : `${device}:`;
10
+ result[`${deviceType}gp-justify-start`] = align?.[device] === 'left';
11
+ result[`${deviceType}gp-justify-center`] = align?.[device] === 'center';
12
+ result[`${deviceType}gp-justify-end`] = align?.[device] === 'right';
13
+ });
14
+ return result;
15
+ };
16
+
17
+ export { convertTextAlignToJustify };
@@ -1,23 +1,20 @@
1
1
  import { getResponsiveValueByScreen } from './get-resonsive-value.js';
2
2
 
3
- const getCarouselContainerHeight = (dotStyle, dotSize, dotGapToCarousel)=>{
4
- const getVal = (dotStyle, dotSize, dotGapToCarousel)=>{
5
- if (dotStyle === 'outside') {
6
- return `calc(100% - ${dotSize ?? '0'}px - ${!dotGapToCarousel || dotGapToCarousel === 'Auto' ? '0' : dotGapToCarousel}px)`;
7
- }
8
- return '100%';
3
+ const getCarouselContainerHeight = (dotStyle)=>{
4
+ const getVal = (dotStyle)=>{
5
+ return dotStyle === 'outside' ? 'auto' : '100%';
9
6
  };
10
7
  return {
11
- desktop: getVal(getResponsiveValueByScreen(dotStyle, 'desktop'), getResponsiveValueByScreen(dotSize, 'desktop'), getResponsiveValueByScreen(dotGapToCarousel, 'desktop')),
12
- tablet: getVal(getResponsiveValueByScreen(dotStyle, 'tablet'), getResponsiveValueByScreen(dotSize, 'tablet'), getResponsiveValueByScreen(dotGapToCarousel, 'tablet')),
13
- mobile: getVal(getResponsiveValueByScreen(dotStyle, 'mobile'), getResponsiveValueByScreen(dotSize, 'mobile'), getResponsiveValueByScreen(dotGapToCarousel, 'mobile'))
8
+ desktop: getVal(getResponsiveValueByScreen(dotStyle, 'desktop')),
9
+ tablet: getVal(getResponsiveValueByScreen(dotStyle, 'tablet')),
10
+ mobile: getVal(getResponsiveValueByScreen(dotStyle, 'mobile'))
14
11
  };
15
12
  };
16
13
  const makeContainerWidthOrHeight = (setting)=>{
17
14
  const getStyleName = (vertical)=>{
18
15
  return vertical ? 'w' : 'h';
19
16
  };
20
- const result = getCarouselContainerHeight(setting.dotStyle, setting.dotSize, setting.dotGapToCarousel);
17
+ const result = getCarouselContainerHeight(setting.dotStyle);
21
18
  return {
22
19
  [`--${getStyleName(getResponsiveValueByScreen(setting?.vertical, 'desktop'))}`]: result.desktop,
23
20
  [`--${getStyleName(getResponsiveValueByScreen(setting?.vertical, 'tablet'))}-tablet`]: result.tablet,
@@ -154,7 +154,7 @@ const getSingleColorVariable = (color)=>{
154
154
  };
155
155
  function isColor(color) {
156
156
  if (!color || typeof color !== 'string') return false;
157
- return color?.startsWith('#') || color?.startsWith('rgb') || color?.startsWith('hsl') || color?.startsWith('transparent');
157
+ return color?.startsWith('#') || color?.startsWith('rgb') || color?.startsWith('hsl') || color?.startsWith('transparent') || color?.startsWith('linear-gradient');
158
158
  }
159
159
  const getGlobalColorStyle = (data)=>{
160
160
  if (!data) return {};
@@ -55,6 +55,51 @@ const getProducts = async (fetcher, { ids, isSample, isStorefront, defaultSelect
55
55
  }
56
56
  };
57
57
  };
58
+ const getProductQueryAll = async (fetcher, arg)=>{
59
+ const limit = arg?.limit || 4;
60
+ delete arg.limit;
61
+ const variables = {
62
+ first: limit,
63
+ firstMedia: 1,
64
+ firstVariant: 1,
65
+ orderBy: {
66
+ field: 'PLATFORM_CREATED_AT',
67
+ direction: 'DESC'
68
+ },
69
+ orderByMedia: {
70
+ field: 'POSITION',
71
+ direction: 'ASC'
72
+ },
73
+ where: {
74
+ status: 'ACTIVE',
75
+ ...arg
76
+ }
77
+ };
78
+ const pageData = await fetchProducts(fetcher, variables);
79
+ return pageData;
80
+ };
81
+ const getListProductByVariables = async (fetcher, arg)=>{
82
+ const variables = {
83
+ first: arg.first || 8,
84
+ firstMedia: 1,
85
+ firstVariant: 1,
86
+ orderBy: {
87
+ field: 'PLATFORM_CREATED_AT',
88
+ direction: 'DESC'
89
+ },
90
+ orderByMedia: {
91
+ field: 'POSITION',
92
+ direction: 'ASC'
93
+ },
94
+ where: {
95
+ status: 'ACTIVE',
96
+ ...arg.where
97
+ },
98
+ after: arg.after
99
+ };
100
+ const pageData = await fetchProducts(fetcher, variables);
101
+ return pageData;
102
+ };
58
103
  const fetchProducts = async (fetcher, variables)=>{
59
104
  return fetcher([
60
105
  ProductsDocument,
@@ -162,4 +207,4 @@ const mergeMediasToProducts = async ({ fetcher, products, isSample, isStorefront
162
207
  // );
163
208
  // };
164
209
 
165
- export { getProducts };
210
+ export { getListProductByVariables, getProductQueryAll, getProducts };
@@ -27,7 +27,7 @@ const composeTypographyV2Css = (typography, isImportant)=>{
27
27
  ${fontSize?.desktop ? `font-size: ${fontSize?.desktop} ${composeImportant};` : ''}
28
28
  ${bold ? `font-weight: bold ${composeImportant};` : fontWeight ? `font-weight: ${fontWeight} ${composeImportant};` : ''}
29
29
  ${letterSpacing ? `letter-spacing: ${letterSpacing} ${composeImportant};` : ''}
30
- ${lineHeight ? `line-height: ${lineHeight} ${composeImportant};` : ''}
30
+ ${lineHeight?.desktop ? `line-height: ${lineHeight?.desktop} ${composeImportant};` : ''}
31
31
  ${italic ? `font-style: italic ${composeImportant};` : ''}
32
32
  ${underline ? `text-decoration-line: underline ${composeImportant};` : ''}
33
33
  ${transform ? `text-transform: ${transform} ${composeImportant};` : ''}
@@ -61,10 +61,10 @@ const composeTypographyV2 = (value, attrs)=>{
61
61
  fs: !attrs?.italic ? value?.fontStyle : undefined,
62
62
  ff: value?.fontFamily ? `var(--g-font-${value.fontFamily.replace(/ /g, '-')}, '${value.fontFamily}'), ${value.fallbackFontFamily}` : undefined,
63
63
  weight: !attrs?.bold ? value?.fontWeight : undefined,
64
- ls: value?.letterSpacing,
65
- lh: value?.lineHeight
64
+ ls: value?.letterSpacing
66
65
  }),
67
- ...makeStyleResponsive('size', value?.fontSize)
66
+ ...makeStyleResponsive('size', value?.fontSize),
67
+ ...makeStyleResponsive('lh', value?.lineHeight)
68
68
  });
69
69
  };
70
70
  const composeTypographyAttr = (attrs)=>{
@@ -0,0 +1,149 @@
1
+ const mock = [
2
+ {
3
+ baseID: 'gid://shopify/OnlineStoreBlog/592066740457',
4
+ id: 592066740457,
5
+ title: 'Blog post might appear in a search engine listing',
6
+ created_at: '2024-05-09T04:06:12-04:00',
7
+ body_html: '<span data-mce-fragment="1">Add a title and description to see how this Blog post might appear in a search engine listing</span><span data-mce-fragment="1">Add a title and description to see how this Blog post might appear in a search engine listing</span><span data-mce-fragment="1">Add a title and description to see how this Blog post might appear in a search engine listing</span><span data-mce-fragment="1">Add a title and description to see how this Blog post might appear in a search engine listing</span><span data-mce-fragment="1">Add a title and description to see how this Blog post might appear in a search engine listing</span><span data-mce-fragment="1">Add a title and description to see how this Blog post might appear in a search engine listing</span><span data-mce-fragment="1">Add a title and description to see how this Blog post might appear in a search engine listing</span><span data-mce-fragment="1">Add a title and description to see how this Blog post might appear in a search engine listing</span><span data-mce-fragment="1">Add a title and description to see how this Blog post might appear in a search engine listing</span><span data-mce-fragment="1">Add a title and description to see how this Blog post might appear in a search engine listing</span><span data-mce-fragment="1">Add a title and description to see how this Blog post might appear in a search engine listing</span><span data-mce-fragment="1">Add a title and description to see how this Blog post might appear in a search engine listing</span><span data-mce-fragment="1">Add a title and description to see how this Blog post might appear in a search engine listing</span><span data-mce-fragment="1">Add a title and description to see how this Blog post might appear in a search engine listing</span>',
8
+ blog_id: 91970044137,
9
+ author: 'Dev Team',
10
+ user_id: 90371653865,
11
+ published_at: '2024-05-09T04:06:12-04:00',
12
+ updated_at: '2024-05-09T04:06:13-04:00',
13
+ summary_html: '',
14
+ template_suffix: '',
15
+ handle: 'blog-post-might-appear-in-a-search-engine-listing',
16
+ tags: 'vintage',
17
+ admin_graphql_api_id: 'gid://shopify/OnlineStoreArticle/592066740457',
18
+ image: {
19
+ created_at: '2024-05-09T04:06:12-04:00',
20
+ alt: '',
21
+ width: 1073,
22
+ height: 719,
23
+ src: 'https://cdn.shopify.com/s/files/1/0692/6562/1225/articles/Screenshot_2.jpg?v=1715241973'
24
+ }
25
+ },
26
+ {
27
+ baseID: 'gid://shopify/OnlineStoreBlog/592066707689',
28
+ id: 592066707689,
29
+ title: 'ar on your home page or blog.',
30
+ created_at: '2024-05-09T04:05:26-04:00',
31
+ body_html: '<span data-mce-fragment="1">Add a title and description to see how this Blog post might appear in a search engine listing</span><span data-mce-fragment="1">Add a title and description to see how this Blog post might appear in a search engine listing</span><span data-mce-fragment="1">Add a title and description to see how this Blog post might appear in a search engine listing</span><span data-mce-fragment="1">Add a title and description to see how this Blog post might appear in a search engine listing</span><span data-mce-fragment="1">Add a title and description to see how this Blog post might appear in a search engine listing</span><span data-mce-fragment="1">Add a title and description to see how this Blog post might appear in a search engine listing</span><span data-mce-fragment="1">Add a title and description to see how this Blog post might appear in a search engine listing</span><span data-mce-fragment="1">Add a title and description to see how this Blog post might appear in a search engine listing</span><span data-mce-fragment="1">Add a title and description to see how this Blog post might appear in a search engine listing</span><span data-mce-fragment="1">Add a title and description to see how this Blog post might appear in a search engine listing</span>',
32
+ blog_id: 91970044137,
33
+ author: 'Dev Team',
34
+ user_id: 90371653865,
35
+ published_at: '2024-05-09T04:05:25-04:00',
36
+ updated_at: '2024-05-09T05:35:29-04:00',
37
+ summary_html: '',
38
+ template_suffix: '',
39
+ handle: 'ar-on-your-home-page-or-blog',
40
+ tags: 'cotton, vintage',
41
+ admin_graphql_api_id: 'gid://shopify/OnlineStoreArticle/592066707689',
42
+ image: {
43
+ created_at: '2024-05-09T04:05:26-04:00',
44
+ alt: '',
45
+ width: 1080,
46
+ height: 719,
47
+ src: 'https://cdn.shopify.com/s/files/1/0692/6562/1225/articles/Screenshot_1.jpg?v=1715241926'
48
+ }
49
+ },
50
+ {
51
+ baseID: 'gid://shopify/OnlineStoreBlog/592066674921',
52
+ id: 592066674921,
53
+ title: 'Add a summary of the post.',
54
+ created_at: '2024-05-09T04:04:44-04:00',
55
+ body_html: '<span data-mce-fragment="1">Add a title and description to see how this Blog post might appear in a search engine listing</span><span data-mce-fragment="1">Add a title and description to see how this Blog post might appear in a search engine listing</span><span data-mce-fragment="1">Add a title and description to see how this Blog post might appear in a search engine listing</span><span data-mce-fragment="1">Add a title and description to see how this Blog post might appear in a search engine listing</span><span data-mce-fragment="1">Add a title and description to see how this Blog post might appear in a search engine listing</span><span data-mce-fragment="1">Add a title and description to see how this Blog post might appear in a search engine listing</span>',
56
+ blog_id: 91970044137,
57
+ author: 'Dev Team',
58
+ user_id: 90371653865,
59
+ published_at: '2024-05-09T04:04:44-04:00',
60
+ updated_at: '2024-05-09T04:04:45-04:00',
61
+ summary_html: '',
62
+ template_suffix: '',
63
+ handle: 'add-a-summary-of-the-post',
64
+ tags: '',
65
+ admin_graphql_api_id: 'gid://shopify/OnlineStoreArticle/592066674921',
66
+ image: {
67
+ created_at: '2024-05-09T04:04:44-04:00',
68
+ alt: '',
69
+ width: 1086,
70
+ height: 718,
71
+ src: 'https://cdn.shopify.com/s/files/1/0692/6562/1225/articles/Screenshot_7.jpg?v=1715241885'
72
+ }
73
+ },
74
+ {
75
+ baseID: 'gid://shopify/OnlineStoreBlog/592058777833',
76
+ id: 592058777833,
77
+ title: 'Article Page - May 7, 10:47:14',
78
+ created_at: '2024-05-06T23:47:59-04:00',
79
+ body_html: '<h2>\n<span>Add a summary of the post to appear on your home page or blog.</span><span data-mce-fragment="1">Add a summary of the post to appear on your home page or blog.</span><span data-mce-fragment="1">Add a summary of the post to appear on your home page or blog.</span><span data-mce-fragment="1">Add a summary of the post to appear on your home page or blog.</span><span data-mce-fragment="1">Add a summary of the post to appear on your home page or blog.</span><span data-mce-fragment="1">Add a summary of the post to appear on your home page or blog.</span><span data-mce-fragment="1">Add a summary of the post to appear on your home page or blog.</span><span data-mce-fragment="1">Add a summary of the post to appear on your home page or blog.</span>\n</h2>',
80
+ blog_id: 91970044137,
81
+ author: 'GemPages',
82
+ user_id: null,
83
+ published_at: '2024-05-06T23:47:59-04:00',
84
+ updated_at: '2024-05-09T04:06:48-04:00',
85
+ summary_html: '',
86
+ template_suffix: 'gp-template-512584275137135821',
87
+ handle: 'article-page-may-7-10-47-14',
88
+ tags: 'vintage',
89
+ admin_graphql_api_id: 'gid://shopify/OnlineStoreArticle/592058777833',
90
+ image: {
91
+ created_at: '2024-05-09T04:06:41-04:00',
92
+ alt: '',
93
+ width: 578,
94
+ height: 585,
95
+ src: 'https://cdn.shopify.com/s/files/1/0692/6562/1225/articles/Screenshot_3.png?v=1715242002'
96
+ }
97
+ },
98
+ {
99
+ baseID: 'gid://shopify/OnlineStoreBlog/592058679529',
100
+ id: 592058679529,
101
+ title: 'Blog about your latest products or deals',
102
+ created_at: '2024-05-06T22:36:55-04:00',
103
+ body_html: '<span data-mce-fragment="1">Add a summary of the post to appear on your home page or blog.</span><span data-mce-fragment="1">Add a summary of the post to appear on your home page or blog.</span><span data-mce-fragment="1">Add a summary of the post to appear on your home page or blog.</span><span data-mce-fragment="1">Add a summary of the post to appear on your home page or blog.</span><span data-mce-fragment="1">Add a summary of the post to appear on your home page or blog.</span><span data-mce-fragment="1">Add a summary of the post to appear on your home page or blog.</span><span data-mce-fragment="1">Add a summary of the post to appear on your home page or blog.</span><span data-mce-fragment="1">Add a summary of the post to appear on your home page or blog.</span><span data-mce-fragment="1">Add a summary of the post to appear on your home page or blog.</span><span data-mce-fragment="1">Add a summary of the post to appear on your home page or blog.</span><span data-mce-fragment="1">Add a summary of the post to appear on your home page or blog.</span><span data-mce-fragment="1">Add a summary of the post to appear on your home page or blog.</span>',
104
+ blog_id: 91970044137,
105
+ author: 'Dev Team',
106
+ user_id: 90371653865,
107
+ published_at: '2024-05-06T22:36:54-04:00',
108
+ updated_at: '2024-05-09T03:46:39-04:00',
109
+ summary_html: '<span data-mce-fragment="1">Add a summary of the post to appear on your home page or blog.</span>',
110
+ template_suffix: 'gp-template-512584275137135821',
111
+ handle: 'blog-about-your-latest-products-or-deals',
112
+ tags: '',
113
+ admin_graphql_api_id: 'gid://shopify/OnlineStoreArticle/592058679529',
114
+ image: {
115
+ created_at: '2024-05-06T22:36:55-04:00',
116
+ alt: '',
117
+ width: 497,
118
+ height: 618,
119
+ src: 'https://cdn.shopify.com/s/files/1/0692/6562/1225/articles/Screenshot_3.jpg?v=1715049415'
120
+ }
121
+ }
122
+ ];
123
+ const useArticlesQuery = ()=>{
124
+ return mock;
125
+ };
126
+ const useBlogsQuery = ()=>{
127
+ return {
128
+ blogs: {
129
+ edges: [
130
+ {
131
+ node: {
132
+ id: '511006979737518962',
133
+ title: 'News',
134
+ baseID: 'gid://shopify/OnlineStoreBlog/91970044137',
135
+ tags: [],
136
+ handle: 'news',
137
+ descriptionMeta: '',
138
+ description: '',
139
+ titleMeta: '',
140
+ templateSuffix: '',
141
+ platform: 'SHOPIFY'
142
+ }
143
+ }
144
+ ]
145
+ }
146
+ };
147
+ };
148
+
149
+ export { useArticlesQuery, useBlogsQuery };
@@ -1,5 +1,6 @@
1
1
  import useSWR from 'swr';
2
- import { getProducts } from '../../helpers/queries/get-products.js';
2
+ import useSWRInfinite from 'swr/infinite';
3
+ import { getProducts, getProductQueryAll, getListProductByVariables } from '../../helpers/queries/get-products.js';
3
4
  import { generateProductsQueryKey } from '../../helpers/query.js';
4
5
  import { useIsSampleProduct, useIsStorefrontProduct } from '../shop.js';
5
6
  import { useFetchHandle } from '../useFetchHandle.js';
@@ -18,5 +19,41 @@ const useProductsQuery = (ids, options, params)=>{
18
19
  return getProducts(params?.fetcher || fetcher, arg);
19
20
  }, options);
20
21
  };
22
+ const getKey = (variable)=>{
23
+ return (pageIndex, previousPageData)=>{
24
+ if (!variable || previousPageData && !previousPageData.products?.pageInfo?.hasNextPage) {
25
+ return null;
26
+ }
27
+ if (pageIndex === 0) {
28
+ return [
29
+ 'query/products',
30
+ variable
31
+ ];
32
+ }
33
+ return [
34
+ 'query/products',
35
+ {
36
+ ...variable,
37
+ after: previousPageData.products?.pageInfo?.endCursor
38
+ }
39
+ ];
40
+ };
41
+ };
42
+ const useListProductQuery = (variable, options)=>{
43
+ const fetcher = useFetchHandle();
44
+ const data = useSWRInfinite(getKey(variable), async ([, arg])=>{
45
+ return getListProductByVariables(fetcher, arg);
46
+ }, options);
47
+ return data;
48
+ };
49
+ const useProductsQueryAll = (variable, options)=>{
50
+ const fetcher = useFetchHandle();
51
+ return useSWR(variable ? [
52
+ 'query/products',
53
+ variable
54
+ ] : null, async ([, arg])=>{
55
+ return getProductQueryAll(fetcher, arg);
56
+ }, options);
57
+ };
21
58
 
22
- export { useProductsQuery };
59
+ export { useListProductQuery, useProductsQuery, useProductsQueryAll };
@@ -5,10 +5,12 @@ import 'zustand';
5
5
  import 'swr';
6
6
  import '@gem-sdk/adapter-shopify';
7
7
  import 'swr/mutation';
8
+ import 'swr/infinite';
8
9
  import 'vanilla-lazyload';
9
10
  import './useCartUI.js';
10
11
  import 'react-transition-group';
11
12
  import '@gem-sdk/core';
13
+ import 'classnames';
12
14
  import '../helpers/convert.js';
13
15
 
14
16
  const useAnimations = ()=>{
@@ -9,10 +9,12 @@ import 'react/jsx-runtime';
9
9
  import 'zustand';
10
10
  import '@gem-sdk/adapter-shopify';
11
11
  import 'swr/mutation';
12
+ import 'swr/infinite';
12
13
  import 'vanilla-lazyload';
13
14
  import './useCartUI.js';
14
15
  import 'react-transition-group';
15
16
  import '@gem-sdk/core';
17
+ import 'classnames';
16
18
  import isBrowser from '../helpers/is-browser.js';
17
19
  import '../helpers/convert.js';
18
20