@gem-sdk/components 2.0.0-dev.278 → 2.0.0-dev.289

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 (302) hide show
  1. package/dist/cjs/accordion/components/Accordion.js +60 -179
  2. package/dist/cjs/accordion/components/Accordion.liquid.js +77 -101
  3. package/dist/cjs/accordion/components/AccordionItem.js +126 -280
  4. package/dist/cjs/accordion/components/AccordionItem.liquid.js +77 -215
  5. package/dist/cjs/accordion/components/common/classes.js +55 -0
  6. package/dist/cjs/accordion/components/common/index.js +146 -0
  7. package/dist/cjs/accordion/components/common/styles.js +131 -0
  8. package/dist/cjs/accordion/hooks/useAccordion.js +145 -0
  9. package/dist/cjs/accordion/hooks/useAccordionItem.js +119 -0
  10. package/dist/cjs/article/components/ArticleImage.js +0 -1
  11. package/dist/cjs/article/components/ArticlePagination.js +1 -1
  12. package/dist/cjs/article/components/ArticlePagination.liquid.js +3 -3
  13. package/dist/cjs/article/setting/configs/ArticleImage/settings.js +5 -5
  14. package/dist/cjs/banner/components/HeroBannerItem.js +0 -6
  15. package/dist/cjs/banner/components/HeroBannerItem.liquid.js +3 -0
  16. package/dist/cjs/banner/setting/setting.js +28 -3
  17. package/dist/cjs/banner/setting/uiV2.js +10 -97
  18. package/dist/cjs/builder.js +18 -20
  19. package/dist/cjs/cart/components/CartLineImage.js +0 -2
  20. package/dist/cjs/code/common/classes.js +11 -0
  21. package/dist/cjs/code/common/styles.js +15 -0
  22. package/dist/cjs/code/components/CSSCode.js +9 -99
  23. package/dist/cjs/code/components/CSSCode.liquid.js +11 -11
  24. package/dist/cjs/code/hooks/useCSSCode.js +102 -0
  25. package/dist/cjs/code/setting/CSSCode.js +7 -121
  26. package/dist/cjs/code/setting/config/setting.js +77 -0
  27. package/dist/cjs/code/setting/config/uiV1.js +52 -0
  28. package/dist/cjs/code/setting/config/uiV2.js +58 -0
  29. package/dist/cjs/estimate-delivery/components/EstimateDate.liquid.js +4 -1
  30. package/dist/cjs/form/components/contact/Contact.js +6 -2
  31. package/dist/cjs/form/components/contact/common/composeStyles.js +21 -0
  32. package/dist/cjs/form/components/form-checkbox/FormCheckbox.js +6 -4
  33. package/dist/cjs/form/components/form-checkbox/FormCheckbox.liquid.js +2 -4
  34. package/dist/cjs/form/components/form-checkbox/common/composeClasses.js +2 -2
  35. package/dist/cjs/form/components/form-checkbox/common/composeStyles.js +23 -10
  36. package/dist/cjs/form/components/form-dropdown/common/composeClasses.js +1 -1
  37. package/dist/cjs/form/components/form-email/FormEmail.js +18 -10
  38. package/dist/cjs/form/components/form-email/common/composeClasses.js +2 -1
  39. package/dist/cjs/form/components/newsletter/Newsletter.js +7 -2
  40. package/dist/cjs/form/components/newsletter/Newsletter.liquid.js +1 -1
  41. package/dist/cjs/form/components/newsletter/common/composeStyles.js +4 -2
  42. package/dist/cjs/form/components/textarea/TextArea.js +16 -8
  43. package/dist/cjs/form/components/textarea/common/composeClasses.js +1 -1
  44. package/dist/cjs/form/components/textfield/TextField.js +17 -9
  45. package/dist/cjs/form/components/textfield/common/composeClasses.js +2 -2
  46. package/dist/cjs/form/setting/contact/Contact.js +5 -1
  47. package/dist/cjs/form/setting/form-checkbox/configs/settings.js +153 -6
  48. package/dist/cjs/form/setting/form-checkbox/configs/uiV2.js +137 -0
  49. package/dist/cjs/form/setting/form-dropdown/configs/settings.js +147 -0
  50. package/dist/cjs/form/setting/form-dropdown/configs/uiV2.js +156 -4
  51. package/dist/cjs/form/setting/newsletter/configs/settings.js +132 -3
  52. package/dist/cjs/form/setting/newsletter/configs/uiV2.js +93 -0
  53. package/dist/cjs/form/setting/submit-button/configs/settings.js +37 -0
  54. package/dist/cjs/form/setting/submit-button/configs/uiV2.js +13 -0
  55. package/dist/cjs/grid/row/commons/getInnerRadius.js +11 -10
  56. package/dist/cjs/grid/row/setting/configs/uiV2.js +1 -1
  57. package/dist/cjs/header/components/kind/basic/index.js +1 -0
  58. package/dist/cjs/header/components/kind/modern/index.js +1 -1
  59. package/dist/cjs/helpers.js +53 -0
  60. package/dist/cjs/icon-list/setting/configs/uiV2.js +1 -1
  61. package/dist/cjs/icon-list-v2/setting/configs/settings.js +5 -5
  62. package/dist/cjs/image/components/AdaptiveImage.js +63 -49
  63. package/dist/cjs/image/components/AdaptiveImage.liquid.js +56 -44
  64. package/dist/cjs/image/components/Image.js +65 -154
  65. package/dist/cjs/image/components/Image.liquid.js +68 -103
  66. package/dist/cjs/image/components/Modal3d.liquid.js +54 -21
  67. package/dist/cjs/image/components/NextImage.js +26 -59
  68. package/dist/cjs/image/components/NextImage.liquid.js +27 -115
  69. package/dist/cjs/image/components/Video.liquid.js +38 -13
  70. package/dist/cjs/image/components/common/attributes.js +115 -0
  71. package/dist/cjs/image/components/common/classes.js +57 -0
  72. package/dist/cjs/image/components/common/constants.js +15 -0
  73. package/dist/cjs/image/components/common/data.js +24 -0
  74. package/dist/cjs/image/components/common/helpers.js +75 -0
  75. package/dist/cjs/image/components/common/styles.js +88 -0
  76. package/dist/cjs/image/components/helpers/getNextImageLiquidAttrs.js +80 -0
  77. package/dist/cjs/image/components/helpers/getNextImageReactAttrs.js +40 -0
  78. package/dist/cjs/image/components/hooks/useCheckNoImage.js +25 -0
  79. package/dist/cjs/image/helpers/getSrcSet.js +0 -2
  80. package/dist/cjs/image/next.js +1 -5
  81. package/dist/cjs/image/setting/configs/settings.js +14 -8
  82. package/dist/cjs/image/setting/configs/uiV2.js +61 -15
  83. package/dist/cjs/image/setting/index.js +1 -3
  84. package/dist/cjs/image-comparison/components/CompareImage.js +1 -1
  85. package/dist/cjs/image-comparison/components/CompareImage.liquid.js +1 -1
  86. package/dist/cjs/index.js +91 -91
  87. package/dist/cjs/index.liquid.js +8 -8
  88. package/dist/cjs/post-purchase/callout-banner/components/CalloutText.js +2 -1
  89. package/dist/cjs/post-purchase/callout-banner/components/common/getClasses.js +5 -2
  90. package/dist/cjs/post-purchase/callout-banner/components/common/getStyles.js +2 -4
  91. package/dist/cjs/post-purchase/callout-banner/setting/config/callout-box/setting.js +4 -10
  92. package/dist/cjs/post-purchase/callout-banner/setting/config/callout-text/setting.js +1 -11
  93. package/dist/cjs/post-purchase/countdown-timer/components/PostPurchaseCountdownTimer.js +9 -23
  94. package/dist/cjs/post-purchase/countdown-timer/components/TextCountdown.js +12 -26
  95. package/dist/cjs/post-purchase/countdown-timer/components/common/getClasses.js +24 -0
  96. package/dist/cjs/post-purchase/countdown-timer/components/common/getStyles.js +21 -0
  97. package/dist/cjs/post-purchase/countdown-timer/hooks/useCountdownTimer.js +18 -1
  98. package/dist/cjs/post-purchase/countdown-timer/hooks/useGetTimeExpired.js +18 -0
  99. package/dist/cjs/post-purchase/countdown-timer/settings/CountdownTimer.js +9 -358
  100. package/dist/cjs/post-purchase/countdown-timer/settings/config/preset.js +26 -0
  101. package/dist/cjs/post-purchase/countdown-timer/settings/config/setting.js +243 -0
  102. package/dist/cjs/post-purchase/countdown-timer/settings/config/uiV1.js +125 -0
  103. package/dist/cjs/post-purchase/countdown-timer/settings/config/uiV2.js +185 -0
  104. package/dist/cjs/post-purchase/image/common/getClasses.js +1 -1
  105. package/dist/cjs/post-purchase/image/setting/setting-v2.js +5 -5
  106. package/dist/cjs/post-purchase/product/components/product-image/carousel-post-purchase/CarouselWrapperPostPurchase.js +24 -26
  107. package/dist/cjs/post-purchase/product/settings/product-image/setting-v2.js +5 -5
  108. package/dist/cjs/post-purchase/product/settings/product-price-breakdown/configs/settings.js +2 -2
  109. package/dist/cjs/post-purchase/product/settings/product-quantity/configs/settings.js +1 -1
  110. package/dist/cjs/product/components/FileUpload/components/common/index.js +3 -0
  111. package/dist/cjs/product/components/Product.liquid.js +1 -1
  112. package/dist/cjs/product/components/ProductBundle/common/classes.js +25 -0
  113. package/dist/cjs/product/components/ProductBundle/common/index.js +5 -0
  114. package/dist/cjs/product/components/ProductBundle/common/styles.js +89 -0
  115. package/dist/cjs/product/components/ProductBundle/components/ProductBundleDiscount.js +82 -0
  116. package/dist/cjs/product/components/ProductBundle/components/ProductBundleDiscount.liquid.js +74 -0
  117. package/dist/cjs/product/components/ProductBundle/components/ProductBundleDiscountChildrenItem.js +69 -0
  118. package/dist/cjs/product/components/ProductBundle/components/ProductBundleDiscountChildrenItem.liquid.js +46 -0
  119. package/dist/cjs/product/components/ProductBundle/components/ProductBundleDiscountItem.js +23 -0
  120. package/dist/cjs/product/components/ProductBundle/components/ProductBundleDiscountItem.liquid.js +14 -0
  121. package/dist/cjs/product/components/{ProductBundleDiscount.js → ProductBundle/hooks/useProductBundleDataState.js} +20 -215
  122. package/dist/cjs/product/components/ProductBundle/hooks/useProductBundleDiscountState.js +56 -0
  123. package/dist/cjs/product/{setting → components/ProductBundle/setting}/ProductBundleDiscount.js +7 -7
  124. package/dist/cjs/product/{setting → components/ProductBundle/setting}/ProductBundleDiscountItem.js +3 -0
  125. package/dist/cjs/product/components/ProductButton.js +2 -2
  126. package/dist/cjs/product/components/ProductButton.liquid.js +2 -2
  127. package/dist/cjs/product/components/ProductPrice/common/getAttr.js +23 -0
  128. package/dist/cjs/product/components/ProductPrice/common/getClasses.js +19 -0
  129. package/dist/cjs/product/components/ProductPrice/common/getTextData.js +40 -0
  130. package/dist/cjs/product/components/ProductPrice/hooks/useGpPrice.js +126 -0
  131. package/dist/cjs/product/components/ProductPrice/index.js +54 -0
  132. package/dist/cjs/product/components/ProductPrice/index.liquid.js +43 -0
  133. package/dist/cjs/product/components/ProductQuickView/ProductQuickView.js +5 -5
  134. package/dist/cjs/product/next.js +3 -3
  135. package/dist/cjs/product/setting/index.js +2 -2
  136. package/dist/cjs/product/setting/product/configs/presets.js +1 -0
  137. package/dist/cjs/product/setting/product-image-v2/configs/setting-v2/ProductFeatureImage.js +6 -7
  138. package/dist/cjs/product/setting/product-image-v2/configs/setting-v2/ProductGalleryImage.js +11 -12
  139. package/dist/cjs/product/setting/product-image-v2/configs/setting-v2/index.js +6 -5
  140. package/dist/cjs/product/setting/product-list/configs/settingsV2.js +10 -8
  141. package/dist/cjs/setting.js +5 -2
  142. package/dist/esm/accordion/components/Accordion.js +61 -180
  143. package/dist/esm/accordion/components/Accordion.liquid.js +78 -102
  144. package/dist/esm/accordion/components/AccordionItem.js +129 -281
  145. package/dist/esm/accordion/components/AccordionItem.liquid.js +76 -214
  146. package/dist/esm/accordion/components/common/classes.js +44 -0
  147. package/dist/esm/accordion/components/common/index.js +136 -0
  148. package/dist/esm/accordion/components/common/styles.js +122 -0
  149. package/dist/esm/accordion/hooks/useAccordion.js +141 -0
  150. package/dist/esm/accordion/hooks/useAccordionItem.js +115 -0
  151. package/dist/esm/article/components/ArticleImage.js +0 -1
  152. package/dist/esm/article/components/ArticlePagination.js +1 -1
  153. package/dist/esm/article/components/ArticlePagination.liquid.js +3 -3
  154. package/dist/esm/article/setting/configs/ArticleImage/settings.js +5 -5
  155. package/dist/esm/banner/components/HeroBannerItem.js +0 -6
  156. package/dist/esm/banner/components/HeroBannerItem.liquid.js +3 -0
  157. package/dist/esm/banner/setting/setting.js +28 -3
  158. package/dist/esm/banner/setting/uiV2.js +10 -97
  159. package/dist/esm/builder.js +3 -5
  160. package/dist/esm/cart/components/CartLineImage.js +0 -2
  161. package/dist/esm/code/common/classes.js +9 -0
  162. package/dist/esm/code/common/styles.js +13 -0
  163. package/dist/esm/code/components/CSSCode.js +9 -99
  164. package/dist/esm/code/components/CSSCode.liquid.js +12 -12
  165. package/dist/esm/code/hooks/useCSSCode.js +98 -0
  166. package/dist/esm/code/setting/CSSCode.js +7 -121
  167. package/dist/esm/code/setting/config/setting.js +75 -0
  168. package/dist/esm/code/setting/config/uiV1.js +50 -0
  169. package/dist/esm/code/setting/config/uiV2.js +56 -0
  170. package/dist/esm/estimate-delivery/components/EstimateDate.liquid.js +4 -1
  171. package/dist/esm/form/components/contact/Contact.js +7 -3
  172. package/dist/esm/form/components/contact/common/composeStyles.js +19 -0
  173. package/dist/esm/form/components/form-checkbox/FormCheckbox.js +7 -5
  174. package/dist/esm/form/components/form-checkbox/FormCheckbox.liquid.js +3 -5
  175. package/dist/esm/form/components/form-checkbox/common/composeClasses.js +2 -2
  176. package/dist/esm/form/components/form-checkbox/common/composeStyles.js +25 -11
  177. package/dist/esm/form/components/form-dropdown/common/composeClasses.js +1 -1
  178. package/dist/esm/form/components/form-email/FormEmail.js +18 -10
  179. package/dist/esm/form/components/form-email/common/composeClasses.js +2 -1
  180. package/dist/esm/form/components/newsletter/Newsletter.js +8 -3
  181. package/dist/esm/form/components/newsletter/Newsletter.liquid.js +1 -1
  182. package/dist/esm/form/components/newsletter/common/composeStyles.js +4 -2
  183. package/dist/esm/form/components/textarea/TextArea.js +16 -8
  184. package/dist/esm/form/components/textarea/common/composeClasses.js +1 -1
  185. package/dist/esm/form/components/textfield/TextField.js +17 -9
  186. package/dist/esm/form/components/textfield/common/composeClasses.js +2 -2
  187. package/dist/esm/form/setting/contact/Contact.js +5 -1
  188. package/dist/esm/form/setting/form-checkbox/configs/settings.js +153 -6
  189. package/dist/esm/form/setting/form-checkbox/configs/uiV2.js +137 -0
  190. package/dist/esm/form/setting/form-dropdown/configs/settings.js +147 -0
  191. package/dist/esm/form/setting/form-dropdown/configs/uiV2.js +156 -4
  192. package/dist/esm/form/setting/newsletter/configs/settings.js +132 -3
  193. package/dist/esm/form/setting/newsletter/configs/uiV2.js +93 -0
  194. package/dist/esm/form/setting/submit-button/configs/settings.js +37 -0
  195. package/dist/esm/form/setting/submit-button/configs/uiV2.js +13 -0
  196. package/dist/esm/grid/row/commons/getInnerRadius.js +11 -10
  197. package/dist/esm/grid/row/setting/configs/uiV2.js +1 -1
  198. package/dist/esm/header/components/kind/basic/index.js +1 -0
  199. package/dist/esm/header/components/kind/modern/index.js +1 -1
  200. package/dist/esm/helpers.js +52 -1
  201. package/dist/esm/icon-list/setting/configs/uiV2.js +1 -1
  202. package/dist/esm/icon-list-v2/setting/configs/settings.js +5 -5
  203. package/dist/esm/image/components/AdaptiveImage.js +64 -50
  204. package/dist/esm/image/components/AdaptiveImage.liquid.js +57 -45
  205. package/dist/esm/image/components/Image.js +66 -155
  206. package/dist/esm/image/components/Image.liquid.js +69 -104
  207. package/dist/esm/image/components/Modal3d.liquid.js +55 -22
  208. package/dist/esm/image/components/NextImage.js +26 -59
  209. package/dist/esm/image/components/NextImage.liquid.js +28 -116
  210. package/dist/esm/image/components/Video.liquid.js +38 -13
  211. package/dist/esm/image/components/common/attributes.js +108 -0
  212. package/dist/esm/image/components/common/classes.js +51 -0
  213. package/dist/esm/image/components/common/constants.js +11 -0
  214. package/dist/esm/image/components/common/data.js +22 -0
  215. package/dist/esm/image/components/common/helpers.js +69 -0
  216. package/dist/esm/image/components/common/styles.js +80 -0
  217. package/dist/esm/image/components/helpers/getNextImageLiquidAttrs.js +78 -0
  218. package/dist/esm/image/components/helpers/getNextImageReactAttrs.js +38 -0
  219. package/dist/esm/image/components/hooks/useCheckNoImage.js +23 -0
  220. package/dist/esm/image/helpers/getSrcSet.js +1 -2
  221. package/dist/esm/image/next.js +1 -5
  222. package/dist/esm/image/setting/configs/settings.js +14 -8
  223. package/dist/esm/image/setting/configs/uiV2.js +61 -15
  224. package/dist/esm/image/setting/index.js +1 -3
  225. package/dist/esm/image-comparison/components/CompareImage.js +1 -1
  226. package/dist/esm/image-comparison/components/CompareImage.liquid.js +1 -1
  227. package/dist/esm/index.js +4 -5
  228. package/dist/esm/index.liquid.js +3 -3
  229. package/dist/esm/post-purchase/callout-banner/components/CalloutText.js +2 -1
  230. package/dist/esm/post-purchase/callout-banner/components/common/getClasses.js +5 -2
  231. package/dist/esm/post-purchase/callout-banner/components/common/getStyles.js +2 -4
  232. package/dist/esm/post-purchase/callout-banner/setting/config/callout-box/setting.js +4 -10
  233. package/dist/esm/post-purchase/callout-banner/setting/config/callout-text/setting.js +1 -11
  234. package/dist/esm/post-purchase/countdown-timer/components/PostPurchaseCountdownTimer.js +9 -23
  235. package/dist/esm/post-purchase/countdown-timer/components/TextCountdown.js +13 -27
  236. package/dist/esm/post-purchase/countdown-timer/components/common/getClasses.js +21 -0
  237. package/dist/esm/post-purchase/countdown-timer/components/common/getStyles.js +19 -0
  238. package/dist/esm/post-purchase/countdown-timer/hooks/useCountdownTimer.js +19 -3
  239. package/dist/esm/post-purchase/countdown-timer/hooks/useGetTimeExpired.js +16 -0
  240. package/dist/esm/post-purchase/countdown-timer/settings/CountdownTimer.js +9 -358
  241. package/dist/esm/post-purchase/countdown-timer/settings/config/preset.js +24 -0
  242. package/dist/esm/post-purchase/countdown-timer/settings/config/setting.js +241 -0
  243. package/dist/esm/post-purchase/countdown-timer/settings/config/uiV1.js +123 -0
  244. package/dist/esm/post-purchase/countdown-timer/settings/config/uiV2.js +183 -0
  245. package/dist/esm/post-purchase/image/common/getClasses.js +1 -1
  246. package/dist/esm/post-purchase/image/setting/setting-v2.js +5 -5
  247. package/dist/esm/post-purchase/product/components/product-image/carousel-post-purchase/CarouselWrapperPostPurchase.js +25 -27
  248. package/dist/esm/post-purchase/product/settings/product-image/setting-v2.js +5 -5
  249. package/dist/esm/post-purchase/product/settings/product-price-breakdown/configs/settings.js +2 -2
  250. package/dist/esm/post-purchase/product/settings/product-quantity/configs/settings.js +1 -1
  251. package/dist/esm/product/components/FileUpload/components/common/index.js +3 -0
  252. package/dist/esm/product/components/Product.liquid.js +1 -1
  253. package/dist/esm/product/components/ProductBundle/common/classes.js +19 -0
  254. package/dist/esm/product/components/ProductBundle/common/index.js +3 -0
  255. package/dist/esm/product/components/ProductBundle/common/styles.js +80 -0
  256. package/dist/esm/product/components/ProductBundle/components/ProductBundleDiscount.js +78 -0
  257. package/dist/esm/product/components/ProductBundle/components/ProductBundleDiscount.liquid.js +70 -0
  258. package/dist/esm/product/components/ProductBundle/components/ProductBundleDiscountChildrenItem.js +65 -0
  259. package/dist/esm/product/components/ProductBundle/components/ProductBundleDiscountChildrenItem.liquid.js +42 -0
  260. package/dist/esm/product/components/ProductBundle/components/ProductBundleDiscountItem.js +19 -0
  261. package/dist/esm/product/components/ProductBundle/components/ProductBundleDiscountItem.liquid.js +10 -0
  262. package/dist/esm/product/components/{ProductBundleDiscount.js → ProductBundle/hooks/useProductBundleDataState.js} +21 -216
  263. package/dist/esm/product/components/ProductBundle/hooks/useProductBundleDiscountState.js +52 -0
  264. package/dist/esm/product/{setting → components/ProductBundle/setting}/ProductBundleDiscount.js +7 -7
  265. package/dist/esm/product/{setting → components/ProductBundle/setting}/ProductBundleDiscountItem.js +3 -0
  266. package/dist/esm/product/components/ProductButton.js +1 -1
  267. package/dist/esm/product/components/ProductButton.liquid.js +1 -1
  268. package/dist/esm/product/components/ProductPrice/common/getAttr.js +21 -0
  269. package/dist/esm/product/components/ProductPrice/common/getClasses.js +17 -0
  270. package/dist/esm/product/components/ProductPrice/common/getTextData.js +38 -0
  271. package/dist/esm/product/components/ProductPrice/hooks/useGpPrice.js +124 -0
  272. package/dist/esm/product/components/ProductPrice/index.js +50 -0
  273. package/dist/esm/product/components/ProductPrice/index.liquid.js +38 -0
  274. package/dist/esm/product/components/ProductQuickView/ProductQuickView.js +1 -1
  275. package/dist/esm/product/next.js +3 -3
  276. package/dist/esm/product/setting/index.js +2 -2
  277. package/dist/esm/product/setting/product/configs/presets.js +1 -0
  278. package/dist/esm/product/setting/product-image-v2/configs/setting-v2/ProductFeatureImage.js +6 -7
  279. package/dist/esm/product/setting/product-image-v2/configs/setting-v2/ProductGalleryImage.js +11 -12
  280. package/dist/esm/product/setting/product-image-v2/configs/setting-v2/index.js +6 -5
  281. package/dist/esm/product/setting/product-list/configs/settingsV2.js +10 -8
  282. package/dist/esm/setting.js +5 -2
  283. package/dist/types/index.d.ts +174 -257
  284. package/package.json +2 -2
  285. package/dist/cjs/image/components/BackgroundImage.js +0 -102
  286. package/dist/cjs/image/components/Img.js +0 -28
  287. package/dist/cjs/image/components/helpers.js +0 -12
  288. package/dist/cjs/image/setting/BackgroundImage.js +0 -364
  289. package/dist/cjs/product/components/ProductBundleDiscount.liquid.js +0 -81
  290. package/dist/cjs/product/components/ProductBundleDiscountItem.js +0 -42
  291. package/dist/cjs/product/components/ProductBundleDiscountItem.liquid.js +0 -103
  292. package/dist/cjs/product/components/ProductPrice.js +0 -209
  293. package/dist/cjs/product/components/ProductPrice.liquid.js +0 -88
  294. package/dist/esm/image/components/BackgroundImage.js +0 -98
  295. package/dist/esm/image/components/Img.js +0 -24
  296. package/dist/esm/image/components/helpers.js +0 -9
  297. package/dist/esm/image/setting/BackgroundImage.js +0 -360
  298. package/dist/esm/product/components/ProductBundleDiscount.liquid.js +0 -77
  299. package/dist/esm/product/components/ProductBundleDiscountItem.js +0 -36
  300. package/dist/esm/product/components/ProductBundleDiscountItem.liquid.js +0 -99
  301. package/dist/esm/product/components/ProductPrice.js +0 -205
  302. package/dist/esm/product/components/ProductPrice.liquid.js +0 -83
@@ -1,72 +1,20 @@
1
- 'use client';
2
- import { jsx, jsxs } from 'react/jsx-runtime';
3
- import { useProductBundleDiscount, makeGlobalSize, useProduct, useEditorMode, makeStyle, cls, isEmptyChildren, makeStyleState, composeRadius, getStyleShadowState, getStyleShadow, getBorderStyle, handleConvertBorderWidth, handleConvertBorderStyle, handleConvertBorderColor, getRadiusStyleActiveState, makeStyleResponsive, getGlobalColorStateStyle } from '@gem-sdk/core';
4
- import { useState, useCallback, useEffect, useMemo, isValidElement } from 'react';
5
- import Loading from '../../common/components/Loading.js';
6
- import NoDataState from '../../common/components/NoDataState.js';
1
+ import { useProduct } from '@gem-sdk/core';
7
2
 
8
- const ProductBundleDiscount = ({ builderAttrs, style, children, setting, styles })=>{
9
- const { seUseProductCompareAtPrice } = useProductBundleDiscount();
10
- const sizeSettings = makeGlobalSize(styles?.size);
3
+ const useProductBundleDataState = ()=>{
11
4
  const product = useProduct();
12
- const [selected, setSelected] = useState(!setting?.hasPreSelectItem ? -1 : setting?.selectItemDefault);
13
- const mode = useEditorMode();
14
- const isSelected = useCallback((i)=>{
15
- return selected === i;
16
- }, [
17
- selected
18
- ]);
19
- useEffect(()=>{
20
- seUseProductCompareAtPrice(setting?.useProductCompareAtPrice);
21
- }, [
22
- seUseProductCompareAtPrice,
23
- setting?.useProductCompareAtPrice
24
- ]);
25
- useEffect(()=>{
26
- if (!setting?.hasPreSelectItem) {
27
- setSelected(-1);
28
- }
29
- }, [
30
- setting?.hasPreSelectItem
31
- ]);
32
- useEffect(()=>{
33
- if (setting?.hasPreSelectItem) {
34
- setSelected(setting?.selectItemDefault);
35
- }
36
- }, [
37
- setting?.hasPreSelectItem,
38
- setting?.selectItemDefault
39
- ]);
40
- const makeAlign = useMemo(()=>{
41
- const alignment = styles?.align === 'left' ? 'start' : styles?.align === 'right' ? 'end' : 'center';
42
- return {
43
- ...makeStyle({
44
- ai: alignment
45
- })
46
- };
47
- }, [
48
- styles?.align
49
- ]);
50
- const [timer, setTimer] = useState(0);
51
- useEffect(()=>{
52
- let inter;
53
- if (timer < 10) {
54
- inter = setInterval(()=>{
55
- setTimer((prevTimer)=>prevTimer + 1);
56
- }, 100);
57
- }
58
- return ()=>clearInterval(inter);
59
- }, [
60
- timer
61
- ]);
62
- if (!setting?.bundleItems) {
63
- return timer >= 10 ? /*#__PURE__*/ jsx("div", {
64
- className: "gp-w-full gp-p-2 gp-text-center gp-border gp-border-[#3C67FF] gp-text-[#676767]",
65
- children: "This product has no bundle discount"
66
- }) : /*#__PURE__*/ jsx(Loading, {});
67
- }
68
- if (!setting.bundleItems.length && mode === 'edit') {
69
- const svg = `
5
+ const redirectGuideline = ()=>{
6
+ window.open('https://help.gempages.net/articles/bundle-discount ', '_blank');
7
+ };
8
+ const emitRedirectSetupPage = ()=>{
9
+ const event = new CustomEvent('editor:redirect-bundle-discount-page', {
10
+ bubbles: true,
11
+ detail: {
12
+ baseID: product?.baseID
13
+ }
14
+ });
15
+ window.dispatchEvent(event);
16
+ };
17
+ const svg = `
70
18
  <svg viewBox="0 0 452 245" fill="none" xmlns="http://www.w3.org/2000/svg">
71
19
  <path d="M0 8.6001C0 4.18182 3.58172 0.600098 8 0.600098H444C448.418 0.600098 452 4.18182 452 8.6001V236.6C452 241.018 448.418 244.6 444 244.6H8C3.58173 244.6 0 241.018 0 236.6V8.6001Z" fill="#F9F9F9"/>
72
20
  <rect x="12.5" y="25.1001" width="427" height="59" rx="9.5" stroke="#9E9E9E"/>
@@ -91,154 +39,11 @@ const ProductBundleDiscount = ({ builderAttrs, style, children, setting, styles
91
39
  <path d="M392.98 201.782V179.964H394.378V201.782H392.98ZM397.011 186.944C396.932 186.2 396.596 185.62 396.005 185.205C395.42 184.79 394.659 184.583 393.721 184.583C393.062 184.583 392.497 184.682 392.025 184.881C391.554 185.08 391.193 185.35 390.943 185.691C390.693 186.032 390.565 186.421 390.559 186.859C390.559 187.222 390.642 187.538 390.807 187.805C390.977 188.072 391.207 188.299 391.497 188.486C391.787 188.668 392.108 188.822 392.46 188.947C392.812 189.072 393.167 189.177 393.525 189.262L395.162 189.671C395.821 189.825 396.454 190.032 397.062 190.293C397.676 190.555 398.224 190.884 398.707 191.282C399.196 191.68 399.582 192.16 399.866 192.722C400.15 193.285 400.292 193.944 400.292 194.7C400.292 195.722 400.031 196.623 399.508 197.401C398.986 198.174 398.23 198.779 397.241 199.217C396.258 199.648 395.068 199.864 393.67 199.864C392.312 199.864 391.133 199.654 390.133 199.234C389.139 198.813 388.361 198.2 387.798 197.393C387.241 196.586 386.94 195.603 386.895 194.444H390.005C390.051 195.052 390.238 195.557 390.568 195.961C390.897 196.364 391.326 196.665 391.855 196.864C392.389 197.063 392.986 197.163 393.645 197.163C394.332 197.163 394.934 197.06 395.451 196.856C395.974 196.646 396.383 196.356 396.679 195.986C396.974 195.611 397.125 195.174 397.13 194.674C397.125 194.219 396.991 193.844 396.73 193.549C396.469 193.248 396.102 192.998 395.63 192.799C395.165 192.594 394.619 192.413 393.994 192.254L392.008 191.742C390.571 191.373 389.434 190.813 388.599 190.063C387.77 189.307 387.355 188.305 387.355 187.055C387.355 186.026 387.633 185.126 388.19 184.353C388.753 183.58 389.517 182.981 390.483 182.555C391.449 182.123 392.542 181.907 393.764 181.907C395.003 181.907 396.088 182.123 397.02 182.555C397.957 182.981 398.693 183.575 399.227 184.336C399.761 185.092 400.037 185.961 400.054 186.944H397.011ZM408.853 199.839C408.018 199.833 407.202 199.688 406.407 199.404C405.611 199.114 404.895 198.646 404.259 197.998C403.623 197.344 403.117 196.478 402.742 195.398C402.367 194.313 402.182 192.969 402.188 191.367C402.188 189.873 402.347 188.54 402.665 187.37C402.984 186.2 403.441 185.211 404.038 184.404C404.634 183.592 405.353 182.972 406.194 182.546C407.04 182.12 407.986 181.907 409.032 181.907C410.128 181.907 411.1 182.123 411.947 182.555C412.799 182.986 413.486 183.577 414.009 184.327C414.532 185.072 414.856 185.913 414.981 186.85H411.87C411.711 186.18 411.384 185.646 410.89 185.248C410.401 184.844 409.782 184.643 409.032 184.643C407.822 184.643 406.89 185.168 406.236 186.219C405.589 187.271 405.262 188.714 405.256 190.549H405.376C405.654 190.049 406.015 189.62 406.458 189.262C406.901 188.904 407.401 188.629 407.958 188.435C408.52 188.236 409.114 188.137 409.739 188.137C410.762 188.137 411.68 188.381 412.492 188.87C413.31 189.359 413.958 190.032 414.435 190.89C414.913 191.742 415.148 192.719 415.143 193.822C415.148 194.969 414.887 196.001 414.359 196.915C413.83 197.825 413.094 198.54 412.151 199.063C411.208 199.586 410.109 199.844 408.853 199.839ZM408.836 197.282C409.455 197.282 410.009 197.131 410.498 196.83C410.986 196.529 411.373 196.123 411.657 195.611C411.941 195.1 412.08 194.526 412.074 193.89C412.08 193.265 411.944 192.7 411.665 192.194C411.393 191.688 411.015 191.288 410.532 190.992C410.049 190.697 409.498 190.549 408.878 190.549C408.418 190.549 407.989 190.637 407.592 190.813C407.194 190.989 406.847 191.234 406.552 191.546C406.256 191.853 406.023 192.211 405.853 192.62C405.688 193.023 405.603 193.455 405.597 193.915C405.603 194.523 405.745 195.083 406.023 195.594C406.302 196.106 406.685 196.515 407.174 196.822C407.663 197.129 408.217 197.282 408.836 197.282ZM423.995 199.932C422.592 199.932 421.387 199.577 420.381 198.867C419.381 198.151 418.612 197.12 418.072 195.773C417.538 194.421 417.271 192.793 417.271 190.89C417.276 188.986 417.546 187.367 418.08 186.032C418.62 184.691 419.39 183.668 420.39 182.964C421.396 182.259 422.597 181.907 423.995 181.907C425.393 181.907 426.594 182.259 427.6 182.964C428.606 183.668 429.376 184.691 429.91 186.032C430.45 187.373 430.719 188.992 430.719 190.89C430.719 192.799 430.45 194.43 429.91 195.782C429.376 197.129 428.606 198.157 427.6 198.867C426.6 199.577 425.398 199.932 423.995 199.932ZM423.995 197.265C425.086 197.265 425.947 196.728 426.577 195.654C427.214 194.575 427.532 192.986 427.532 190.89C427.532 189.504 427.387 188.339 427.097 187.396C426.808 186.452 426.398 185.742 425.87 185.265C425.342 184.782 424.717 184.54 423.995 184.54C422.91 184.54 422.052 185.08 421.421 186.16C420.79 187.234 420.472 188.81 420.467 190.89C420.461 192.282 420.6 193.452 420.884 194.401C421.174 195.35 421.583 196.066 422.112 196.549C422.64 197.026 423.268 197.265 423.995 197.265Z" fill="#9E9E9E"/>
92
40
  </svg>
93
41
  `;
94
- const redirectGuideline = ()=>{
95
- window.open('https://help.gempages.net/articles/bundle-discount ', '_blank');
96
- };
97
- const emitRedirectSetupPage = ()=>{
98
- const event = new CustomEvent('editor:redirect-bundle-discount-page', {
99
- bubbles: true,
100
- detail: {
101
- baseID: product?.baseID
102
- }
103
- });
104
- window.dispatchEvent(event);
105
- };
106
- return /*#__PURE__*/ jsx(NoDataState, {
107
- elementType: "secondary",
108
- description: "Increase AOV with bundle quantity.",
109
- descriptionActions: [
110
- {
111
- text: 'Setup bundle discount',
112
- callback: emitRedirectSetupPage
113
- },
114
- {
115
- text: 'read guideline',
116
- callback: redirectGuideline
117
- }
118
- ],
119
- additionalMedia: svg
120
- });
121
- }
122
- return /*#__PURE__*/ jsxs("div", {
123
- ...builderAttrs,
124
- className: cls({
125
- 'gp-flex-col': setting?.layout === 'vertical-layout'
126
- }, 'gp-flex'),
127
- style: {
128
- ...sizeSettings.gap,
129
- ...makeAlign,
130
- ...style
131
- },
132
- children: [
133
- isEmptyChildren(children) || setting?.bundleItems?.length == 0 && /*#__PURE__*/ jsx("div", {
134
- className: "gp-w-full gp-p-2 gp-text-center gp-border gp-border-[#3C67FF] gp-text-[#676767]",
135
- children: "This product has no bundle discount"
136
- }),
137
- setting?.bundleItems?.map((item, index)=>{
138
- if (setting?.hideNoDiscountItem && item?.discountType === 'no_discount') return null;
139
- const c = children;
140
- const child = c?.[index];
141
- if (/*#__PURE__*/ isValidElement(child)) {
142
- return /*#__PURE__*/ jsx("div", {
143
- "aria-hidden": true,
144
- className: "cursor-pointer",
145
- onClick: ()=>setSelected(index),
146
- style: {
147
- ...sizeSettings.width,
148
- ...sizeSettings.padding,
149
- ...makeStyleState('bg', styles?.backgroundColor),
150
- ...makeStyle({
151
- bg: isSelected(index) ? styles?.backgroundColor?.active : styles?.backgroundColor?.normal
152
- }),
153
- ...composeRadius(styles?.roundedBundle),
154
- ...getStyleShadowState(styles?.boxShadowBundle, 'box-shadow', styles?.hasBoxShadowBundle),
155
- ...isSelected(index) ? getStyleShadow({
156
- value: styles?.boxShadowBundle?.active,
157
- styleAppliedFor: 'box-shadow',
158
- isEnableShadow: styles?.hasBoxShadowBundle?.active
159
- }) : {
160
- ...getStyleShadow({
161
- value: styles?.boxShadowBundle?.normal,
162
- styleAppliedFor: 'box-shadow',
163
- isEnableShadow: styles?.hasBoxShadowBundle?.normal
164
- })
165
- },
166
- ...isSelected(index) ? getBorderStyle(styles?.borderBundle?.active) : {
167
- ...handleConvertBorderWidth(styles?.borderBundle),
168
- ...handleConvertBorderStyle(styles?.borderBundle),
169
- ...handleConvertBorderColor(styles?.borderBundle)
170
- },
171
- ...isSelected(index) ? getRadiusStyleActiveState({
172
- ...styles?.roundedBundle,
173
- active: {
174
- ...styles?.roundedBundle?.active ? styles?.roundedBundle?.active : styles?.roundedBundle?.normal,
175
- radiusType: 'custom'
176
- }
177
- }) : {}
178
- },
179
- children: /*#__PURE__*/ jsxs("div", {
180
- className: cls({
181
- 'gp-items-center': setting?.layout === 'vertical-layout' ? setting?.iconPosition === 'center' : setting?.iconHorizontalPosition === 'center',
182
- 'gp-items-start': setting?.layout === 'vertical-layout' ? setting?.iconPosition === 'baseline' : setting?.iconHorizontalPosition === 'baseline',
183
- 'gp-flex-col': setting?.layout === 'horizontal-layout'
184
- }, 'gp-flex gp-justify-start'),
185
- children: [
186
- setting?.enableIcon && /*#__PURE__*/ jsx("div", {
187
- className: "gp-flex-none",
188
- style: {
189
- ...setting?.layout !== 'horizontal-layout' ? makeStyle({
190
- mr: setting.iconSpacing
191
- }) : makeStyle({
192
- mb: setting.iconSpacing
193
- }),
194
- ...makeStyleResponsive('w', setting.iconSize, 'px'),
195
- ...makeStyleResponsive('h', setting.iconSize, 'px')
196
- },
197
- children: isSelected(index) ? /*#__PURE__*/ jsx("svg", {
198
- style: {
199
- ...getGlobalColorStateStyle('c', styles?.iconColor),
200
- ...makeStyle({
201
- c: styles?.iconColor?.active
202
- })
203
- },
204
- xmlns: "http://www.w3.org/2000/svg",
205
- viewBox: "0 0 256 256",
206
- fill: "currentColor",
207
- "data-id": "493334324348453213",
208
- children: /*#__PURE__*/ jsx("path", {
209
- fill: "currentColor",
210
- strokeLinecap: "round",
211
- strokeLinejoin: "round",
212
- d: "M128,24A104,104,0,1,0,232,128,104.11,104.11,0,0,0,128,24Zm0,192a88,88,0,1,1,88-88A88.1,88.1,0,0,1,128,216Zm64-88a64,64,0,1,1-64-64A64.07,64.07,0,0,1,192,128Z"
213
- })
214
- }) : /*#__PURE__*/ jsx("svg", {
215
- style: {
216
- ...getGlobalColorStateStyle('c', styles?.iconColor)
217
- },
218
- xmlns: "http://www.w3.org/2000/svg",
219
- viewBox: "0 0 256 256",
220
- fill: "currentColor",
221
- "data-id": "508817616304734568",
222
- children: /*#__PURE__*/ jsx("path", {
223
- fill: "currentColor",
224
- strokeLinecap: "round",
225
- strokeLinejoin: "round",
226
- d: "M128,26A102,102,0,1,0,230,128,102.12,102.12,0,0,0,128,26Zm0,192a90,90,0,1,1,90-90A90.1,90.1,0,0,1,128,218Z"
227
- })
228
- })
229
- }),
230
- /*#__PURE__*/ jsx(child.type, {
231
- ...child.props,
232
- "bundle-item": setting?.bundleItems?.[index],
233
- className: "gp-w-full"
234
- })
235
- ]
236
- })
237
- }, index);
238
- }
239
- })
240
- ]
241
- });
42
+ return {
43
+ emitRedirectSetupPage,
44
+ redirectGuideline,
45
+ svg
46
+ };
242
47
  };
243
48
 
244
- export { ProductBundleDiscount as default };
49
+ export { useProductBundleDataState as default };
@@ -0,0 +1,52 @@
1
+ import { useProductBundleDiscount } from '@gem-sdk/core';
2
+ import { useState, useCallback, useEffect } from 'react';
3
+
4
+ const useProductBundleDiscountState = (setting)=>{
5
+ const [timer, setTimer] = useState(0);
6
+ const { seUseProductCompareAtPrice } = useProductBundleDiscount();
7
+ const [selected, setSelected] = useState(!setting?.hasPreSelectItem ? -1 : setting?.selectItemDefault);
8
+ const isSelected = useCallback((i)=>{
9
+ return selected === i;
10
+ }, [
11
+ selected
12
+ ]);
13
+ useEffect(()=>{
14
+ seUseProductCompareAtPrice(setting?.useProductCompareAtPrice);
15
+ }, [
16
+ seUseProductCompareAtPrice,
17
+ setting?.useProductCompareAtPrice
18
+ ]);
19
+ useEffect(()=>{
20
+ if (!setting?.hasPreSelectItem) {
21
+ setSelected(-1);
22
+ }
23
+ }, [
24
+ setting?.hasPreSelectItem
25
+ ]);
26
+ useEffect(()=>{
27
+ if (setting?.hasPreSelectItem) {
28
+ setSelected(setting?.selectItemDefault);
29
+ }
30
+ }, [
31
+ setting?.hasPreSelectItem,
32
+ setting?.selectItemDefault
33
+ ]);
34
+ useEffect(()=>{
35
+ let inter;
36
+ if (timer < 10) {
37
+ inter = setInterval(()=>{
38
+ setTimer((prevTimer)=>prevTimer + 1);
39
+ }, 100);
40
+ }
41
+ return ()=>clearInterval(inter);
42
+ }, [
43
+ timer
44
+ ]);
45
+ return {
46
+ timer,
47
+ isSelected,
48
+ setSelected
49
+ };
50
+ };
51
+
52
+ export { useProductBundleDiscountState as default };
@@ -1,9 +1,9 @@
1
- import { verticalOne } from './constant/bundle-layout/verticalOne.js';
2
- import { verticalTwo } from './constant/bundle-layout/verticalTwo.js';
3
- import { verticalThree } from './constant/bundle-layout/verticalThree.js';
4
- import { horizontalThree } from './constant/bundle-layout/horizontalThree.js';
5
- import { horizontalTwo } from './constant/bundle-layout/horizontalTwo.js';
6
- import { horizontalOne } from './constant/bundle-layout/horizontalOne.js';
1
+ import { verticalOne } from '../../../setting/constant/bundle-layout/verticalOne.js';
2
+ import { verticalTwo } from '../../../setting/constant/bundle-layout/verticalTwo.js';
3
+ import { verticalThree } from '../../../setting/constant/bundle-layout/verticalThree.js';
4
+ import { horizontalThree } from '../../../setting/constant/bundle-layout/horizontalThree.js';
5
+ import { horizontalTwo } from '../../../setting/constant/bundle-layout/horizontalTwo.js';
6
+ import { horizontalOne } from '../../../setting/constant/bundle-layout/horizontalOne.js';
7
7
 
8
8
  const config = {
9
9
  tag: 'ProductBundleDiscount',
@@ -402,7 +402,7 @@ const config = {
402
402
  {
403
403
  type: 'control',
404
404
  label: {
405
- en: "Use product compare-at price"
405
+ en: 'Use product compare-at price'
406
406
  },
407
407
  setting: {
408
408
  id: 'useProductCompareAtPrice'
@@ -2,6 +2,9 @@ const config = {
2
2
  tag: 'ProductBundleDiscountItem',
3
3
  label: 'Bundle Item',
4
4
  settings: [],
5
+ advanced: {
6
+ w: '100%'
7
+ },
5
8
  editorConfigs: {
6
9
  component: {
7
10
  noSetting: true,
@@ -7,7 +7,7 @@ import useNotification from '../../notification/hooks/use-notification.js';
7
7
  import '../../notification/components/Notice.js';
8
8
  import Text from '../../text/components/Text.js';
9
9
  import { addToCartTracking } from '../helpers/tracking.js';
10
- import ProductPrice from './ProductPrice.js';
10
+ import ProductPrice from './ProductPrice/index.js';
11
11
 
12
12
  const NODE_PRICE_EMPTY = null;
13
13
  const minusIcon = `
@@ -1,7 +1,7 @@
1
1
  import { splitStyle, template, makeStyleResponsive, RenderIf, isLocalEnv, baseAssetURL, makeStyle } from '@gem-sdk/core';
2
2
  import Button from '../../button/components/Button.liquid.js';
3
3
  import { getInsertLinkData, getDynamicSourceLocales, getSettingPreloadData } from '../../helpers.js';
4
- import { ProductPrice } from './ProductPrice.liquid.js';
4
+ import { ProductPrice } from './ProductPrice/index.liquid.js';
5
5
 
6
6
  const NODE_PRICE_EMPTY = null;
7
7
  const minusIcon = `
@@ -0,0 +1,21 @@
1
+ import { filterTruthyObject } from '../../../../helpers.js';
2
+
3
+ const getAttrs = (props, productId)=>{
4
+ const { builderAttrs, styles, builderProps } = props;
5
+ const isComparePrice = styles?.priceType === 'compare' || false;
6
+ const getDataHidden = ()=>{
7
+ if (isComparePrice) {
8
+ return `{% if variant.compare_at_price > variant.price and variant.compare_at_price >= 0 %}false{% else %}true{% endif %}`;
9
+ }
10
+ return false;
11
+ };
12
+ return filterTruthyObject({
13
+ ...builderAttrs,
14
+ id: `shopify-text-element-${builderProps?.uid}`,
15
+ 'data-id': builderProps?.uid,
16
+ 'data-product-id': productId,
17
+ 'data-hidden': getDataHidden()
18
+ });
19
+ };
20
+
21
+ export { getAttrs };
@@ -0,0 +1,17 @@
1
+ const getWrapperClasses = (props)=>{
2
+ const { builderProps, classNames, advanced } = props;
3
+ return {
4
+ 'gp-product-price group-data-[state=loading]:gp-invisible data-[hidden=true]:gp-hidden': true,
5
+ ...builderProps?.uid && {
6
+ [builderProps.uid]: true
7
+ },
8
+ ...advanced?.cssClass && {
9
+ [advanced.cssClass]: true
10
+ },
11
+ ...classNames && {
12
+ [classNames]: true
13
+ }
14
+ };
15
+ };
16
+
17
+ export { getWrapperClasses };
@@ -0,0 +1,38 @@
1
+ import { getGlobalColorClass, cls } from '@gem-sdk/core';
2
+
3
+ const getTextProps = (props, text)=>{
4
+ const { setting, styles, builderProps, classNames } = props;
5
+ const isComparePrice = styles?.priceType === 'compare' || false;
6
+ const colorClass = getGlobalColorClass('decoration', styles?.lineColor);
7
+ const priceCompare = ()=>{
8
+ return `
9
+ {% if variant.compare_at_price %}
10
+ {{ variant.compare_at_price | ${setting?.moneyWithCurrentFormat ? `money_with_currency` : `money`}}}
11
+ {% else %}
12
+
13
+ {% endif %}
14
+ `;
15
+ };
16
+ const defaultPrice = ()=>{
17
+ return `
18
+ {% if variant.price %}
19
+ {{ variant.price | ${setting?.moneyWithCurrentFormat ? `money_with_currency` : `money`}}}
20
+ {% endif %}
21
+ `;
22
+ };
23
+ return {
24
+ id: `p-price-${builderProps?.uid}`,
25
+ styles,
26
+ setting: {
27
+ text: text ?? `${isComparePrice ? priceCompare() : defaultPrice()}`,
28
+ excludeFlex: true
29
+ },
30
+ className: cls('gp-price', {
31
+ 'gp-money': !isComparePrice,
32
+ 'gp-product-compare-price': isComparePrice,
33
+ 'gp-line-through': isComparePrice && styles?.lineThrough
34
+ }, colorClass, classNames)
35
+ };
36
+ };
37
+
38
+ export { getTextProps };
@@ -0,0 +1,124 @@
1
+ import { useRef, useMemo } from 'react';
2
+ import { useTransition } from '../../ProductVariants/common.js';
3
+ import { useEditorMode, useQuantity, useCurrentVariant, useProductBundleDiscount, useInteraction, useProduct, useFormatMoney } from '@gem-sdk/core';
4
+
5
+ const useGpPrice = (props)=>{
6
+ const { styles, setting, builderProps } = props;
7
+ const elementRef = useRef(null);
8
+ const mode = useEditorMode();
9
+ const { quantity, hasUpdatePrice } = useQuantity();
10
+ const currentVariant = useCurrentVariant();
11
+ const { useProductCompareAtPrice } = useProductBundleDiscount();
12
+ const bundleItem = props['bundle-item'];
13
+ const price = currentVariant?.price ?? 0;
14
+ const salePrice = currentVariant?.salePrice ?? 0;
15
+ const isComparePrice = styles?.priceType === 'compare' || false;
16
+ const { trigger } = useInteraction();
17
+ const currentProduct = useProduct();
18
+ const currentProductId = currentProduct?.baseID?.replace('gid://shopify/Product/', '');
19
+ const quantityProduct = useMemo(()=>{
20
+ if (bundleItem?.quantity) {
21
+ return bundleItem.quantity;
22
+ }
23
+ return hasUpdatePrice ? quantity || 1 : 1;
24
+ }, [
25
+ quantity,
26
+ hasUpdatePrice,
27
+ bundleItem?.quantity
28
+ ]);
29
+ const bundleDiscount = useMemo(()=>{
30
+ const value = parseInt(bundleItem?.discountValue);
31
+ if (bundleItem?.discountType === 'percentage') {
32
+ return price * quantityProduct * value / 100;
33
+ }
34
+ return value;
35
+ }, [
36
+ bundleItem?.discountType,
37
+ bundleItem?.discountValue,
38
+ price,
39
+ quantityProduct
40
+ ]);
41
+ const priceCompare = useMemo(()=>{
42
+ if (bundleItem?.discountValue) {
43
+ if (useProductCompareAtPrice) {
44
+ return (salePrice || price) * quantityProduct;
45
+ }
46
+ return price * quantityProduct;
47
+ }
48
+ return salePrice * quantityProduct;
49
+ }, [
50
+ bundleItem?.discountValue,
51
+ price,
52
+ quantityProduct,
53
+ salePrice,
54
+ useProductCompareAtPrice
55
+ ]);
56
+ const displayPrice = useMemo(()=>{
57
+ const quantityPrice = price * quantityProduct;
58
+ if (isComparePrice) {
59
+ return priceCompare;
60
+ }
61
+ if (bundleDiscount) {
62
+ return Math.max(0, quantityPrice - bundleDiscount);
63
+ }
64
+ return quantityPrice;
65
+ }, [
66
+ price,
67
+ quantityProduct,
68
+ bundleDiscount,
69
+ priceCompare,
70
+ isComparePrice
71
+ ]);
72
+ const dispatchInteractionChangePrice = (value, type)=>{
73
+ trigger({
74
+ event: type === 'price' ? 'gp:rollback:price-change' : 'gp:rollback:compare-price-change',
75
+ selector: `[data-id="${builderProps?.uid}"]`,
76
+ element: elementRef.current
77
+ });
78
+ trigger({
79
+ event: type === 'price' ? 'gp:price-change' : 'gp:compare-price-change',
80
+ data: value,
81
+ selector: `[data-id="${builderProps?.uid}"]`,
82
+ element: elementRef.current
83
+ });
84
+ };
85
+ useTransition((oldPrice)=>{
86
+ if (oldPrice !== price) {
87
+ dispatchInteractionChangePrice(price, 'price');
88
+ }
89
+ }, [
90
+ price
91
+ ]);
92
+ useTransition((oldPriceCompare)=>{
93
+ if (oldPriceCompare !== salePrice) {
94
+ dispatchInteractionChangePrice(salePrice, 'compare');
95
+ }
96
+ }, [
97
+ salePrice
98
+ ]);
99
+ const emitNoDataSignal = ()=>{
100
+ if (mode !== 'edit') return;
101
+ const event = new CustomEvent('editor:product-source-no-data-warning', {
102
+ bubbles: true,
103
+ detail: {
104
+ uid: builderProps?.uid,
105
+ value: !displayPrice && isComparePrice,
106
+ tag: 'ProductPrice'
107
+ }
108
+ });
109
+ window.dispatchEvent(event);
110
+ };
111
+ const moneyFormatted = useFormatMoney(displayPrice ?? 0, setting?.moneyWithCurrentFormat || false);
112
+ const isNoComparePrice = isComparePrice && !displayPrice;
113
+ const isNoComparePriceILP = mode !== 'edit' && isNoComparePrice;
114
+ return {
115
+ elementRef,
116
+ moneyFormatted,
117
+ currentProductId,
118
+ isNoComparePrice,
119
+ isNoComparePriceILP,
120
+ emitNoDataSignal
121
+ };
122
+ };
123
+
124
+ export { useGpPrice };
@@ -0,0 +1,50 @@
1
+ 'use client';
2
+ import { jsx, jsxs } from 'react/jsx-runtime';
3
+ import Text from '../../../text/components/Text.js';
4
+ import { createClass, createAttr } from '@gem-sdk/system';
5
+ import { getWrapperClasses } from './common/getClasses.js';
6
+ import { getAttrs } from './common/getAttr.js';
7
+ import { getTextProps } from './common/getTextData.js';
8
+ import { useGpPrice } from './hooks/useGpPrice.js';
9
+ import NoDataState from '../../../common/components/NoDataState.js';
10
+ import { filterToolbarPreview } from '@gem-sdk/core';
11
+
12
+ const ProductPrice = (props)=>{
13
+ const { style, builderAttrs, children } = props;
14
+ const { elementRef, moneyFormatted, currentProductId, isNoComparePrice, isNoComparePriceILP, emitNoDataSignal } = useGpPrice(props);
15
+ const wrapperClasses = createClass(getWrapperClasses(props));
16
+ const wrapperAttrs = createAttr(getAttrs(props, currentProductId));
17
+ const textProps = getTextProps(props, moneyFormatted);
18
+ const hiddenStyle = {
19
+ visibility: 'hidden',
20
+ opacity: 0,
21
+ maxWidth: 0,
22
+ maxHeight: 0
23
+ };
24
+ const wrapperStyle = isNoComparePriceILP ? hiddenStyle : style;
25
+ if (isNoComparePrice) {
26
+ return /*#__PURE__*/ jsx(NoDataState, {
27
+ builderAttrs: builderAttrs,
28
+ elementType: "secondary",
29
+ description: "No compare price",
30
+ rawMode: true
31
+ });
32
+ }
33
+ return /*#__PURE__*/ jsxs("div", {
34
+ ref: elementRef,
35
+ ...wrapperAttrs,
36
+ className: wrapperClasses,
37
+ style: wrapperStyle,
38
+ "aria-hidden": "true",
39
+ onClick: emitNoDataSignal,
40
+ children: [
41
+ /*#__PURE__*/ jsx(Text, {
42
+ ...textProps
43
+ }),
44
+ children,
45
+ filterToolbarPreview(children, true)
46
+ ]
47
+ });
48
+ };
49
+
50
+ export { ProductPrice as default };
@@ -0,0 +1,38 @@
1
+ import { template, dataStringify, isLocalEnv, baseAssetURL } from '@gem-sdk/core';
2
+ import { getSettingPreloadData } from '../../../helpers.js';
3
+ import Text from '../../../text/components/Text.liquid.js';
4
+ import { createClass, createAttr, createStateOrContext, Liquid } from '@gem-sdk/system';
5
+ import { getWrapperClasses } from './common/getClasses.js';
6
+ import { getAttrs } from './common/getAttr.js';
7
+ import { getTextProps } from './common/getTextData.js';
8
+
9
+ const ProductPrice = (props)=>{
10
+ const { style, setting, styles, builderProps } = props;
11
+ const wrapperClasses = createClass(getWrapperClasses(props));
12
+ const wrapperAttrs = createAttr(getAttrs(props));
13
+ const textProps = getTextProps(props);
14
+ const stateData = createStateOrContext({
15
+ priceType: styles?.priceType,
16
+ uid: builderProps?.uid,
17
+ locale: `{{shop.locale}}`,
18
+ currency: `{{shop.currency}}`,
19
+ moneyFormat: `{{ ${setting?.moneyWithCurrentFormat ? 'shop.money_with_currency_format' : 'shop.money_format'} | replace: '"', '\\"' | escape }}`
20
+ });
21
+ const renderScript = ()=>{
22
+ const jsURL = isLocalEnv ? `{{ 'gp-product-price.js' | asset_url }}` : `${baseAssetURL}/assets-v2/gp-product-price.js?v={{ shop.metafields.GEMPAGES.ASSETS_VERSION }}`;
23
+ return `<script ${getSettingPreloadData('class="gps-link" delay', 'src')}="${jsURL}" defer="defer"></script>`;
24
+ };
25
+ return Liquid(template /*liquid*/ `
26
+ <gp-product-price
27
+ ${wrapperAttrs}
28
+ class="${wrapperClasses}"
29
+ style="${style}"
30
+ gp-data='${dataStringify(stateData)}'
31
+ >
32
+ ${Text(textProps)}
33
+ </gp-product-price>
34
+ ${renderScript()}
35
+ `);
36
+ };
37
+
38
+ export { ProductPrice, ProductPrice as default };