@gem-sdk/core 1.5.17 → 1.5.23

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 (206) hide show
  1. package/dist/cjs/components/AddOn.js +7 -7
  2. package/dist/cjs/components/ComponentWrapper.js +14 -8
  3. package/dist/cjs/components/ComponentWrapperPreview.js +55 -46
  4. package/dist/cjs/components/Empty.js +1 -1
  5. package/dist/cjs/components/Render.js +50 -13
  6. package/dist/cjs/components/Render.liquid.js +81 -57
  7. package/dist/cjs/components/RenderBlock.js +41 -8
  8. package/dist/cjs/components/RenderPreview.js +51 -13
  9. package/dist/cjs/components/RenderSection.js +11 -7
  10. package/dist/cjs/components/constant.js +24 -24
  11. package/dist/cjs/contexts/AddonContext.js +25 -14
  12. package/dist/cjs/contexts/BuilderComponent.js +23 -19
  13. package/dist/cjs/contexts/BuilderContext.js +25 -19
  14. package/dist/cjs/contexts/BuilderPreviewContext.js +349 -341
  15. package/dist/cjs/contexts/CartLineContext.js +19 -14
  16. package/dist/cjs/contexts/CollectionContext.js +21 -13
  17. package/dist/cjs/contexts/ProductContext.js +136 -115
  18. package/dist/cjs/contexts/ProductListContext.js +21 -13
  19. package/dist/cjs/contexts/SectionContext.js +41 -37
  20. package/dist/cjs/contexts/ShopContext.js +54 -31
  21. package/dist/cjs/graphql/fragments/analytic.generated.js +1 -1
  22. package/dist/cjs/graphql/fragments/collection-detail.generated.js +1 -1
  23. package/dist/cjs/graphql/fragments/collection-product.generated.js +1 -1
  24. package/dist/cjs/graphql/fragments/custom-code.generated.js +1 -1
  25. package/dist/cjs/graphql/fragments/data-seo.generated.js +1 -1
  26. package/dist/cjs/graphql/fragments/media.generated.js +1 -1
  27. package/dist/cjs/graphql/fragments/product-little.generated.js +1 -1
  28. package/dist/cjs/graphql/fragments/product-option-value.generated.js +1 -1
  29. package/dist/cjs/graphql/fragments/product-option.generated.js +1 -1
  30. package/dist/cjs/graphql/fragments/product.generated.js +1 -1
  31. package/dist/cjs/graphql/fragments/published-custom-section.generated.js +1 -1
  32. package/dist/cjs/graphql/fragments/published-page-section.generated.js +1 -1
  33. package/dist/cjs/graphql/fragments/published-theme-page.generated.js +1 -1
  34. package/dist/cjs/graphql/fragments/published-theme-style.generated.js +1 -1
  35. package/dist/cjs/graphql/fragments/selected-option.generated.js +1 -1
  36. package/dist/cjs/graphql/fragments/variant.generated.js +1 -1
  37. package/dist/cjs/graphql/mutations/page-view-up.generated.js +1 -1
  38. package/dist/cjs/graphql/queries/products.generated.js +1 -1
  39. package/dist/cjs/graphql/queries/store-property.generated.js +1 -1
  40. package/dist/cjs/helpers/GlobalEvent.js +12 -10
  41. package/dist/cjs/helpers/background.js +96 -96
  42. package/dist/cjs/helpers/borders.js +123 -127
  43. package/dist/cjs/helpers/clone-deep.js +1 -1
  44. package/dist/cjs/helpers/cls.js +11 -15
  45. package/dist/cjs/helpers/colors.js +121 -156
  46. package/dist/cjs/helpers/compose-advance-style.js +115 -121
  47. package/dist/cjs/helpers/constant.js +16 -11
  48. package/dist/cjs/helpers/css-variable.js +2 -2
  49. package/dist/cjs/helpers/email.js +3 -3
  50. package/dist/cjs/helpers/flatten-connection.js +4 -5
  51. package/dist/cjs/helpers/get-resonsive-value.js +24 -25
  52. package/dist/cjs/helpers/get-shortname.js +87 -87
  53. package/dist/cjs/helpers/is-browser.js +2 -2
  54. package/dist/cjs/helpers/is-defined.js +2 -2
  55. package/dist/cjs/helpers/is-empty-children.js +2 -2
  56. package/dist/cjs/helpers/layout.js +9 -10
  57. package/dist/cjs/helpers/load-script.js +26 -27
  58. package/dist/cjs/helpers/make-style.js +77 -86
  59. package/dist/cjs/helpers/normalize-builder-data.js +18 -12
  60. package/dist/cjs/helpers/prefetch-queries.js +72 -52
  61. package/dist/cjs/helpers/product.js +25 -29
  62. package/dist/cjs/helpers/queries/get-collection.js +179 -167
  63. package/dist/cjs/helpers/queries/get-product-by-slug.js +103 -94
  64. package/dist/cjs/helpers/queries/get-product.js +121 -106
  65. package/dist/cjs/helpers/queries/get-products.js +137 -125
  66. package/dist/cjs/helpers/radius.js +78 -81
  67. package/dist/cjs/helpers/render.js +56 -56
  68. package/dist/cjs/helpers/shadow.js +38 -38
  69. package/dist/cjs/helpers/size.js +12 -13
  70. package/dist/cjs/helpers/spacing.js +35 -37
  71. package/dist/cjs/helpers/tracking/fpixel.js +21 -22
  72. package/dist/cjs/helpers/tracking/gtag.js +84 -90
  73. package/dist/cjs/helpers/tracking/tiktokpixel.js +12 -12
  74. package/dist/cjs/helpers/typography.js +2 -2
  75. package/dist/cjs/hooks/cart/use-add-to-cart.js +10 -10
  76. package/dist/cjs/hooks/cart/use-cart-data.js +18 -16
  77. package/dist/cjs/hooks/cart/use-cart-discount-codes-update.js +10 -10
  78. package/dist/cjs/hooks/cart/use-cart-note-update.js +10 -10
  79. package/dist/cjs/hooks/cart/use-create-cart.js +12 -12
  80. package/dist/cjs/hooks/cart/use-remove-cart-item.js +10 -10
  81. package/dist/cjs/hooks/cart/use-update-cart-item.js +10 -10
  82. package/dist/cjs/hooks/shop/use-collection-query.js +12 -6
  83. package/dist/cjs/hooks/shop/use-product-query.js +12 -6
  84. package/dist/cjs/hooks/shop/use-products-query.js +14 -6
  85. package/dist/cjs/hooks/shop.js +86 -67
  86. package/dist/cjs/hooks/use-current-device.js +14 -16
  87. package/dist/cjs/hooks/use-lazy-video.js +7 -7
  88. package/dist/cjs/hooks/useCartId.js +35 -27
  89. package/dist/cjs/hooks/useCartLine.js +2 -2
  90. package/dist/cjs/hooks/useCartUI.js +37 -31
  91. package/dist/cjs/hooks/useCollection.js +2 -2
  92. package/dist/cjs/hooks/useFetchHandle.js +6 -6
  93. package/dist/cjs/hooks/useFormatMoney.js +11 -7
  94. package/dist/cjs/hooks/useIsomorphicLayoutEffect.js +1 -1
  95. package/dist/cjs/hooks/useLoadScript.js +22 -20
  96. package/dist/cjs/hooks/useMoney.js +59 -42
  97. package/dist/cjs/hooks/usePrevious.js +12 -10
  98. package/dist/cjs/hooks/useProduct.js +92 -69
  99. package/dist/cjs/hooks/useProductList.js +11 -11
  100. package/dist/cjs/hooks/useSuspenseFetch.js +20 -17
  101. package/dist/cjs/hooks/useSwatchesOptions.js +32 -30
  102. package/dist/cjs/types/global-style.js +9 -2
  103. package/dist/esm/components/AddOn.js +7 -7
  104. package/dist/esm/components/ComponentWrapper.js +14 -8
  105. package/dist/esm/components/ComponentWrapperPreview.js +55 -46
  106. package/dist/esm/components/Empty.js +1 -1
  107. package/dist/esm/components/Render.js +50 -13
  108. package/dist/esm/components/Render.liquid.js +81 -57
  109. package/dist/esm/components/RenderBlock.js +41 -8
  110. package/dist/esm/components/RenderPreview.js +51 -13
  111. package/dist/esm/components/RenderSection.js +11 -7
  112. package/dist/esm/components/constant.js +24 -24
  113. package/dist/esm/contexts/AddonContext.js +26 -15
  114. package/dist/esm/contexts/BuilderComponent.js +24 -20
  115. package/dist/esm/contexts/BuilderContext.js +26 -20
  116. package/dist/esm/contexts/BuilderPreviewContext.js +350 -342
  117. package/dist/esm/contexts/CartLineContext.js +20 -15
  118. package/dist/esm/contexts/CollectionContext.js +22 -14
  119. package/dist/esm/contexts/ProductContext.js +137 -116
  120. package/dist/esm/contexts/ProductListContext.js +22 -14
  121. package/dist/esm/contexts/SectionContext.js +42 -38
  122. package/dist/esm/contexts/ShopContext.js +55 -32
  123. package/dist/esm/graphql/fragments/analytic.generated.js +1 -1
  124. package/dist/esm/graphql/fragments/collection-detail.generated.js +1 -1
  125. package/dist/esm/graphql/fragments/collection-product.generated.js +1 -1
  126. package/dist/esm/graphql/fragments/custom-code.generated.js +1 -1
  127. package/dist/esm/graphql/fragments/data-seo.generated.js +1 -1
  128. package/dist/esm/graphql/fragments/media.generated.js +1 -1
  129. package/dist/esm/graphql/fragments/product-little.generated.js +1 -1
  130. package/dist/esm/graphql/fragments/product-option-value.generated.js +1 -1
  131. package/dist/esm/graphql/fragments/product-option.generated.js +1 -1
  132. package/dist/esm/graphql/fragments/product.generated.js +1 -1
  133. package/dist/esm/graphql/fragments/published-custom-section.generated.js +1 -1
  134. package/dist/esm/graphql/fragments/published-page-section.generated.js +1 -1
  135. package/dist/esm/graphql/fragments/published-theme-page.generated.js +1 -1
  136. package/dist/esm/graphql/fragments/published-theme-style.generated.js +1 -1
  137. package/dist/esm/graphql/fragments/selected-option.generated.js +1 -1
  138. package/dist/esm/graphql/fragments/variant.generated.js +1 -1
  139. package/dist/esm/graphql/mutations/page-view-up.generated.js +1 -1
  140. package/dist/esm/graphql/queries/products.generated.js +1 -1
  141. package/dist/esm/graphql/queries/store-property.generated.js +1 -1
  142. package/dist/esm/helpers/GlobalEvent.js +12 -10
  143. package/dist/esm/helpers/background.js +96 -96
  144. package/dist/esm/helpers/borders.js +123 -127
  145. package/dist/esm/helpers/clone-deep.js +1 -1
  146. package/dist/esm/helpers/cls.js +11 -15
  147. package/dist/esm/helpers/colors.js +121 -156
  148. package/dist/esm/helpers/compose-advance-style.js +115 -121
  149. package/dist/esm/helpers/constant.js +16 -11
  150. package/dist/esm/helpers/css-variable.js +2 -2
  151. package/dist/esm/helpers/email.js +3 -3
  152. package/dist/esm/helpers/flatten-connection.js +4 -5
  153. package/dist/esm/helpers/get-resonsive-value.js +24 -25
  154. package/dist/esm/helpers/get-shortname.js +87 -87
  155. package/dist/esm/helpers/is-browser.js +2 -2
  156. package/dist/esm/helpers/is-defined.js +2 -2
  157. package/dist/esm/helpers/is-empty-children.js +2 -2
  158. package/dist/esm/helpers/layout.js +9 -10
  159. package/dist/esm/helpers/load-script.js +26 -27
  160. package/dist/esm/helpers/make-style.js +77 -86
  161. package/dist/esm/helpers/normalize-builder-data.js +18 -12
  162. package/dist/esm/helpers/prefetch-queries.js +72 -52
  163. package/dist/esm/helpers/product.js +25 -29
  164. package/dist/esm/helpers/queries/get-collection.js +179 -167
  165. package/dist/esm/helpers/queries/get-product-by-slug.js +103 -94
  166. package/dist/esm/helpers/queries/get-product.js +121 -106
  167. package/dist/esm/helpers/queries/get-products.js +137 -125
  168. package/dist/esm/helpers/radius.js +78 -81
  169. package/dist/esm/helpers/render.js +56 -56
  170. package/dist/esm/helpers/shadow.js +38 -38
  171. package/dist/esm/helpers/size.js +12 -13
  172. package/dist/esm/helpers/spacing.js +35 -37
  173. package/dist/esm/helpers/tracking/fpixel.js +21 -22
  174. package/dist/esm/helpers/tracking/gtag.js +84 -90
  175. package/dist/esm/helpers/tracking/tiktokpixel.js +12 -12
  176. package/dist/esm/helpers/typography.js +2 -2
  177. package/dist/esm/hooks/cart/use-add-to-cart.js +10 -10
  178. package/dist/esm/hooks/cart/use-cart-data.js +18 -16
  179. package/dist/esm/hooks/cart/use-cart-discount-codes-update.js +10 -10
  180. package/dist/esm/hooks/cart/use-cart-note-update.js +10 -10
  181. package/dist/esm/hooks/cart/use-create-cart.js +12 -12
  182. package/dist/esm/hooks/cart/use-remove-cart-item.js +10 -10
  183. package/dist/esm/hooks/cart/use-update-cart-item.js +10 -10
  184. package/dist/esm/hooks/shop/use-collection-query.js +12 -6
  185. package/dist/esm/hooks/shop/use-product-query.js +12 -6
  186. package/dist/esm/hooks/shop/use-products-query.js +14 -6
  187. package/dist/esm/hooks/shop.js +86 -67
  188. package/dist/esm/hooks/use-current-device.js +14 -16
  189. package/dist/esm/hooks/use-lazy-video.js +7 -7
  190. package/dist/esm/hooks/useCartId.js +35 -27
  191. package/dist/esm/hooks/useCartLine.js +2 -2
  192. package/dist/esm/hooks/useCartUI.js +37 -31
  193. package/dist/esm/hooks/useCollection.js +2 -2
  194. package/dist/esm/hooks/useFetchHandle.js +6 -6
  195. package/dist/esm/hooks/useFormatMoney.js +11 -7
  196. package/dist/esm/hooks/useIsomorphicLayoutEffect.js +1 -1
  197. package/dist/esm/hooks/useLoadScript.js +22 -20
  198. package/dist/esm/hooks/useMoney.js +59 -42
  199. package/dist/esm/hooks/usePrevious.js +12 -10
  200. package/dist/esm/hooks/useProduct.js +92 -69
  201. package/dist/esm/hooks/useProductList.js +11 -11
  202. package/dist/esm/hooks/useSuspenseFetch.js +20 -17
  203. package/dist/esm/hooks/useSwatchesOptions.js +32 -30
  204. package/dist/esm/types/global-style.js +9 -2
  205. package/dist/types/index.d.ts +30 -2
  206. package/package.json +1 -1
@@ -2,19 +2,18 @@
2
2
 
3
3
  var constant = require('./constant.js');
4
4
 
5
- function getCustomSizeCSSByDevice(size, device) {
6
- if (!size || !device)
7
- return {};
8
- const suffix = constant.devicesMapping[device] ?? '';
9
- return {
10
- [`--pl${suffix}`]: size?.[device]?.horizontal,
11
- [`--pr${suffix}`]: size?.[device]?.horizontal,
12
- [`--pt${suffix}`]: size?.[device]?.vertical,
13
- [`--pb${suffix}`]: size?.[device]?.vertical,
14
- };
15
- }
16
- const composeSize = (size) => {
17
- return Object.assign({}, getCustomSizeCSSByDevice(size, 'desktop'), getCustomSizeCSSByDevice(size, 'tablet'), getCustomSizeCSSByDevice(size, 'mobile'));
5
+ function getCustomSizeCSSByDevice(size, device) {
6
+ if (!size || !device) return {};
7
+ const suffix = constant.devicesMapping[device] ?? '';
8
+ return {
9
+ [`--pl${suffix}`]: size?.[device]?.horizontal,
10
+ [`--pr${suffix}`]: size?.[device]?.horizontal,
11
+ [`--pt${suffix}`]: size?.[device]?.vertical,
12
+ [`--pb${suffix}`]: size?.[device]?.vertical
13
+ };
14
+ }
15
+ const composeSize = (size)=>{
16
+ return Object.assign({}, getCustomSizeCSSByDevice(size, 'desktop'), getCustomSizeCSSByDevice(size, 'tablet'), getCustomSizeCSSByDevice(size, 'mobile'));
18
17
  };
19
18
 
20
19
  exports.composeSize = composeSize;
@@ -2,43 +2,41 @@
2
2
 
3
3
  var constant = require('./constant.js');
4
4
 
5
- function getSpacingCSSByType(key, device) {
6
- if (!key)
7
- return {};
8
- const suffix = device ? constant.devicesMapping?.[device] ?? '' : '';
9
- return {
10
- [`--p${suffix}`]: `var(--g-s-${key})`,
11
- };
12
- }
13
- function getSpacingVariable(key) {
14
- if (!key)
15
- return '';
16
- return `var(--g-s-${key})`;
17
- }
18
- const composeSpacing = (spacingValue) => {
19
- const style = {};
20
- switch (spacingValue?.desktop) {
21
- case 'm':
22
- case 'l':
23
- case 's':
24
- Object.assign(style, getSpacingCSSByType(spacingValue.desktop));
25
- break;
26
- }
27
- switch (spacingValue?.tablet) {
28
- case 'm':
29
- case 'l':
30
- case 's':
31
- Object.assign(style, getSpacingCSSByType(spacingValue.tablet, 'tablet'));
32
- break;
33
- }
34
- switch (spacingValue?.mobile) {
35
- case 'm':
36
- case 'l':
37
- case 's':
38
- Object.assign(style, getSpacingCSSByType(spacingValue.mobile, 'mobile'));
39
- break;
40
- }
41
- return style;
5
+ function getSpacingCSSByType(key, device) {
6
+ if (!key) return {};
7
+ const suffix = device ? constant.devicesMapping?.[device] ?? '' : '';
8
+ return {
9
+ [`--p${suffix}`]: `var(--g-s-${key})`
10
+ };
11
+ }
12
+ function getSpacingVariable(key) {
13
+ if (!key) return '';
14
+ return `var(--g-s-${key})`;
15
+ }
16
+ const composeSpacing = (spacingValue)=>{
17
+ const style = {};
18
+ switch(spacingValue?.desktop){
19
+ case 'm':
20
+ case 'l':
21
+ case 's':
22
+ Object.assign(style, getSpacingCSSByType(spacingValue.desktop));
23
+ break;
24
+ }
25
+ switch(spacingValue?.tablet){
26
+ case 'm':
27
+ case 'l':
28
+ case 's':
29
+ Object.assign(style, getSpacingCSSByType(spacingValue.tablet, 'tablet'));
30
+ break;
31
+ }
32
+ switch(spacingValue?.mobile){
33
+ case 'm':
34
+ case 'l':
35
+ case 's':
36
+ Object.assign(style, getSpacingCSSByType(spacingValue.mobile, 'mobile'));
37
+ break;
38
+ }
39
+ return style;
42
40
  };
43
41
 
44
42
  exports.composeSpacing = composeSpacing;
@@ -1,27 +1,26 @@
1
1
  'use strict';
2
2
 
3
- const pageview = () => {
4
- if (!window.fbq)
5
- return;
6
- window.fbq('track', 'PageView');
7
- };
8
- // https://developers.facebook.com/docs/facebook-pixel/advanced/
9
- const event = (name, options = {}) => {
10
- if (!window.fbq)
11
- return;
12
- window.fbq('track', name, options);
13
- };
14
- const addToCart = (product) => {
15
- if (!window.fbq)
16
- return;
17
- window.fbq('track', 'AddToCart', {
18
- content_ids: [product.id],
19
- content_name: product.name,
20
- content_category: product.category,
21
- content_type: 'product',
22
- value: product.price,
23
- currency: product.currency,
24
- });
3
+ const pageview = ()=>{
4
+ if (!window.fbq) return;
5
+ window.fbq('track', 'PageView');
6
+ };
7
+ // https://developers.facebook.com/docs/facebook-pixel/advanced/
8
+ const event = (name, options = {})=>{
9
+ if (!window.fbq) return;
10
+ window.fbq('track', name, options);
11
+ };
12
+ const addToCart = (product)=>{
13
+ if (!window.fbq) return;
14
+ window.fbq('track', 'AddToCart', {
15
+ content_ids: [
16
+ product.id
17
+ ],
18
+ content_name: product.name,
19
+ content_category: product.category,
20
+ content_type: 'product',
21
+ value: product.price,
22
+ currency: product.currency
23
+ });
25
24
  };
26
25
 
27
26
  exports.addToCart = addToCart;
@@ -1,95 +1,89 @@
1
1
  'use strict';
2
2
 
3
- // https://developers.google.com/analytics/devguides/collection/gtagjs/pages
4
- const pageview = (url, trackingId) => {
5
- // GA 4
6
- if (window.gtag && trackingId) {
7
- window.gtag('config', trackingId, {
8
- page_path: url,
9
- });
10
- }
11
- // GA 3
12
- if (window.ga) {
13
- window.ga('send', 'pageview', url);
14
- }
15
- };
16
- /** Addition to cart events
17
- * https://developers.google.com/analytics/devguides/collection/analyticsjs/enhanced-ecommerce#add-remove-cart
18
- */
19
- const addToCart = (product) => {
20
- // GA 3
21
- if (!window.ga || !product) {
22
- return;
23
- }
24
- window.ga('ec:addProduct', {
25
- ...product,
26
- id: product.sku,
27
- name: product.variant === 'Default Title' ? product.name : `${product.name} - ${product.variant}`,
28
- variant: product.variant === 'Default Title' ? product.name : product.variant,
29
- });
30
- window.ga('ec:setAction', 'add');
31
- window.ga('send', 'event', {
32
- eventCategory: 'EnhancedEcommerce',
33
- eventAction: 'Added Product',
34
- nonInteraction: true,
35
- });
36
- };
37
- /** Product clicked event
38
- * https://developers.google.com/analytics/devguides/collection/analyticsjs/enhanced-ecommerce#product-click
39
- */
40
- const productClick = (product) => {
41
- if (!window.ga) {
42
- return;
43
- }
44
- ga('ec:addProduct', {
45
- id: product.id,
46
- name: product.name,
47
- category: product.category,
48
- brand: product.brand,
49
- variant: product.variant,
50
- });
51
- ga('ec:setAction', 'click');
52
- ga('send', 'event', {
53
- eventAction: 'Click',
54
- eventCategory: 'Product',
55
- });
56
- };
57
- /** Product viewed event
58
- * https://developers.google.com/analytics/devguides/collection/analyticsjs/enhanced-ecommerce#measuring-actvities
59
- */
60
- const productDetail = (product) => {
61
- if (!product || !window.ga)
62
- return;
63
- ga('ec:addProduct', {
64
- brand: product.brand,
65
- category: product.category,
66
- id: product.id,
67
- name: product.name,
68
- variant: product.variant,
69
- });
70
- ga('ec:setAction', 'detail');
71
- ga('send', 'event', {
72
- eventAction: 'Detail',
73
- eventCategory: 'Ecommerce',
74
- nonInteraction: 1,
75
- });
76
- };
77
- /** Removal from cart events
78
- * https://developers.google.com/analytics/devguides/collection/analyticsjs/enhanced-ecommerce#add-remove-cart
79
- */
80
- const removeFromCart = (product, price) => {
81
- if (!product || !window.ga)
82
- return;
83
- ga('ec:addProduct', {
84
- id: product.id,
85
- name: product.name,
86
- price,
87
- });
88
- ga('ec:setAction', 'remove');
89
- ga('send', 'event', {
90
- eventAction: 'Click',
91
- eventCategory: 'Remove from cart',
92
- });
3
+ // https://developers.google.com/analytics/devguides/collection/gtagjs/pages
4
+ const pageview = (url, trackingId)=>{
5
+ // GA 4
6
+ if (window.gtag && trackingId) {
7
+ window.gtag('config', trackingId, {
8
+ page_path: url
9
+ });
10
+ }
11
+ // GA 3
12
+ if (window.ga) {
13
+ window.ga('send', 'pageview', url);
14
+ }
15
+ };
16
+ /** Addition to cart events
17
+ * https://developers.google.com/analytics/devguides/collection/analyticsjs/enhanced-ecommerce#add-remove-cart
18
+ */ const addToCart = (product)=>{
19
+ // GA 3
20
+ if (!window.ga || !product) {
21
+ return;
22
+ }
23
+ window.ga('ec:addProduct', {
24
+ ...product,
25
+ id: product.sku,
26
+ name: product.variant === 'Default Title' ? product.name : `${product.name} - ${product.variant}`,
27
+ variant: product.variant === 'Default Title' ? product.name : product.variant
28
+ });
29
+ window.ga('ec:setAction', 'add');
30
+ window.ga('send', 'event', {
31
+ eventCategory: 'EnhancedEcommerce',
32
+ eventAction: 'Added Product',
33
+ nonInteraction: true
34
+ });
35
+ };
36
+ /** Product clicked event
37
+ * https://developers.google.com/analytics/devguides/collection/analyticsjs/enhanced-ecommerce#product-click
38
+ */ const productClick = (product)=>{
39
+ if (!window.ga) {
40
+ return;
41
+ }
42
+ ga('ec:addProduct', {
43
+ id: product.id,
44
+ name: product.name,
45
+ category: product.category,
46
+ brand: product.brand,
47
+ variant: product.variant
48
+ });
49
+ ga('ec:setAction', 'click');
50
+ ga('send', 'event', {
51
+ eventAction: 'Click',
52
+ eventCategory: 'Product'
53
+ });
54
+ };
55
+ /** Product viewed event
56
+ * https://developers.google.com/analytics/devguides/collection/analyticsjs/enhanced-ecommerce#measuring-actvities
57
+ */ const productDetail = (product)=>{
58
+ if (!product || !window.ga) return;
59
+ ga('ec:addProduct', {
60
+ brand: product.brand,
61
+ category: product.category,
62
+ id: product.id,
63
+ name: product.name,
64
+ variant: product.variant
65
+ });
66
+ ga('ec:setAction', 'detail');
67
+ ga('send', 'event', {
68
+ eventAction: 'Detail',
69
+ eventCategory: 'Ecommerce',
70
+ nonInteraction: 1
71
+ });
72
+ };
73
+ /** Removal from cart events
74
+ * https://developers.google.com/analytics/devguides/collection/analyticsjs/enhanced-ecommerce#add-remove-cart
75
+ */ const removeFromCart = (product, price)=>{
76
+ if (!product || !window.ga) return;
77
+ ga('ec:addProduct', {
78
+ id: product.id,
79
+ name: product.name,
80
+ price
81
+ });
82
+ ga('ec:setAction', 'remove');
83
+ ga('send', 'event', {
84
+ eventAction: 'Click',
85
+ eventCategory: 'Remove from cart'
86
+ });
93
87
  };
94
88
 
95
89
  exports.addToCart = addToCart;
@@ -1,17 +1,17 @@
1
1
  'use strict';
2
2
 
3
- const addToCart = (product) => {
4
- if (!window?.ttq?.track)
5
- return;
6
- window.ttq.track('AddToCart', {
7
- content_id: product.id,
8
- content_type: 'product',
9
- content_name: product.name,
10
- quantity: product.quantity,
11
- price: product.price,
12
- value: (product.price ?? 0) * (product.quantity ?? 0),
13
- currency: product.currency,
14
- });
3
+ // @ts-nocheck
4
+ const addToCart = (product)=>{
5
+ if (!window?.ttq?.track) return;
6
+ window.ttq.track('AddToCart', {
7
+ content_id: product.id,
8
+ content_type: 'product',
9
+ content_name: product.name,
10
+ quantity: product.quantity,
11
+ price: product.price,
12
+ value: (product.price ?? 0) * (product.quantity ?? 0),
13
+ currency: product.currency
14
+ });
15
15
  };
16
16
 
17
17
  exports.addToCart = addToCart;
@@ -1,7 +1,7 @@
1
1
  'use strict';
2
2
 
3
- const genTypoClass = (name) => {
4
- return `g-${name}`;
3
+ const genTypoClass = (name)=>{
4
+ return `g-${name}`;
5
5
  };
6
6
 
7
7
  exports.genTypoClass = genTypoClass;
@@ -5,16 +5,16 @@ var useSWR = require('swr');
5
5
  var useSWRMutation = require('swr/mutation');
6
6
  var shop = require('../shop.js');
7
7
 
8
- const useAddToCart = (options) => {
9
- const shop$1 = shop.useStoreFront();
10
- const { mutate } = useSWR.useSWRConfig();
11
- return useSWRMutation('add-to-cart', (_, { arg }) => adapterShopify.addToCartOperation(shop$1)(arg), {
12
- ...options,
13
- onSuccess: (result, key, config) => {
14
- mutate('cart', result, false);
15
- options?.onSuccess?.(result, key, config);
16
- },
17
- });
8
+ const useAddToCart = (options)=>{
9
+ const shop$1 = shop.useStoreFront();
10
+ const { mutate } = useSWR.useSWRConfig();
11
+ return useSWRMutation('add-to-cart', (_, { arg })=>adapterShopify.addToCartOperation(shop$1)(arg), {
12
+ ...options,
13
+ onSuccess: (result, key, config)=>{
14
+ mutate('cart', result, false);
15
+ options?.onSuccess?.(result, key, config);
16
+ }
17
+ });
18
18
  };
19
19
 
20
20
  exports.useAddToCart = useAddToCart;
@@ -5,22 +5,24 @@ var useSWR = require('swr');
5
5
  var shop = require('../shop.js');
6
6
  var useCartId = require('../useCartId.js');
7
7
 
8
- const useCartData = (options) => {
9
- const { cartId, clearCartId } = useCartId.default();
10
- const shop$1 = shop.useStoreFront();
11
- return useSWR(cartId ? 'cart' : null, () => adapterShopify.getCartOperation(shop$1)({ cartId: cartId }), {
12
- revalidateOnMount: true,
13
- revalidateOnFocus: true,
14
- keepPreviousData: false,
15
- dedupingInterval: 2000,
16
- ...options,
17
- onSuccess(data, key, config) {
18
- if (!data) {
19
- clearCartId();
20
- }
21
- options?.onSuccess?.(data, key, config);
22
- },
23
- });
8
+ const useCartData = (options)=>{
9
+ const { cartId , clearCartId } = useCartId.default();
10
+ const shop$1 = shop.useStoreFront();
11
+ return useSWR(cartId ? 'cart' : null, ()=>adapterShopify.getCartOperation(shop$1)({
12
+ cartId: cartId
13
+ }), {
14
+ revalidateOnMount: true,
15
+ revalidateOnFocus: true,
16
+ keepPreviousData: false,
17
+ dedupingInterval: 2000,
18
+ ...options,
19
+ onSuccess (data, key, config) {
20
+ if (!data) {
21
+ clearCartId();
22
+ }
23
+ options?.onSuccess?.(data, key, config);
24
+ }
25
+ });
24
26
  };
25
27
 
26
28
  exports.useCartData = useCartData;
@@ -5,16 +5,16 @@ var useSWR = require('swr');
5
5
  var useSWRMutation = require('swr/mutation');
6
6
  var shop = require('../shop.js');
7
7
 
8
- const useCartDiscountCodesUpdate = (options) => {
9
- const shop$1 = shop.useStoreFront();
10
- const { mutate } = useSWR.useSWRConfig();
11
- return useSWRMutation('cart-discount-codes-update', (_, { arg }) => adapterShopify.cartDiscountCodesUpdateOperation(shop$1)(arg), {
12
- ...options,
13
- onSuccess: (result, key, config) => {
14
- mutate('cart', result, false);
15
- options?.onSuccess?.(result, key, config);
16
- },
17
- });
8
+ const useCartDiscountCodesUpdate = (options)=>{
9
+ const shop$1 = shop.useStoreFront();
10
+ const { mutate } = useSWR.useSWRConfig();
11
+ return useSWRMutation('cart-discount-codes-update', (_, { arg })=>adapterShopify.cartDiscountCodesUpdateOperation(shop$1)(arg), {
12
+ ...options,
13
+ onSuccess: (result, key, config)=>{
14
+ mutate('cart', result, false);
15
+ options?.onSuccess?.(result, key, config);
16
+ }
17
+ });
18
18
  };
19
19
 
20
20
  exports.useCartDiscountCodesUpdate = useCartDiscountCodesUpdate;
@@ -5,16 +5,16 @@ var useSWR = require('swr');
5
5
  var useSWRMutation = require('swr/mutation');
6
6
  var shop = require('../shop.js');
7
7
 
8
- const useCartNoteUpdate = (options) => {
9
- const shop$1 = shop.useStoreFront();
10
- const { mutate } = useSWR.useSWRConfig();
11
- return useSWRMutation('cart-note-update', (_, { arg }) => adapterShopify.cartNoteUpdateOperation(shop$1)(arg), {
12
- ...options,
13
- onSuccess: (result, key, config) => {
14
- mutate('cart', result, false);
15
- options?.onSuccess?.(result, key, config);
16
- },
17
- });
8
+ const useCartNoteUpdate = (options)=>{
9
+ const shop$1 = shop.useStoreFront();
10
+ const { mutate } = useSWR.useSWRConfig();
11
+ return useSWRMutation('cart-note-update', (_, { arg })=>adapterShopify.cartNoteUpdateOperation(shop$1)(arg), {
12
+ ...options,
13
+ onSuccess: (result, key, config)=>{
14
+ mutate('cart', result, false);
15
+ options?.onSuccess?.(result, key, config);
16
+ }
17
+ });
18
18
  };
19
19
 
20
20
  exports.useCartNoteUpdate = useCartNoteUpdate;
@@ -5,18 +5,18 @@ var useSWR = require('swr');
5
5
  var useSWRMutation = require('swr/mutation');
6
6
  var shop = require('../shop.js');
7
7
 
8
- const useCreateCart = (options) => {
9
- const shop$1 = shop.useStoreFront();
10
- const { mutate } = useSWR.useSWRConfig();
11
- return useSWRMutation('create-cart', (_, { arg }) => {
12
- return adapterShopify.createCartOperation(shop$1)(arg);
13
- }, {
14
- ...options,
15
- onSuccess: (result, key, config) => {
16
- mutate('cart', result, false);
17
- options?.onSuccess?.(result, key, config);
18
- },
19
- });
8
+ const useCreateCart = (options)=>{
9
+ const shop$1 = shop.useStoreFront();
10
+ const { mutate } = useSWR.useSWRConfig();
11
+ return useSWRMutation('create-cart', (_, { arg })=>{
12
+ return adapterShopify.createCartOperation(shop$1)(arg);
13
+ }, {
14
+ ...options,
15
+ onSuccess: (result, key, config)=>{
16
+ mutate('cart', result, false);
17
+ options?.onSuccess?.(result, key, config);
18
+ }
19
+ });
20
20
  };
21
21
 
22
22
  exports.useCreateCart = useCreateCart;
@@ -5,16 +5,16 @@ var useSWR = require('swr');
5
5
  var useSWRMutation = require('swr/mutation');
6
6
  var shop = require('../shop.js');
7
7
 
8
- const useRemoveCartItem = (options) => {
9
- const shop$1 = shop.useStoreFront();
10
- const { mutate } = useSWR.useSWRConfig();
11
- return useSWRMutation('remove-cart-item', (_, { arg }) => adapterShopify.removeCartItemOperation(shop$1)(arg), {
12
- ...options,
13
- onSuccess: (result, key, config) => {
14
- mutate('cart', result, false);
15
- options?.onSuccess?.(result, key, config);
16
- },
17
- });
8
+ const useRemoveCartItem = (options)=>{
9
+ const shop$1 = shop.useStoreFront();
10
+ const { mutate } = useSWR.useSWRConfig();
11
+ return useSWRMutation('remove-cart-item', (_, { arg })=>adapterShopify.removeCartItemOperation(shop$1)(arg), {
12
+ ...options,
13
+ onSuccess: (result, key, config)=>{
14
+ mutate('cart', result, false);
15
+ options?.onSuccess?.(result, key, config);
16
+ }
17
+ });
18
18
  };
19
19
 
20
20
  exports.useRemoveCartItem = useRemoveCartItem;
@@ -5,16 +5,16 @@ var useSWR = require('swr');
5
5
  var useSWRMutation = require('swr/mutation');
6
6
  var shop = require('../shop.js');
7
7
 
8
- const useUpdateCartItem = (options) => {
9
- const shop$1 = shop.useStoreFront();
10
- const { mutate } = useSWR.useSWRConfig();
11
- return useSWRMutation('update-cart-item', (_, { arg }) => adapterShopify.updateCartLineOperation(shop$1)(arg), {
12
- ...options,
13
- onSuccess: (result, key, config) => {
14
- mutate('cart', result, false);
15
- options?.onSuccess?.(result, key, config);
16
- },
17
- });
8
+ const useUpdateCartItem = (options)=>{
9
+ const shop$1 = shop.useStoreFront();
10
+ const { mutate } = useSWR.useSWRConfig();
11
+ return useSWRMutation('update-cart-item', (_, { arg })=>adapterShopify.updateCartLineOperation(shop$1)(arg), {
12
+ ...options,
13
+ onSuccess: (result, key, config)=>{
14
+ mutate('cart', result, false);
15
+ options?.onSuccess?.(result, key, config);
16
+ }
17
+ });
18
18
  };
19
19
 
20
20
  exports.useUpdateCartItem = useUpdateCartItem;
@@ -5,12 +5,18 @@ var getCollection = require('../../helpers/queries/get-collection.js');
5
5
  var shop = require('../shop.js');
6
6
  var useFetchHandle = require('../useFetchHandle.js');
7
7
 
8
- const useCollectionQuery = (args, options) => {
9
- const fetcher = useFetchHandle.useFetchHandle();
10
- const isSample = shop.useIsSampleProduct();
11
- return useSWR(['query/collection', { ...args, isSample }], ([, arg]) => {
12
- return getCollection.getCollection(fetcher, arg);
13
- }, options);
8
+ const useCollectionQuery = (args, options)=>{
9
+ const fetcher = useFetchHandle.useFetchHandle();
10
+ const isSample = shop.useIsSampleProduct();
11
+ return useSWR([
12
+ 'query/collection',
13
+ {
14
+ ...args,
15
+ isSample
16
+ }
17
+ ], ([, arg])=>{
18
+ return getCollection.getCollection(fetcher, arg);
19
+ }, options);
14
20
  };
15
21
 
16
22
  exports.useCollectionQuery = useCollectionQuery;
@@ -5,12 +5,18 @@ var getProduct = require('../../helpers/queries/get-product.js');
5
5
  var shop = require('../shop.js');
6
6
  var useFetchHandle = require('../useFetchHandle.js');
7
7
 
8
- const useProductQuery = (productId, options) => {
9
- const fetcher = useFetchHandle.useFetchHandle();
10
- const isSample = shop.useIsSampleProduct();
11
- return useSWR(productId ? ['query/product', { id: productId ?? 'latest', isSample }] : null, async ([, arg]) => {
12
- return getProduct.getProduct(fetcher, arg);
13
- }, options);
8
+ const useProductQuery = (productId, options)=>{
9
+ const fetcher = useFetchHandle.useFetchHandle();
10
+ const isSample = shop.useIsSampleProduct();
11
+ return useSWR(productId ? [
12
+ 'query/product',
13
+ {
14
+ id: productId ?? 'latest',
15
+ isSample
16
+ }
17
+ ] : null, async ([, arg])=>{
18
+ return getProduct.getProduct(fetcher, arg);
19
+ }, options);
14
20
  };
15
21
 
16
22
  exports.useProductQuery = useProductQuery;