@gem-sdk/core 1.0.0

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 (214) hide show
  1. package/dist/cjs/components/AddOn.js +18 -0
  2. package/dist/cjs/components/ComponentWrapper.js +45 -0
  3. package/dist/cjs/components/ComponentWrapperPreview.js +58 -0
  4. package/dist/cjs/components/Empty.js +7 -0
  5. package/dist/cjs/components/Render.js +28 -0
  6. package/dist/cjs/components/RenderBlock.js +21 -0
  7. package/dist/cjs/components/RenderPreview.js +28 -0
  8. package/dist/cjs/components/RenderSection.js +19 -0
  9. package/dist/cjs/contexts/AddonContext.js +25 -0
  10. package/dist/cjs/contexts/BuilderComponent.js +30 -0
  11. package/dist/cjs/contexts/BuilderContext.js +29 -0
  12. package/dist/cjs/contexts/BuilderPreviewContext.js +353 -0
  13. package/dist/cjs/contexts/CartLineContext.js +24 -0
  14. package/dist/cjs/contexts/CollectionContext.js +24 -0
  15. package/dist/cjs/contexts/ProductContext.js +126 -0
  16. package/dist/cjs/contexts/ProductListContext.js +24 -0
  17. package/dist/cjs/contexts/SectionContext.js +49 -0
  18. package/dist/cjs/contexts/ShopContext.js +43 -0
  19. package/dist/cjs/graphql/fragments/analytic.generated.js +11 -0
  20. package/dist/cjs/graphql/fragments/collection-detail.generated.js +13 -0
  21. package/dist/cjs/graphql/fragments/collection-product.generated.js +26 -0
  22. package/dist/cjs/graphql/fragments/data-seo.generated.js +11 -0
  23. package/dist/cjs/graphql/fragments/media.generated.js +14 -0
  24. package/dist/cjs/graphql/fragments/product-little.generated.js +25 -0
  25. package/dist/cjs/graphql/fragments/product-option-value.generated.js +13 -0
  26. package/dist/cjs/graphql/fragments/product-option.generated.js +14 -0
  27. package/dist/cjs/graphql/fragments/product.generated.js +33 -0
  28. package/dist/cjs/graphql/fragments/published-custom-section.generated.js +12 -0
  29. package/dist/cjs/graphql/fragments/published-page-section.generated.js +11 -0
  30. package/dist/cjs/graphql/fragments/published-theme-page.generated.js +27 -0
  31. package/dist/cjs/graphql/fragments/published-theme-style.generated.js +11 -0
  32. package/dist/cjs/graphql/fragments/selected-option.generated.js +11 -0
  33. package/dist/cjs/graphql/fragments/variant.generated.js +35 -0
  34. package/dist/cjs/graphql/queries/collection-detail-filter.generated.js +34 -0
  35. package/dist/cjs/graphql/queries/collection.generated.js +52 -0
  36. package/dist/cjs/graphql/queries/preview-page.generated.js +23 -0
  37. package/dist/cjs/graphql/queries/product-little-detail.generated.js +24 -0
  38. package/dist/cjs/graphql/queries/product-medias.generated.js +29 -0
  39. package/dist/cjs/graphql/queries/product-variants.generated.js +33 -0
  40. package/dist/cjs/graphql/queries/products.generated.js +41 -0
  41. package/dist/cjs/graphql/queries/published-theme-pages.generated.js +23 -0
  42. package/dist/cjs/graphql/queries/storeProperty.generated.js +12 -0
  43. package/dist/cjs/helpers/GlobalEvent.js +17 -0
  44. package/dist/cjs/helpers/background.js +104 -0
  45. package/dist/cjs/helpers/borders.js +138 -0
  46. package/dist/cjs/helpers/clone-deep.js +5 -0
  47. package/dist/cjs/helpers/cls.js +20 -0
  48. package/dist/cjs/helpers/colors.js +157 -0
  49. package/dist/cjs/helpers/compose-advance-style.js +132 -0
  50. package/dist/cjs/helpers/constant.js +17 -0
  51. package/dist/cjs/helpers/css-variable.js +7 -0
  52. package/dist/cjs/helpers/email.js +11 -0
  53. package/dist/cjs/helpers/flatten-connection.js +10 -0
  54. package/dist/cjs/helpers/fpixel.js +29 -0
  55. package/dist/cjs/helpers/get-resonsive-value.js +32 -0
  56. package/dist/cjs/helpers/get-shortname.js +92 -0
  57. package/dist/cjs/helpers/gtag.js +48 -0
  58. package/dist/cjs/helpers/is-browser.js +9 -0
  59. package/dist/cjs/helpers/is-defined.js +7 -0
  60. package/dist/cjs/helpers/is-empty-children.js +12 -0
  61. package/dist/cjs/helpers/layout.js +17 -0
  62. package/dist/cjs/helpers/load-script.js +32 -0
  63. package/dist/cjs/helpers/make-style.js +99 -0
  64. package/dist/cjs/helpers/normalize-builder-data.js +17 -0
  65. package/dist/cjs/helpers/prefetch-queries.js +68 -0
  66. package/dist/cjs/helpers/product.js +35 -0
  67. package/dist/cjs/helpers/queries/get-collection.js +173 -0
  68. package/dist/cjs/helpers/queries/get-product-by-slug.js +99 -0
  69. package/dist/cjs/helpers/queries/get-product.js +113 -0
  70. package/dist/cjs/helpers/queries/get-products.js +135 -0
  71. package/dist/cjs/helpers/radius.js +91 -0
  72. package/dist/cjs/helpers/shadow.js +48 -0
  73. package/dist/cjs/helpers/size.js +20 -0
  74. package/dist/cjs/helpers/spacing.js +45 -0
  75. package/dist/cjs/helpers/tiktokpixel.js +17 -0
  76. package/dist/cjs/helpers/typography.js +7 -0
  77. package/dist/cjs/hooks/cart/use-add-to-cart.js +20 -0
  78. package/dist/cjs/hooks/cart/use-cart-data.js +26 -0
  79. package/dist/cjs/hooks/cart/use-cart-discount-codes-update.js +20 -0
  80. package/dist/cjs/hooks/cart/use-cart-note-update.js +20 -0
  81. package/dist/cjs/hooks/cart/use-create-cart.js +22 -0
  82. package/dist/cjs/hooks/cart/use-remove-cart-item.js +20 -0
  83. package/dist/cjs/hooks/cart/use-update-cart-item.js +20 -0
  84. package/dist/cjs/hooks/shop/use-collection-query.js +16 -0
  85. package/dist/cjs/hooks/shop/use-product-query.js +16 -0
  86. package/dist/cjs/hooks/shop/use-products-query.js +16 -0
  87. package/dist/cjs/hooks/shop.js +80 -0
  88. package/dist/cjs/hooks/use-current-device.js +23 -0
  89. package/dist/cjs/hooks/use-lazy-video.js +15 -0
  90. package/dist/cjs/hooks/useCartId.js +36 -0
  91. package/dist/cjs/hooks/useCartLine.js +11 -0
  92. package/dist/cjs/hooks/useCartUI.js +42 -0
  93. package/dist/cjs/hooks/useCollection.js +9 -0
  94. package/dist/cjs/hooks/useFetchHandle.js +13 -0
  95. package/dist/cjs/hooks/useFormatMoney.js +17 -0
  96. package/dist/cjs/hooks/useIsomorphicLayoutEffect.js +10 -0
  97. package/dist/cjs/hooks/useLoadScript.js +30 -0
  98. package/dist/cjs/hooks/useMoney.js +52 -0
  99. package/dist/cjs/hooks/usePrevious.js +17 -0
  100. package/dist/cjs/hooks/useProduct.js +90 -0
  101. package/dist/cjs/hooks/useProductList.js +21 -0
  102. package/dist/cjs/hooks/useSuspenseFetch.js +24 -0
  103. package/dist/cjs/hooks/useSwatchesOptions.js +39 -0
  104. package/dist/cjs/index.js +229 -0
  105. package/dist/cjs/types/global-style.js +7 -0
  106. package/dist/cjs/types/shop.js +2 -0
  107. package/dist/esm/components/AddOn.js +14 -0
  108. package/dist/esm/components/ComponentWrapper.js +40 -0
  109. package/dist/esm/components/ComponentWrapperPreview.js +54 -0
  110. package/dist/esm/components/Empty.js +3 -0
  111. package/dist/esm/components/Render.js +24 -0
  112. package/dist/esm/components/RenderBlock.js +17 -0
  113. package/dist/esm/components/RenderPreview.js +24 -0
  114. package/dist/esm/components/RenderSection.js +15 -0
  115. package/dist/esm/contexts/AddonContext.js +21 -0
  116. package/dist/esm/contexts/BuilderComponent.js +27 -0
  117. package/dist/esm/contexts/BuilderContext.js +26 -0
  118. package/dist/esm/contexts/BuilderPreviewContext.js +350 -0
  119. package/dist/esm/contexts/CartLineContext.js +21 -0
  120. package/dist/esm/contexts/CollectionContext.js +20 -0
  121. package/dist/esm/contexts/ProductContext.js +123 -0
  122. package/dist/esm/contexts/ProductListContext.js +20 -0
  123. package/dist/esm/contexts/SectionContext.js +45 -0
  124. package/dist/esm/contexts/ShopContext.js +40 -0
  125. package/dist/esm/graphql/fragments/analytic.generated.js +9 -0
  126. package/dist/esm/graphql/fragments/collection-detail.generated.js +11 -0
  127. package/dist/esm/graphql/fragments/collection-product.generated.js +24 -0
  128. package/dist/esm/graphql/fragments/data-seo.generated.js +9 -0
  129. package/dist/esm/graphql/fragments/media.generated.js +12 -0
  130. package/dist/esm/graphql/fragments/product-little.generated.js +23 -0
  131. package/dist/esm/graphql/fragments/product-option-value.generated.js +11 -0
  132. package/dist/esm/graphql/fragments/product-option.generated.js +12 -0
  133. package/dist/esm/graphql/fragments/product.generated.js +31 -0
  134. package/dist/esm/graphql/fragments/published-custom-section.generated.js +10 -0
  135. package/dist/esm/graphql/fragments/published-page-section.generated.js +9 -0
  136. package/dist/esm/graphql/fragments/published-theme-page.generated.js +25 -0
  137. package/dist/esm/graphql/fragments/published-theme-style.generated.js +9 -0
  138. package/dist/esm/graphql/fragments/selected-option.generated.js +9 -0
  139. package/dist/esm/graphql/fragments/variant.generated.js +33 -0
  140. package/dist/esm/graphql/queries/collection-detail-filter.generated.js +32 -0
  141. package/dist/esm/graphql/queries/collection.generated.js +50 -0
  142. package/dist/esm/graphql/queries/preview-page.generated.js +21 -0
  143. package/dist/esm/graphql/queries/product-little-detail.generated.js +22 -0
  144. package/dist/esm/graphql/queries/product-medias.generated.js +27 -0
  145. package/dist/esm/graphql/queries/product-variants.generated.js +31 -0
  146. package/dist/esm/graphql/queries/products.generated.js +38 -0
  147. package/dist/esm/graphql/queries/published-theme-pages.generated.js +21 -0
  148. package/dist/esm/graphql/queries/storeProperty.generated.js +10 -0
  149. package/dist/esm/helpers/GlobalEvent.js +13 -0
  150. package/dist/esm/helpers/background.js +102 -0
  151. package/dist/esm/helpers/borders.js +133 -0
  152. package/dist/esm/helpers/clone-deep.js +3 -0
  153. package/dist/esm/helpers/cls.js +18 -0
  154. package/dist/esm/helpers/colors.js +145 -0
  155. package/dist/esm/helpers/compose-advance-style.js +130 -0
  156. package/dist/esm/helpers/constant.js +13 -0
  157. package/dist/esm/helpers/css-variable.js +5 -0
  158. package/dist/esm/helpers/email.js +6 -0
  159. package/dist/esm/helpers/flatten-connection.js +8 -0
  160. package/dist/esm/helpers/fpixel.js +25 -0
  161. package/dist/esm/helpers/get-resonsive-value.js +28 -0
  162. package/dist/esm/helpers/get-shortname.js +90 -0
  163. package/dist/esm/helpers/gtag.js +45 -0
  164. package/dist/esm/helpers/is-browser.js +5 -0
  165. package/dist/esm/helpers/is-defined.js +5 -0
  166. package/dist/esm/helpers/is-empty-children.js +7 -0
  167. package/dist/esm/helpers/layout.js +15 -0
  168. package/dist/esm/helpers/load-script.js +30 -0
  169. package/dist/esm/helpers/make-style.js +91 -0
  170. package/dist/esm/helpers/normalize-builder-data.js +15 -0
  171. package/dist/esm/helpers/prefetch-queries.js +66 -0
  172. package/dist/esm/helpers/product.js +32 -0
  173. package/dist/esm/helpers/queries/get-collection.js +170 -0
  174. package/dist/esm/helpers/queries/get-product-by-slug.js +97 -0
  175. package/dist/esm/helpers/queries/get-product.js +109 -0
  176. package/dist/esm/helpers/queries/get-products.js +133 -0
  177. package/dist/esm/helpers/radius.js +86 -0
  178. package/dist/esm/helpers/shadow.js +45 -0
  179. package/dist/esm/helpers/size.js +18 -0
  180. package/dist/esm/helpers/spacing.js +42 -0
  181. package/dist/esm/helpers/tiktokpixel.js +15 -0
  182. package/dist/esm/helpers/typography.js +5 -0
  183. package/dist/esm/hooks/cart/use-add-to-cart.js +18 -0
  184. package/dist/esm/hooks/cart/use-cart-data.js +24 -0
  185. package/dist/esm/hooks/cart/use-cart-discount-codes-update.js +18 -0
  186. package/dist/esm/hooks/cart/use-cart-note-update.js +18 -0
  187. package/dist/esm/hooks/cart/use-create-cart.js +20 -0
  188. package/dist/esm/hooks/cart/use-remove-cart-item.js +18 -0
  189. package/dist/esm/hooks/cart/use-update-cart-item.js +18 -0
  190. package/dist/esm/hooks/shop/use-collection-query.js +14 -0
  191. package/dist/esm/hooks/shop/use-product-query.js +14 -0
  192. package/dist/esm/hooks/shop/use-products-query.js +14 -0
  193. package/dist/esm/hooks/shop.js +68 -0
  194. package/dist/esm/hooks/use-current-device.js +21 -0
  195. package/dist/esm/hooks/use-lazy-video.js +13 -0
  196. package/dist/esm/hooks/useCartId.js +32 -0
  197. package/dist/esm/hooks/useCartLine.js +7 -0
  198. package/dist/esm/hooks/useCartUI.js +38 -0
  199. package/dist/esm/hooks/useCollection.js +7 -0
  200. package/dist/esm/hooks/useFetchHandle.js +11 -0
  201. package/dist/esm/hooks/useFormatMoney.js +13 -0
  202. package/dist/esm/hooks/useIsomorphicLayoutEffect.js +6 -0
  203. package/dist/esm/hooks/useLoadScript.js +26 -0
  204. package/dist/esm/hooks/useMoney.js +48 -0
  205. package/dist/esm/hooks/usePrevious.js +15 -0
  206. package/dist/esm/hooks/useProduct.js +78 -0
  207. package/dist/esm/hooks/useProductList.js +16 -0
  208. package/dist/esm/hooks/useSuspenseFetch.js +20 -0
  209. package/dist/esm/hooks/useSwatchesOptions.js +35 -0
  210. package/dist/esm/index.js +82 -0
  211. package/dist/esm/types/global-style.js +4 -0
  212. package/dist/esm/types/shop.js +1 -0
  213. package/dist/types/index.d.ts +7393 -0
  214. package/package.json +50 -0
@@ -0,0 +1,133 @@
1
+ import { getGlobalColorStateResponsiveStyle, getGlobalColorStateStyle, getGlobalColorStateResponsiveClass, getGlobalColorStateClass } from './colors.js';
2
+ import { makeStyleResponsiveState, makeStyleState } from './make-style.js';
3
+
4
+ const handleConvertBorderStyle = (value) => {
5
+ if (!value)
6
+ return undefined;
7
+ if ('desktop' in value || 'tablet' in value || 'mobile' in value) {
8
+ const data = value;
9
+ const newVal = {
10
+ desktop: {
11
+ normal: data.desktop?.normal?.border,
12
+ hover: data.desktop?.hover?.border,
13
+ focus: data.desktop?.focus?.border,
14
+ },
15
+ tablet: {
16
+ normal: data.tablet?.normal?.border,
17
+ hover: data.tablet?.hover?.border,
18
+ focus: data.tablet?.focus?.border,
19
+ },
20
+ mobile: {
21
+ normal: data.mobile?.normal?.border,
22
+ hover: data.mobile?.hover?.border,
23
+ focus: data.mobile?.focus?.border,
24
+ },
25
+ };
26
+ return makeStyleResponsiveState('bs', newVal);
27
+ }
28
+ const data = value;
29
+ const newVal = {
30
+ normal: data?.normal?.border,
31
+ hover: data?.hover?.border,
32
+ focus: data?.focus?.border,
33
+ };
34
+ return makeStyleState('bs', newVal);
35
+ };
36
+ const handleConvertBorderWidth = (value) => {
37
+ if (!value)
38
+ return undefined;
39
+ if ('desktop' in value || 'tablet' in value || 'mobile' in value) {
40
+ const data = value;
41
+ const newVal = {
42
+ desktop: {
43
+ normal: data.desktop?.normal?.width,
44
+ hover: data.desktop?.hover?.width,
45
+ focus: data.desktop?.focus?.width,
46
+ },
47
+ tablet: {
48
+ normal: data.tablet?.normal?.width,
49
+ hover: data.tablet?.hover?.width,
50
+ focus: data.tablet?.focus?.width,
51
+ },
52
+ mobile: {
53
+ normal: data.mobile?.normal?.width,
54
+ hover: data.mobile?.hover?.width,
55
+ focus: data.mobile?.focus?.width,
56
+ },
57
+ };
58
+ return makeStyleResponsiveState('bw', newVal);
59
+ }
60
+ const data = value;
61
+ const newVal = {
62
+ normal: data?.normal?.width,
63
+ hover: data?.hover?.width,
64
+ focus: data?.focus?.width,
65
+ };
66
+ return makeStyleState('bw', newVal);
67
+ };
68
+ const handleConvertBorderColor = (value) => {
69
+ if (!value)
70
+ return undefined;
71
+ if ('desktop' in value || 'tablet' in value || 'mobile' in value) {
72
+ const data = value;
73
+ const newVal = {
74
+ desktop: {
75
+ normal: data.desktop?.normal?.color,
76
+ hover: data.desktop?.hover?.color,
77
+ focus: data.desktop?.focus?.color,
78
+ },
79
+ tablet: {
80
+ normal: data.tablet?.normal?.color,
81
+ hover: data.tablet?.hover?.color,
82
+ focus: data.tablet?.focus?.color,
83
+ },
84
+ mobile: {
85
+ normal: data.mobile?.normal?.color,
86
+ hover: data.mobile?.hover?.color,
87
+ focus: data.mobile?.focus?.color,
88
+ },
89
+ };
90
+ return getGlobalColorStateResponsiveStyle('bc', newVal);
91
+ }
92
+ const data = value;
93
+ const newVal = {
94
+ normal: data?.normal?.color,
95
+ hover: data?.hover?.color,
96
+ focus: data?.focus?.color,
97
+ };
98
+ return getGlobalColorStateStyle('bc', newVal);
99
+ };
100
+ const handleConvertClassColor = (value) => {
101
+ if (!value)
102
+ return undefined;
103
+ if ('desktop' in value || 'tablet' in value || 'mobile' in value) {
104
+ const data = value;
105
+ const newVal = {
106
+ desktop: {
107
+ normal: data.desktop?.normal?.color,
108
+ hover: data.desktop?.hover?.color,
109
+ focus: data.desktop?.focus?.color,
110
+ },
111
+ tablet: {
112
+ normal: data.tablet?.normal?.color,
113
+ hover: data.tablet?.hover?.color,
114
+ focus: data.tablet?.focus?.color,
115
+ },
116
+ mobile: {
117
+ normal: data.mobile?.normal?.color,
118
+ hover: data.mobile?.hover?.color,
119
+ focus: data.mobile?.focus?.color,
120
+ },
121
+ };
122
+ return getGlobalColorStateResponsiveClass('border', newVal);
123
+ }
124
+ const data = value;
125
+ const newVal = {
126
+ normal: data?.normal?.color,
127
+ hover: data?.hover?.color,
128
+ focus: data?.focus?.color,
129
+ };
130
+ return getGlobalColorStateClass('border', newVal);
131
+ };
132
+
133
+ export { handleConvertBorderColor, handleConvertBorderStyle, handleConvertBorderWidth, handleConvertClassColor };
@@ -0,0 +1,3 @@
1
+ const cloneDeep = (data) => JSON.parse(JSON.stringify(data));
2
+
3
+ export { cloneDeep };
@@ -0,0 +1,18 @@
1
+ function toVal(mix) {
2
+ if (typeof mix === 'string') {
3
+ return mix;
4
+ }
5
+ else if (typeof mix === 'object' && mix !== null) {
6
+ return Object.keys(mix)
7
+ .filter((key) => mix[key])
8
+ .join(' ');
9
+ }
10
+ else {
11
+ return false;
12
+ }
13
+ }
14
+ function cls(...classes) {
15
+ return classes.map(toVal).filter(Boolean).join(' ');
16
+ }
17
+
18
+ export { cls };
@@ -0,0 +1,145 @@
1
+ import { isDefined } from './is-defined.js';
2
+ import { stateMapping } from './constant.js';
3
+
4
+ const getGlobalColorCSSProp = (color) => {
5
+ return getSingleColorVariable(color);
6
+ };
7
+ const getGlobalColorClass = (type, color) => {
8
+ if (typeof color !== 'string' ||
9
+ !color ||
10
+ color?.startsWith('#') ||
11
+ color?.startsWith('rgb') ||
12
+ color?.startsWith('hsl') ||
13
+ color?.startsWith('transparent'))
14
+ return '';
15
+ return `${type}-g-${color}`;
16
+ };
17
+ const getGlobalColorResponsiveClass = (type, data) => {
18
+ if (!data)
19
+ return '';
20
+ return Object.entries(data)
21
+ .map(([device, value]) => {
22
+ if (device === 'desktop') {
23
+ return getGlobalColorClass(type, value);
24
+ }
25
+ else {
26
+ return `${device}:${getGlobalColorClass(type, value)}`;
27
+ }
28
+ })
29
+ .join(' ');
30
+ };
31
+ const getGlobalColorStateClass = (type, data) => {
32
+ if (!data)
33
+ return '';
34
+ return Object.entries(data)
35
+ .map(([state, value]) => {
36
+ if (state === 'normal') {
37
+ return getGlobalColorClass(type, value);
38
+ }
39
+ else {
40
+ return `${state}:${getGlobalColorClass(type, value)}`;
41
+ }
42
+ })
43
+ .join(' ');
44
+ };
45
+ const getGlobalColorStateResponsiveClass = (type, data) => {
46
+ if (!data)
47
+ return '';
48
+ return Object.entries(data)
49
+ .map(([device, objectState]) => {
50
+ if (device === 'desktop') {
51
+ return Object.entries(objectState)
52
+ .map(([state, value]) => {
53
+ if (state === 'normal') {
54
+ return getGlobalColorClass(type, value);
55
+ }
56
+ else {
57
+ return `${state}:${getGlobalColorClass(type, value)}`;
58
+ }
59
+ })
60
+ .join(' ');
61
+ }
62
+ else {
63
+ return Object.entries(objectState)
64
+ .map(([state, value]) => {
65
+ if (state === 'normal') {
66
+ return `${device}:${getGlobalColorClass(type, value)}`;
67
+ }
68
+ else {
69
+ return `${device}:${state}:${getGlobalColorClass(type, value)}`;
70
+ }
71
+ })
72
+ .join(' ');
73
+ }
74
+ })
75
+ .join(' ');
76
+ };
77
+ const getGlobalColorResponsiveStyle = (type, data) => {
78
+ if (!data)
79
+ return {};
80
+ return Object.fromEntries(Object.entries(data).map(([device, value]) => {
81
+ if (device === 'desktop') {
82
+ return [`--${type}`, getSingleColorVariable(value)];
83
+ }
84
+ else {
85
+ return [`--${type}-${device}`, getSingleColorVariable(value)];
86
+ }
87
+ }));
88
+ };
89
+ const getGlobalColorStateStyle = (type, data) => {
90
+ if (!data)
91
+ return {};
92
+ return Object.fromEntries(Object.entries(data)
93
+ .map(([state, value]) => {
94
+ if (state === 'active')
95
+ return [];
96
+ return [`-${stateMapping?.[state]}-${type}`, getSingleColorVariable(value)];
97
+ })
98
+ .filter(isDefined));
99
+ };
100
+ const getGlobalColorStateResponsiveStyle = (type, data) => {
101
+ if (!data)
102
+ return {};
103
+ return Object.entries(data)
104
+ .map(([device, objectState]) => {
105
+ if (device === 'desktop') {
106
+ return Object.fromEntries(Object.entries(objectState)
107
+ .map(([state, value]) => {
108
+ if (state === 'active')
109
+ return [];
110
+ return [`-${stateMapping[state]}-${type}`, getSingleColorVariable(value)];
111
+ })
112
+ .filter(isDefined));
113
+ }
114
+ else {
115
+ return Object.fromEntries(Object.entries(objectState)
116
+ .map(([state, value]) => {
117
+ if (state === 'active')
118
+ return [];
119
+ return [`-${stateMapping[state]}-${type}-${device}`, getSingleColorVariable(value)];
120
+ })
121
+ .filter(isDefined));
122
+ }
123
+ })
124
+ .reduce((acc, curr) => ({ ...acc, ...curr }), {});
125
+ };
126
+ const getSingleColorVariable = (color) => {
127
+ if (!color)
128
+ return undefined;
129
+ if (isColor(color))
130
+ return color;
131
+ return `var(--g-c-${color}, ${color})`;
132
+ };
133
+ function isColor(color) {
134
+ return (color?.startsWith('#') ||
135
+ color?.startsWith('rgb') ||
136
+ color?.startsWith('hsl') ||
137
+ color?.startsWith('transparent'));
138
+ }
139
+ const getGlobalColorStyle = (data) => {
140
+ if (!data)
141
+ return {};
142
+ return { '--c': getSingleColorVariable(data) };
143
+ };
144
+
145
+ export { getGlobalColorCSSProp, getGlobalColorClass, getGlobalColorResponsiveClass, getGlobalColorResponsiveStyle, getGlobalColorStateClass, getGlobalColorStateResponsiveClass, getGlobalColorStateResponsiveStyle, getGlobalColorStateStyle, getGlobalColorStyle, getSingleColorVariable, isColor };
@@ -0,0 +1,130 @@
1
+ import { handleConvertBorderStyle, handleConvertBorderWidth, handleConvertBorderColor } from './borders.js';
2
+ import { isColor } from './colors.js';
3
+ import { layoutComponent } from './constant.js';
4
+ import { composeRadius } from './radius.js';
5
+ import { getStyleShadowState } from './shadow.js';
6
+
7
+ const composeSpacing = ({ source, spacing, type, suffix = '', }) => {
8
+ const { top, left, bottom, right } = spacing;
9
+ if (top)
10
+ source[`--${type}t${suffix}`] = top;
11
+ if (left)
12
+ source[`--${type}l${suffix}`] = left;
13
+ if (bottom)
14
+ source[`--${type}b${suffix}`] = bottom;
15
+ if (right)
16
+ source[`--${type}r${suffix}`] = right;
17
+ };
18
+ const getAttrValue = (attr, value, tag) => {
19
+ if (value === undefined || value === null)
20
+ return undefined;
21
+ switch (attr) {
22
+ case 'bgc':
23
+ case 'c':
24
+ return isColor(value.toString()) ? value : `var(--g-c-${value})`;
25
+ case 'd':
26
+ if (!value)
27
+ return 'none';
28
+ if (value && tag && layoutComponent.includes(tag))
29
+ return 'grid';
30
+ return 'inline';
31
+ default:
32
+ return value;
33
+ }
34
+ };
35
+ function composeAdvanceStyle(data, tag) {
36
+ if (!data)
37
+ return {};
38
+ const styles = {};
39
+ const devices = ['desktop', 'tablet', 'mobile'];
40
+ const states = ['hover', 'normal'];
41
+ Object.keys(data).forEach((attr) => {
42
+ const value = data[attr];
43
+ if (value === undefined || value === null)
44
+ return;
45
+ const hasBoxShadow = (data.hasBoxShadow ? data.hasBoxShadow : {});
46
+ if (typeof value === 'object') {
47
+ if (Array.isArray(value))
48
+ return;
49
+ Object.keys(value).forEach((composeAttr) => {
50
+ if (devices.includes(composeAttr)) {
51
+ const deviceValue = value[composeAttr];
52
+ if (deviceValue !== undefined) {
53
+ // Responsive border with state
54
+ if (attr === 'border') {
55
+ Object.assign(styles, handleConvertBorderStyle(value), handleConvertBorderWidth(value), handleConvertBorderColor(value));
56
+ }
57
+ if (attr === 'rounded') {
58
+ Object.assign(styles, composeRadius(value));
59
+ }
60
+ if (composeAttr === 'desktop') {
61
+ switch (attr) {
62
+ case 'padding':
63
+ composeSpacing({
64
+ source: styles,
65
+ spacing: deviceValue,
66
+ type: 'p',
67
+ });
68
+ break;
69
+ case 'margin':
70
+ composeSpacing({
71
+ source: styles,
72
+ spacing: deviceValue,
73
+ type: 'm',
74
+ });
75
+ break;
76
+ case 'm':
77
+ case 'p':
78
+ break;
79
+ default:
80
+ styles[`--${attr}`] = getAttrValue(attr, deviceValue, tag);
81
+ break;
82
+ }
83
+ }
84
+ else {
85
+ switch (attr) {
86
+ case 'padding':
87
+ composeSpacing({
88
+ source: styles,
89
+ spacing: deviceValue,
90
+ type: 'p',
91
+ suffix: `-${composeAttr}`,
92
+ });
93
+ break;
94
+ case 'margin':
95
+ composeSpacing({
96
+ source: styles,
97
+ spacing: deviceValue,
98
+ type: 'm',
99
+ suffix: `-${composeAttr}`,
100
+ });
101
+ break;
102
+ case 'm':
103
+ case 'p':
104
+ break;
105
+ default:
106
+ styles[`--${attr}-${composeAttr}`] = getAttrValue(attr, deviceValue, tag);
107
+ break;
108
+ }
109
+ }
110
+ }
111
+ }
112
+ else if (states.includes(composeAttr)) {
113
+ switch (attr) {
114
+ case 'hasBoxShadow':
115
+ break;
116
+ case 'boxShadow':
117
+ Object.assign(styles, getStyleShadowState(value, 'box-shadow', hasBoxShadow));
118
+ break;
119
+ }
120
+ }
121
+ });
122
+ }
123
+ else {
124
+ styles[`--${attr}`] = getAttrValue(attr, value, tag);
125
+ }
126
+ });
127
+ return styles;
128
+ }
129
+
130
+ export { composeAdvanceStyle };
@@ -0,0 +1,13 @@
1
+ const stateMapping = {
2
+ normal: '',
3
+ hover: '-hvr',
4
+ focus: '-focus',
5
+ };
6
+ const devicesMapping = {
7
+ desktop: '',
8
+ tablet: '-tablet',
9
+ mobile: '-mobile',
10
+ };
11
+ const layoutComponent = ['Row', 'Section', 'Product', 'HeroBanner'];
12
+
13
+ export { devicesMapping, layoutComponent, stateMapping };
@@ -0,0 +1,5 @@
1
+ const genVariable = (variableName) => {
2
+ return `var(--g-${variableName})`;
3
+ };
4
+
5
+ export { genVariable };
@@ -0,0 +1,6 @@
1
+ const validateEmail = (email) => {
2
+ const emailRegex = new RegExp(/^(?:[^<>()[\]\\.,;:\s@"]+(?:\.[^<>()[\]\\.,;:\s@"]+)*|".+")@(?:\[\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}\]|(?:[a-zA-Z\-\d]+\.)+[a-zA-Z]{2,})$/);
3
+ return emailRegex.test(email);
4
+ };
5
+
6
+ export { validateEmail as default, validateEmail };
@@ -0,0 +1,8 @@
1
+ /**
2
+ * The `flattenConnection` utility transforms a connection object from the Storefront API (for example, [Product-related connections](api/storefront/reference/products/product#connections)) into a flat array of nodes.
3
+ */
4
+ const flattenConnection = (connection) => {
5
+ return connection?.edges?.map((edge) => edge.node) ?? [];
6
+ };
7
+
8
+ export { flattenConnection };
@@ -0,0 +1,25 @@
1
+ const pageview = () => {
2
+ if (!window.fbq)
3
+ return;
4
+ window.fbq('track', 'PageView');
5
+ };
6
+ // https://developers.facebook.com/docs/facebook-pixel/advanced/
7
+ const event = (name, options = {}) => {
8
+ if (!window.fbq)
9
+ return;
10
+ window.fbq('track', name, options);
11
+ };
12
+ const addToCart = (product) => {
13
+ if (!window.fbq)
14
+ return;
15
+ window.fbq('track', 'AddToCart', {
16
+ content_ids: [product.id],
17
+ content_name: product.name,
18
+ content_category: product.category,
19
+ content_type: 'product',
20
+ value: product.price,
21
+ currency: product.currency,
22
+ });
23
+ };
24
+
25
+ export { addToCart, event, pageview };
@@ -0,0 +1,28 @@
1
+ const getResponsiveValue = (input, k) => {
2
+ if (!k)
3
+ return {};
4
+ return {
5
+ desktop: input?.desktop?.[k],
6
+ tablet: input?.tablet?.[k],
7
+ mobile: input?.mobile?.[k],
8
+ };
9
+ };
10
+ const getResponsiveStateValue = (k, input) => {
11
+ return {
12
+ desktop: input?.desktop?.[k],
13
+ tablet: input?.tablet?.[k],
14
+ mobile: input?.mobile?.[k],
15
+ };
16
+ };
17
+ const getResponsiveValueByScreen = (value, breakpoint, defaultValue) => {
18
+ switch (breakpoint) {
19
+ case 'tablet':
20
+ return value?.tablet ?? value?.desktop ?? defaultValue;
21
+ case 'mobile':
22
+ return value?.mobile ?? value?.tablet ?? value?.desktop ?? defaultValue;
23
+ default:
24
+ return value?.desktop ?? defaultValue;
25
+ }
26
+ };
27
+
28
+ export { getResponsiveStateValue, getResponsiveValue, getResponsiveValueByScreen };
@@ -0,0 +1,90 @@
1
+ const globalSortNameMapping = {
2
+ 'typography-heading-1-fontFamily': 'h1-ff',
3
+ 'typography-heading-1-fontSize': 'h1-size',
4
+ 'typography-heading-1-fontWeight': 'h1-weight',
5
+ 'typography-heading-1-lineHeight': 'h1-lh',
6
+ 'typography-heading-1-letterSpacing': 'h1-ls',
7
+ 'typography-heading-1-fontStyle': 'h1-fs',
8
+ 'typography-heading-2-fontFamily': 'h2-ff',
9
+ 'typography-heading-2-fontSize': 'h2-size',
10
+ 'typography-heading-2-fontWeight': 'h2-weight',
11
+ 'typography-heading-2-lineHeight': 'h2-lh',
12
+ 'typography-heading-2-letterSpacing': 'h2-ls',
13
+ 'typography-heading-2-fontStyle': 'h2-fs',
14
+ 'typography-heading-3-fontFamily': 'h3-ff',
15
+ 'typography-heading-3-fontSize': 'h3-size',
16
+ 'typography-heading-3-fontWeight': 'h3-weight',
17
+ 'typography-heading-3-lineHeight': 'h3-lh',
18
+ 'typography-heading-3-letterSpacing': 'h3-ls',
19
+ 'typography-heading-3-fontStyle': 'h3-fs',
20
+ 'typography-subheading-1-fontFamily': 'sh1-ff',
21
+ 'typography-subheading-1-fontSize': 'sh1-size',
22
+ 'typography-subheading-1-fontWeight': 'sh1-weight',
23
+ 'typography-subheading-1-lineHeight': 'sh1-lh',
24
+ 'typography-subheading-1-letterSpacing': 'sh1-ls',
25
+ 'typography-subheading-1-fontStyle': 'sh1-fs',
26
+ 'typography-subheading-2-fontFamily': 'sh2-ff',
27
+ 'typography-subheading-2-fontSize': 'sh2-size',
28
+ 'typography-subheading-2-fontWeight': 'sh2-weight',
29
+ 'typography-subheading-2-lineHeight': 'sh2-lh',
30
+ 'typography-subheading-2-letterSpacing': 'sh2-ls',
31
+ 'typography-subheading-2-fontStyle': 'sh2-fs',
32
+ 'typography-subheading-3-fontFamily': 'sh3-ff',
33
+ 'typography-subheading-3-fontSize': 'sh3-size',
34
+ 'typography-subheading-3-fontWeight': 'sh3-weight',
35
+ 'typography-subheading-3-lineHeight': 'sh3-lh',
36
+ 'typography-subheading-3-letterSpacing': 'sh3-ls',
37
+ 'typography-subheading-3-fontStyle': 'sh3-fs',
38
+ 'typography-paragraph-1-fontFamily': 'p1-ff',
39
+ 'typography-paragraph-1-fontSize': 'p1-size',
40
+ 'typography-paragraph-1-fontWeight': 'p1-weight',
41
+ 'typography-paragraph-1-lineHeight': 'p1-lh',
42
+ 'typography-paragraph-1-letterSpacing': 'p1-ls',
43
+ 'typography-paragraph-1-fontStyle': 'p1-fs',
44
+ 'typography-paragraph-2-fontFamily': 'p2-ff',
45
+ 'typography-paragraph-2-fontSize': 'p2-size',
46
+ 'typography-paragraph-2-fontWeight': 'p2-weight',
47
+ 'typography-paragraph-2-lineHeight': 'p2-lh',
48
+ 'typography-paragraph-2-letterSpacing': 'p2-ls',
49
+ 'typography-paragraph-2-fontStyle': 'p2-fs',
50
+ 'typography-paragraph-3-fontFamily': 'p3-ff',
51
+ 'typography-paragraph-3-fontSize': 'p3-size',
52
+ 'typography-paragraph-3-fontWeight': 'p3-weight',
53
+ 'typography-paragraph-3-lineHeight': 'p3-lh',
54
+ 'typography-paragraph-3-letterSpacing': 'p3-ls',
55
+ 'typography-paragraph-3-fontStyle': 'p3-fs',
56
+ 'color-brand': 'c-brand',
57
+ 'color-highlight': 'c-highlight',
58
+ 'color-text-1': 'c-text-1',
59
+ 'color-text-2': 'c-text-2',
60
+ 'color-text-3': 'c-text-3',
61
+ 'color-bg-1': 'c-bg-1',
62
+ 'color-bg-2': 'c-bg-2',
63
+ 'color-bg-3': 'c-bg-3',
64
+ 'color-line-1': 'c-line-1',
65
+ 'color-line-2': 'c-line-2',
66
+ 'color-line-3': 'c-line-3',
67
+ 'color-success': 'c-success',
68
+ 'color-info': 'c-info',
69
+ 'color-warning': 'c-warning',
70
+ 'color-error': 'c-error',
71
+ 'spacing-xxs': 's-xxs',
72
+ 'spacing-xs': 's-xs',
73
+ 'spacing-s': 's-s',
74
+ 'spacing-m': 's-m',
75
+ 'spacing-l': 's-l',
76
+ 'spacing-xl': 's-xl',
77
+ 'spacing-2xl': 's-2xl',
78
+ 'spacing-3xl': 's-3xl',
79
+ 'spacing-4xl': 's-4xl',
80
+ 'spacing-5xl': 's-5xl',
81
+ 'container-width': 'ct-w',
82
+ 'container-padding': 'ct-p',
83
+ 'text-shadow': 'ts',
84
+ 'box-shadow': 'shadow',
85
+ };
86
+ function getShortName(name) {
87
+ return globalSortNameMapping[name] || name;
88
+ }
89
+
90
+ export { getShortName };
@@ -0,0 +1,45 @@
1
+ // https://developers.google.com/analytics/devguides/collection/gtagjs/pages
2
+ const pageview = (url, trackingId) => {
3
+ // GA 4
4
+ if (window.gtag && trackingId) {
5
+ window.gtag('config', trackingId, {
6
+ page_path: url,
7
+ });
8
+ }
9
+ // GA 3
10
+ if (window.ga) {
11
+ window.ga('send', 'pageview', url);
12
+ }
13
+ };
14
+ const addToCart = (product) => {
15
+ // GA 3
16
+ if (window.ga) {
17
+ window.ga('ec:addProduct', product);
18
+ window.ga('send', 'event', {
19
+ eventCategory: 'EnhancedEcommerce',
20
+ eventAction: 'Added Product',
21
+ eventLabel: undefined,
22
+ nonInteraction: true,
23
+ });
24
+ }
25
+ // GA 4
26
+ if (window.gtag) {
27
+ window.gtag('event', 'add_to_cart', {
28
+ currency: product.currency,
29
+ value: product.price,
30
+ items: [
31
+ {
32
+ currency: product.currency,
33
+ item_brand: product.brand,
34
+ item_id: product.id,
35
+ item_name: product.name,
36
+ item_variant: product.variant,
37
+ item_category: product.category,
38
+ },
39
+ ],
40
+ debug_mode: true,
41
+ });
42
+ }
43
+ };
44
+
45
+ export { addToCart, pageview };
@@ -0,0 +1,5 @@
1
+ function isBrowser() {
2
+ return typeof window !== 'undefined';
3
+ }
4
+
5
+ export { isBrowser as default };
@@ -0,0 +1,5 @@
1
+ function isDefined(argument) {
2
+ return argument !== undefined;
3
+ }
4
+
5
+ export { isDefined };