@gem-sdk/core 1.14.0-next.91 → 1.14.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 (241) hide show
  1. package/dist/cjs/components/AddOn.js +18 -1
  2. package/dist/cjs/components/ComponentWrapper.js +28 -1
  3. package/dist/cjs/components/ComponentWrapperPreview.js +72 -1
  4. package/dist/cjs/components/Empty.js +7 -1
  5. package/dist/cjs/components/Render.js +65 -1
  6. package/dist/cjs/components/Render.liquid.js +158 -3
  7. package/dist/cjs/components/RenderBlock.js +54 -1
  8. package/dist/cjs/components/RenderPreview.js +66 -1
  9. package/dist/cjs/components/RenderSection.js +23 -1
  10. package/dist/cjs/components/constant.js +39 -1
  11. package/dist/cjs/contexts/AddonContext.js +36 -1
  12. package/dist/cjs/contexts/BuilderComponent.js +34 -1
  13. package/dist/cjs/contexts/BuilderContext.js +35 -1
  14. package/dist/cjs/contexts/BuilderPreviewContext.js +370 -1
  15. package/dist/cjs/contexts/CartLineContext.js +29 -1
  16. package/dist/cjs/contexts/CollectionContext.js +38 -1
  17. package/dist/cjs/contexts/ModalContext.js +47 -1
  18. package/dist/cjs/contexts/ProductContext.js +149 -1
  19. package/dist/cjs/contexts/ProductListContext.js +32 -1
  20. package/dist/cjs/contexts/SectionContext.js +53 -1
  21. package/dist/cjs/contexts/ShopContext.js +70 -1
  22. package/dist/cjs/graphql/fragments/analytic.generated.js +6 -2
  23. package/dist/cjs/graphql/fragments/collection-detail.generated.js +6 -2
  24. package/dist/cjs/graphql/fragments/collection-product.generated.js +6 -2
  25. package/dist/cjs/graphql/fragments/collection.generated.js +6 -2
  26. package/dist/cjs/graphql/fragments/custom-code.generated.js +6 -2
  27. package/dist/cjs/graphql/fragments/data-seo.generated.js +6 -2
  28. package/dist/cjs/graphql/fragments/media.generated.js +6 -3
  29. package/dist/cjs/graphql/fragments/product-little.generated.js +6 -2
  30. package/dist/cjs/graphql/fragments/product-option-value.generated.js +6 -2
  31. package/dist/cjs/graphql/fragments/product-option.generated.js +6 -2
  32. package/dist/cjs/graphql/fragments/product.generated.js +6 -2
  33. package/dist/cjs/graphql/fragments/published-custom-section.generated.js +6 -2
  34. package/dist/cjs/graphql/fragments/published-page-section.generated.js +6 -2
  35. package/dist/cjs/graphql/fragments/published-theme-page.generated.js +6 -2
  36. package/dist/cjs/graphql/fragments/published-theme-style.generated.js +6 -2
  37. package/dist/cjs/graphql/fragments/selected-option.generated.js +6 -2
  38. package/dist/cjs/graphql/fragments/variant.generated.js +6 -2
  39. package/dist/cjs/graphql/mutations/page-view-up.generated.js +7 -3
  40. package/dist/cjs/graphql/queries/collection-detail-filter.generated.js +16 -2
  41. package/dist/cjs/graphql/queries/collection.generated.js +14 -2
  42. package/dist/cjs/graphql/queries/collections.generated.js +9 -2
  43. package/dist/cjs/graphql/queries/preview-page.generated.js +14 -2
  44. package/dist/cjs/graphql/queries/product-little-detail.generated.js +11 -2
  45. package/dist/cjs/graphql/queries/product-medias.generated.js +8 -2
  46. package/dist/cjs/graphql/queries/product-variants.generated.js +10 -2
  47. package/dist/cjs/graphql/queries/products.generated.js +17 -3
  48. package/dist/cjs/graphql/queries/published-theme-pages.generated.js +14 -2
  49. package/dist/cjs/graphql/queries/store-property.generated.js +6 -2
  50. package/dist/cjs/helpers/GlobalEvent.js +19 -1
  51. package/dist/cjs/helpers/background.js +109 -1
  52. package/dist/cjs/helpers/borders.js +183 -4
  53. package/dist/cjs/helpers/clone-deep.js +5 -1
  54. package/dist/cjs/helpers/cls.js +16 -1
  55. package/dist/cjs/helpers/colors.js +183 -1
  56. package/dist/cjs/helpers/compose-advance-style.js +188 -1
  57. package/dist/cjs/helpers/constant.js +23 -1
  58. package/dist/cjs/helpers/convert.js +7 -1
  59. package/dist/cjs/helpers/css-variable.js +7 -1
  60. package/dist/cjs/helpers/email.js +11 -1
  61. package/dist/cjs/helpers/flatten-connection.js +9 -1
  62. package/dist/cjs/helpers/get-resonsive-value.js +31 -1
  63. package/dist/cjs/helpers/get-shortname.js +92 -1
  64. package/dist/cjs/helpers/is-browser.js +9 -1
  65. package/dist/cjs/helpers/is-defined.js +7 -1
  66. package/dist/cjs/helpers/is-empty-children.js +12 -1
  67. package/dist/cjs/helpers/is-safari.js +9 -1
  68. package/dist/cjs/helpers/layout.js +59 -1
  69. package/dist/cjs/helpers/load-script.js +31 -1
  70. package/dist/cjs/helpers/make-style.js +128 -1
  71. package/dist/cjs/helpers/normalize-builder-data.js +23 -1
  72. package/dist/cjs/helpers/prefetch-queries.js +78 -1
  73. package/dist/cjs/helpers/product.js +45 -1
  74. package/dist/cjs/helpers/queries/get-collection.js +220 -1
  75. package/dist/cjs/helpers/queries/get-collections.js +21 -1
  76. package/dist/cjs/helpers/queries/get-product-by-slug.js +125 -1
  77. package/dist/cjs/helpers/queries/get-product.js +154 -1
  78. package/dist/cjs/helpers/queries/get-products.js +161 -1
  79. package/dist/cjs/helpers/query.js +29 -1
  80. package/dist/cjs/helpers/radius.js +131 -6
  81. package/dist/cjs/helpers/render.js +71 -1
  82. package/dist/cjs/helpers/shadow.js +56 -1
  83. package/dist/cjs/helpers/size.js +35 -4
  84. package/dist/cjs/helpers/spacing.js +43 -1
  85. package/dist/cjs/helpers/tracking/fpixel.js +28 -1
  86. package/dist/cjs/helpers/tracking/gtag.js +93 -1
  87. package/dist/cjs/helpers/tracking/tiktokpixel.js +17 -1
  88. package/dist/cjs/helpers/typography.js +105 -17
  89. package/dist/cjs/helpers/variant.js +8 -1
  90. package/dist/cjs/hooks/cart/use-add-to-cart.js +20 -1
  91. package/dist/cjs/hooks/cart/use-cart-data.js +28 -1
  92. package/dist/cjs/hooks/cart/use-cart-discount-codes-update.js +20 -1
  93. package/dist/cjs/hooks/cart/use-cart-note-update.js +20 -1
  94. package/dist/cjs/hooks/cart/use-create-cart.js +22 -1
  95. package/dist/cjs/hooks/cart/use-remove-cart-item.js +20 -1
  96. package/dist/cjs/hooks/cart/use-update-cart-item.js +20 -1
  97. package/dist/cjs/hooks/shop/use-collection-query.js +22 -1
  98. package/dist/cjs/hooks/shop/use-collections-query.js +17 -1
  99. package/dist/cjs/hooks/shop/use-product-query.js +22 -1
  100. package/dist/cjs/hooks/shop/use-products-query.js +22 -1
  101. package/dist/cjs/hooks/shop.js +126 -1
  102. package/dist/cjs/hooks/use-current-device.js +21 -1
  103. package/dist/cjs/hooks/use-lazy-video.js +15 -1
  104. package/dist/cjs/hooks/useCartId.js +44 -1
  105. package/dist/cjs/hooks/useCartLine.js +11 -1
  106. package/dist/cjs/hooks/useCartUI.js +48 -1
  107. package/dist/cjs/hooks/useCollection.js +9 -1
  108. package/dist/cjs/hooks/useFetchHandle.js +13 -1
  109. package/dist/cjs/hooks/useFormatMoney.js +58 -1
  110. package/dist/cjs/hooks/useIsomorphicLayoutEffect.js +10 -1
  111. package/dist/cjs/hooks/useLoadScript.js +32 -1
  112. package/dist/cjs/hooks/useMoney.js +84 -1
  113. package/dist/cjs/hooks/usePrevious.js +19 -1
  114. package/dist/cjs/hooks/useProduct.js +124 -1
  115. package/dist/cjs/hooks/useProductList.js +21 -1
  116. package/dist/cjs/hooks/useSuspenseFetch.js +27 -1
  117. package/dist/cjs/hooks/useSwatchesOptions.js +41 -1
  118. package/dist/cjs/index.js +291 -1
  119. package/dist/cjs/types/global-style.js +14 -1
  120. package/dist/cjs/types/shop.js +2 -1
  121. package/dist/esm/components/AddOn.js +14 -1
  122. package/dist/esm/components/ComponentWrapper.js +24 -1
  123. package/dist/esm/components/ComponentWrapperPreview.js +68 -1
  124. package/dist/esm/components/Empty.js +3 -1
  125. package/dist/esm/components/Render.js +61 -1
  126. package/dist/esm/components/Render.liquid.js +153 -3
  127. package/dist/esm/components/RenderBlock.js +50 -1
  128. package/dist/esm/components/RenderPreview.js +62 -1
  129. package/dist/esm/components/RenderSection.js +19 -1
  130. package/dist/esm/components/constant.js +37 -1
  131. package/dist/esm/contexts/AddonContext.js +32 -1
  132. package/dist/esm/contexts/BuilderComponent.js +31 -1
  133. package/dist/esm/contexts/BuilderContext.js +32 -1
  134. package/dist/esm/contexts/BuilderPreviewContext.js +367 -1
  135. package/dist/esm/contexts/CartLineContext.js +26 -1
  136. package/dist/esm/contexts/CollectionContext.js +35 -1
  137. package/dist/esm/contexts/ModalContext.js +44 -1
  138. package/dist/esm/contexts/ProductContext.js +146 -1
  139. package/dist/esm/contexts/ProductListContext.js +28 -1
  140. package/dist/esm/contexts/SectionContext.js +49 -1
  141. package/dist/esm/contexts/ShopContext.js +67 -1
  142. package/dist/esm/graphql/fragments/analytic.generated.js +4 -2
  143. package/dist/esm/graphql/fragments/collection-detail.generated.js +4 -2
  144. package/dist/esm/graphql/fragments/collection-product.generated.js +4 -2
  145. package/dist/esm/graphql/fragments/collection.generated.js +4 -2
  146. package/dist/esm/graphql/fragments/custom-code.generated.js +4 -2
  147. package/dist/esm/graphql/fragments/data-seo.generated.js +4 -2
  148. package/dist/esm/graphql/fragments/media.generated.js +4 -3
  149. package/dist/esm/graphql/fragments/product-little.generated.js +4 -2
  150. package/dist/esm/graphql/fragments/product-option-value.generated.js +4 -2
  151. package/dist/esm/graphql/fragments/product-option.generated.js +4 -2
  152. package/dist/esm/graphql/fragments/product.generated.js +4 -2
  153. package/dist/esm/graphql/fragments/published-custom-section.generated.js +4 -2
  154. package/dist/esm/graphql/fragments/published-page-section.generated.js +4 -2
  155. package/dist/esm/graphql/fragments/published-theme-page.generated.js +4 -2
  156. package/dist/esm/graphql/fragments/published-theme-style.generated.js +4 -2
  157. package/dist/esm/graphql/fragments/selected-option.generated.js +4 -2
  158. package/dist/esm/graphql/fragments/variant.generated.js +4 -2
  159. package/dist/esm/graphql/mutations/page-view-up.generated.js +5 -3
  160. package/dist/esm/graphql/queries/collection-detail-filter.generated.js +22 -10
  161. package/dist/esm/graphql/queries/collection.generated.js +18 -8
  162. package/dist/esm/graphql/queries/collections.generated.js +8 -3
  163. package/dist/esm/graphql/queries/preview-page.generated.js +18 -8
  164. package/dist/esm/graphql/queries/product-little-detail.generated.js +12 -5
  165. package/dist/esm/graphql/queries/product-medias.generated.js +6 -2
  166. package/dist/esm/graphql/queries/product-variants.generated.js +10 -4
  167. package/dist/esm/graphql/queries/products.generated.js +20 -9
  168. package/dist/esm/graphql/queries/published-theme-pages.generated.js +18 -8
  169. package/dist/esm/graphql/queries/store-property.generated.js +4 -2
  170. package/dist/esm/helpers/GlobalEvent.js +15 -1
  171. package/dist/esm/helpers/background.js +106 -1
  172. package/dist/esm/helpers/borders.js +175 -4
  173. package/dist/esm/helpers/clone-deep.js +3 -1
  174. package/dist/esm/helpers/cls.js +14 -1
  175. package/dist/esm/helpers/colors.js +168 -1
  176. package/dist/esm/helpers/compose-advance-style.js +185 -1
  177. package/dist/esm/helpers/constant.js +19 -1
  178. package/dist/esm/helpers/convert.js +4 -1
  179. package/dist/esm/helpers/css-variable.js +5 -1
  180. package/dist/esm/helpers/email.js +6 -1
  181. package/dist/esm/helpers/flatten-connection.js +7 -1
  182. package/dist/esm/helpers/get-resonsive-value.js +27 -1
  183. package/dist/esm/helpers/get-shortname.js +90 -1
  184. package/dist/esm/helpers/is-browser.js +5 -1
  185. package/dist/esm/helpers/is-defined.js +5 -1
  186. package/dist/esm/helpers/is-empty-children.js +7 -1
  187. package/dist/esm/helpers/is-safari.js +5 -1
  188. package/dist/esm/helpers/layout.js +54 -1
  189. package/dist/esm/helpers/load-script.js +29 -1
  190. package/dist/esm/helpers/make-style.js +117 -1
  191. package/dist/esm/helpers/normalize-builder-data.js +21 -1
  192. package/dist/esm/helpers/prefetch-queries.js +76 -1
  193. package/dist/esm/helpers/product.js +41 -1
  194. package/dist/esm/helpers/queries/get-collection.js +217 -1
  195. package/dist/esm/helpers/queries/get-collections.js +19 -1
  196. package/dist/esm/helpers/queries/get-product-by-slug.js +123 -1
  197. package/dist/esm/helpers/queries/get-product.js +150 -1
  198. package/dist/esm/helpers/queries/get-products.js +159 -1
  199. package/dist/esm/helpers/query.js +25 -1
  200. package/dist/esm/helpers/radius.js +124 -6
  201. package/dist/esm/helpers/render.js +64 -1
  202. package/dist/esm/helpers/shadow.js +51 -1
  203. package/dist/esm/helpers/size.js +31 -4
  204. package/dist/esm/helpers/spacing.js +40 -1
  205. package/dist/esm/helpers/tracking/fpixel.js +24 -1
  206. package/dist/esm/helpers/tracking/gtag.js +87 -1
  207. package/dist/esm/helpers/tracking/tiktokpixel.js +15 -1
  208. package/dist/esm/helpers/typography.js +96 -17
  209. package/dist/esm/helpers/variant.js +6 -1
  210. package/dist/esm/hooks/cart/use-add-to-cart.js +18 -1
  211. package/dist/esm/hooks/cart/use-cart-data.js +26 -1
  212. package/dist/esm/hooks/cart/use-cart-discount-codes-update.js +18 -1
  213. package/dist/esm/hooks/cart/use-cart-note-update.js +18 -1
  214. package/dist/esm/hooks/cart/use-create-cart.js +20 -1
  215. package/dist/esm/hooks/cart/use-remove-cart-item.js +18 -1
  216. package/dist/esm/hooks/cart/use-update-cart-item.js +18 -1
  217. package/dist/esm/hooks/shop/use-collection-query.js +20 -1
  218. package/dist/esm/hooks/shop/use-collections-query.js +15 -1
  219. package/dist/esm/hooks/shop/use-product-query.js +20 -1
  220. package/dist/esm/hooks/shop/use-products-query.js +20 -1
  221. package/dist/esm/hooks/shop.js +111 -1
  222. package/dist/esm/hooks/use-current-device.js +19 -1
  223. package/dist/esm/hooks/use-lazy-video.js +13 -1
  224. package/dist/esm/hooks/useCartId.js +40 -1
  225. package/dist/esm/hooks/useCartLine.js +7 -1
  226. package/dist/esm/hooks/useCartUI.js +44 -1
  227. package/dist/esm/hooks/useCollection.js +7 -1
  228. package/dist/esm/hooks/useFetchHandle.js +11 -1
  229. package/dist/esm/hooks/useFormatMoney.js +56 -1
  230. package/dist/esm/hooks/useIsomorphicLayoutEffect.js +6 -1
  231. package/dist/esm/hooks/useLoadScript.js +28 -1
  232. package/dist/esm/hooks/useMoney.js +80 -1
  233. package/dist/esm/hooks/usePrevious.js +17 -1
  234. package/dist/esm/hooks/useProduct.js +111 -1
  235. package/dist/esm/hooks/useProductList.js +16 -1
  236. package/dist/esm/hooks/useSuspenseFetch.js +23 -1
  237. package/dist/esm/hooks/useSwatchesOptions.js +37 -1
  238. package/dist/esm/index.js +92 -1
  239. package/dist/esm/types/global-style.js +11 -1
  240. package/dist/types/index.d.ts +27 -28
  241. package/package.json +2 -2
@@ -1 +1,185 @@
1
- import{handleConvertBorderStyle as e,handleConvertBorderWidth as o,handleConvertBorderColor as s,getBorderStyle as a}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 l}from"./radius.js";import{getStyleShadowState as d,getStyleShadow as n}from"./shadow.js";let composeSpacing=({source:e,spacing:o,type:s,suffix:a=""})=>{let{top:t,left:r,bottom:i,right:c}=o;t&&(e[`--${s}t${a}`]=t),r&&(e[`--${s}l${a}`]=r),i&&(e[`--${s}b${a}`]=i),c&&(e[`--${s}r${a}`]=c)},getAttrValue=(e,o,s)=>{if(null!=o)switch(e){case"bgc":case"c":return t(o.toString())?o:`var(--g-c-${o})`;case"d":if(!o)return"none";if(o&&s&&r.includes(s))return"grid";return"block";default:return o}};function composeAdvanceStyle(t,r){if(!t)return{};let i={},p=["desktop","tablet","mobile"],b=["hover","normal"];return Object.keys(t).forEach(u=>{let h=t[u];if(null==h)return;let f=t.hasBoxShadow?t.hasBoxShadow:{};if("object"==typeof h){if(Array.isArray(h))return;Object.keys(h).forEach(m=>{if(p.includes(m)){let a=h[m];if(void 0!==a){if("border"===u&&Object.assign(i,e(h),o(h),s(h)),"rounded"===u&&Object.assign(i,c(h)),"desktop"===m)switch(u){case"padding":composeSpacing({source:i,spacing:a,type:"p"});break;case"margin":composeSpacing({source:i,spacing:a,type:"m"});break;case"m":case"p":break;default:i[`--${u}`]=getAttrValue(u,a,r)}else switch(u){case"padding":composeSpacing({source:i,spacing:a,type:"p",suffix:`-${m}`});break;case"margin":composeSpacing({source:i,spacing:a,type:"m",suffix:`-${m}`});break;case"m":case"p":break;default:i[`--${u}-${m}`]=getAttrValue(u,a,r)}}}else if(b.includes(m))switch(u){case"hasBoxShadow":break;case"boxShadow":Object.assign(i,d(h,"box-shadow",f))}else"border"===u&&("none"===h.border&&(h.border="solid",h.color="#121212",h.isCustom=!0,h.width="0px",h.position="all"),Object.assign(i,a(h))),"rounded"===u&&Object.assign(i,l(h)),"hasBoxShadow"===u&&Object.assign(i,n({value:t.boxShadow,styleAppliedFor:"box-shadow",isEnableShadow:t.hasBoxShadow})),"boxShadow"===u&&Object.assign(i,n({value:h,styleAppliedFor:"box-shadow",isEnableShadow:t.hasBoxShadow}))})}else i[`--${u}`]=getAttrValue(u,h,r),"hasBoxShadow"===u&&t.boxShadow&&Object.assign(i,n({value:t.boxShadow,styleAppliedFor:"box-shadow",isEnableShadow:t.hasBoxShadow}))}),i}let splitStyle=(e,o={})=>{let s=e.map(e=>i(e)).flat(),a=Object.keys(o).filter(e=>s.includes(e)),t=a.reduce((e,s)=>({...e,[s]:o[s]}),{}),r=Object.keys(o).filter(e=>!a.includes(e)).reduce((e,s)=>({...e,[s]:o[s]}),{});return[t,r]};export{composeAdvanceStyle,splitStyle};
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 +1,19 @@
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
+ 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 +1,4 @@
1
- let isLocalEnv="local"===process.env.NEXT_CONVERT_ENV,baseAssetURL=process.env.GP_BASE_ASSET_URL||"https://d3kbi0je7pp4lw.cloudfront.net";export{baseAssetURL,isLocalEnv};
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 +1,5 @@
1
- let genVariable=e=>`var(--g-${e})`;export{genVariable};
1
+ const genVariable = (variableName)=>{
2
+ return `var(--g-${variableName})`;
3
+ };
4
+
5
+ export { genVariable };
@@ -1 +1,6 @@
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
+ 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 +1,7 @@
1
- let flattenConnection=e=>e?.edges?.map(e=>e.node)??[];export{flattenConnection};
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 +1,27 @@
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}};export{getResponsiveStateValue,getResponsiveValue,getResponsiveValueByScreen};
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 +1,90 @@
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
+ 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 +1,5 @@
1
- function isBrowser(){return"undefined"!=typeof window}export{isBrowser as default};
1
+ function isBrowser() {
2
+ return typeof window !== 'undefined';
3
+ }
4
+
5
+ export { isBrowser as default };
@@ -1 +1,5 @@
1
- function isDefined(e){return void 0!==e}export{isDefined};
1
+ function isDefined(argument) {
2
+ return argument !== undefined;
3
+ }
4
+
5
+ export { isDefined };
@@ -1 +1,7 @@
1
- import{Children as t}from"react";let isEmptyChildren=e=>1>t.count(e)||!e;export{isEmptyChildren as default,isEmptyChildren};
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 +1,5 @@
1
- function isSafari(){return -1!=navigator.userAgent.indexOf("Safari")&&-1==navigator.userAgent.indexOf("Chrome")}export{isSafari as default};
1
+ function isSafari() {
2
+ return navigator.userAgent.indexOf('Safari') != -1 && navigator.userAgent.indexOf('Chrome') == -1;
3
+ }
4
+
5
+ export { isSafari as default };
@@ -1 +1,54 @@
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
+ 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 +1,29 @@
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
+ 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 +1,117 @@
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)}},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)=>({desktop:t?.desktop==="custom"?`${e(o,"desktop")}/${e(l,"desktop")}`:t?.desktop,tablet:t?.tablet==="custom"?`${e(o,"tablet")}/${e(l,"tablet")}`:t?.tablet,mobile:t?.mobile==="custom"?`${e(o,"mobile")}/${e(l,"mobile")}`:t?.mobile}),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,makeHeight,makeLineClamp,makeStyle,makeStyleKey,makeStyleResponsive,makeStyleResponsiveState,makeStyleState,makeWidth,removeNullUndefined};
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 +1,21 @@
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};
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 };