@gem-sdk/core 1.13.24 → 1.13.42

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 (88) hide show
  1. package/dist/cjs/components/AddOn.js +1 -1
  2. package/dist/cjs/components/ComponentWrapper.js +1 -1
  3. package/dist/cjs/components/ComponentWrapperPreview.js +1 -1
  4. package/dist/cjs/components/Render.js +2 -2
  5. package/dist/cjs/components/Render.liquid.js +1 -1
  6. package/dist/cjs/components/RenderBlock.js +2 -2
  7. package/dist/cjs/components/RenderPreview.js +2 -2
  8. package/dist/cjs/components/RenderSection.js +1 -1
  9. package/dist/cjs/contexts/AddonContext.js +1 -1
  10. package/dist/cjs/contexts/BuilderComponent.js +1 -1
  11. package/dist/cjs/contexts/BuilderContext.js +1 -1
  12. package/dist/cjs/contexts/BuilderPreviewContext.js +4 -4
  13. package/dist/cjs/contexts/CartLineContext.js +1 -1
  14. package/dist/cjs/contexts/CollectionContext.js +2 -2
  15. package/dist/cjs/contexts/ModalContext.js +1 -1
  16. package/dist/cjs/contexts/ProductContext.js +1 -1
  17. package/dist/cjs/contexts/ProductListContext.js +1 -1
  18. package/dist/cjs/contexts/SectionContext.js +2 -2
  19. package/dist/cjs/contexts/ShopContext.js +2 -2
  20. package/dist/cjs/graphql/fragments/collection.generated.js +1 -0
  21. package/dist/cjs/helpers/borders.js +1 -1
  22. package/dist/cjs/helpers/compose-advance-style.js +2 -2
  23. package/dist/cjs/helpers/product.js +15 -1
  24. package/dist/cjs/helpers/queries/get-collection.js +1 -1
  25. package/dist/cjs/helpers/queries/get-product.js +4 -4
  26. package/dist/cjs/helpers/queries/get-products.js +4 -4
  27. package/dist/cjs/helpers/radius.js +1 -1
  28. package/dist/cjs/helpers/shadow.js +5 -5
  29. package/dist/cjs/helpers/typography.js +4 -4
  30. package/dist/cjs/hooks/cart/use-add-to-cart.js +2 -2
  31. package/dist/cjs/hooks/cart/use-cart-data.js +1 -1
  32. package/dist/cjs/hooks/cart/use-cart-discount-codes-update.js +2 -2
  33. package/dist/cjs/hooks/cart/use-cart-note-update.js +2 -2
  34. package/dist/cjs/hooks/cart/use-create-cart.js +2 -2
  35. package/dist/cjs/hooks/cart/use-remove-cart-item.js +2 -2
  36. package/dist/cjs/hooks/cart/use-update-cart-item.js +2 -2
  37. package/dist/cjs/hooks/shop.js +4 -4
  38. package/dist/cjs/hooks/useFetchHandle.js +1 -1
  39. package/dist/cjs/hooks/useFormatMoney.js +1 -1
  40. package/dist/cjs/hooks/useMoney.js +2 -2
  41. package/dist/cjs/hooks/useProduct.js +8 -11
  42. package/dist/cjs/hooks/useSwatchesOptions.js +1 -1
  43. package/dist/cjs/index.js +1 -0
  44. package/dist/esm/components/AddOn.js +1 -1
  45. package/dist/esm/components/ComponentWrapper.js +1 -1
  46. package/dist/esm/components/ComponentWrapperPreview.js +1 -1
  47. package/dist/esm/components/Render.js +2 -2
  48. package/dist/esm/components/Render.liquid.js +1 -1
  49. package/dist/esm/components/RenderBlock.js +2 -2
  50. package/dist/esm/components/RenderPreview.js +2 -2
  51. package/dist/esm/components/RenderSection.js +1 -1
  52. package/dist/esm/contexts/AddonContext.js +1 -1
  53. package/dist/esm/contexts/BuilderComponent.js +1 -1
  54. package/dist/esm/contexts/BuilderContext.js +1 -1
  55. package/dist/esm/contexts/BuilderPreviewContext.js +4 -4
  56. package/dist/esm/contexts/CartLineContext.js +1 -1
  57. package/dist/esm/contexts/CollectionContext.js +2 -2
  58. package/dist/esm/contexts/ModalContext.js +1 -1
  59. package/dist/esm/contexts/ProductContext.js +1 -1
  60. package/dist/esm/contexts/ProductListContext.js +1 -1
  61. package/dist/esm/contexts/SectionContext.js +2 -2
  62. package/dist/esm/contexts/ShopContext.js +2 -2
  63. package/dist/esm/graphql/fragments/collection.generated.js +1 -0
  64. package/dist/esm/helpers/borders.js +1 -1
  65. package/dist/esm/helpers/compose-advance-style.js +2 -2
  66. package/dist/esm/helpers/product.js +15 -2
  67. package/dist/esm/helpers/queries/get-collection.js +1 -1
  68. package/dist/esm/helpers/queries/get-product.js +4 -4
  69. package/dist/esm/helpers/queries/get-products.js +4 -4
  70. package/dist/esm/helpers/radius.js +1 -1
  71. package/dist/esm/helpers/shadow.js +5 -5
  72. package/dist/esm/helpers/typography.js +4 -4
  73. package/dist/esm/hooks/cart/use-add-to-cart.js +2 -2
  74. package/dist/esm/hooks/cart/use-cart-data.js +1 -1
  75. package/dist/esm/hooks/cart/use-cart-discount-codes-update.js +2 -2
  76. package/dist/esm/hooks/cart/use-cart-note-update.js +2 -2
  77. package/dist/esm/hooks/cart/use-create-cart.js +2 -2
  78. package/dist/esm/hooks/cart/use-remove-cart-item.js +2 -2
  79. package/dist/esm/hooks/cart/use-update-cart-item.js +2 -2
  80. package/dist/esm/hooks/shop.js +4 -4
  81. package/dist/esm/hooks/useFetchHandle.js +1 -1
  82. package/dist/esm/hooks/useFormatMoney.js +1 -1
  83. package/dist/esm/hooks/useMoney.js +2 -2
  84. package/dist/esm/hooks/useProduct.js +8 -11
  85. package/dist/esm/hooks/useSwatchesOptions.js +1 -1
  86. package/dist/esm/index.js +1 -1
  87. package/dist/types/index.d.ts +6 -3
  88. package/package.json +4 -4
@@ -6,7 +6,7 @@ var jsxRuntime = require('react/jsx-runtime');
6
6
  var AddonContext = require('../contexts/AddonContext.js');
7
7
  var shop = require('../hooks/shop.js');
8
8
 
9
- const AddOn = ({ name })=>{
9
+ const AddOn = ({ name })=>{
10
10
  const Comp = AddonContext.useAddon(name);
11
11
  const plugins = shop.usePluginEnable();
12
12
  if (!plugins?.includes(name)) {
@@ -7,7 +7,7 @@ var react = require('react');
7
7
  var composeAdvanceStyle = require('../helpers/compose-advance-style.js');
8
8
  var constant = require('./constant.js');
9
9
 
10
- const ComponentWrapper = ({ children , ...props })=>{
10
+ const ComponentWrapper = ({ children, ...props })=>{
11
11
  if (props.type === 'section') return null;
12
12
  const style = composeAdvanceStyle.composeAdvanceStyle(props.advanced, props.tag);
13
13
  const advanced = props.advanced;
@@ -7,7 +7,7 @@ var react = require('react');
7
7
  var composeAdvanceStyle = require('../helpers/compose-advance-style.js');
8
8
  var constant = require('./constant.js');
9
9
 
10
- const ComponentWrapperPreview = ({ children , ...props })=>{
10
+ const ComponentWrapperPreview = ({ children, ...props })=>{
11
11
  if (props.type === 'section') {
12
12
  return null;
13
13
  }
@@ -10,7 +10,7 @@ var BuilderContext = require('../contexts/BuilderContext.js');
10
10
  var ComponentWrapper = require('./ComponentWrapper.js');
11
11
  var RenderSection = require('./RenderSection.js');
12
12
 
13
- const Render = ({ uid , ...passProps })=>{
13
+ const Render = ({ uid, ...passProps })=>{
14
14
  const item = BuilderContext.useBuilderStore((s)=>s.getItem(uid));
15
15
  const Component = BuilderComponent.useBuilderComponent(item?.tag);
16
16
  if (!item) return null;
@@ -20,7 +20,7 @@ const Render = ({ uid , ...passProps })=>{
20
20
  });
21
21
  } else {
22
22
  return /*#__PURE__*/ jsxRuntime.jsx(reactErrorBoundary.ErrorBoundary, {
23
- fallbackRender: ({ error , resetErrorBoundary })=>/*#__PURE__*/ jsxRuntime.jsxs(jsxRuntime.Fragment, {
23
+ fallbackRender: ({ error, resetErrorBoundary })=>/*#__PURE__*/ jsxRuntime.jsxs(jsxRuntime.Fragment, {
24
24
  children: [
25
25
  /*#__PURE__*/ jsxRuntime.jsx("span", {
26
26
  "aria-label": "Error message",
@@ -16,7 +16,7 @@ const componentTexts = [
16
16
  'Text',
17
17
  'Heading'
18
18
  ];
19
- const Render = ({ uid , builder , components , parentId , extraFiles ={} , ...passProps })=>{
19
+ const Render = ({ uid, builder, components, parentId, extraFiles = {}, ...passProps })=>{
20
20
  const item = builder[uid];
21
21
  const Component = components[item?.tag];
22
22
  if (!Component) {
@@ -9,12 +9,12 @@ var BuilderComponent = require('../contexts/BuilderComponent.js');
9
9
  var BuilderContext = require('../contexts/BuilderContext.js');
10
10
  var ComponentWrapper = require('./ComponentWrapper.js');
11
11
 
12
- const RenderBlock = ({ uid })=>{
12
+ const RenderBlock = ({ uid })=>{
13
13
  const item = BuilderContext.useBuilderStore((s)=>s.getItem(uid));
14
14
  const Component = BuilderComponent.useBuilderComponent(item?.tag);
15
15
  if (!item || item.type === 'section') return null;
16
16
  return /*#__PURE__*/ jsxRuntime.jsx(reactErrorBoundary.ErrorBoundary, {
17
- fallbackRender: ({ error , resetErrorBoundary })=>/*#__PURE__*/ jsxRuntime.jsxs(ComponentWrapper.default, {
17
+ fallbackRender: ({ error, resetErrorBoundary })=>/*#__PURE__*/ jsxRuntime.jsxs(ComponentWrapper.default, {
18
18
  ...item,
19
19
  children: [
20
20
  /*#__PURE__*/ jsxRuntime.jsx("span", {
@@ -10,7 +10,7 @@ var BuilderPreviewContext = require('../contexts/BuilderPreviewContext.js');
10
10
  var ComponentWrapperPreview = require('./ComponentWrapperPreview.js');
11
11
  var RenderSection = require('./RenderSection.js');
12
12
 
13
- const RenderPreview = ({ uid , ...passProps })=>{
13
+ const RenderPreview = ({ uid, ...passProps })=>{
14
14
  const item = BuilderPreviewContext.useBuilderPreviewStore((s)=>s.getItem(uid));
15
15
  const Component = BuilderComponent.useBuilderComponent(item?.tag);
16
16
  if (!item) return null;
@@ -20,7 +20,7 @@ const RenderPreview = ({ uid , ...passProps })=>{
20
20
  });
21
21
  } else {
22
22
  return /*#__PURE__*/ jsxRuntime.jsx(reactErrorBoundary.ErrorBoundary, {
23
- fallbackRender: ({ error , resetErrorBoundary })=>/*#__PURE__*/ jsxRuntime.jsxs(ComponentWrapperPreview.default, {
23
+ fallbackRender: ({ error, resetErrorBoundary })=>/*#__PURE__*/ jsxRuntime.jsxs(ComponentWrapperPreview.default, {
24
24
  ...item,
25
25
  children: [
26
26
  /*#__PURE__*/ jsxRuntime.jsx("span", {
@@ -8,7 +8,7 @@ var BuilderContext = require('../contexts/BuilderContext.js');
8
8
  var SectionContext = require('../contexts/SectionContext.js');
9
9
  var RenderBlock = require('./RenderBlock.js');
10
10
 
11
- const RenderSection = ({ sectionId })=>{
11
+ const RenderSection = ({ sectionId })=>{
12
12
  const state = SectionContext.useSection(sectionId);
13
13
  if (!state) return null;
14
14
  return /*#__PURE__*/ jsxRuntime.jsx(BuilderContext.BuilderProvider, {
@@ -5,7 +5,7 @@ var react = require('react');
5
5
  var Empty = require('../components/Empty.js');
6
6
 
7
7
  const AddonContext = /*#__PURE__*/ react.createContext(null);
8
- const AddonProvider = ({ children , components , ...passProps })=>{
8
+ const AddonProvider = ({ children, components, ...passProps })=>{
9
9
  return /*#__PURE__*/ jsxRuntime.jsx(AddonContext.Provider, {
10
10
  ...passProps,
11
11
  value: {
@@ -12,7 +12,7 @@ const createBuilderComponentStore = (components)=>zustand.createStore((_, get)=>
12
12
  return get().components[id];
13
13
  }
14
14
  }));
15
- const BuilderComponentProvider = ({ children , components , ...passProps })=>{
15
+ const BuilderComponentProvider = ({ children, components, ...passProps })=>{
16
16
  return /*#__PURE__*/ jsxRuntime.jsx(BuilderComponentContext.Provider, {
17
17
  ...passProps,
18
18
  value: createBuilderComponentStore(components),
@@ -11,7 +11,7 @@ const createBuilderProvider = (data)=>zustand.createStore((_, get)=>({
11
11
  return get().state[id];
12
12
  }
13
13
  }));
14
- const BuilderProvider = ({ children , state , lazy , priority , ...passProps })=>{
14
+ const BuilderProvider = ({ children, state, lazy, priority, ...passProps })=>{
15
15
  const Component = lazy ? react.Suspense : react.Fragment;
16
16
  const store = createBuilderProvider(state);
17
17
  return /*#__PURE__*/ jsxRuntime.jsx(Component, {
@@ -32,7 +32,7 @@ const createBuilderPreviewProvider = (args)=>zustand.createStore((set, get)=>({
32
32
  state: args,
33
33
  loaded: false,
34
34
  addItem: (args)=>{
35
- const { position , data } = args;
35
+ const { position, data } = args;
36
36
  const state = get().state;
37
37
  const dateModified = Date.now();
38
38
  if (args.type === 'section') {
@@ -61,7 +61,7 @@ const createBuilderPreviewProvider = (args)=>zustand.createStore((set, get)=>({
61
61
  });
62
62
  }
63
63
  } else {
64
- const { id , data } = args;
64
+ const { id, data } = args;
65
65
  const parent = id ? state[id] ?? state.ROOT : state.ROOT;
66
66
  // Can't add item to section
67
67
  if (parent.type === 'section') return;
@@ -158,7 +158,7 @@ const createBuilderPreviewProvider = (args)=>zustand.createStore((set, get)=>({
158
158
  }
159
159
  }
160
160
  },
161
- changeItemPropByKey: ({ id , key , data , group })=>{
161
+ changeItemPropByKey: ({ id, key, data, group })=>{
162
162
  if (!group || ![
163
163
  'setting',
164
164
  'style',
@@ -342,7 +342,7 @@ const createBuilderPreviewProvider = (args)=>zustand.createStore((set, get)=>({
342
342
  });
343
343
  }
344
344
  }));
345
- const BuilderPreviewProvider = ({ children , state , lazy , ...passProps })=>{
345
+ const BuilderPreviewProvider = ({ children, state, lazy, ...passProps })=>{
346
346
  const Component = lazy ? react.Suspense : react.Fragment;
347
347
  const value = react.useMemo(()=>{
348
348
  return createBuilderPreviewProvider(state);
@@ -8,7 +8,7 @@ const CartLineContext = /*#__PURE__*/ react.createContext(null);
8
8
  const createCartLineStore = (data)=>zustand.createStore(()=>({
9
9
  ...data
10
10
  }));
11
- const CartLineProvider = ({ children , line })=>{
11
+ const CartLineProvider = ({ children, line })=>{
12
12
  return /*#__PURE__*/ jsxRuntime.jsx(CartLineContext.Provider, {
13
13
  value: createCartLineStore({
14
14
  line
@@ -7,13 +7,13 @@ var zustand = require('zustand');
7
7
  const CollectionContext = /*#__PURE__*/ react.createContext(null);
8
8
  const createCollectionProvider = (data)=>zustand.createStore((set)=>({
9
9
  ...data,
10
- changeCollectionStore: ({ collection })=>{
10
+ changeCollectionStore: ({ collection })=>{
11
11
  set({
12
12
  collection: collection
13
13
  });
14
14
  }
15
15
  }));
16
- const CollectionProvider = ({ collection , children })=>{
16
+ const CollectionProvider = ({ collection, children })=>{
17
17
  const store = react.useMemo(()=>{
18
18
  return createCollectionProvider({
19
19
  collection
@@ -26,7 +26,7 @@ const createModalProvider = (data)=>zustand.createStore((set)=>({
26
26
  });
27
27
  }
28
28
  }));
29
- const ModalProvider = ({ children , activeId , ...passProps })=>{
29
+ const ModalProvider = ({ children, activeId, ...passProps })=>{
30
30
  const store = createModalProvider(activeId);
31
31
  return /*#__PURE__*/ jsxRuntime.jsx(ModalContext.Provider, {
32
32
  ...passProps,
@@ -96,7 +96,7 @@ const createProductStoreProvider = (data)=>zustand.createStore((set, get)=>({
96
96
  });
97
97
  }
98
98
  }));
99
- const ProductProvider = ({ children , product , initialVariantId , quantity =1 })=>{
99
+ const ProductProvider = ({ children, product, initialVariantId, quantity = 1 })=>{
100
100
  const uiqueId = react.useId();
101
101
  const store = react.useMemo(()=>{
102
102
  let selectedOptions = {};
@@ -8,7 +8,7 @@ const ProductListContext = /*#__PURE__*/ react.createContext(null);
8
8
  const createProductListProvider = (data)=>zustand.createStore(()=>({
9
9
  ...data
10
10
  }));
11
- const ProductListProvider = ({ children , collection , products , settings , styles })=>{
11
+ const ProductListProvider = ({ children, collection, products, settings, styles })=>{
12
12
  return /*#__PURE__*/ jsxRuntime.jsx(ProductListContext.Provider, {
13
13
  value: createProductListProvider({
14
14
  products,
@@ -24,14 +24,14 @@ const createSectionProvider = (data)=>zustand.createStore((set, get)=>({
24
24
  },
25
25
  removeSection: (id)=>{
26
26
  set((prev)=>{
27
- const { [id]: _ , ...rest } = prev.data;
27
+ const { [id]: _, ...rest } = prev.data;
28
28
  return {
29
29
  data: rest
30
30
  };
31
31
  });
32
32
  }
33
33
  }));
34
- const SectionProvider = ({ children , data , ...passProps })=>{
34
+ const SectionProvider = ({ children, data, ...passProps })=>{
35
35
  return /*#__PURE__*/ jsxRuntime.jsx(SectionContext.Provider, {
36
36
  ...passProps,
37
37
  value: createSectionProvider(data),
@@ -32,14 +32,14 @@ const createShopStoreProvider = (data)=>zustand.createStore((set)=>({
32
32
  layoutSettings
33
33
  });
34
34
  },
35
- changeStorefrontInfo: ({ url , token })=>{
35
+ changeStorefrontInfo: ({ url, token })=>{
36
36
  set({
37
37
  storefrontUrl: url,
38
38
  storefrontToken: token
39
39
  });
40
40
  }
41
41
  }));
42
- const ShopProvider = ({ children , addons , storeOption , queryOption , ...passProps })=>{
42
+ const ShopProvider = ({ children, addons, storeOption, queryOption, ...passProps })=>{
43
43
  const store = react.useMemo(()=>createShopStoreProvider(storeOption), [
44
44
  storeOption
45
45
  ]);
@@ -16,6 +16,7 @@
16
16
  }
17
17
  }
18
18
  }
19
+ totalCount
19
20
  }
20
21
  }
21
22
  `;
@@ -167,7 +167,7 @@ const handleConvertClassColorDynamicBtn = (value)=>{
167
167
  };
168
168
  const composeBorderCss = (borderV)=>{
169
169
  if (!borderV) return '';
170
- const { border , width , color } = borderV;
170
+ const { border, width, color } = borderV;
171
171
  return `${border ? `border-style: ${border};` : ''}
172
172
  ${width ? `border-width: ${width};` : ''}
173
173
  ${color ? `border-color: ${colors.getSingleColorVariable(color)};` : ''}
@@ -7,8 +7,8 @@ var makeStyle = require('./make-style.js');
7
7
  var radius = require('./radius.js');
8
8
  var shadow = require('./shadow.js');
9
9
 
10
- const composeSpacing = ({ source , spacing , type , suffix ='' })=>{
11
- const { top , left , bottom , right } = spacing;
10
+ const composeSpacing = ({ source, spacing, type, suffix = '' })=>{
11
+ const { top, left, bottom, right } = spacing;
12
12
  if (top) source[`--${type}t${suffix}`] = top;
13
13
  if (left) source[`--${type}l${suffix}`] = left;
14
14
  if (bottom) source[`--${type}b${suffix}`] = bottom;
@@ -1,5 +1,7 @@
1
1
  'use strict';
2
2
 
3
+ var variant = require('./variant.js');
4
+
3
5
  function getSelectedVariant(variants, choices) {
4
6
  /**
5
7
  * Ensure the user has selected all the required options, not just some.
@@ -16,7 +18,7 @@ function parseSelectedOption(options) {
16
18
  if (!options || options && options.length === 0) {
17
19
  return;
18
20
  }
19
- return options.reduce((acc, { name , value })=>{
21
+ return options.reduce((acc, { name, value })=>{
20
22
  if (name && value) {
21
23
  return {
22
24
  ...acc,
@@ -26,6 +28,18 @@ function parseSelectedOption(options) {
26
28
  return acc;
27
29
  }, {});
28
30
  }
31
+ function checkAvailableVariantInStock(variants, optionId, optionValue) {
32
+ return variants ? variants.some((item)=>{
33
+ if (item) {
34
+ const { selectedOptions } = item;
35
+ const opt = selectedOptions?.some((option)=>option?.name === optionId && option.value === optionValue);
36
+ const isInStock = variant.checkInStock(item);
37
+ return opt && isInStock;
38
+ }
39
+ return false;
40
+ }) : false;
41
+ }
29
42
 
43
+ exports.checkAvailableVariantInStock = checkAvailableVariantInStock;
30
44
  exports.getSelectedVariant = getSelectedVariant;
31
45
  exports.parseSelectedOption = parseSelectedOption;
@@ -171,7 +171,7 @@ const mergeProductCollectionVariant = async (fetcher, collection, isSample)=>{
171
171
  };
172
172
  return newCollection;
173
173
  };
174
- const fetchVariantsByBaseIds = async (fetcher, { ids , isSample , isStorefront })=>{
174
+ const fetchVariantsByBaseIds = async (fetcher, { ids, isSample, isStorefront })=>{
175
175
  const chunkedIds = chunkArray(ids ?? [], 8);
176
176
  const defaultEdges = [];
177
177
  const query = async (variables)=>{
@@ -4,7 +4,7 @@ var productLittleDetail_generated = require('../../graphql/queries/product-littl
4
4
  var productMedias_generated = require('../../graphql/queries/product-medias.generated.js');
5
5
  var productVariants_generated = require('../../graphql/queries/product-variants.generated.js');
6
6
 
7
- const getProduct = async (fetcher, { id , isSample , isStorefront })=>{
7
+ const getProduct = async (fetcher, { id, isSample, isStorefront })=>{
8
8
  const [product, variants, medias] = await Promise.all([
9
9
  fetchProduct(fetcher, {
10
10
  id,
@@ -39,7 +39,7 @@ const orderBy = {
39
39
  field: 'CREATED_AT',
40
40
  direction: 'DESC'
41
41
  };
42
- const fetchProduct = async (fetcher, { id , isSample , isStorefront })=>{
42
+ const fetchProduct = async (fetcher, { id, isSample, isStorefront })=>{
43
43
  const variables = {
44
44
  orderBy,
45
45
  where: {
@@ -61,7 +61,7 @@ const fetchProduct = async (fetcher, { id , isSample , isStorefront })=>{
61
61
  ]);
62
62
  return response.product?.edges?.[0]?.node;
63
63
  };
64
- const fetchVariants = async (fetcher, { id , isSample , isStorefront })=>{
64
+ const fetchVariants = async (fetcher, { id, isSample, isStorefront })=>{
65
65
  const initVariables = {
66
66
  orderBy,
67
67
  where: {
@@ -102,7 +102,7 @@ const fetchVariants = async (fetcher, { id , isSample , isStorefront })=>{
102
102
  };
103
103
  return query(initVariables, []);
104
104
  };
105
- const fetchMedias = async (fetcher, { id , isSample , isStorefront })=>{
105
+ const fetchMedias = async (fetcher, { id, isSample, isStorefront })=>{
106
106
  const initVariables = {
107
107
  orderBy,
108
108
  where: {
@@ -4,7 +4,7 @@ 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 })=>{
8
8
  const products = await loopFetchProducts(fetcher, {
9
9
  ids,
10
10
  isSample,
@@ -61,7 +61,7 @@ const fetchProducts = async (fetcher, variables)=>{
61
61
  variables
62
62
  ]);
63
63
  };
64
- const loopFetchProducts = async (fetcher, { ids , isSample , isStorefront })=>{
64
+ const loopFetchProducts = async (fetcher, { ids, isSample, isStorefront })=>{
65
65
  const numberOfProducts = (ids?.length == 0 ? 4 : ids?.length) ?? 4;
66
66
  const productsPerPage = 8; // number of products per page
67
67
  let variables; // variables of collection query
@@ -118,7 +118,7 @@ const loopFetchProducts = async (fetcher, { ids , isSample , isStorefront })=>{
118
118
  }
119
119
  return dataProducts;
120
120
  };
121
- const mergeVariantsToProducts = async ({ fetcher , products , isSample , isStorefront })=>{
121
+ const mergeVariantsToProducts = async ({ fetcher, products, isSample, isStorefront })=>{
122
122
  const productsWithVariants = await Promise.all(products?.products?.edges?.map(async (product)=>{
123
123
  const variants = await getProduct.fetchVariants(fetcher, {
124
124
  id: product?.node?.baseID,
@@ -132,7 +132,7 @@ const mergeVariantsToProducts = async ({ fetcher , products , isSample , isStore
132
132
  }) ?? []);
133
133
  return productsWithVariants;
134
134
  };
135
- const mergeMediasToProducts = async ({ fetcher , products , isSample , isStorefront })=>{
135
+ const mergeMediasToProducts = async ({ fetcher, products, isSample, isStorefront })=>{
136
136
  const productsWithMedias = await Promise.all(products?.products?.edges?.map(async (product)=>{
137
137
  const medias = await getProduct.fetchMedias(fetcher, {
138
138
  id: product?.node?.baseID,
@@ -101,7 +101,7 @@ const composeCornerCss = (value)=>{
101
101
  if (!value) {
102
102
  return;
103
103
  }
104
- const { radiusType , bblr , bbrr , btlr , btrr } = value;
104
+ const { radiusType, bblr, bbrr, btlr, btrr } = value;
105
105
  let radiusValue = undefined;
106
106
  switch(radiusType){
107
107
  case 'medium':
@@ -20,12 +20,12 @@ const parseValueWithUnit = (valueWithUnit)=>{
20
20
  };
21
21
  };
22
22
  const getStyleShadow = (shadowStyle, isActiveState = false)=>{
23
- const { styleAppliedFor , value , isEnableShadow } = shadowStyle || {};
24
- let { state } = shadowStyle || {};
23
+ const { styleAppliedFor, value, isEnableShadow } = shadowStyle || {};
24
+ let { state } = shadowStyle || {};
25
25
  if (!state) state = 'normal';
26
26
  if (!styleAppliedFor || !value) return {};
27
27
  if (typeof value.distance == 'undefined') return {};
28
- const { value: distance , unit: unitDistance } = parseValueWithUnit(`${value?.distance}`);
28
+ const { value: distance, unit: unitDistance } = parseValueWithUnit(`${value?.distance}`);
29
29
  return {
30
30
  [`-${!isActiveState ? constant.stateMapping?.[state] : ''}-${getShortname.getShortName(styleAppliedFor)}`]: isEnableShadow ? `${Math.cos(parseFloat(`${value?.angle}`) * Math.PI / 180) * parseFloat(`${distance}`)}${unitDistance} ${Math.sin(parseFloat(`${value?.angle}`) * Math.PI / 180) * parseFloat(`${distance}`)}${unitDistance} ${value?.blur} ${styleAppliedFor === 'box-shadow' ? value?.spread + ' ' : ''}${colors.getSingleColorVariable(value?.color)}` : 'none'
31
31
  };
@@ -43,10 +43,10 @@ const getStyleShadowState = (shadow, styleAppliedFor, isEnableShadow)=>{
43
43
  }
44
44
  return style;
45
45
  };
46
- const composeShadowCss = ({ hasBoxShadow , boxShadowValue })=>{
46
+ const composeShadowCss = ({ hasBoxShadow, boxShadowValue })=>{
47
47
  if (!hasBoxShadow) return undefined;
48
48
  if (!boxShadowValue) return undefined;
49
- const { value: distance , unit: unitDistance } = parseValueWithUnit(`${boxShadowValue?.distance}`);
49
+ const { value: distance, unit: unitDistance } = parseValueWithUnit(`${boxShadowValue?.distance}`);
50
50
  return `box-shadow: ${Math.cos(parseFloat(`${boxShadowValue?.angle}`) * Math.PI / 180) * parseFloat(`${distance}`)}${unitDistance} ${Math.sin(parseFloat(`${boxShadowValue?.angle}`) * Math.PI / 180) * parseFloat(`${distance}`)}${unitDistance} ${boxShadowValue?.blur} ${boxShadowValue?.spread + ' '}${colors.getSingleColorVariable(boxShadowValue?.color)};`;
51
51
  };
52
52
 
@@ -8,7 +8,7 @@ const genTypoClass = (name)=>{
8
8
  };
9
9
  const composeTypographyCss = (typography)=>{
10
10
  const typographyCustom = typography?.custom;
11
- const { fontFamily , fontSize , fontStyle , fontWeight , lineHeight , letterSpacing } = typographyCustom?.desktop ?? {};
11
+ const { fontFamily, fontSize, fontStyle, fontWeight, lineHeight, letterSpacing } = typographyCustom?.desktop ?? {};
12
12
  return `
13
13
  ${fontFamily ? `font-family: var(--g-font-${fontFamily}, ${fontFamily});` : ''}
14
14
  ${fontSize ? `font-size: ${fontSize};` : ''}
@@ -20,9 +20,9 @@ const composeTypographyCss = (typography)=>{
20
20
  };
21
21
  const composeTypographyV2Css = (typography)=>{
22
22
  const typographyCustom = typography?.custom;
23
- const { fontFamily , fontSize , fontWeight , lineHeight , letterSpacing } = typographyCustom ?? {};
23
+ const { fontFamily, fontSize, fontWeight, lineHeight, letterSpacing } = typographyCustom ?? {};
24
24
  const typographyAttrs = typography?.attrs;
25
- const { bold , italic , underline , transform } = typographyAttrs ?? {};
25
+ const { bold, italic, underline, transform } = typographyAttrs ?? {};
26
26
  return `
27
27
  ${fontFamily ? `font-family: var(--g-font-${fontFamily}, ${fontFamily});` : ''}
28
28
  ${fontSize?.desktop ? `font-size: ${fontSize?.desktop};` : ''}
@@ -37,7 +37,7 @@ const composeTypographyV2Css = (typography)=>{
37
37
  function getCustomCSSByDevice(typography, device) {
38
38
  if (!typography || !device) return {};
39
39
  const suffix = device === 'desktop' || !device ? '' : `-${device}`;
40
- const { fontFamily } = typography?.[device] ?? {};
40
+ const { fontFamily } = typography?.[device] ?? {};
41
41
  return {
42
42
  [`--size${suffix}`]: typography?.[device]?.fontSize,
43
43
  [`--lh${suffix}`]: typography?.[device]?.lineHeight,
@@ -7,8 +7,8 @@ var shop = require('../shop.js');
7
7
 
8
8
  const useAddToCart = (options)=>{
9
9
  const shop$1 = shop.useStoreFront();
10
- const { mutate } = useSWR.useSWRConfig();
11
- return useSWRMutation('add-to-cart', (_, { arg })=>adapterShopify.addToCartOperation(shop$1)(arg), {
10
+ const { mutate } = useSWR.useSWRConfig();
11
+ return useSWRMutation('add-to-cart', (_, { arg })=>adapterShopify.addToCartOperation(shop$1)(arg), {
12
12
  ...options,
13
13
  onSuccess: (result, key, config)=>{
14
14
  mutate('cart', result, false);
@@ -6,7 +6,7 @@ var shop = require('../shop.js');
6
6
  var useCartId = require('../useCartId.js');
7
7
 
8
8
  const useCartData = (options)=>{
9
- const { cartId , clearCartId } = useCartId.default();
9
+ const { cartId, clearCartId } = useCartId.default();
10
10
  const shop$1 = shop.useStoreFront();
11
11
  return useSWR(cartId ? 'cart' : null, ()=>adapterShopify.getCartOperation(shop$1)({
12
12
  cartId: cartId
@@ -7,8 +7,8 @@ var shop = require('../shop.js');
7
7
 
8
8
  const useCartDiscountCodesUpdate = (options)=>{
9
9
  const shop$1 = shop.useStoreFront();
10
- const { mutate } = useSWR.useSWRConfig();
11
- return useSWRMutation('cart-discount-codes-update', (_, { arg })=>adapterShopify.cartDiscountCodesUpdateOperation(shop$1)(arg), {
10
+ const { mutate } = useSWR.useSWRConfig();
11
+ return useSWRMutation('cart-discount-codes-update', (_, { arg })=>adapterShopify.cartDiscountCodesUpdateOperation(shop$1)(arg), {
12
12
  ...options,
13
13
  onSuccess: (result, key, config)=>{
14
14
  mutate('cart', result, false);
@@ -7,8 +7,8 @@ var shop = require('../shop.js');
7
7
 
8
8
  const useCartNoteUpdate = (options)=>{
9
9
  const shop$1 = shop.useStoreFront();
10
- const { mutate } = useSWR.useSWRConfig();
11
- return useSWRMutation('cart-note-update', (_, { arg })=>adapterShopify.cartNoteUpdateOperation(shop$1)(arg), {
10
+ const { mutate } = useSWR.useSWRConfig();
11
+ return useSWRMutation('cart-note-update', (_, { arg })=>adapterShopify.cartNoteUpdateOperation(shop$1)(arg), {
12
12
  ...options,
13
13
  onSuccess: (result, key, config)=>{
14
14
  mutate('cart', result, false);
@@ -7,8 +7,8 @@ var shop = require('../shop.js');
7
7
 
8
8
  const useCreateCart = (options)=>{
9
9
  const shop$1 = shop.useStoreFront();
10
- const { mutate } = useSWR.useSWRConfig();
11
- return useSWRMutation('create-cart', (_, { arg })=>{
10
+ const { mutate } = useSWR.useSWRConfig();
11
+ return useSWRMutation('create-cart', (_, { arg })=>{
12
12
  return adapterShopify.createCartOperation(shop$1)(arg);
13
13
  }, {
14
14
  ...options,
@@ -7,8 +7,8 @@ var shop = require('../shop.js');
7
7
 
8
8
  const useRemoveCartItem = (options)=>{
9
9
  const shop$1 = shop.useStoreFront();
10
- const { mutate } = useSWR.useSWRConfig();
11
- return useSWRMutation('remove-cart-item', (_, { arg })=>adapterShopify.removeCartItemOperation(shop$1)(arg), {
10
+ const { mutate } = useSWR.useSWRConfig();
11
+ return useSWRMutation('remove-cart-item', (_, { arg })=>adapterShopify.removeCartItemOperation(shop$1)(arg), {
12
12
  ...options,
13
13
  onSuccess: (result, key, config)=>{
14
14
  mutate('cart', result, false);
@@ -7,8 +7,8 @@ var shop = require('../shop.js');
7
7
 
8
8
  const useUpdateCartItem = (options)=>{
9
9
  const shop$1 = shop.useStoreFront();
10
- const { mutate } = useSWR.useSWRConfig();
11
- return useSWRMutation('update-cart-item', (_, { arg })=>adapterShopify.updateCartLineOperation(shop$1)(arg), {
10
+ const { mutate } = useSWR.useSWRConfig();
11
+ return useSWRMutation('update-cart-item', (_, { arg })=>adapterShopify.updateCartLineOperation(shop$1)(arg), {
12
12
  ...options,
13
13
  onSuccess: (result, key, config)=>{
14
14
  mutate('cart', result, false);
@@ -74,7 +74,7 @@ const useMobileOnly = ()=>{
74
74
  return ShopContext.useShopStore((state)=>state.mobileOnly);
75
75
  };
76
76
  const useMatchMutate = ()=>{
77
- const { cache , mutate } = useSWR.useSWRConfig();
77
+ const { cache, mutate } = useSWR.useSWRConfig();
78
78
  return (matcher, opts)=>{
79
79
  if (!(cache instanceof Map)) {
80
80
  throw new Error('matchMutate requires the cache provider to be a Map instance');
@@ -93,11 +93,11 @@ const useMatchMutate = ()=>{
93
93
  };
94
94
  };
95
95
  function useConnectedShopify() {
96
- const { storefrontToken } = useStoreFront();
96
+ const { storefrontToken } = useStoreFront();
97
97
  return !!storefrontToken;
98
98
  }
99
99
  function useIsSampleProduct() {
100
- const { storefrontToken } = useStoreFront();
100
+ const { storefrontToken } = useStoreFront();
101
101
  const isStorefront = ShopContext.useShopStore((state)=>state.isStorefront);
102
102
  return isStorefront && !storefrontToken;
103
103
  }
@@ -105,7 +105,7 @@ function useIsStorefrontProduct() {
105
105
  return ShopContext.useShopStore((state)=>state.isStorefront);
106
106
  }
107
107
  function useCheckoutUrl(url) {
108
- const { storefrontToken } = useStoreFront();
108
+ const { storefrontToken } = useStoreFront();
109
109
  if (!url) return undefined;
110
110
  return storefrontToken ? `${url}?access_token=${storefrontToken}` : url;
111
111
  }
@@ -3,7 +3,7 @@
3
3
  var useSWR = require('swr');
4
4
 
5
5
  const useFetchHandle = ()=>{
6
- const { fetcher } = useSWR.useSWRConfig();
6
+ const { fetcher } = useSWR.useSWRConfig();
7
7
  if (!fetcher) {
8
8
  throw new Error('Application must be init within a fetcher');
9
9
  }
@@ -3,7 +3,7 @@
3
3
  var shop = require('./shop.js');
4
4
 
5
5
  const useFormatMoney = (amount, withCurrency)=>{
6
- const { moneyFormat , moneyWithCurrencyFormat } = shop.useMoneyFormat();
6
+ const { moneyFormat, moneyWithCurrencyFormat } = shop.useMoneyFormat();
7
7
  const formatMoney = function(cents, format) {
8
8
  let value = '';
9
9
  const placeholderRegex = /\{\{\s*(\w+)\s*\}\}/;