@gem-sdk/core 1.23.0-staging.453 → 1.23.0-staging.458

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.
@@ -14,6 +14,7 @@ const Render = ({ uid, ...passProps })=>{
14
14
  const item = BuilderContext.useBuilderStore((s)=>s.getItem(uid));
15
15
  const Component = BuilderComponent.useBuilderComponent(item?.tag);
16
16
  const isPostPurchase = BuilderContext.useBuilderStore((s)=>s.getIsPostPurchase());
17
+ const isPreview = BuilderContext.useBuilderStore((s)=>s.getIsPreview());
17
18
  const pageType = react.useMemo(()=>{
18
19
  return isPostPurchase ? 'POST_PURCHASE' : undefined;
19
20
  }, [
@@ -45,7 +46,8 @@ const Render = ({ uid, ...passProps })=>{
45
46
  children: item?.childrens?.length ? /*#__PURE__*/ jsxRuntime.jsx(Component, {
46
47
  builderProps: {
47
48
  uid,
48
- builderData: item
49
+ builderData: item,
50
+ isPreview
49
51
  },
50
52
  styles: item.styles,
51
53
  setting: item.settings,
@@ -56,7 +58,8 @@ const Render = ({ uid, ...passProps })=>{
56
58
  }) : /*#__PURE__*/ jsxRuntime.jsx(Component, {
57
59
  builderProps: {
58
60
  uid,
59
- builderData: item
61
+ builderData: item,
62
+ isPreview
60
63
  },
61
64
  styles: item.styles,
62
65
  setting: item.settings,
@@ -5,17 +5,19 @@ var react = require('react');
5
5
  var zustand = require('zustand');
6
6
 
7
7
  const BuilderContext = /*#__PURE__*/ react.createContext(null);
8
- const createBuilderProvider = (data, isPostPurchase)=>zustand.createStore((_, get)=>({
8
+ const createBuilderProvider = (data, isPostPurchase, isPreview)=>zustand.createStore((_, get)=>({
9
9
  state: data,
10
10
  isPostPurchase: isPostPurchase,
11
+ isPreview: isPreview,
11
12
  getItem: (id)=>{
12
13
  return get().state[id];
13
14
  },
14
- getIsPostPurchase: ()=>get().isPostPurchase
15
+ getIsPostPurchase: ()=>get().isPostPurchase,
16
+ getIsPreview: ()=>get().isPreview
15
17
  }));
16
- const BuilderProvider = ({ children, state, isPostPurchase, lazy, priority, ...passProps })=>{
18
+ const BuilderProvider = ({ children, state, isPostPurchase, isPreview, lazy, priority, ...passProps })=>{
17
19
  const Component = lazy ? react.Suspense : react.Fragment;
18
- const store = createBuilderProvider(state, isPostPurchase);
20
+ const store = createBuilderProvider(state, isPostPurchase, isPreview);
19
21
  return /*#__PURE__*/ jsxRuntime.jsx(Component, {
20
22
  children: /*#__PURE__*/ jsxRuntime.jsx(BuilderContext.Provider, {
21
23
  ...passProps,
@@ -26,15 +26,24 @@ const createPageStoreProvider = (data)=>zustand.createStore((set)=>({
26
26
  set({
27
27
  salePageProductId: id
28
28
  });
29
+ },
30
+ setPublicStoreFrontData: (publicStoreFrontData)=>{
31
+ set({
32
+ publicStoreFrontData: publicStoreFrontData
33
+ });
29
34
  }
30
35
  }));
31
- const PageProvider = ({ children, dynamicProduct, dynamicCollection, ...passProps })=>{
36
+ const PageProvider = ({ children, dynamicProduct, dynamicCollection, productOffers, publicStoreFrontData, ...passProps })=>{
32
37
  const store = react.useMemo(()=>createPageStoreProvider({
33
38
  dynamicProduct,
34
- dynamicCollection
39
+ dynamicCollection,
40
+ productOffers,
41
+ publicStoreFrontData
35
42
  }), [
36
43
  dynamicProduct,
37
- dynamicCollection
44
+ dynamicCollection,
45
+ productOffers,
46
+ publicStoreFrontData
38
47
  ]);
39
48
  return /*#__PURE__*/ jsxRuntime.jsx(PageContext.Provider, {
40
49
  ...passProps,
@@ -0,0 +1,25 @@
1
+ 'use strict';
2
+
3
+ /* eslint-disable */ const LibrarySaleFunnelDocument = `
4
+ query LibrarySaleFunnel($librarySaleFunnelId: ID!) {
5
+ librarySaleFunnel(id: $librarySaleFunnelId) {
6
+ id
7
+ type
8
+ name
9
+ offers {
10
+ id
11
+ discounts {
12
+ id
13
+ objectBaseID
14
+ objectType
15
+ position
16
+ title
17
+ type
18
+ value
19
+ }
20
+ }
21
+ }
22
+ }
23
+ `;
24
+
25
+ exports.LibrarySaleFunnelDocument = LibrarySaleFunnelDocument;
@@ -0,0 +1,38 @@
1
+ 'use strict';
2
+
3
+ /* eslint-disable */ const SaleFunnelDiscountsDocument = `
4
+ query SaleFunnelDiscounts($where: SaleFunnelDiscountWhereInput, $orderBy: SaleFunnelDiscountOrder, $last: Int, $before: Cursor, $first: Int, $after: Cursor) {
5
+ saleFunnelDiscounts(
6
+ where: $where
7
+ orderBy: $orderBy
8
+ last: $last
9
+ before: $before
10
+ first: $first
11
+ after: $after
12
+ ) {
13
+ edges {
14
+ node {
15
+ id
16
+ objectBaseID
17
+ objectType
18
+ position
19
+ title
20
+ type
21
+ value
22
+ valueType
23
+ isEnabled
24
+ }
25
+ cursor
26
+ }
27
+ pageInfo {
28
+ endCursor
29
+ hasNextPage
30
+ hasPreviousPage
31
+ startCursor
32
+ }
33
+ totalCount
34
+ }
35
+ }
36
+ `;
37
+
38
+ exports.SaleFunnelDiscountsDocument = SaleFunnelDiscountsDocument;
@@ -1,7 +1,7 @@
1
1
  'use strict';
2
2
 
3
3
  /* eslint-disable */ const ThemePageDocument = `
4
- query ThemePage($themePageId: ID!) {
4
+ query ThemePage($themePageId: ID!, $first: Int, $where: ThemeStyleWhereInput) {
5
5
  themePage(id: $themePageId) {
6
6
  id
7
7
  name
@@ -12,11 +12,19 @@
12
12
  cid
13
13
  component
14
14
  id
15
+ deletedAt
15
16
  }
16
- themeStyle {
17
+ theme {
17
18
  id
18
- data
19
- name
19
+ themeStyles(first: $first, where: $where) {
20
+ edges {
21
+ node {
22
+ data
23
+ id
24
+ name
25
+ }
26
+ }
27
+ }
20
28
  }
21
29
  }
22
30
  }
@@ -134,8 +134,8 @@ const makeAspectRatio = (aspectRatio, aspectWidth, aspectHeight)=>{
134
134
  };
135
135
  const makeLineClamp = (lineClampValue, hasLineClampValue)=>{
136
136
  const getVal = (deviceValue, lineClampValue, hasLineClampValue)=>{
137
- const lineClamp = lineClampValue?.[deviceValue];
138
- const hasLineClamp = hasLineClampValue?.[deviceValue] || hasLineClampValue?.['desktop'];
137
+ const lineClamp = getResonsiveValue.getResponsiveValueByScreen(lineClampValue, deviceValue);
138
+ const hasLineClamp = getResonsiveValue.getResponsiveValueByScreen(hasLineClampValue, deviceValue);
139
139
  if (hasLineClamp || hasLineClamp === undefined) {
140
140
  return lineClamp;
141
141
  }
@@ -6,7 +6,7 @@ var shop = require('../shop.js');
6
6
  var useFetchHandle = require('../useFetchHandle.js');
7
7
  var query = require('../../helpers/query.js');
8
8
 
9
- const useProductQuery = (productId, options)=>{
9
+ const useProductQuery = (productId, options, customFetcher)=>{
10
10
  const fetcher = useFetchHandle.useFetchHandle();
11
11
  const isSample = shop.useIsSampleProduct();
12
12
  const isStorefront = shop.useIsStorefrontProduct();
@@ -15,7 +15,7 @@ const useProductQuery = (productId, options)=>{
15
15
  isSample,
16
16
  isStorefront
17
17
  }) : null, async ([, arg])=>{
18
- return getProduct.getProduct(fetcher, arg);
18
+ return getProduct.getProduct(customFetcher || fetcher, arg);
19
19
  }, options);
20
20
  };
21
21
 
@@ -17,7 +17,7 @@ const useProductsQuery = (ids, options, params)=>{
17
17
  defaultSelectedProductCount: params?.defaultSelectedProductCount,
18
18
  allStatus: params?.allStatus
19
19
  }) : null, async ([, arg])=>{
20
- return getProducts.getProducts(fetcher, arg);
20
+ return getProducts.getProducts(params?.fetcher || fetcher, arg);
21
21
  }, options);
22
22
  };
23
23
  const useProductsQueryAll = (variable, options)=>{
@@ -8,6 +8,17 @@ var variantPresets = require('../components/src/product/helpers/variant-presets.
8
8
  var shop = require('./shop.js');
9
9
  var useFetchHandle = require('./useFetchHandle.js');
10
10
  var ShopContext = require('../contexts/ShopContext.js');
11
+ require('react');
12
+ require('react/jsx-runtime');
13
+ require('zustand');
14
+ require('@gem-sdk/adapter-shopify');
15
+ require('swr/mutation');
16
+ require('vanilla-lazyload');
17
+ require('./useCartUI.js');
18
+ require('react-transition-group');
19
+ require('@gem-sdk/core');
20
+ var isBrowser = require('../helpers/is-browser.js');
21
+ require('../helpers/convert.js');
11
22
 
12
23
  let swatchChange = false;
13
24
  let colorChange = false;
@@ -37,7 +48,7 @@ const useInitialSwatchesOptions = (options)=>{
37
48
  });
38
49
  if (!options) return [];
39
50
  setDefaultSwatches(swatches, options);
40
- if (swatches?.length && (swatchChange || colorChange)) {
51
+ if (isBrowser.default() && swatches?.length && (swatchChange || colorChange)) {
41
52
  window?.parent?.postMessage?.(JSON.stringify({
42
53
  type: 'update-swatches',
43
54
  swatches
package/dist/cjs/index.js CHANGED
@@ -24,8 +24,10 @@ var publishedThemePages_generated = require('./graphql/queries/published-theme-p
24
24
  var products_generated = require('./graphql/queries/products.generated.js');
25
25
  var storeProperty_generated = require('./graphql/queries/store-property.generated.js');
26
26
  var previewPage_generated = require('./graphql/queries/preview-page.generated.js');
27
- var ThemePage_generated = require('./graphql-app-api/queries/ThemePage.generated.js');
28
27
  var LibraryTemplate_generated = require('./graphql-app-api/queries/LibraryTemplate.generated.js');
28
+ var ThemePage_generated = require('./graphql-app-api/queries/ThemePage.generated.js');
29
+ var SaleFunnelDiscounts_generated = require('./graphql-app-api/queries/SaleFunnelDiscounts.generated.js');
30
+ var LibrarySaleFunnelDiscount_generated = require('./graphql-app-api/queries/LibrarySaleFunnelDiscount.generated.js');
29
31
  var borders = require('./helpers/borders.js');
30
32
  var carousel = require('./helpers/carousel.js');
31
33
  var cls = require('./helpers/cls.js');
@@ -142,8 +144,10 @@ exports.PublishedThemePagesDocument = publishedThemePages_generated.PublishedThe
142
144
  exports.ProductsDocument = products_generated.ProductsDocument;
143
145
  exports.StorePropertyDocument = storeProperty_generated.StorePropertyDocument;
144
146
  exports.PreviewPageDocument = previewPage_generated.PreviewPageDocument;
145
- exports.ThemePageDocument = ThemePage_generated.ThemePageDocument;
146
147
  exports.LibraryTemplateDocument = LibraryTemplate_generated.LibraryTemplateDocument;
148
+ exports.ThemePageDocument = ThemePage_generated.ThemePageDocument;
149
+ exports.SaleFunnelDiscountsDocument = SaleFunnelDiscounts_generated.SaleFunnelDiscountsDocument;
150
+ exports.LibrarySaleFunnelDocument = LibrarySaleFunnelDiscount_generated.LibrarySaleFunnelDocument;
147
151
  exports.composeBorderCss = borders.composeBorderCss;
148
152
  exports.getBorderStyle = borders.getBorderStyle;
149
153
  exports.handleConvertBorderColor = borders.handleConvertBorderColor;
@@ -10,6 +10,7 @@ const Render = ({ uid, ...passProps })=>{
10
10
  const item = useBuilderStore((s)=>s.getItem(uid));
11
11
  const Component = useBuilderComponent(item?.tag);
12
12
  const isPostPurchase = useBuilderStore((s)=>s.getIsPostPurchase());
13
+ const isPreview = useBuilderStore((s)=>s.getIsPreview());
13
14
  const pageType = useMemo(()=>{
14
15
  return isPostPurchase ? 'POST_PURCHASE' : undefined;
15
16
  }, [
@@ -41,7 +42,8 @@ const Render = ({ uid, ...passProps })=>{
41
42
  children: item?.childrens?.length ? /*#__PURE__*/ jsx(Component, {
42
43
  builderProps: {
43
44
  uid,
44
- builderData: item
45
+ builderData: item,
46
+ isPreview
45
47
  },
46
48
  styles: item.styles,
47
49
  setting: item.settings,
@@ -52,7 +54,8 @@ const Render = ({ uid, ...passProps })=>{
52
54
  }) : /*#__PURE__*/ jsx(Component, {
53
55
  builderProps: {
54
56
  uid,
55
- builderData: item
57
+ builderData: item,
58
+ isPreview
56
59
  },
57
60
  styles: item.styles,
58
61
  setting: item.settings,
@@ -3,17 +3,19 @@ import { useContext, createContext, Suspense, Fragment } from 'react';
3
3
  import { useStore, createStore } from 'zustand';
4
4
 
5
5
  const BuilderContext = /*#__PURE__*/ createContext(null);
6
- const createBuilderProvider = (data, isPostPurchase)=>createStore((_, get)=>({
6
+ const createBuilderProvider = (data, isPostPurchase, isPreview)=>createStore((_, get)=>({
7
7
  state: data,
8
8
  isPostPurchase: isPostPurchase,
9
+ isPreview: isPreview,
9
10
  getItem: (id)=>{
10
11
  return get().state[id];
11
12
  },
12
- getIsPostPurchase: ()=>get().isPostPurchase
13
+ getIsPostPurchase: ()=>get().isPostPurchase,
14
+ getIsPreview: ()=>get().isPreview
13
15
  }));
14
- const BuilderProvider = ({ children, state, isPostPurchase, lazy, priority, ...passProps })=>{
16
+ const BuilderProvider = ({ children, state, isPostPurchase, isPreview, lazy, priority, ...passProps })=>{
15
17
  const Component = lazy ? Suspense : Fragment;
16
- const store = createBuilderProvider(state, isPostPurchase);
18
+ const store = createBuilderProvider(state, isPostPurchase, isPreview);
17
19
  return /*#__PURE__*/ jsx(Component, {
18
20
  children: /*#__PURE__*/ jsx(BuilderContext.Provider, {
19
21
  ...passProps,
@@ -24,15 +24,24 @@ const createPageStoreProvider = (data)=>createStore((set)=>({
24
24
  set({
25
25
  salePageProductId: id
26
26
  });
27
+ },
28
+ setPublicStoreFrontData: (publicStoreFrontData)=>{
29
+ set({
30
+ publicStoreFrontData: publicStoreFrontData
31
+ });
27
32
  }
28
33
  }));
29
- const PageProvider = ({ children, dynamicProduct, dynamicCollection, ...passProps })=>{
34
+ const PageProvider = ({ children, dynamicProduct, dynamicCollection, productOffers, publicStoreFrontData, ...passProps })=>{
30
35
  const store = useMemo(()=>createPageStoreProvider({
31
36
  dynamicProduct,
32
- dynamicCollection
37
+ dynamicCollection,
38
+ productOffers,
39
+ publicStoreFrontData
33
40
  }), [
34
41
  dynamicProduct,
35
- dynamicCollection
42
+ dynamicCollection,
43
+ productOffers,
44
+ publicStoreFrontData
36
45
  ]);
37
46
  return /*#__PURE__*/ jsx(PageContext.Provider, {
38
47
  ...passProps,
@@ -0,0 +1,23 @@
1
+ /* eslint-disable */ const LibrarySaleFunnelDocument = `
2
+ query LibrarySaleFunnel($librarySaleFunnelId: ID!) {
3
+ librarySaleFunnel(id: $librarySaleFunnelId) {
4
+ id
5
+ type
6
+ name
7
+ offers {
8
+ id
9
+ discounts {
10
+ id
11
+ objectBaseID
12
+ objectType
13
+ position
14
+ title
15
+ type
16
+ value
17
+ }
18
+ }
19
+ }
20
+ }
21
+ `;
22
+
23
+ export { LibrarySaleFunnelDocument };
@@ -0,0 +1,36 @@
1
+ /* eslint-disable */ const SaleFunnelDiscountsDocument = `
2
+ query SaleFunnelDiscounts($where: SaleFunnelDiscountWhereInput, $orderBy: SaleFunnelDiscountOrder, $last: Int, $before: Cursor, $first: Int, $after: Cursor) {
3
+ saleFunnelDiscounts(
4
+ where: $where
5
+ orderBy: $orderBy
6
+ last: $last
7
+ before: $before
8
+ first: $first
9
+ after: $after
10
+ ) {
11
+ edges {
12
+ node {
13
+ id
14
+ objectBaseID
15
+ objectType
16
+ position
17
+ title
18
+ type
19
+ value
20
+ valueType
21
+ isEnabled
22
+ }
23
+ cursor
24
+ }
25
+ pageInfo {
26
+ endCursor
27
+ hasNextPage
28
+ hasPreviousPage
29
+ startCursor
30
+ }
31
+ totalCount
32
+ }
33
+ }
34
+ `;
35
+
36
+ export { SaleFunnelDiscountsDocument };
@@ -1,5 +1,5 @@
1
1
  /* eslint-disable */ const ThemePageDocument = `
2
- query ThemePage($themePageId: ID!) {
2
+ query ThemePage($themePageId: ID!, $first: Int, $where: ThemeStyleWhereInput) {
3
3
  themePage(id: $themePageId) {
4
4
  id
5
5
  name
@@ -10,11 +10,19 @@
10
10
  cid
11
11
  component
12
12
  id
13
+ deletedAt
13
14
  }
14
- themeStyle {
15
+ theme {
15
16
  id
16
- data
17
- name
17
+ themeStyles(first: $first, where: $where) {
18
+ edges {
19
+ node {
20
+ data
21
+ id
22
+ name
23
+ }
24
+ }
25
+ }
18
26
  }
19
27
  }
20
28
  }
@@ -132,8 +132,8 @@ const makeAspectRatio = (aspectRatio, aspectWidth, aspectHeight)=>{
132
132
  };
133
133
  const makeLineClamp = (lineClampValue, hasLineClampValue)=>{
134
134
  const getVal = (deviceValue, lineClampValue, hasLineClampValue)=>{
135
- const lineClamp = lineClampValue?.[deviceValue];
136
- const hasLineClamp = hasLineClampValue?.[deviceValue] || hasLineClampValue?.['desktop'];
135
+ const lineClamp = getResponsiveValueByScreen(lineClampValue, deviceValue);
136
+ const hasLineClamp = getResponsiveValueByScreen(hasLineClampValue, deviceValue);
137
137
  if (hasLineClamp || hasLineClamp === undefined) {
138
138
  return lineClamp;
139
139
  }
@@ -4,7 +4,7 @@ import { useIsSampleProduct, useIsStorefrontProduct } from '../shop.js';
4
4
  import { useFetchHandle } from '../useFetchHandle.js';
5
5
  import { generateProductQueryKey } from '../../helpers/query.js';
6
6
 
7
- const useProductQuery = (productId, options)=>{
7
+ const useProductQuery = (productId, options, customFetcher)=>{
8
8
  const fetcher = useFetchHandle();
9
9
  const isSample = useIsSampleProduct();
10
10
  const isStorefront = useIsStorefrontProduct();
@@ -13,7 +13,7 @@ const useProductQuery = (productId, options)=>{
13
13
  isSample,
14
14
  isStorefront
15
15
  }) : null, async ([, arg])=>{
16
- return getProduct(fetcher, arg);
16
+ return getProduct(customFetcher || fetcher, arg);
17
17
  }, options);
18
18
  };
19
19
 
@@ -15,7 +15,7 @@ const useProductsQuery = (ids, options, params)=>{
15
15
  defaultSelectedProductCount: params?.defaultSelectedProductCount,
16
16
  allStatus: params?.allStatus
17
17
  }) : null, async ([, arg])=>{
18
- return getProducts(fetcher, arg);
18
+ return getProducts(params?.fetcher || fetcher, arg);
19
19
  }, options);
20
20
  };
21
21
  const useProductsQueryAll = (variable, options)=>{
@@ -4,6 +4,17 @@ import { colorPreset } from '../components/src/product/helpers/variant-presets.j
4
4
  import { useSwatches } from './shop.js';
5
5
  import { useFetchHandle } from './useFetchHandle.js';
6
6
  import { useShopStore } from '../contexts/ShopContext.js';
7
+ import 'react';
8
+ import 'react/jsx-runtime';
9
+ import 'zustand';
10
+ import '@gem-sdk/adapter-shopify';
11
+ import 'swr/mutation';
12
+ import 'vanilla-lazyload';
13
+ import './useCartUI.js';
14
+ import 'react-transition-group';
15
+ import '@gem-sdk/core';
16
+ import isBrowser from '../helpers/is-browser.js';
17
+ import '../helpers/convert.js';
7
18
 
8
19
  let swatchChange = false;
9
20
  let colorChange = false;
@@ -33,7 +44,7 @@ const useInitialSwatchesOptions = (options)=>{
33
44
  });
34
45
  if (!options) return [];
35
46
  setDefaultSwatches(swatches, options);
36
- if (swatches?.length && (swatchChange || colorChange)) {
47
+ if (isBrowser() && swatches?.length && (swatchChange || colorChange)) {
37
48
  window?.parent?.postMessage?.(JSON.stringify({
38
49
  type: 'update-swatches',
39
50
  swatches
package/dist/esm/index.js CHANGED
@@ -22,8 +22,10 @@ export { PublishedThemePagesDocument } from './graphql/queries/published-theme-p
22
22
  export { ProductsDocument } from './graphql/queries/products.generated.js';
23
23
  export { StorePropertyDocument } from './graphql/queries/store-property.generated.js';
24
24
  export { PreviewPageDocument } from './graphql/queries/preview-page.generated.js';
25
- export { ThemePageDocument } from './graphql-app-api/queries/ThemePage.generated.js';
26
25
  export { LibraryTemplateDocument } from './graphql-app-api/queries/LibraryTemplate.generated.js';
26
+ export { ThemePageDocument } from './graphql-app-api/queries/ThemePage.generated.js';
27
+ export { SaleFunnelDiscountsDocument } from './graphql-app-api/queries/SaleFunnelDiscounts.generated.js';
28
+ export { LibrarySaleFunnelDocument } from './graphql-app-api/queries/LibrarySaleFunnelDiscount.generated.js';
27
29
  export { composeBorderCss, getBorderStyle, handleConvertBorderColor, handleConvertBorderStyle, handleConvertBorderWidth, handleConvertClassColor, handleConvertClassColorDynamicBtn } from './helpers/borders.js';
28
30
  export { getCarouselContainerHeight, makeContainerWidthOrHeight, makeDotGapToCarouselStyle } from './helpers/carousel.js';
29
31
  export { cls } from './helpers/cls.js';