@gem-sdk/core 1.13.42 → 1.14.0-dev.284

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 (249) hide show
  1. package/dist/cjs/components/AddOn.js +1 -18
  2. package/dist/cjs/components/ComponentWrapper.js +1 -28
  3. package/dist/cjs/components/ComponentWrapperPreview.js +1 -72
  4. package/dist/cjs/components/Empty.js +1 -7
  5. package/dist/cjs/components/Render.js +1 -65
  6. package/dist/cjs/components/Render.liquid.js +15 -158
  7. package/dist/cjs/components/RenderBlock.js +1 -54
  8. package/dist/cjs/components/RenderCustomCode.js +5 -0
  9. package/dist/cjs/components/RenderPreview.js +1 -66
  10. package/dist/cjs/components/RenderSection.js +1 -23
  11. package/dist/cjs/components/constant.js +1 -39
  12. package/dist/cjs/components/src/product/helpers/variant-presets.js +1 -0
  13. package/dist/cjs/contexts/AddonContext.js +1 -36
  14. package/dist/cjs/contexts/BuilderComponent.js +1 -34
  15. package/dist/cjs/contexts/BuilderContext.js +1 -35
  16. package/dist/cjs/contexts/BuilderPreviewContext.js +1 -370
  17. package/dist/cjs/contexts/CartLineContext.js +1 -29
  18. package/dist/cjs/contexts/CollectionContext.js +1 -38
  19. package/dist/cjs/contexts/ModalContext.js +1 -47
  20. package/dist/cjs/contexts/ProductContext.js +1 -149
  21. package/dist/cjs/contexts/ProductListContext.js +1 -32
  22. package/dist/cjs/contexts/SectionContext.js +1 -53
  23. package/dist/cjs/contexts/ShopContext.js +1 -70
  24. package/dist/cjs/graphql/fragments/analytic.generated.js +2 -6
  25. package/dist/cjs/graphql/fragments/collection-detail.generated.js +2 -6
  26. package/dist/cjs/graphql/fragments/collection-product.generated.js +2 -6
  27. package/dist/cjs/graphql/fragments/collection.generated.js +2 -6
  28. package/dist/cjs/graphql/fragments/custom-code.generated.js +2 -6
  29. package/dist/cjs/graphql/fragments/data-seo.generated.js +2 -6
  30. package/dist/cjs/graphql/fragments/media.generated.js +3 -6
  31. package/dist/cjs/graphql/fragments/product-little.generated.js +2 -6
  32. package/dist/cjs/graphql/fragments/product-option-value.generated.js +2 -6
  33. package/dist/cjs/graphql/fragments/product-option.generated.js +2 -6
  34. package/dist/cjs/graphql/fragments/product.generated.js +2 -6
  35. package/dist/cjs/graphql/fragments/published-custom-section.generated.js +2 -6
  36. package/dist/cjs/graphql/fragments/published-page-section.generated.js +2 -6
  37. package/dist/cjs/graphql/fragments/published-theme-page.generated.js +2 -6
  38. package/dist/cjs/graphql/fragments/published-theme-style.generated.js +2 -6
  39. package/dist/cjs/graphql/fragments/selected-option.generated.js +2 -6
  40. package/dist/cjs/graphql/fragments/variant.generated.js +2 -6
  41. package/dist/cjs/graphql/mutations/page-view-up.generated.js +3 -7
  42. package/dist/cjs/graphql/queries/collection-detail-filter.generated.js +2 -16
  43. package/dist/cjs/graphql/queries/collection.generated.js +2 -14
  44. package/dist/cjs/graphql/queries/collections.generated.js +2 -9
  45. package/dist/cjs/graphql/queries/preview-page.generated.js +2 -14
  46. package/dist/cjs/graphql/queries/product-little-detail.generated.js +2 -11
  47. package/dist/cjs/graphql/queries/product-medias.generated.js +2 -8
  48. package/dist/cjs/graphql/queries/product-value-label.generated.js +7 -0
  49. package/dist/cjs/graphql/queries/product-variants.generated.js +2 -10
  50. package/dist/cjs/graphql/queries/products.generated.js +3 -17
  51. package/dist/cjs/graphql/queries/published-theme-pages.generated.js +2 -14
  52. package/dist/cjs/graphql/queries/store-property.generated.js +2 -6
  53. package/dist/cjs/helpers/GlobalEvent.js +1 -19
  54. package/dist/cjs/helpers/background.js +1 -109
  55. package/dist/cjs/helpers/borders.js +4 -183
  56. package/dist/cjs/helpers/clone-deep.js +1 -5
  57. package/dist/cjs/helpers/cls.js +1 -16
  58. package/dist/cjs/helpers/colors.js +1 -183
  59. package/dist/cjs/helpers/compose-advance-style.js +1 -188
  60. package/dist/cjs/helpers/constant.js +1 -23
  61. package/dist/cjs/helpers/convert.js +1 -7
  62. package/dist/cjs/helpers/css-variable.js +1 -7
  63. package/dist/cjs/helpers/email.js +1 -11
  64. package/dist/cjs/helpers/flatten-connection.js +1 -9
  65. package/dist/cjs/helpers/get-resonsive-value.js +1 -31
  66. package/dist/cjs/helpers/get-shortname.js +1 -92
  67. package/dist/cjs/helpers/is-browser.js +1 -9
  68. package/dist/cjs/helpers/is-defined.js +1 -7
  69. package/dist/cjs/helpers/is-empty-children.js +1 -12
  70. package/dist/cjs/helpers/is-safari.js +1 -9
  71. package/dist/cjs/helpers/layout.js +1 -59
  72. package/dist/cjs/helpers/load-script.js +1 -31
  73. package/dist/cjs/helpers/make-style.js +1 -128
  74. package/dist/cjs/helpers/normalize-builder-data.js +1 -23
  75. package/dist/cjs/helpers/prefetch-queries.js +1 -78
  76. package/dist/cjs/helpers/product.js +1 -45
  77. package/dist/cjs/helpers/queries/get-collection.js +1 -220
  78. package/dist/cjs/helpers/queries/get-collections.js +1 -21
  79. package/dist/cjs/helpers/queries/get-product-by-slug.js +1 -125
  80. package/dist/cjs/helpers/queries/get-product.js +1 -154
  81. package/dist/cjs/helpers/queries/get-products.js +1 -161
  82. package/dist/cjs/helpers/query.js +1 -29
  83. package/dist/cjs/helpers/radius.js +6 -134
  84. package/dist/cjs/helpers/render.js +1 -71
  85. package/dist/cjs/helpers/shadow.js +1 -56
  86. package/dist/cjs/helpers/size.js +4 -35
  87. package/dist/cjs/helpers/spacing.js +1 -43
  88. package/dist/cjs/helpers/tracking/fpixel.js +1 -28
  89. package/dist/cjs/helpers/tracking/gtag.js +1 -93
  90. package/dist/cjs/helpers/tracking/tiktokpixel.js +1 -17
  91. package/dist/cjs/helpers/typography.js +17 -105
  92. package/dist/cjs/helpers/variant.js +1 -8
  93. package/dist/cjs/hooks/cart/use-add-to-cart.js +1 -20
  94. package/dist/cjs/hooks/cart/use-cart-data.js +1 -28
  95. package/dist/cjs/hooks/cart/use-cart-discount-codes-update.js +1 -20
  96. package/dist/cjs/hooks/cart/use-cart-note-update.js +1 -20
  97. package/dist/cjs/hooks/cart/use-create-cart.js +1 -22
  98. package/dist/cjs/hooks/cart/use-remove-cart-item.js +1 -20
  99. package/dist/cjs/hooks/cart/use-update-cart-item.js +1 -20
  100. package/dist/cjs/hooks/shop/use-collection-query.js +1 -22
  101. package/dist/cjs/hooks/shop/use-collections-query.js +1 -17
  102. package/dist/cjs/hooks/shop/use-product-query.js +1 -22
  103. package/dist/cjs/hooks/shop/use-products-query.js +1 -22
  104. package/dist/cjs/hooks/shop.js +1 -126
  105. package/dist/cjs/hooks/use-current-device.js +1 -21
  106. package/dist/cjs/hooks/use-lazy-video.js +1 -15
  107. package/dist/cjs/hooks/useCartId.js +1 -44
  108. package/dist/cjs/hooks/useCartLine.js +1 -11
  109. package/dist/cjs/hooks/useCartUI.js +1 -48
  110. package/dist/cjs/hooks/useCollection.js +1 -9
  111. package/dist/cjs/hooks/useFetchHandle.js +1 -13
  112. package/dist/cjs/hooks/useFormatMoney.js +1 -58
  113. package/dist/cjs/hooks/useInitialSwatchesOptions.js +1 -0
  114. package/dist/cjs/hooks/useIsomorphicLayoutEffect.js +1 -10
  115. package/dist/cjs/hooks/useLoadScript.js +1 -32
  116. package/dist/cjs/hooks/useMoney.js +1 -84
  117. package/dist/cjs/hooks/usePrevious.js +1 -19
  118. package/dist/cjs/hooks/useProduct.js +1 -124
  119. package/dist/cjs/hooks/useProductList.js +1 -21
  120. package/dist/cjs/hooks/useSuspenseFetch.js +1 -27
  121. package/dist/cjs/hooks/useSwatchesOptions.js +1 -41
  122. package/dist/cjs/index.js +1 -291
  123. package/dist/cjs/types/global-style.js +1 -14
  124. package/dist/cjs/types/shop.js +1 -2
  125. package/dist/esm/components/AddOn.js +1 -14
  126. package/dist/esm/components/ComponentWrapper.js +1 -24
  127. package/dist/esm/components/ComponentWrapperPreview.js +1 -68
  128. package/dist/esm/components/Empty.js +1 -3
  129. package/dist/esm/components/Render.js +1 -61
  130. package/dist/esm/components/Render.liquid.js +15 -153
  131. package/dist/esm/components/RenderBlock.js +1 -50
  132. package/dist/esm/components/RenderCustomCode.js +5 -0
  133. package/dist/esm/components/RenderPreview.js +1 -62
  134. package/dist/esm/components/RenderSection.js +1 -19
  135. package/dist/esm/components/constant.js +1 -37
  136. package/dist/esm/components/src/product/helpers/variant-presets.js +1 -0
  137. package/dist/esm/contexts/AddonContext.js +1 -32
  138. package/dist/esm/contexts/BuilderComponent.js +1 -31
  139. package/dist/esm/contexts/BuilderContext.js +1 -32
  140. package/dist/esm/contexts/BuilderPreviewContext.js +1 -367
  141. package/dist/esm/contexts/CartLineContext.js +1 -26
  142. package/dist/esm/contexts/CollectionContext.js +1 -35
  143. package/dist/esm/contexts/ModalContext.js +1 -44
  144. package/dist/esm/contexts/ProductContext.js +1 -146
  145. package/dist/esm/contexts/ProductListContext.js +1 -28
  146. package/dist/esm/contexts/SectionContext.js +1 -49
  147. package/dist/esm/contexts/ShopContext.js +1 -67
  148. package/dist/esm/graphql/fragments/analytic.generated.js +2 -4
  149. package/dist/esm/graphql/fragments/collection-detail.generated.js +2 -4
  150. package/dist/esm/graphql/fragments/collection-product.generated.js +2 -4
  151. package/dist/esm/graphql/fragments/collection.generated.js +2 -4
  152. package/dist/esm/graphql/fragments/custom-code.generated.js +2 -4
  153. package/dist/esm/graphql/fragments/data-seo.generated.js +2 -4
  154. package/dist/esm/graphql/fragments/media.generated.js +3 -4
  155. package/dist/esm/graphql/fragments/product-little.generated.js +2 -4
  156. package/dist/esm/graphql/fragments/product-option-value.generated.js +2 -4
  157. package/dist/esm/graphql/fragments/product-option.generated.js +2 -4
  158. package/dist/esm/graphql/fragments/product.generated.js +2 -4
  159. package/dist/esm/graphql/fragments/published-custom-section.generated.js +2 -4
  160. package/dist/esm/graphql/fragments/published-page-section.generated.js +2 -4
  161. package/dist/esm/graphql/fragments/published-theme-page.generated.js +2 -4
  162. package/dist/esm/graphql/fragments/published-theme-style.generated.js +2 -4
  163. package/dist/esm/graphql/fragments/selected-option.generated.js +2 -4
  164. package/dist/esm/graphql/fragments/variant.generated.js +2 -4
  165. package/dist/esm/graphql/mutations/page-view-up.generated.js +3 -5
  166. package/dist/esm/graphql/queries/collection-detail-filter.generated.js +10 -22
  167. package/dist/esm/graphql/queries/collection.generated.js +8 -18
  168. package/dist/esm/graphql/queries/collections.generated.js +3 -8
  169. package/dist/esm/graphql/queries/preview-page.generated.js +8 -18
  170. package/dist/esm/graphql/queries/product-little-detail.generated.js +5 -12
  171. package/dist/esm/graphql/queries/product-medias.generated.js +2 -6
  172. package/dist/esm/graphql/queries/product-value-label.generated.js +7 -0
  173. package/dist/esm/graphql/queries/product-variants.generated.js +4 -10
  174. package/dist/esm/graphql/queries/products.generated.js +9 -20
  175. package/dist/esm/graphql/queries/published-theme-pages.generated.js +8 -18
  176. package/dist/esm/graphql/queries/store-property.generated.js +2 -4
  177. package/dist/esm/helpers/GlobalEvent.js +1 -15
  178. package/dist/esm/helpers/background.js +1 -106
  179. package/dist/esm/helpers/borders.js +4 -175
  180. package/dist/esm/helpers/clone-deep.js +1 -3
  181. package/dist/esm/helpers/cls.js +1 -14
  182. package/dist/esm/helpers/colors.js +1 -168
  183. package/dist/esm/helpers/compose-advance-style.js +1 -185
  184. package/dist/esm/helpers/constant.js +1 -19
  185. package/dist/esm/helpers/convert.js +1 -4
  186. package/dist/esm/helpers/css-variable.js +1 -5
  187. package/dist/esm/helpers/email.js +1 -6
  188. package/dist/esm/helpers/flatten-connection.js +1 -7
  189. package/dist/esm/helpers/get-resonsive-value.js +1 -27
  190. package/dist/esm/helpers/get-shortname.js +1 -90
  191. package/dist/esm/helpers/is-browser.js +1 -5
  192. package/dist/esm/helpers/is-defined.js +1 -5
  193. package/dist/esm/helpers/is-empty-children.js +1 -7
  194. package/dist/esm/helpers/is-safari.js +1 -5
  195. package/dist/esm/helpers/layout.js +1 -54
  196. package/dist/esm/helpers/load-script.js +1 -29
  197. package/dist/esm/helpers/make-style.js +1 -117
  198. package/dist/esm/helpers/normalize-builder-data.js +1 -21
  199. package/dist/esm/helpers/prefetch-queries.js +1 -76
  200. package/dist/esm/helpers/product.js +1 -41
  201. package/dist/esm/helpers/queries/get-collection.js +1 -217
  202. package/dist/esm/helpers/queries/get-collections.js +1 -19
  203. package/dist/esm/helpers/queries/get-product-by-slug.js +1 -123
  204. package/dist/esm/helpers/queries/get-product.js +1 -150
  205. package/dist/esm/helpers/queries/get-products.js +1 -159
  206. package/dist/esm/helpers/query.js +1 -25
  207. package/dist/esm/helpers/radius.js +6 -127
  208. package/dist/esm/helpers/render.js +1 -64
  209. package/dist/esm/helpers/shadow.js +1 -51
  210. package/dist/esm/helpers/size.js +4 -31
  211. package/dist/esm/helpers/spacing.js +1 -40
  212. package/dist/esm/helpers/tracking/fpixel.js +1 -24
  213. package/dist/esm/helpers/tracking/gtag.js +1 -87
  214. package/dist/esm/helpers/tracking/tiktokpixel.js +1 -15
  215. package/dist/esm/helpers/typography.js +17 -96
  216. package/dist/esm/helpers/variant.js +1 -6
  217. package/dist/esm/hooks/cart/use-add-to-cart.js +1 -18
  218. package/dist/esm/hooks/cart/use-cart-data.js +1 -26
  219. package/dist/esm/hooks/cart/use-cart-discount-codes-update.js +1 -18
  220. package/dist/esm/hooks/cart/use-cart-note-update.js +1 -18
  221. package/dist/esm/hooks/cart/use-create-cart.js +1 -20
  222. package/dist/esm/hooks/cart/use-remove-cart-item.js +1 -18
  223. package/dist/esm/hooks/cart/use-update-cart-item.js +1 -18
  224. package/dist/esm/hooks/shop/use-collection-query.js +1 -20
  225. package/dist/esm/hooks/shop/use-collections-query.js +1 -15
  226. package/dist/esm/hooks/shop/use-product-query.js +1 -20
  227. package/dist/esm/hooks/shop/use-products-query.js +1 -20
  228. package/dist/esm/hooks/shop.js +1 -111
  229. package/dist/esm/hooks/use-current-device.js +1 -19
  230. package/dist/esm/hooks/use-lazy-video.js +1 -13
  231. package/dist/esm/hooks/useCartId.js +1 -40
  232. package/dist/esm/hooks/useCartLine.js +1 -7
  233. package/dist/esm/hooks/useCartUI.js +1 -44
  234. package/dist/esm/hooks/useCollection.js +1 -7
  235. package/dist/esm/hooks/useFetchHandle.js +1 -11
  236. package/dist/esm/hooks/useFormatMoney.js +1 -56
  237. package/dist/esm/hooks/useInitialSwatchesOptions.js +1 -0
  238. package/dist/esm/hooks/useIsomorphicLayoutEffect.js +1 -6
  239. package/dist/esm/hooks/useLoadScript.js +1 -28
  240. package/dist/esm/hooks/useMoney.js +1 -80
  241. package/dist/esm/hooks/usePrevious.js +1 -17
  242. package/dist/esm/hooks/useProduct.js +1 -111
  243. package/dist/esm/hooks/useProductList.js +1 -16
  244. package/dist/esm/hooks/useSuspenseFetch.js +1 -23
  245. package/dist/esm/hooks/useSwatchesOptions.js +1 -37
  246. package/dist/esm/index.js +1 -92
  247. package/dist/esm/types/global-style.js +1 -11
  248. package/dist/types/index.d.ts +1212 -1031
  249. package/package.json +3 -3
@@ -1,185 +1 @@
1
- import { handleConvertBorderStyle, handleConvertBorderWidth, handleConvertBorderColor, getBorderStyle } from './borders.js';
2
- import { isColor } from './colors.js';
3
- import { layoutComponent } from './constant.js';
4
- import { makeStyleKey } from './make-style.js';
5
- import { composeRadius, getCornerCSSFromGlobal } from './radius.js';
6
- import { getStyleShadowState, getStyleShadow } from './shadow.js';
7
-
8
- const composeSpacing = ({ source, spacing, type, suffix = '' })=>{
9
- const { top, left, bottom, right } = spacing;
10
- if (top) source[`--${type}t${suffix}`] = top;
11
- if (left) source[`--${type}l${suffix}`] = left;
12
- if (bottom) source[`--${type}b${suffix}`] = bottom;
13
- if (right) source[`--${type}r${suffix}`] = right;
14
- };
15
- const getAttrValue = (attr, value, tag)=>{
16
- if (value === undefined || value === null) return undefined;
17
- switch(attr){
18
- case 'bgc':
19
- case 'c':
20
- return isColor(value.toString()) ? value : `var(--g-c-${value})`;
21
- case 'd':
22
- if (!value) return 'none';
23
- if (value && tag && layoutComponent.includes(tag)) return 'grid';
24
- return 'block';
25
- default:
26
- return value;
27
- }
28
- };
29
- function composeAdvanceStyle(data, tag) {
30
- if (!data) return {};
31
- const styles = {};
32
- const devices = [
33
- 'desktop',
34
- 'tablet',
35
- 'mobile'
36
- ];
37
- const states = [
38
- 'hover',
39
- 'normal'
40
- ];
41
- Object.keys(data).forEach((attr)=>{
42
- const value = data[attr];
43
- if (value === undefined || value === null) return;
44
- const hasBoxShadow = data.hasBoxShadow ? data.hasBoxShadow : {};
45
- if (typeof value === 'object') {
46
- if (Array.isArray(value)) return;
47
- Object.keys(value).forEach((composeAttr)=>{
48
- if (devices.includes(composeAttr)) {
49
- const deviceValue = value[composeAttr];
50
- if (deviceValue !== undefined) {
51
- // Responsive border with state
52
- if (attr === 'border') {
53
- Object.assign(styles, handleConvertBorderStyle(value), handleConvertBorderWidth(value), handleConvertBorderColor(value));
54
- }
55
- if (attr === 'rounded') {
56
- Object.assign(styles, composeRadius(value));
57
- }
58
- if (composeAttr === 'desktop') {
59
- switch(attr){
60
- case 'padding':
61
- composeSpacing({
62
- source: styles,
63
- spacing: deviceValue,
64
- type: 'p'
65
- });
66
- break;
67
- case 'margin':
68
- composeSpacing({
69
- source: styles,
70
- spacing: deviceValue,
71
- type: 'm'
72
- });
73
- break;
74
- case 'm':
75
- case 'p':
76
- break;
77
- default:
78
- styles[`--${attr}`] = getAttrValue(attr, deviceValue, tag);
79
- break;
80
- }
81
- } else {
82
- switch(attr){
83
- case 'padding':
84
- composeSpacing({
85
- source: styles,
86
- spacing: deviceValue,
87
- type: 'p',
88
- suffix: `-${composeAttr}`
89
- });
90
- break;
91
- case 'margin':
92
- composeSpacing({
93
- source: styles,
94
- spacing: deviceValue,
95
- type: 'm',
96
- suffix: `-${composeAttr}`
97
- });
98
- break;
99
- case 'm':
100
- case 'p':
101
- break;
102
- default:
103
- styles[`--${attr}-${composeAttr}`] = getAttrValue(attr, deviceValue, tag);
104
- break;
105
- }
106
- }
107
- }
108
- } else if (states.includes(composeAttr)) {
109
- switch(attr){
110
- case 'hasBoxShadow':
111
- break;
112
- case 'boxShadow':
113
- Object.assign(styles, getStyleShadowState(value, 'box-shadow', hasBoxShadow));
114
- break;
115
- }
116
- } else {
117
- if (attr === 'border') {
118
- const borderStyle = value;
119
- if (borderStyle.border === 'none') {
120
- borderStyle.border = 'solid';
121
- borderStyle.color = '#121212';
122
- borderStyle.isCustom = true;
123
- borderStyle.width = '0px';
124
- borderStyle.position = 'all';
125
- }
126
- Object.assign(styles, getBorderStyle(borderStyle));
127
- }
128
- if (attr === 'rounded') {
129
- Object.assign(styles, getCornerCSSFromGlobal(value));
130
- }
131
- if (attr === 'hasBoxShadow') {
132
- Object.assign(styles, getStyleShadow({
133
- value: data.boxShadow,
134
- styleAppliedFor: 'box-shadow',
135
- isEnableShadow: data.hasBoxShadow
136
- }));
137
- }
138
- if (attr === 'boxShadow') {
139
- Object.assign(styles, getStyleShadow({
140
- value: value,
141
- styleAppliedFor: 'box-shadow',
142
- isEnableShadow: data.hasBoxShadow
143
- }));
144
- }
145
- }
146
- });
147
- } else {
148
- styles[`--${attr}`] = getAttrValue(attr, value, tag);
149
- if (attr === 'hasBoxShadow' && data.boxShadow) {
150
- Object.assign(styles, getStyleShadow({
151
- value: data.boxShadow,
152
- styleAppliedFor: 'box-shadow',
153
- isEnableShadow: data.hasBoxShadow
154
- }));
155
- }
156
- }
157
- });
158
- return styles;
159
- }
160
- const splitStyle = (keys, style = {})=>{
161
- const fullKeys = keys.map((key)=>makeStyleKey(key)).flat();
162
- const splitKeys = Object.keys(style).filter((key)=>{
163
- return fullKeys.includes(key);
164
- });
165
- const splitStyle = splitKeys.reduce((curr, key)=>{
166
- return {
167
- ...curr,
168
- [key]: style[key]
169
- };
170
- }, {});
171
- const restStyle = Object.keys(style).filter((key)=>{
172
- return !splitKeys.includes(key);
173
- }).reduce((curr, key)=>{
174
- return {
175
- ...curr,
176
- [key]: style[key]
177
- };
178
- }, {});
179
- return [
180
- splitStyle,
181
- restStyle
182
- ];
183
- };
184
-
185
- export { composeAdvanceStyle, splitStyle };
1
+ import{handleConvertBorderStyle as e,handleConvertBorderWidth as s,handleConvertBorderColor as a,getBorderStyle as o}from"./borders.js";import{isColor as t}from"./colors.js";import{layoutComponent as r}from"./constant.js";import{makeStyleKey as i}from"./make-style.js";import{composeRadius as c,getCornerCSSFromGlobal as n}from"./radius.js";import{getStyleShadowState as l,getStyleShadow as p}from"./shadow.js";let composeSpacing=({source:e,spacing:s,type:a,suffix:o=""})=>{let{top:t,left:r,bottom:i,right:c}=s;t&&(e[`--${a}t${o}`]=t),r&&(e[`--${a}l${o}`]=r),i&&(e[`--${a}b${o}`]=i),c&&(e[`--${a}r${o}`]=c)},composeSpacingV2=({source:e,spacing:s,suffix:a=""})=>{if(s&&s.margin){let{top:o,left:t,bottom:r,right:i}=s.margin;o&&(e[`--mt${a}`]=o),t&&(e[`--ml${a}`]=t),r&&(e[`--mb${a}`]=r),i&&(e[`--mr${a}`]=i)}if(s&&s.padding){let{top:o,left:t,bottom:r,right:i}=s.padding;o&&(e[`--pt${a}`]=o),t&&(e[`--pl${a}`]=t),r&&(e[`--pb${a}`]=r),i&&(e[`--pr${a}`]=i)}},getAttrValue=(e,s,a)=>{if(null!=s)switch(e){case"bgc":case"c":return t(s.toString())?s:`var(--g-c-${s})`;case"d":if(!s)return"none";if(s&&a&&r.includes(a))return"grid";return"block";default:return s}};function composeAdvanceStyle(t,r){if(!t)return{};let i={},d=["desktop","tablet","mobile"],b=["hover","normal"];return Object.keys(t).forEach(u=>{let g=t[u];if("cssClass"===u||null==g)return;let m=t.hasBoxShadow?t.hasBoxShadow:{};if("object"==typeof g){if(Array.isArray(g))return;Object.keys(g).forEach(h=>{if(d.includes(h)){let o=g[h];if(void 0!==o){if("border"===u&&Object.assign(i,e(g),s(g),a(g)),"rounded"===u&&Object.assign(i,c(g)),"desktop"===h)switch(u){case"padding":composeSpacing({source:i,spacing:o,type:"p"});break;case"margin":composeSpacing({source:i,spacing:o,type:"m"});break;case"spacing-setting":composeSpacingV2({source:i,spacing:o});break;case"m":case"p":break;default:i[`--${u}`]=getAttrValue(u,o,r)}else switch(u){case"padding":composeSpacing({source:i,spacing:o,type:"p",suffix:`-${h}`});break;case"margin":composeSpacing({source:i,spacing:o,type:"m",suffix:`-${h}`});break;case"spacing-setting":composeSpacingV2({source:i,spacing:o,suffix:`-${h}`});break;case"m":case"p":break;default:i[`--${u}-${h}`]=getAttrValue(u,o,r)}}}else if(b.includes(h))switch(u){case"hasBoxShadow":break;case"boxShadow":Object.assign(i,l(g,"box-shadow",m))}else"border"===u&&("none"===g.border&&(g.border="solid",g.color="#121212",g.isCustom=!0,g.width="0px",g.position="all"),Object.assign(i,o(g))),"rounded"===u&&Object.assign(i,n(g)),"hasBoxShadow"===u&&Object.assign(i,p({value:t.boxShadow,styleAppliedFor:"box-shadow",isEnableShadow:t.hasBoxShadow})),"boxShadow"===u&&Object.assign(i,p({value:g,styleAppliedFor:"box-shadow",isEnableShadow:t.hasBoxShadow}))})}else i[`--${u}`]=getAttrValue(u,g,r),"hasBoxShadow"===u&&t.boxShadow&&Object.assign(i,p({value:t.boxShadow,styleAppliedFor:"box-shadow",isEnableShadow:t.hasBoxShadow}))}),i}let splitStyle=(e,s={})=>{let a=e.map(e=>i(e)).flat(),o=Object.keys(s).filter(e=>a.includes(e)),t=o.reduce((e,a)=>({...e,[a]:s[a]}),{}),r=Object.keys(s).filter(e=>!o.includes(e)).reduce((e,a)=>({...e,[a]:s[a]}),{});return[t,r]};export{composeAdvanceStyle,splitStyle};
@@ -1,19 +1 @@
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 = [
12
- 'Row',
13
- 'Section',
14
- 'Product',
15
- 'HeroBanner',
16
- 'CollectionBanner'
17
- ];
18
-
19
- export { devicesMapping, layoutComponent, stateMapping };
1
+ let stateMapping={normal:"",hover:"-hvr",focus:"-focus"},devicesMapping={desktop:"",tablet:"-tablet",mobile:"-mobile"},layoutComponent=["Row","Section","Product","HeroBanner","CollectionBanner"];export{devicesMapping,layoutComponent,stateMapping};
@@ -1,4 +1 @@
1
- const isLocalEnv = process.env.NEXT_CONVERT_ENV === 'local';
2
- const baseAssetURL = process.env.GP_BASE_ASSET_URL || 'https://d3kbi0je7pp4lw.cloudfront.net';
3
-
4
- export { baseAssetURL, isLocalEnv };
1
+ let isLocalEnv="local"===process.env.NEXT_CONVERT_ENV,baseAssetURL=process.env.GP_BASE_ASSET_URL||"https://d3kbi0je7pp4lw.cloudfront.net";export{baseAssetURL,isLocalEnv};
@@ -1,5 +1 @@
1
- const genVariable = (variableName)=>{
2
- return `var(--g-${variableName})`;
3
- };
4
-
5
- export { genVariable };
1
+ let genVariable=e=>`var(--g-${e})`;export{genVariable};
@@ -1,6 +1 @@
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 };
1
+ let validateEmail=a=>{let e=new RegExp(/^(?:[^<>()[\]\\.,;:\s@"]+(?:\.[^<>()[\]\\.,;:\s@"]+)*|".+")@(?:\[\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}\]|(?:[a-zA-Z\-\d]+\.)+[a-zA-Z]{2,})$/);return e.test(a)};export{validateEmail as default,validateEmail};
@@ -1,7 +1 @@
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
- */ const flattenConnection = (connection)=>{
4
- return connection?.edges?.map((edge)=>edge.node) ?? [];
5
- };
6
-
7
- export { flattenConnection };
1
+ let flattenConnection=e=>e?.edges?.map(e=>e.node)??[];export{flattenConnection};
@@ -1,27 +1 @@
1
- const getResponsiveValue = (input, k)=>{
2
- if (!k) return {};
3
- return {
4
- desktop: input?.desktop?.[k],
5
- tablet: input?.tablet?.[k],
6
- mobile: input?.mobile?.[k]
7
- };
8
- };
9
- const getResponsiveStateValue = (k, input)=>{
10
- return {
11
- desktop: input?.desktop?.[k],
12
- tablet: input?.tablet?.[k],
13
- mobile: input?.mobile?.[k]
14
- };
15
- };
16
- const getResponsiveValueByScreen = (value, breakpoint, defaultValue)=>{
17
- switch(breakpoint){
18
- case 'tablet':
19
- return value?.tablet ?? value?.desktop ?? defaultValue;
20
- case 'mobile':
21
- return value?.mobile ?? value?.tablet ?? value?.desktop ?? defaultValue;
22
- default:
23
- return value?.desktop ?? defaultValue;
24
- }
25
- };
26
-
27
- export { getResponsiveStateValue, getResponsiveValue, getResponsiveValueByScreen };
1
+ let getResponsiveValue=(e,t)=>t?{desktop:e?.desktop?.[t],tablet:e?.tablet?.[t],mobile:e?.mobile?.[t]}:{},getResponsiveStateValue=(e,t)=>({desktop:t?.desktop?.[e],tablet:t?.tablet?.[e],mobile:t?.mobile?.[e]}),getResponsiveValueByScreen=(e,t,s)=>{switch(t){case"tablet":return e?.tablet??e?.desktop??s;case"mobile":return e?.mobile??e?.tablet??e?.desktop??s;default:return e?.desktop??s}},isColumnDirectionExist=(e,t)=>"desktop"!==t&&"tablet"!==t&&e?.[t]?.cols?.length!==e?.desktop?.cols?.length;export{getResponsiveStateValue,getResponsiveValue,getResponsiveValueByScreen,isColumnDirectionExist};
@@ -1,90 +1 @@
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 };
1
+ let globalSortNameMapping={"typography-heading-1-fontFamily":"h1-ff","typography-heading-1-fontSize":"h1-size","typography-heading-1-fontWeight":"h1-weight","typography-heading-1-lineHeight":"h1-lh","typography-heading-1-letterSpacing":"h1-ls","typography-heading-1-fontStyle":"h1-fs","typography-heading-2-fontFamily":"h2-ff","typography-heading-2-fontSize":"h2-size","typography-heading-2-fontWeight":"h2-weight","typography-heading-2-lineHeight":"h2-lh","typography-heading-2-letterSpacing":"h2-ls","typography-heading-2-fontStyle":"h2-fs","typography-heading-3-fontFamily":"h3-ff","typography-heading-3-fontSize":"h3-size","typography-heading-3-fontWeight":"h3-weight","typography-heading-3-lineHeight":"h3-lh","typography-heading-3-letterSpacing":"h3-ls","typography-heading-3-fontStyle":"h3-fs","typography-subheading-1-fontFamily":"sh1-ff","typography-subheading-1-fontSize":"sh1-size","typography-subheading-1-fontWeight":"sh1-weight","typography-subheading-1-lineHeight":"sh1-lh","typography-subheading-1-letterSpacing":"sh1-ls","typography-subheading-1-fontStyle":"sh1-fs","typography-subheading-2-fontFamily":"sh2-ff","typography-subheading-2-fontSize":"sh2-size","typography-subheading-2-fontWeight":"sh2-weight","typography-subheading-2-lineHeight":"sh2-lh","typography-subheading-2-letterSpacing":"sh2-ls","typography-subheading-2-fontStyle":"sh2-fs","typography-subheading-3-fontFamily":"sh3-ff","typography-subheading-3-fontSize":"sh3-size","typography-subheading-3-fontWeight":"sh3-weight","typography-subheading-3-lineHeight":"sh3-lh","typography-subheading-3-letterSpacing":"sh3-ls","typography-subheading-3-fontStyle":"sh3-fs","typography-paragraph-1-fontFamily":"p1-ff","typography-paragraph-1-fontSize":"p1-size","typography-paragraph-1-fontWeight":"p1-weight","typography-paragraph-1-lineHeight":"p1-lh","typography-paragraph-1-letterSpacing":"p1-ls","typography-paragraph-1-fontStyle":"p1-fs","typography-paragraph-2-fontFamily":"p2-ff","typography-paragraph-2-fontSize":"p2-size","typography-paragraph-2-fontWeight":"p2-weight","typography-paragraph-2-lineHeight":"p2-lh","typography-paragraph-2-letterSpacing":"p2-ls","typography-paragraph-2-fontStyle":"p2-fs","typography-paragraph-3-fontFamily":"p3-ff","typography-paragraph-3-fontSize":"p3-size","typography-paragraph-3-fontWeight":"p3-weight","typography-paragraph-3-lineHeight":"p3-lh","typography-paragraph-3-letterSpacing":"p3-ls","typography-paragraph-3-fontStyle":"p3-fs","color-brand":"c-brand","color-highlight":"c-highlight","color-text-1":"c-text-1","color-text-2":"c-text-2","color-text-3":"c-text-3","color-bg-1":"c-bg-1","color-bg-2":"c-bg-2","color-bg-3":"c-bg-3","color-line-1":"c-line-1","color-line-2":"c-line-2","color-line-3":"c-line-3","color-success":"c-success","color-info":"c-info","color-warning":"c-warning","color-error":"c-error","spacing-xxs":"s-xxs","spacing-xs":"s-xs","spacing-s":"s-s","spacing-m":"s-m","spacing-l":"s-l","spacing-xl":"s-xl","spacing-2xl":"s-2xl","spacing-3xl":"s-3xl","spacing-4xl":"s-4xl","spacing-5xl":"s-5xl","container-width":"ct-w","container-padding":"ct-p","text-shadow":"ts","box-shadow":"shadow"};function getShortName(h){return globalSortNameMapping[h]||h}export{getShortName};
@@ -1,5 +1 @@
1
- function isBrowser() {
2
- return typeof window !== 'undefined';
3
- }
4
-
5
- export { isBrowser as default };
1
+ function isBrowser(){return"undefined"!=typeof window}export{isBrowser as default};
@@ -1,5 +1 @@
1
- function isDefined(argument) {
2
- return argument !== undefined;
3
- }
4
-
5
- export { isDefined };
1
+ function isDefined(e){return void 0!==e}export{isDefined};
@@ -1,7 +1 @@
1
- import { Children } from 'react';
2
-
3
- const isEmptyChildren = (children)=>{
4
- return Children.count(children) < 1 || !children;
5
- };
6
-
7
- export { isEmptyChildren as default, isEmptyChildren };
1
+ import{Children as t}from"react";let isEmptyChildren=e=>1>t.count(e)||!e;export{isEmptyChildren as default,isEmptyChildren};
@@ -1,5 +1 @@
1
- function isSafari() {
2
- return navigator.userAgent.indexOf('Safari') != -1 && navigator.userAgent.indexOf('Chrome') == -1;
3
- }
4
-
5
- export { isSafari as default };
1
+ function isSafari(){return -1!=navigator.userAgent.indexOf("Safari")&&-1==navigator.userAgent.indexOf("Chrome")}export{isSafari as default};
@@ -1,54 +1 @@
1
- import { devicesMapping } from './constant.js';
2
- import { getResponsiveValueByScreen, getResponsiveValue } from './get-resonsive-value.js';
3
-
4
- const gridToArrayRegex = // eslint-disable-next-line regexp/no-super-linear-backtracking
5
- /[^\s()]+(?:\([^\s()]+(?:\([^()]+\))?(?:, *[^\s()]+(?:\([^()]+\))?)*\))?/g; // Regex convert css grid to array
6
- const optionLayoutStyle = (column)=>{
7
- if (!column) return {};
8
- const style = {};
9
- for (const [key, value] of Object.entries(column)){
10
- Object.assign(style, {
11
- [`--gtc${devicesMapping?.[key]}`]: `repeat(${parseFloat(value + '') || 1}, minmax(0, 1fr))`
12
- });
13
- }
14
- return style;
15
- };
16
- const composeGridLayout = (layout)=>{
17
- const display = getResponsiveValue(layout, 'display');
18
- const desktop = (getResponsiveValueByScreen(display, 'desktop') === 'fit' ? layout?.desktop?.cols?.map(()=>`minmax(0, auto)`) : layout?.desktop?.cols?.map((col)=>`minmax(0, ${col}fr)`))?.join(' ');
19
- const tablet = (getResponsiveValueByScreen(display, 'tablet') === 'fit' ? layout?.tablet?.cols?.map(()=>`minmax(0, auto)`) : layout?.tablet?.cols?.map((col)=>`minmax(0, ${col}fr)`))?.join(' ');
20
- const mobile = (getResponsiveValueByScreen(display, 'mobile') === 'fit' ? layout?.mobile?.cols?.map(()=>`minmax(0, auto)`) : layout?.mobile?.cols?.map((col)=>`minmax(0, ${col}fr)`))?.join(' ');
21
- return {
22
- [`--gtc`]: desktop,
23
- [`--gtc-tablet`]: tablet,
24
- [`--gtc-mobile`]: mobile
25
- };
26
- };
27
- const gridToArray = (layout)=>{
28
- return layout ? layout.match(gridToArrayRegex) ?? [] : [];
29
- };
30
- const convertOldLayout = (layout)=>{
31
- const desktopCol = gridToArray(layout?.desktop).length;
32
- const tabletCol = gridToArray(layout?.tablet).length;
33
- const mobileCol = gridToArray(layout?.mobile).length;
34
- return {
35
- desktop: {
36
- cols: desktopCol ? Array.from({
37
- length: desktopCol
38
- }, ()=>12 / desktopCol) : undefined,
39
- display: 'fill'
40
- },
41
- tablet: {
42
- cols: tabletCol ? Array.from({
43
- length: tabletCol
44
- }, ()=>12 / tabletCol) : undefined
45
- },
46
- mobile: {
47
- cols: mobileCol ? Array.from({
48
- length: mobileCol
49
- }, ()=>12 / mobileCol) : undefined
50
- }
51
- };
52
- };
53
-
54
- export { composeGridLayout, convertOldLayout, gridToArrayRegex, optionLayoutStyle };
1
+ import{devicesMapping as t}from"./constant.js";import{getResponsiveValueByScreen as o,getResponsiveValue as e}from"./get-resonsive-value.js";let gridToArrayRegex=/[^\s()]+(?:\([^\s()]+(?:\([^()]+\))?(?:, *[^\s()]+(?:\([^()]+\))?)*\))?/g,optionLayoutStyle=o=>{if(!o)return{};let e={};for(let[r,a]of Object.entries(o))Object.assign(e,{[`--gtc${t?.[r]}`]:`repeat(${parseFloat(a+"")||1}, minmax(0, 1fr))`});return e},composeGridLayout=t=>{let r=e(t,"display"),a=("fit"===o(r,"desktop")?t?.desktop?.cols?.map(()=>"minmax(0, auto)"):t?.desktop?.cols?.map(t=>`minmax(0, ${t}fr)`))?.join(" "),i=("fit"===o(r,"tablet")?t?.tablet?.cols?.map(()=>"minmax(0, auto)"):t?.tablet?.cols?.map(t=>`minmax(0, ${t}fr)`))?.join(" "),l=("fit"===o(r,"mobile")?t?.mobile?.cols?.map(()=>"minmax(0, auto)"):t?.mobile?.cols?.map(t=>`minmax(0, ${t}fr)`))?.join(" ");return{"--gtc":a,"--gtc-tablet":i,"--gtc-mobile":l}},gridToArray=t=>t?t.match(gridToArrayRegex)??[]:[],convertOldLayout=t=>{let o=gridToArray(t?.desktop).length,e=gridToArray(t?.tablet).length,r=gridToArray(t?.mobile).length;return{desktop:{cols:o?Array.from({length:o},()=>12/o):void 0,display:"fill"},tablet:{cols:e?Array.from({length:e},()=>12/e):void 0},mobile:{cols:r?Array.from({length:r},()=>12/r):void 0}}};export{composeGridLayout,convertOldLayout,gridToArrayRegex,optionLayoutStyle};
@@ -1,29 +1 @@
1
- const SCRIPTS_LOADED = {};
2
- function loadScript(src, options) {
3
- const isScriptLoaded = SCRIPTS_LOADED[src];
4
- if (isScriptLoaded) {
5
- return isScriptLoaded;
6
- }
7
- const promise = new Promise((resolve, reject)=>{
8
- const script = document.createElement('script');
9
- if (options?.module) {
10
- script.type = 'module';
11
- }
12
- script.src = src;
13
- script.onload = ()=>{
14
- resolve(true);
15
- };
16
- script.onerror = ()=>{
17
- reject(false);
18
- };
19
- if (options?.in === 'head') {
20
- document.head.appendChild(script);
21
- } else {
22
- document.body.appendChild(script);
23
- }
24
- });
25
- SCRIPTS_LOADED[src] = promise;
26
- return promise;
27
- }
28
-
29
- export { loadScript };
1
+ let SCRIPTS_LOADED={};function loadScript(e,t){let d=SCRIPTS_LOADED[e];if(d)return d;let o=new Promise((d,o)=>{let n=document.createElement("script");t?.module&&(n.type="module"),n.src=e,n.onload=()=>{d(!0)},n.onerror=()=>{o(!1)},t?.in==="head"?document.head.appendChild(n):document.body.appendChild(n)});return SCRIPTS_LOADED[e]=o,o}export{loadScript};
@@ -1,117 +1 @@
1
- import { getResponsiveValueByScreen } from './get-resonsive-value.js';
2
-
3
- const removeNullUndefined = (obj)=>Object.entries(obj).reduce((a, [k, v])=>{
4
- if (v === null || v === undefined) return a;
5
- return {
6
- ...a,
7
- [k]: v
8
- };
9
- }, {});
10
- const makeStyleKey = (name)=>{
11
- return [
12
- name,
13
- `hvr-${name}`,
14
- `focus-${name}`,
15
- `${name}-tablet`,
16
- `hvr-${name}-tablet`,
17
- `focus-${name}-tablet`,
18
- `${name}-mobile`,
19
- `hvr-${name}-mobile`,
20
- `focus-${name}-mobile`
21
- ].map((key)=>`--${key}`);
22
- };
23
- const makeStyle = (style)=>{
24
- return removeNullUndefined(Object.fromEntries(Object.entries(style).map(([key, value])=>[
25
- `--${key}`,
26
- value
27
- ])));
28
- };
29
- const makeStyleState = (name, value)=>{
30
- if (!value) return {};
31
- return {
32
- [`--${name}`]: value?.normal,
33
- [`--hvr-${name}`]: value?.hover,
34
- [`--focus-${name}`]: value?.focus
35
- };
36
- };
37
- const makeStyleResponsiveState = (name, value)=>{
38
- if (!value) return {};
39
- return {
40
- [`--${name}`]: value?.desktop?.normal,
41
- [`--hvr-${name}`]: value?.desktop?.hover,
42
- [`--focus-${name}`]: value?.desktop?.focus,
43
- [`--${name}-tablet`]: value?.tablet?.normal,
44
- [`--hvr-${name}-tablet`]: value?.tablet?.hover,
45
- [`--focus-${name}-tablet`]: value?.tablet?.focus,
46
- [`--${name}-mobile`]: value?.mobile?.normal,
47
- [`--hvr-${name}-mobile`]: value?.mobile?.hover,
48
- [`--focus-${name}-mobile`]: value?.mobile?.focus
49
- };
50
- };
51
- const makeStyleResponsive = (name, value)=>{
52
- return {
53
- [`--${name}`]: value?.desktop,
54
- [`--${name}-tablet`]: value?.tablet,
55
- [`--${name}-mobile`]: value?.mobile
56
- };
57
- };
58
- const makeWidth = (widthValue, fullWidthValue)=>{
59
- const getVal = (deviceValue, widthValue, fullWidthValue)=>{
60
- const widthVal = widthValue?.[deviceValue] === undefined ? widthValue?.['desktop'] : widthValue?.[deviceValue];
61
- const fullWidthVal = fullWidthValue?.[deviceValue] === undefined ? fullWidthValue?.['desktop'] : fullWidthValue?.[deviceValue];
62
- if (fullWidthVal) {
63
- return '100%';
64
- } else if (fullWidthVal === false) {
65
- return widthVal ?? widthVal;
66
- } else {
67
- return widthVal || 'auto';
68
- }
69
- };
70
- return {
71
- desktop: getVal('desktop', widthValue, fullWidthValue),
72
- tablet: getVal('tablet', widthValue, fullWidthValue),
73
- mobile: getVal('mobile', widthValue, fullWidthValue)
74
- };
75
- };
76
- const makeHeight = (heighValue, autoHeight)=>{
77
- const getVal = (deviceValue, heighValue, autoHeight)=>{
78
- const heightVal = heighValue?.[deviceValue];
79
- const isAuto = autoHeight?.[deviceValue];
80
- if (isAuto) {
81
- return 'auto';
82
- } else if (isAuto === false) {
83
- return heightVal ?? heightVal;
84
- } else {
85
- return heightVal;
86
- }
87
- };
88
- return {
89
- desktop: getVal('desktop', heighValue, autoHeight),
90
- tablet: getVal('tablet', heighValue, autoHeight),
91
- mobile: getVal('mobile', heighValue, autoHeight)
92
- };
93
- };
94
- const makeAspectRatio = (aspectRatio, aspectWidth, aspectHeight)=>{
95
- return {
96
- desktop: aspectRatio?.desktop === 'custom' ? `${getResponsiveValueByScreen(aspectWidth, 'desktop')}/${getResponsiveValueByScreen(aspectHeight, 'desktop')}` : aspectRatio?.desktop,
97
- tablet: aspectRatio?.tablet === 'custom' ? `${getResponsiveValueByScreen(aspectWidth, 'tablet')}/${getResponsiveValueByScreen(aspectHeight, 'tablet')}` : aspectRatio?.tablet,
98
- mobile: aspectRatio?.mobile === 'custom' ? `${getResponsiveValueByScreen(aspectWidth, 'mobile')}/${getResponsiveValueByScreen(aspectHeight, 'mobile')}` : aspectRatio?.mobile
99
- };
100
- };
101
- const makeLineClamp = (lineClampValue, hasLineClampValue)=>{
102
- const getVal = (deviceValue, lineClampValue, hasLineClampValue)=>{
103
- const lineClamp = lineClampValue?.[deviceValue];
104
- const hasLineClamp = hasLineClampValue?.[deviceValue] || hasLineClampValue?.['desktop'];
105
- if (hasLineClamp || hasLineClamp === undefined) {
106
- return lineClamp;
107
- }
108
- return 'unset';
109
- };
110
- return {
111
- desktop: getVal('desktop', lineClampValue, hasLineClampValue),
112
- tablet: getVal('tablet', lineClampValue, hasLineClampValue),
113
- mobile: getVal('mobile', lineClampValue, hasLineClampValue)
114
- };
115
- };
116
-
117
- export { makeAspectRatio, makeHeight, makeLineClamp, makeStyle, makeStyleKey, makeStyleResponsive, makeStyleResponsiveState, makeStyleState, makeWidth, removeNullUndefined };
1
+ import{getResponsiveValueByScreen as e}from"./get-resonsive-value.js";let removeNullUndefined=e=>Object.entries(e).reduce((e,[t,o])=>null==o?e:{...e,[t]:o},{}),makeStyleKey=e=>[e,`hvr-${e}`,`focus-${e}`,`${e}-tablet`,`hvr-${e}-tablet`,`focus-${e}-tablet`,`${e}-mobile`,`hvr-${e}-mobile`,`focus-${e}-mobile`].map(e=>`--${e}`),makeStyle=e=>removeNullUndefined(Object.fromEntries(Object.entries(e).map(([e,t])=>[`--${e}`,t]))),makeStyleState=(e,t)=>t?{[`--${e}`]:t?.normal,[`--hvr-${e}`]:t?.hover,[`--focus-${e}`]:t?.focus}:{},makeStyleResponsiveState=(e,t)=>t?{[`--${e}`]:t?.desktop?.normal,[`--hvr-${e}`]:t?.desktop?.hover,[`--focus-${e}`]:t?.desktop?.focus,[`--${e}-tablet`]:t?.tablet?.normal,[`--hvr-${e}-tablet`]:t?.tablet?.hover,[`--focus-${e}-tablet`]:t?.tablet?.focus,[`--${e}-mobile`]:t?.mobile?.normal,[`--hvr-${e}-mobile`]:t?.mobile?.hover,[`--focus-${e}-mobile`]:t?.mobile?.focus}:{},makeStyleResponsive=(e,t)=>({[`--${e}`]:t?.desktop,[`--${e}-tablet`]:t?.tablet,[`--${e}-mobile`]:t?.mobile}),makeWidth=(e,t)=>{let o=(e,t,o)=>{let l=t?.[e]===void 0?t?.desktop:t?.[e],a=o?.[e]===void 0?o?.desktop:o?.[e];return a?"100%":!1===a?l??l:l||"auto"};return{desktop:o("desktop",e,t),tablet:o("tablet",e,t),mobile:o("mobile",e,t)}},makeGlobalSizeWidthResponsive=e=>({"--w":e?.desktop?.width,"--w-tablet":e?.tablet?.width,"--w-mobile":e?.mobile?.width}),makeHeight=(e,t)=>{let o=(e,t,o)=>{let l=t?.[e],a=o?.[e];return a?"auto":!1===a?l??l:l};return{desktop:o("desktop",e,t),tablet:o("tablet",e,t),mobile:o("mobile",e,t)}},makeAspectRatio=(t,o,l)=>{let a={},m=["desktop","mobile","tablet"];return m.forEach(m=>{let i=e(t,m);"none"!==i&&(a={...a,[m]:"custom"!==i?i:`${e(o,"desktop")}/${e(l,"desktop")}`})}),a},makeLineClamp=(e,t)=>{let o=(e,t,o)=>{let l=t?.[e],a=o?.[e]||o?.desktop;return a||void 0===a?l:"unset"};return{desktop:o("desktop",e,t),tablet:o("tablet",e,t),mobile:o("mobile",e,t)}};export{makeAspectRatio,makeGlobalSizeWidthResponsive,makeHeight,makeLineClamp,makeStyle,makeStyleKey,makeStyleResponsive,makeStyleResponsiveState,makeStyleState,makeWidth,removeNullUndefined};
@@ -1,21 +1 @@
1
- function normalizeBuilderData(data) {
2
- const result = {};
3
- function compose(data, res = {}) {
4
- const childrens = data.childrens;
5
- const items = childrens?.map((child)=>child.uid) ?? [];
6
- res[data.uid] = {
7
- ...data,
8
- childrens: items,
9
- type: 'component'
10
- };
11
- if (childrens) {
12
- childrens.map((child)=>compose(child, res));
13
- }
14
- }
15
- compose(data, result);
16
- return {
17
- ...result
18
- };
19
- }
20
-
21
- export { normalizeBuilderData };
1
+ function normalizeBuilderData(e){let n={};return!function e(n,i={}){let t=n.childrens,r=t?.map(e=>e.uid)??[];i[n.uid]={...n,childrens:r,type:"component"},t&&t.map(n=>e(n,i))}(e,n),{...n}}export{normalizeBuilderData};