@gem-sdk/core 1.37.5 → 2.0.0-dev.832

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 (329) hide show
  1. package/dist/cjs/components/AddOn.js +1 -18
  2. package/dist/cjs/components/ComponentToolbarPreview.js +1 -465
  3. package/dist/cjs/components/ComponentWrapper.js +1 -46
  4. package/dist/cjs/components/ComponentWrapperPreview.js +1 -136
  5. package/dist/cjs/components/Empty.js +1 -7
  6. package/dist/cjs/components/Render.js +1 -65
  7. package/dist/cjs/components/Render.liquid.js +14 -288
  8. package/dist/cjs/components/RenderBlock.js +1 -54
  9. package/dist/cjs/components/RenderCustomCode.js +3 -56
  10. package/dist/cjs/components/RenderPreview.js +1 -66
  11. package/dist/cjs/components/RenderSection.js +1 -23
  12. package/dist/cjs/components/ai-generator/AIContentGenerator.js +1 -0
  13. package/dist/cjs/components/ai-generator/AIGenContentLoading.js +1 -0
  14. package/dist/cjs/components/ai-generator/components/PickProduct.js +1 -0
  15. package/dist/cjs/components/ai-generator/components/ToneAndVoice.js +1 -0
  16. package/dist/cjs/components/ai-generator/hooks/useGettingGenerateRequest.js +1 -0
  17. package/dist/cjs/components/ai-generator/hooks/useListenEventGenerate.js +1 -0
  18. package/dist/cjs/components/ai-generator/icons/AIIcon.js +1 -0
  19. package/dist/cjs/components/ai-generator/icons/CloseIcon.js +1 -0
  20. package/dist/cjs/components/ai-generator/icons/DropdownIcon.js +1 -0
  21. package/dist/cjs/components/ai-generator/icons/ShowMoreIcon.js +1 -0
  22. package/dist/cjs/components/animation/AnimationWrapper.js +1 -0
  23. package/dist/cjs/components/constant.js +1 -54
  24. package/dist/cjs/components/resize/Resize.js +1 -16
  25. package/dist/cjs/components/resize/Spacing.js +1 -248
  26. package/dist/cjs/components/src/product/helpers/variant-presets.js +1 -56
  27. package/dist/cjs/components/theme-section/CreateThemeSection.js +1 -117
  28. package/dist/cjs/components/theme-section/ThemeSectionStatus.js +1 -36
  29. package/dist/cjs/components/theme-section/ThemeSectionTooltip.js +1 -102
  30. package/dist/cjs/components/toolbar/Tooltip.js +1 -22
  31. package/dist/cjs/contexts/AddonContext.js +1 -36
  32. package/dist/cjs/contexts/BuilderComponent.js +1 -34
  33. package/dist/cjs/contexts/BuilderContext.js +1 -35
  34. package/dist/cjs/contexts/BuilderPreviewContext.js +1 -479
  35. package/dist/cjs/contexts/CartLineContext.js +1 -29
  36. package/dist/cjs/contexts/CollectionContext.js +1 -38
  37. package/dist/cjs/contexts/ModalContext.js +1 -47
  38. package/dist/cjs/contexts/PageContext.js +1 -44
  39. package/dist/cjs/contexts/ProductContext.js +1 -156
  40. package/dist/cjs/contexts/ProductListContext.js +1 -32
  41. package/dist/cjs/contexts/SectionContext.js +1 -53
  42. package/dist/cjs/contexts/ShopContext.js +1 -80
  43. package/dist/cjs/graphql/fragments/analytic.generated.js +2 -6
  44. package/dist/cjs/graphql/fragments/collection-detail.generated.js +2 -6
  45. package/dist/cjs/graphql/fragments/collection-product.generated.js +2 -6
  46. package/dist/cjs/graphql/fragments/collection.generated.js +2 -6
  47. package/dist/cjs/graphql/fragments/custom-code.generated.js +2 -6
  48. package/dist/cjs/graphql/fragments/custom-font.generated.js +2 -6
  49. package/dist/cjs/graphql/fragments/data-seo.generated.js +2 -6
  50. package/dist/cjs/graphql/fragments/media.generated.js +2 -6
  51. package/dist/cjs/graphql/fragments/product-little.generated.js +11 -6
  52. package/dist/cjs/graphql/fragments/product-option-value.generated.js +2 -6
  53. package/dist/cjs/graphql/fragments/product-option.generated.js +2 -6
  54. package/dist/cjs/graphql/fragments/product.generated.js +11 -6
  55. package/dist/cjs/graphql/fragments/published-custom-section.generated.js +2 -6
  56. package/dist/cjs/graphql/fragments/published-page-section.generated.js +2 -6
  57. package/dist/cjs/graphql/fragments/published-theme-page.generated.js +3 -9
  58. package/dist/cjs/graphql/fragments/published-theme-style.generated.js +2 -6
  59. package/dist/cjs/graphql/fragments/selected-option.generated.js +2 -6
  60. package/dist/cjs/graphql/fragments/variant.generated.js +2 -6
  61. package/dist/cjs/graphql/mutations/page-view-up.generated.js +3 -7
  62. package/dist/cjs/graphql/queries/collection-detail-filter.generated.js +2 -16
  63. package/dist/cjs/graphql/queries/collection.generated.js +2 -14
  64. package/dist/cjs/graphql/queries/collections.generated.js +2 -9
  65. package/dist/cjs/graphql/queries/preview-page.generated.js +2 -14
  66. package/dist/cjs/graphql/queries/product-little-detail.generated.js +2 -11
  67. package/dist/cjs/graphql/queries/product-medias.generated.js +2 -8
  68. package/dist/cjs/graphql/queries/product-value-label.generated.js +2 -6
  69. package/dist/cjs/graphql/queries/product-variants.generated.js +2 -10
  70. package/dist/cjs/graphql/queries/products.generated.js +12 -17
  71. package/dist/cjs/graphql/queries/published-theme-pages.generated.js +2 -15
  72. package/dist/cjs/graphql/queries/store-property.generated.js +2 -6
  73. package/dist/cjs/graphql-app-api/queries/LibraryTemplate.generated.js +13 -0
  74. package/dist/cjs/graphql-app-api/queries/SaleFunnelDiscounts.generated.js +34 -0
  75. package/dist/cjs/graphql-app-api/queries/ThemePage.generated.js +22 -0
  76. package/dist/cjs/helpers/GlobalEvent.js +1 -19
  77. package/dist/cjs/helpers/animations.js +1 -213
  78. package/dist/cjs/helpers/background.js +1 -230
  79. package/dist/cjs/helpers/borders.js +4 -183
  80. package/dist/cjs/helpers/carousel.js +1 -58
  81. package/dist/cjs/helpers/clone-deep.js +1 -5
  82. package/dist/cjs/helpers/cls.js +1 -16
  83. package/dist/cjs/helpers/colors.js +1 -184
  84. package/dist/cjs/helpers/compose-advance-style.js +1 -268
  85. package/dist/cjs/helpers/constant.js +1 -23
  86. package/dist/cjs/helpers/convert.js +1 -7
  87. package/dist/cjs/helpers/covert-entities-html.js +1 -19
  88. package/dist/cjs/helpers/css-variable.js +1 -7
  89. package/dist/cjs/helpers/email.js +1 -11
  90. package/dist/cjs/helpers/filter-toolbar-preview.js +1 -14
  91. package/dist/cjs/helpers/flatten-connection.js +1 -9
  92. package/dist/cjs/helpers/get-resonsive-value.js +1 -36
  93. package/dist/cjs/helpers/get-shortname.js +1 -92
  94. package/dist/cjs/helpers/icon-list.js +1 -61
  95. package/dist/cjs/helpers/is-browser.js +1 -9
  96. package/dist/cjs/helpers/is-defined.js +1 -7
  97. package/dist/cjs/helpers/is-empty-children.js +1 -15
  98. package/dist/cjs/helpers/is-safari.js +1 -9
  99. package/dist/cjs/helpers/layout.js +1 -59
  100. package/dist/cjs/helpers/load-script.js +1 -31
  101. package/dist/cjs/helpers/make-style.js +1 -163
  102. package/dist/cjs/helpers/normalize-builder-data.js +1 -23
  103. package/dist/cjs/helpers/prefetch-queries.js +1 -78
  104. package/dist/cjs/helpers/product.js +1 -48
  105. package/dist/cjs/helpers/queries/get-collection.js +1 -226
  106. package/dist/cjs/helpers/queries/get-collections.js +1 -21
  107. package/dist/cjs/helpers/queries/get-product-by-slug.js +1 -125
  108. package/dist/cjs/helpers/queries/get-product.js +1 -154
  109. package/dist/cjs/helpers/queries/get-products.js +1 -163
  110. package/dist/cjs/helpers/query.js +1 -29
  111. package/dist/cjs/helpers/radius.js +6 -140
  112. package/dist/cjs/helpers/render.js +1 -76
  113. package/dist/cjs/helpers/shadow.js +1 -57
  114. package/dist/cjs/helpers/size.js +4 -183
  115. package/dist/cjs/helpers/spacing.js +1 -43
  116. package/dist/cjs/helpers/tracking/fpixel.js +1 -28
  117. package/dist/cjs/helpers/tracking/gtag.js +1 -93
  118. package/dist/cjs/helpers/tracking/tiktokpixel.js +1 -17
  119. package/dist/cjs/helpers/typography.js +17 -126
  120. package/dist/cjs/helpers/variant.js +1 -11
  121. package/dist/cjs/hooks/animation/animations.js +1 -0
  122. package/dist/cjs/hooks/animation/useAnimationActions.js +1 -39
  123. package/dist/cjs/hooks/animation/useAnimationConfig.js +1 -29
  124. package/dist/cjs/hooks/animation/useAnimationPreview.js +1 -31
  125. package/dist/cjs/hooks/animation/useAnimationTarget.js +1 -120
  126. package/dist/cjs/hooks/animation/useApplyAnimation.js +1 -87
  127. package/dist/cjs/hooks/animation/useLivePageAnimation.js +1 -0
  128. package/dist/cjs/hooks/cart/use-add-to-cart.js +1 -20
  129. package/dist/cjs/hooks/cart/use-cart-data.js +1 -28
  130. package/dist/cjs/hooks/cart/use-cart-discount-codes-update.js +1 -20
  131. package/dist/cjs/hooks/cart/use-cart-note-update.js +1 -20
  132. package/dist/cjs/hooks/cart/use-create-cart.js +1 -22
  133. package/dist/cjs/hooks/cart/use-remove-cart-item.js +1 -20
  134. package/dist/cjs/hooks/cart/use-update-cart-item.js +1 -20
  135. package/dist/cjs/hooks/shop/use-collection-query.js +1 -22
  136. package/dist/cjs/hooks/shop/use-collections-query.js +1 -17
  137. package/dist/cjs/hooks/shop/use-product-query.js +1 -22
  138. package/dist/cjs/hooks/shop/use-products-query.js +1 -23
  139. package/dist/cjs/hooks/shop.js +1 -126
  140. package/dist/cjs/hooks/use-current-device.js +1 -21
  141. package/dist/cjs/hooks/use-lazy-video.js +1 -15
  142. package/dist/cjs/hooks/useAnimations.js +1 -26
  143. package/dist/cjs/hooks/useCartId.js +1 -44
  144. package/dist/cjs/hooks/useCartLine.js +1 -11
  145. package/dist/cjs/hooks/useCartUI.js +1 -48
  146. package/dist/cjs/hooks/useCollection.js +1 -9
  147. package/dist/cjs/hooks/useFetchHandle.js +1 -13
  148. package/dist/cjs/hooks/useFormatMoney.js +1 -58
  149. package/dist/cjs/hooks/useInitialSwatchesOptions.js +1 -113
  150. package/dist/cjs/hooks/useIsomorphicLayoutEffect.js +1 -10
  151. package/dist/cjs/hooks/useLoadScript.js +1 -32
  152. package/dist/cjs/hooks/useMoney.js +1 -84
  153. package/dist/cjs/hooks/usePrevious.js +1 -19
  154. package/dist/cjs/hooks/useProduct.js +1 -206
  155. package/dist/cjs/hooks/useProductList.js +1 -21
  156. package/dist/cjs/hooks/useSuspenseFetch.js +1 -27
  157. package/dist/cjs/hooks/useSwatchesOptions.js +1 -41
  158. package/dist/cjs/hooks/useToolbarPostPurchase.js +1 -0
  159. package/dist/cjs/index.js +1 -361
  160. package/dist/cjs/types/animations.js +1 -47
  161. package/dist/cjs/types/appAPI.js +1 -0
  162. package/dist/cjs/types/global-style.js +1 -15
  163. package/dist/cjs/types/shop.js +1 -2
  164. package/dist/cjs/web-components/src/helpers/styles/constant.js +1 -9
  165. package/dist/esm/components/AddOn.js +1 -14
  166. package/dist/esm/components/ComponentToolbarPreview.js +1 -463
  167. package/dist/esm/components/ComponentWrapper.js +1 -42
  168. package/dist/esm/components/ComponentWrapperPreview.js +1 -132
  169. package/dist/esm/components/Empty.js +1 -3
  170. package/dist/esm/components/Render.js +1 -61
  171. package/dist/esm/components/Render.liquid.js +14 -282
  172. package/dist/esm/components/RenderBlock.js +1 -50
  173. package/dist/esm/components/RenderCustomCode.js +3 -52
  174. package/dist/esm/components/RenderPreview.js +1 -62
  175. package/dist/esm/components/RenderSection.js +1 -19
  176. package/dist/esm/components/ai-generator/AIContentGenerator.js +1 -0
  177. package/dist/esm/components/ai-generator/AIGenContentLoading.js +1 -0
  178. package/dist/esm/components/ai-generator/components/PickProduct.js +1 -0
  179. package/dist/esm/components/ai-generator/components/ToneAndVoice.js +1 -0
  180. package/dist/esm/components/ai-generator/hooks/useGettingGenerateRequest.js +1 -0
  181. package/dist/esm/components/ai-generator/hooks/useListenEventGenerate.js +1 -0
  182. package/dist/esm/components/ai-generator/icons/AIIcon.js +1 -0
  183. package/dist/esm/components/ai-generator/icons/CloseIcon.js +1 -0
  184. package/dist/esm/components/ai-generator/icons/DropdownIcon.js +1 -0
  185. package/dist/esm/components/ai-generator/icons/ShowMoreIcon.js +1 -0
  186. package/dist/esm/components/animation/AnimationWrapper.js +1 -0
  187. package/dist/esm/components/constant.js +1 -50
  188. package/dist/esm/components/resize/Resize.js +1 -12
  189. package/dist/esm/components/resize/Spacing.js +1 -244
  190. package/dist/esm/components/src/product/helpers/variant-presets.js +1 -54
  191. package/dist/esm/components/theme-section/CreateThemeSection.js +1 -115
  192. package/dist/esm/components/theme-section/ThemeSectionStatus.js +1 -34
  193. package/dist/esm/components/theme-section/ThemeSectionTooltip.js +1 -100
  194. package/dist/esm/components/toolbar/Tooltip.js +1 -18
  195. package/dist/esm/contexts/AddonContext.js +1 -32
  196. package/dist/esm/contexts/BuilderComponent.js +1 -31
  197. package/dist/esm/contexts/BuilderContext.js +1 -32
  198. package/dist/esm/contexts/BuilderPreviewContext.js +1 -476
  199. package/dist/esm/contexts/CartLineContext.js +1 -26
  200. package/dist/esm/contexts/CollectionContext.js +1 -35
  201. package/dist/esm/contexts/ModalContext.js +1 -44
  202. package/dist/esm/contexts/PageContext.js +1 -41
  203. package/dist/esm/contexts/ProductContext.js +1 -153
  204. package/dist/esm/contexts/ProductListContext.js +1 -28
  205. package/dist/esm/contexts/SectionContext.js +1 -49
  206. package/dist/esm/contexts/ShopContext.js +1 -77
  207. package/dist/esm/graphql/fragments/analytic.generated.js +2 -4
  208. package/dist/esm/graphql/fragments/collection-detail.generated.js +2 -4
  209. package/dist/esm/graphql/fragments/collection-product.generated.js +2 -4
  210. package/dist/esm/graphql/fragments/collection.generated.js +2 -4
  211. package/dist/esm/graphql/fragments/custom-code.generated.js +2 -4
  212. package/dist/esm/graphql/fragments/custom-font.generated.js +2 -4
  213. package/dist/esm/graphql/fragments/data-seo.generated.js +2 -4
  214. package/dist/esm/graphql/fragments/media.generated.js +2 -4
  215. package/dist/esm/graphql/fragments/product-little.generated.js +11 -4
  216. package/dist/esm/graphql/fragments/product-option-value.generated.js +2 -4
  217. package/dist/esm/graphql/fragments/product-option.generated.js +2 -4
  218. package/dist/esm/graphql/fragments/product.generated.js +11 -4
  219. package/dist/esm/graphql/fragments/published-custom-section.generated.js +2 -4
  220. package/dist/esm/graphql/fragments/published-page-section.generated.js +2 -4
  221. package/dist/esm/graphql/fragments/published-theme-page.generated.js +3 -6
  222. package/dist/esm/graphql/fragments/published-theme-style.generated.js +2 -4
  223. package/dist/esm/graphql/fragments/selected-option.generated.js +2 -4
  224. package/dist/esm/graphql/fragments/variant.generated.js +2 -4
  225. package/dist/esm/graphql/mutations/page-view-up.generated.js +3 -5
  226. package/dist/esm/graphql/queries/collection-detail-filter.generated.js +10 -22
  227. package/dist/esm/graphql/queries/collection.generated.js +8 -18
  228. package/dist/esm/graphql/queries/collections.generated.js +3 -8
  229. package/dist/esm/graphql/queries/preview-page.generated.js +8 -18
  230. package/dist/esm/graphql/queries/product-little-detail.generated.js +5 -12
  231. package/dist/esm/graphql/queries/product-medias.generated.js +2 -6
  232. package/dist/esm/graphql/queries/product-value-label.generated.js +2 -4
  233. package/dist/esm/graphql/queries/product-variants.generated.js +4 -10
  234. package/dist/esm/graphql/queries/products.generated.js +18 -20
  235. package/dist/esm/graphql/queries/published-theme-pages.generated.js +9 -20
  236. package/dist/esm/graphql/queries/store-property.generated.js +2 -4
  237. package/dist/esm/graphql-app-api/queries/LibraryTemplate.generated.js +13 -0
  238. package/dist/esm/graphql-app-api/queries/SaleFunnelDiscounts.generated.js +34 -0
  239. package/dist/esm/graphql-app-api/queries/ThemePage.generated.js +22 -0
  240. package/dist/esm/helpers/GlobalEvent.js +1 -15
  241. package/dist/esm/helpers/animations.js +1 -211
  242. package/dist/esm/helpers/background.js +1 -222
  243. package/dist/esm/helpers/borders.js +4 -175
  244. package/dist/esm/helpers/carousel.js +1 -54
  245. package/dist/esm/helpers/clone-deep.js +1 -3
  246. package/dist/esm/helpers/cls.js +1 -14
  247. package/dist/esm/helpers/colors.js +1 -169
  248. package/dist/esm/helpers/compose-advance-style.js +1 -261
  249. package/dist/esm/helpers/constant.js +1 -19
  250. package/dist/esm/helpers/convert.js +1 -4
  251. package/dist/esm/helpers/covert-entities-html.js +1 -17
  252. package/dist/esm/helpers/css-variable.js +1 -5
  253. package/dist/esm/helpers/email.js +1 -6
  254. package/dist/esm/helpers/filter-toolbar-preview.js +1 -9
  255. package/dist/esm/helpers/flatten-connection.js +1 -7
  256. package/dist/esm/helpers/get-resonsive-value.js +1 -31
  257. package/dist/esm/helpers/get-shortname.js +1 -90
  258. package/dist/esm/helpers/icon-list.js +1 -58
  259. package/dist/esm/helpers/is-browser.js +1 -5
  260. package/dist/esm/helpers/is-defined.js +1 -5
  261. package/dist/esm/helpers/is-empty-children.js +1 -10
  262. package/dist/esm/helpers/is-safari.js +1 -5
  263. package/dist/esm/helpers/layout.js +1 -54
  264. package/dist/esm/helpers/load-script.js +1 -29
  265. package/dist/esm/helpers/make-style.js +1 -149
  266. package/dist/esm/helpers/normalize-builder-data.js +1 -21
  267. package/dist/esm/helpers/prefetch-queries.js +1 -76
  268. package/dist/esm/helpers/product.js +1 -44
  269. package/dist/esm/helpers/queries/get-collection.js +1 -223
  270. package/dist/esm/helpers/queries/get-collections.js +1 -19
  271. package/dist/esm/helpers/queries/get-product-by-slug.js +1 -123
  272. package/dist/esm/helpers/queries/get-product.js +1 -150
  273. package/dist/esm/helpers/queries/get-products.js +1 -161
  274. package/dist/esm/helpers/query.js +1 -25
  275. package/dist/esm/helpers/radius.js +6 -132
  276. package/dist/esm/helpers/render.js +1 -68
  277. package/dist/esm/helpers/shadow.js +1 -52
  278. package/dist/esm/helpers/size.js +4 -171
  279. package/dist/esm/helpers/spacing.js +1 -40
  280. package/dist/esm/helpers/tracking/fpixel.js +1 -24
  281. package/dist/esm/helpers/tracking/gtag.js +1 -87
  282. package/dist/esm/helpers/tracking/tiktokpixel.js +1 -15
  283. package/dist/esm/helpers/typography.js +17 -116
  284. package/dist/esm/helpers/variant.js +1 -9
  285. package/dist/esm/hooks/animation/animations.js +1 -0
  286. package/dist/esm/hooks/animation/useAnimationActions.js +1 -37
  287. package/dist/esm/hooks/animation/useAnimationConfig.js +1 -27
  288. package/dist/esm/hooks/animation/useAnimationPreview.js +1 -29
  289. package/dist/esm/hooks/animation/useAnimationTarget.js +1 -118
  290. package/dist/esm/hooks/animation/useApplyAnimation.js +1 -83
  291. package/dist/esm/hooks/animation/useLivePageAnimation.js +1 -0
  292. package/dist/esm/hooks/cart/use-add-to-cart.js +1 -18
  293. package/dist/esm/hooks/cart/use-cart-data.js +1 -26
  294. package/dist/esm/hooks/cart/use-cart-discount-codes-update.js +1 -18
  295. package/dist/esm/hooks/cart/use-cart-note-update.js +1 -18
  296. package/dist/esm/hooks/cart/use-create-cart.js +1 -20
  297. package/dist/esm/hooks/cart/use-remove-cart-item.js +1 -18
  298. package/dist/esm/hooks/cart/use-update-cart-item.js +1 -18
  299. package/dist/esm/hooks/shop/use-collection-query.js +1 -20
  300. package/dist/esm/hooks/shop/use-collections-query.js +1 -15
  301. package/dist/esm/hooks/shop/use-product-query.js +1 -20
  302. package/dist/esm/hooks/shop/use-products-query.js +1 -21
  303. package/dist/esm/hooks/shop.js +1 -111
  304. package/dist/esm/hooks/use-current-device.js +1 -19
  305. package/dist/esm/hooks/use-lazy-video.js +1 -13
  306. package/dist/esm/hooks/useAnimations.js +1 -24
  307. package/dist/esm/hooks/useCartId.js +1 -40
  308. package/dist/esm/hooks/useCartLine.js +1 -7
  309. package/dist/esm/hooks/useCartUI.js +1 -44
  310. package/dist/esm/hooks/useCollection.js +1 -7
  311. package/dist/esm/hooks/useFetchHandle.js +1 -11
  312. package/dist/esm/hooks/useFormatMoney.js +1 -56
  313. package/dist/esm/hooks/useInitialSwatchesOptions.js +1 -109
  314. package/dist/esm/hooks/useIsomorphicLayoutEffect.js +1 -6
  315. package/dist/esm/hooks/useLoadScript.js +1 -28
  316. package/dist/esm/hooks/useMoney.js +1 -80
  317. package/dist/esm/hooks/usePrevious.js +1 -17
  318. package/dist/esm/hooks/useProduct.js +1 -192
  319. package/dist/esm/hooks/useProductList.js +1 -16
  320. package/dist/esm/hooks/useSuspenseFetch.js +1 -23
  321. package/dist/esm/hooks/useSwatchesOptions.js +1 -37
  322. package/dist/esm/hooks/useToolbarPostPurchase.js +1 -0
  323. package/dist/esm/index.js +1 -100
  324. package/dist/esm/types/animations.js +1 -47
  325. package/dist/esm/types/appAPI.js +1 -0
  326. package/dist/esm/types/global-style.js +1 -12
  327. package/dist/esm/web-components/src/helpers/styles/constant.js +1 -7
  328. package/dist/types/index.d.ts +24802 -6237
  329. package/package.json +8 -3
@@ -1,109 +1 @@
1
- import useSWR from 'swr';
2
- import { ProductOptionNameDocument } from '../graphql/queries/product-value-label.generated.js';
3
- import { colorPreset } from '../components/src/product/helpers/variant-presets.js';
4
- import { useSwatches } from './shop.js';
5
- import { useFetchHandle } from './useFetchHandle.js';
6
- import { useShopStore } from '../contexts/ShopContext.js';
7
-
8
- let swatchChange = false;
9
- let colorChange = false;
10
- const useInitialSwatchesOptions = (options)=>{
11
- const fetcher = useFetchHandle();
12
- const changeSwatches = useShopStore((s)=>s.changeSwatches);
13
- const { swatches } = useSwatches();
14
- const { data: productOptionName } = useSWR([
15
- '/query/productOptionName',
16
- {}
17
- ], async ()=>fetchProductValueLabel(fetcher), {
18
- revalidateOnMount: true
19
- });
20
- const swatchesTitleList = [];
21
- swatches?.forEach((el)=>{
22
- swatchesTitleList.push(el.optionTitle);
23
- });
24
- productOptionName?.productOptionName?.forEach((el)=>{
25
- if (!swatchesTitleList.includes(el)) {
26
- swatchChange = true;
27
- swatches?.push({
28
- optionTitle: el,
29
- optionType: 'rectangle_list',
30
- optionValues: []
31
- });
32
- }
33
- });
34
- if (!options) return [];
35
- setDefaultSwatches(swatches, options);
36
- if (swatches?.length && (swatchChange || colorChange)) {
37
- window?.parent?.postMessage?.(JSON.stringify({
38
- type: 'update-swatches',
39
- swatches
40
- }), '*');
41
- changeSwatches(swatches);
42
- }
43
- };
44
- const getColorDefault = (label, color)=>{
45
- const colorByLabel = label ? colorPreset[label.toLocaleLowerCase()] : undefined;
46
- const colorArray = colorByLabel ? [
47
- colorByLabel
48
- ] : [];
49
- const firstColor = color?.[0];
50
- if (!firstColor && colorArray.length) colorChange = true;
51
- return firstColor ? [
52
- firstColor
53
- ] : colorArray;
54
- };
55
- const getProductOptionsLabelByName = (options, name)=>{
56
- const labels = [];
57
- const optionByName = options.find((op)=>op.name === name);
58
- optionByName?.values.forEach((val)=>{
59
- labels.push(val.label ?? '');
60
- });
61
- return labels;
62
- };
63
- const getSwatchesOptionsLabel = (options)=>{
64
- const labels = [];
65
- options.forEach((op)=>{
66
- labels.push(op.label ?? '');
67
- return;
68
- });
69
- return labels;
70
- };
71
- const setDefaultSwatches = (swatches, options)=>{
72
- if (swatches) {
73
- swatches?.map((sw)=>{
74
- const productLabels = getProductOptionsLabelByName(options, sw.optionTitle);
75
- const swLabels = getSwatchesOptionsLabel(sw.optionValues);
76
- productLabels.forEach((label)=>{
77
- if (!swLabels.includes(label)) {
78
- sw.optionValues.push({
79
- label,
80
- colors: getColorDefault(label),
81
- imageUrl: ''
82
- });
83
- }
84
- });
85
- sw.optionValues = sw.optionValues.map((op)=>{
86
- if (op.imageUrl === undefined) swatchChange = true;
87
- return {
88
- label: op.label ?? '',
89
- colors: getColorDefault(op.label, op.colors),
90
- imageUrl: op.imageUrl ?? ''
91
- };
92
- });
93
- });
94
- }
95
- return swatches;
96
- };
97
- const fetchProductValueLabel = async (fetcher)=>{
98
- const initVariables = {};
99
- const query = async (variables)=>{
100
- const response = await fetcher([
101
- ProductOptionNameDocument,
102
- variables
103
- ]);
104
- return response;
105
- };
106
- return query(initVariables);
107
- };
108
-
109
- export { useInitialSwatchesOptions as default };
1
+ import e from"swr";import{ProductOptionNameDocument as t}from"../graphql/queries/product-value-label.generated.js";import{colorPreset as a}from"../components/src/product/helpers/variant-presets.js";import{useSwatches as o}from"./shop.js";import{useFetchHandle as l}from"./useFetchHandle.js";import{useShopStore as r}from"../contexts/ShopContext.js";let swatchChange=!1,colorChange=!1,useInitialSwatchesOptions=t=>{let a=l(),s=r(e=>e.changeSwatches),{swatches:n}=o(),{data:i}=e(["/query/productOptionName",{}],async()=>fetchProductValueLabel(a),{revalidateOnMount:!0}),p=[];if(n?.forEach(e=>{p.push(e.optionTitle)}),i?.productOptionName?.forEach(e=>{p.includes(e)||(swatchChange=!0,n?.push({optionTitle:e,optionType:"rectangle_list",optionValues:[]}))}),!t)return[];setDefaultSwatches(n,t),n?.length&&(swatchChange||colorChange)&&(window?.parent?.postMessage?.(JSON.stringify({type:"update-swatches",swatches:n}),"*"),s(n))},getColorDefault=(e,t)=>{let o=e?a[e.toLocaleLowerCase()]:void 0,l=o?[o]:[],r=t?.[0];return!r&&l.length&&(colorChange=!0),r?[r]:l},getProductOptionsLabelByName=(e,t)=>{let a=[],o=e.find(e=>e.name===t);return o?.values.forEach(e=>{a.push(e.label??"")}),a},getSwatchesOptionsLabel=e=>{let t=[];return e.forEach(e=>{t.push(e.label??"")}),t},setDefaultSwatches=(e,t)=>(e&&e?.map(e=>{let a=getProductOptionsLabelByName(t,e.optionTitle),o=getSwatchesOptionsLabel(e.optionValues);a.forEach(t=>{o.includes(t)||e.optionValues.push({label:t,colors:getColorDefault(t),imageUrl:""})}),e.optionValues=e.optionValues.map(e=>(void 0===e.imageUrl&&(swatchChange=!0),{label:e.label??"",colors:getColorDefault(e.label,e.colors),imageUrl:e.imageUrl??""}))}),e),fetchProductValueLabel=async e=>{let a={},o=async a=>{let o=await e([t,a]);return o};return o(a)};export{useInitialSwatchesOptions as default};
@@ -1,6 +1 @@
1
- import { useLayoutEffect } from 'react';
2
-
3
- // const isBrowser = typeof window !== 'undefined';
4
- const useIsomorphicLayoutEffect = useLayoutEffect;
5
-
6
- export { useIsomorphicLayoutEffect as default };
1
+ import{useLayoutEffect as o}from"react";let useIsomorphicLayoutEffect=o;export{useIsomorphicLayoutEffect as default};
@@ -1,28 +1 @@
1
- import { useState, useEffect } from 'react';
2
- import { loadScript } from '../helpers/load-script.js';
3
-
4
- /**
5
- * The `useLoadScript` hook loads an external script tag on the client-side.
6
- */ function useLoadScript(url, options) {
7
- const [status, setStatus] = useState('loading');
8
- const stringifiedOptions = JSON.stringify(options);
9
- useEffect(()=>{
10
- async function loadScriptWrapper() {
11
- try {
12
- setStatus('loading');
13
- await loadScript(url, options);
14
- setStatus('done');
15
- } catch (error) {
16
- setStatus('error');
17
- }
18
- }
19
- loadScriptWrapper();
20
- }, [
21
- url,
22
- stringifiedOptions,
23
- options
24
- ]);
25
- return status;
26
- }
27
-
28
- export { useLoadScript as default };
1
+ import{useState as r,useEffect as t}from"react";import{loadScript as o}from"../helpers/load-script.js";function useLoadScript(a,i){let[e,n]=r("loading"),c=JSON.stringify(i);return t(()=>{(async function(){try{n("loading"),await o(a,i),n("done")}catch(r){n("error")}})()},[a,c,i]),e}export{useLoadScript as default};
@@ -1,80 +1 @@
1
- import { useMemo } from 'react';
2
- import { useLocale, useCurrency } from './shop.js';
3
-
4
- const useMoney = (amount)=>{
5
- const { locale } = useLocale();
6
- const { currency } = useCurrency();
7
- const options = useMemo(()=>({
8
- style: 'currency',
9
- currency: currency
10
- }), [
11
- currency
12
- ]);
13
- const defaultFormatter = useLazyFormatter(locale, options);
14
- const nameFormatter = useLazyFormatter(locale, {
15
- ...options,
16
- currencyDisplay: 'name'
17
- });
18
- const narrowSymbolFormatter = useLazyFormatter(locale, {
19
- ...options,
20
- currencyDisplay: 'narrowSymbol'
21
- });
22
- const withoutTrailingZerosFormatter = useLazyFormatter(locale, {
23
- ...options,
24
- minimumFractionDigits: 0,
25
- maximumFractionDigits: 0
26
- });
27
- const withoutCurrencyFormatter = useLazyFormatter(locale);
28
- const withoutTrailingZerosOrCurrencyFormatter = useLazyFormatter(locale, {
29
- minimumFractionDigits: 0,
30
- maximumFractionDigits: 0
31
- });
32
- const isPartCurrency = (part)=>part.type === 'currency';
33
- // By wrapping these properties in functions, we only
34
- // create formatters if they are going to be used.
35
- const lazyFormatters = useMemo(()=>({
36
- currencyCode: ()=>currency,
37
- localizedString: ()=>defaultFormatter().format(amount),
38
- parts: ()=>defaultFormatter().formatToParts(amount),
39
- withoutTrailingZeros: ()=>amount % 1 === 0 ? withoutTrailingZerosFormatter().format(amount) : defaultFormatter().format(amount),
40
- withoutTrailingZerosAndCurrency: ()=>amount % 1 === 0 ? withoutTrailingZerosOrCurrencyFormatter().format(amount) : withoutCurrencyFormatter().format(amount),
41
- currencyName: ()=>nameFormatter().formatToParts(amount).find(isPartCurrency)?.value ?? currency,
42
- currencySymbol: ()=>defaultFormatter().formatToParts(amount).find(isPartCurrency)?.value ?? currency,
43
- currencyNarrowSymbol: ()=>narrowSymbolFormatter().formatToParts(amount).find(isPartCurrency)?.value ?? '',
44
- amount: ()=>defaultFormatter().formatToParts(amount).filter((part)=>[
45
- 'decimal',
46
- 'fraction',
47
- 'group',
48
- 'integer',
49
- 'literal'
50
- ].includes(part.type)).map((part)=>part.value).join('')
51
- }), [
52
- currency,
53
- amount,
54
- nameFormatter,
55
- defaultFormatter,
56
- narrowSymbolFormatter,
57
- withoutCurrencyFormatter,
58
- withoutTrailingZerosFormatter,
59
- withoutTrailingZerosOrCurrencyFormatter
60
- ]);
61
- // Call functions automatically when the properties are accessed
62
- // to keep these functions as an implementation detail.
63
- return useMemo(()=>new Proxy(lazyFormatters, {
64
- // eslint-disable-next-line @typescript-eslint/no-unsafe-return, @typescript-eslint/no-unsafe-member-access, @typescript-eslint/no-unsafe-call
65
- get: (target, key)=>Reflect.get(target, key)?.call(null)
66
- }), [
67
- lazyFormatters
68
- ]);
69
- };
70
- function useLazyFormatter(locale, options) {
71
- return useMemo(()=>{
72
- let memoized;
73
- return ()=>memoized ??= new Intl.NumberFormat(locale, options);
74
- }, [
75
- locale,
76
- options
77
- ]);
78
- }
79
-
80
- export { useMoney as default };
1
+ import{useMemo as r}from"react";import{useLocale as t,useCurrency as e}from"./shop.js";let useMoney=a=>{let{locale:o}=t(),{currency:m}=e(),i=r(()=>({style:"currency",currency:m}),[m]),n=useLazyFormatter(o,i),u=useLazyFormatter(o,{...i,currencyDisplay:"name"}),c=useLazyFormatter(o,{...i,currencyDisplay:"narrowSymbol"}),l=useLazyFormatter(o,{...i,minimumFractionDigits:0,maximumFractionDigits:0}),s=useLazyFormatter(o),y=useLazyFormatter(o,{minimumFractionDigits:0,maximumFractionDigits:0}),f=r=>"currency"===r.type,F=r(()=>({currencyCode:()=>m,localizedString:()=>n().format(a),parts:()=>n().formatToParts(a),withoutTrailingZeros:()=>a%1==0?l().format(a):n().format(a),withoutTrailingZerosAndCurrency:()=>a%1==0?y().format(a):s().format(a),currencyName:()=>u().formatToParts(a).find(f)?.value??m,currencySymbol:()=>n().formatToParts(a).find(f)?.value??m,currencyNarrowSymbol:()=>c().formatToParts(a).find(f)?.value??"",amount:()=>n().formatToParts(a).filter(r=>["decimal","fraction","group","integer","literal"].includes(r.type)).map(r=>r.value).join("")}),[m,a,u,n,c,s,l,y]);return r(()=>new Proxy(F,{get:(r,t)=>Reflect.get(r,t)?.call(null)}),[F])};function useLazyFormatter(t,e){return r(()=>{let r;return()=>r??=new Intl.NumberFormat(t,e)},[t,e])}export{useMoney as default};
@@ -1,17 +1 @@
1
- import { useRef, useEffect } from 'react';
2
-
3
- const usePrevious = (value)=>{
4
- // The ref object is a generic container whose current property is mutable ...
5
- // ... and can hold any value, similar to an instance property on a class
6
- const ref = useRef();
7
- // Store current value in ref
8
- useEffect(()=>{
9
- ref.current = value;
10
- }, [
11
- value
12
- ]); // Only re-run if value changes
13
- // Return previous value (happens before update in useEffect above)
14
- return ref.current;
15
- };
16
-
17
- export { usePrevious };
1
+ import{useRef as r,useEffect as e}from"react";let usePrevious=t=>{let u=r();return e(()=>{u.current=t},[t]),u.current};export{usePrevious};
@@ -1,192 +1 @@
1
- import { useCallback, useEffect, useMemo } from 'react';
2
- import { useProductStore } from '../contexts/ProductContext.js';
3
- import 'react/jsx-runtime';
4
- import 'zustand';
5
- import 'swr';
6
- import '@gem-sdk/adapter-shopify';
7
- import 'swr/mutation';
8
- import 'vanilla-lazyload';
9
- import './useCartUI.js';
10
- import { checkInStock } from '../helpers/variant.js';
11
- import 'react-transition-group';
12
- import '@gem-sdk/core';
13
- import { flattenConnection } from '../helpers/flatten-connection.js';
14
- import '../helpers/convert.js';
15
- import { getSelectedVariant } from '../helpers/product.js';
16
-
17
- const useUniqProductID = ()=>{
18
- return useProductStore((s)=>s.uiqueId);
19
- };
20
- const useProduct = ()=>{
21
- return useProductStore((s)=>s.product);
22
- };
23
- const useFeaturedImageGlobal = ()=>{
24
- return useProductStore((s)=>s.featuredImageGlobal);
25
- };
26
- const useProductProperties = ()=>{
27
- return useProductStore((s)=>s.properties);
28
- };
29
- const useIsSyncProduct = ()=>{
30
- return useProductStore((s)=>s.isSyncProduct);
31
- };
32
- const useQuantity = ()=>{
33
- const quantity = useProductStore((s)=>s.quantity);
34
- const hasUpdatePrice = useProductStore((s)=>s.updatePrice);
35
- const decrement = useProductStore((s)=>s.decrementQuantity);
36
- const increment = useProductStore((s)=>s.incrementQuantity);
37
- const updateQuantity = useProductStore((s)=>s.setQuantity);
38
- const updatePrice = useProductStore((s)=>s.setHasUpdatePriceFollowQuantity);
39
- const isSyncProduct = useProductStore((s)=>s.isSyncProduct);
40
- const product = useProductStore((s)=>s.product);
41
- const productId = product?.id;
42
- const reset = useCallback(()=>{
43
- updateQuantity(1);
44
- }, [
45
- updateQuantity
46
- ]);
47
- useEffect(()=>{
48
- if (isSyncProduct) {
49
- const setOption = new CustomEvent('set-product-quantity', {
50
- bubbles: true,
51
- cancelable: true,
52
- composed: true,
53
- detail: {
54
- quantity,
55
- productId
56
- }
57
- });
58
- window.dispatchEvent(setOption);
59
- }
60
- }, [
61
- quantity,
62
- isSyncProduct,
63
- productId
64
- ]);
65
- return useMemo(()=>({
66
- quantity,
67
- hasUpdatePrice,
68
- increment,
69
- decrement,
70
- reset,
71
- setQuantity: updateQuantity,
72
- setUpdatePrice: updatePrice
73
- }), [
74
- decrement,
75
- increment,
76
- quantity,
77
- reset,
78
- updateQuantity,
79
- updatePrice,
80
- hasUpdatePrice
81
- ]);
82
- };
83
- const useSelectedOption = ()=>{
84
- const setSelectedOption = useProductStore((s)=>s.setSelectedOption);
85
- const selectedOptions = useProductStore((s)=>s.selectedOptions);
86
- const forceSelectedOption = useProductStore((s)=>s.forceSelectedOption);
87
- const isSyncProduct = useProductStore((s)=>s.isSyncProduct);
88
- const updateOption = useCallback((optionId, optionValue, productId, noEmit)=>{
89
- if (!noEmit && isSyncProduct) {
90
- const setOption = new CustomEvent('set-selected-option', {
91
- bubbles: true,
92
- cancelable: true,
93
- composed: true,
94
- detail: {
95
- optionId,
96
- optionValue,
97
- productId
98
- }
99
- });
100
- window.dispatchEvent(setOption);
101
- }
102
- setSelectedOption(optionId, optionValue);
103
- }, [
104
- setSelectedOption,
105
- isSyncProduct
106
- ]);
107
- const forceOption = useCallback((selectedOption, productId, noEmit)=>{
108
- if (!noEmit && isSyncProduct) {
109
- const forceOption = new CustomEvent('force-selected-option', {
110
- bubbles: true,
111
- cancelable: true,
112
- composed: true,
113
- detail: {
114
- selectedOption,
115
- productId
116
- }
117
- });
118
- window.dispatchEvent(forceOption);
119
- }
120
- forceSelectedOption(selectedOption);
121
- }, [
122
- forceSelectedOption,
123
- isSyncProduct
124
- ]);
125
- return useMemo(()=>({
126
- selectedOptions,
127
- setSelectedOption: updateOption,
128
- forceSelectedOption: forceOption
129
- }), [
130
- selectedOptions,
131
- updateOption,
132
- forceOption
133
- ]);
134
- };
135
- const useVariants = ()=>{
136
- const variants = useProductStore((s)=>s.product?.variants);
137
- return flattenConnection(variants);
138
- };
139
- const useVariant = (id)=>{
140
- const variants = useVariants();
141
- return useMemo(()=>variants?.find((v)=>v?.id === id), [
142
- id,
143
- variants
144
- ]);
145
- };
146
- const useCurrentVariant = ()=>{
147
- const { selectedOptions } = useSelectedOption();
148
- const variants = useVariants();
149
- return useMemo(()=>getSelectedVariant(variants, selectedOptions), [
150
- selectedOptions,
151
- variants
152
- ]);
153
- };
154
- const useCurrentVariantInStock = ()=>{
155
- const currentVariant = useCurrentVariant();
156
- const currentProduct = useProduct();
157
- return checkInStock(currentVariant, currentProduct);
158
- };
159
- const useVariantOutStock = (optionId, optionValue, options)=>{
160
- const { selectedOptions } = useSelectedOption();
161
- const variants = useVariants();
162
- const lastPos = options.optionNumber - 1;
163
- if (options.position < lastPos) {
164
- return variants.some((variant)=>{
165
- if (variant) {
166
- const { selectedOptions } = variant;
167
- const opt = selectedOptions?.some((option)=>option?.name === optionId && option.value === optionValue);
168
- const isInStock = checkInStock(variant);
169
- return opt && isInStock;
170
- }
171
- });
172
- }
173
- const matchedVariant = getSelectedVariant(variants, {
174
- ...selectedOptions,
175
- [optionId]: optionValue
176
- });
177
- return checkInStock(matchedVariant);
178
- };
179
- const useCheckAvailableVariantInStock = (optionId, optionValue)=>{
180
- const variants = useVariants();
181
- return variants ? variants.some((item)=>{
182
- if (item) {
183
- const { selectedOptions } = item;
184
- const opt = selectedOptions?.some((option)=>option?.name === optionId && option.value === optionValue);
185
- const isInStock = checkInStock(item);
186
- return opt && isInStock;
187
- }
188
- return false;
189
- }) : false;
190
- };
191
-
192
- export { useCheckAvailableVariantInStock, useCurrentVariant, useCurrentVariantInStock, useFeaturedImageGlobal, useIsSyncProduct, useProduct, useProductProperties, useQuantity, useSelectedOption, useUniqProductID, useVariant, useVariantOutStock, useVariants };
1
+ import{useCallback as e,useEffect as t,useMemo as r}from"react";import{useProductStore as n}from"../contexts/ProductContext.js";import"react/jsx-runtime";import"zustand";import"swr";import{usePageStore as s}from"../contexts/PageContext.js";import"@gem-sdk/adapter-shopify";import"swr/mutation";import"vanilla-lazyload";import"./useCartUI.js";import{checkInStock as u}from"../helpers/variant.js";import"react-transition-group";import"@gem-sdk/core";import"classnames";import{flattenConnection as o}from"../helpers/flatten-connection.js";import"../helpers/convert.js";import{getSelectedVariant as i}from"../helpers/product.js";let useUniqProductID=()=>n(e=>e.uiqueId),useProduct=()=>n(e=>e.product),useFeaturedImageGlobal=()=>n(e=>e.featuredImageGlobal),useProductProperties=()=>n(e=>e.properties),useIsSyncProduct=()=>n(e=>e.isSyncProduct),useQuantity=()=>{let s=n(e=>e.quantity),u=n(e=>e.updatePrice),o=n(e=>e.decrementQuantity),i=n(e=>e.incrementQuantity),a=n(e=>e.setQuantity),c=n(e=>e.setHasUpdatePriceFollowQuantity),l=n(e=>e.isSyncProduct),d=n(e=>e.product),p=d?.id,m=e(()=>{a(1)},[a]);return t(()=>{if(l){let e=new CustomEvent("set-product-quantity",{bubbles:!0,cancelable:!0,composed:!0,detail:{quantity:s,productId:p}});window.dispatchEvent(e)}},[s,l,p]),r(()=>({quantity:s,hasUpdatePrice:u,increment:i,decrement:o,reset:m,setQuantity:a,setUpdatePrice:c}),[o,i,s,m,a,c,u])},useSelectedOption=()=>{let t=n(e=>e.setSelectedOption),s=n(e=>e.selectedOptions),u=n(e=>e.forceSelectedOption),o=n(e=>e.isSyncProduct),i=e((e,r,n,s)=>{if(!s&&o){let t=new CustomEvent("set-selected-option",{bubbles:!0,cancelable:!0,composed:!0,detail:{optionId:e,optionValue:r,productId:n}});window.dispatchEvent(t)}t(e,r)},[t,o]),a=e((e,t,r)=>{if(!r&&o){let r=new CustomEvent("force-selected-option",{bubbles:!0,cancelable:!0,composed:!0,detail:{selectedOption:e,productId:t}});window.dispatchEvent(r)}u(e)},[u,o]);return r(()=>({selectedOptions:s,setSelectedOption:i,forceSelectedOption:a}),[s,i,a])},useVariants=()=>{let e=n(e=>e.product?.variants);return o(e)},useVariant=e=>{let t=useVariants();return r(()=>t?.find(t=>t?.id===e),[e,t])},useCurrentVariant=()=>{let{selectedOptions:e}=useSelectedOption(),t=useVariants();return r(()=>i(t,e),[e,t])},useCurrentVariantInStock=()=>{let e=useCurrentVariant(),t=useVariants();return u(e,t)},useVariantOutStock=(e,t,r)=>{let{selectedOptions:n}=useSelectedOption(),s=useVariants(),o=r.optionNumber-1;if(r.position<o)return s.some(r=>{if(r){let{selectedOptions:n}=r,s=n?.some(r=>r?.name===e&&r.value===t),o=u(r);return s&&o}});let a=i(s,{...n,[e]:t});return u(a)},useCheckAvailableVariantInStock=(e,t)=>{let r=useVariants();return!!r&&r.some(r=>{if(r){let{selectedOptions:n}=r,s=n?.some(r=>r?.name===e&&r.value===t),o=u(r);return s&&o}return!1})},useProductOfferDiscount=()=>{let e=s(e=>e.productOffers),t=useProduct(),r=useCurrentVariant(),n=e?.find(e=>e?.node?.objectBaseID===t?.baseID)?.node;if(!n||!n.isEnabled)return 0;let u=n?.value;if(n&&"PERCENTAGE"===n.valueType&&u){let e=r?.price||0;u=u*e/100}return u||0};export{useCheckAvailableVariantInStock,useCurrentVariant,useCurrentVariantInStock,useFeaturedImageGlobal,useIsSyncProduct,useProduct,useProductOfferDiscount,useProductProperties,useQuantity,useSelectedOption,useUniqProductID,useVariant,useVariantOutStock,useVariants};
@@ -1,16 +1 @@
1
- import { useProductListStore } from '../contexts/ProductListContext.js';
2
-
3
- const useProductList = ()=>{
4
- return useProductListStore((s)=>s.collection);
5
- };
6
- const useProductListProducts = ()=>{
7
- return useProductListStore((s)=>s.products);
8
- };
9
- const useProductListSettings = ()=>{
10
- return useProductListStore((s)=>s.settings);
11
- };
12
- const useProductListStyles = ()=>{
13
- return useProductListStore((s)=>s.styles);
14
- };
15
-
16
- export { useProductList, useProductListProducts, useProductListSettings, useProductListStyles };
1
+ import{useProductListStore as t}from"../contexts/ProductListContext.js";let useProductList=()=>t(t=>t.collection),useProductListProducts=()=>t(t=>t.products),useProductListSettings=()=>t(t=>t.settings),useProductListStyles=()=>t(t=>t.styles);export{useProductList,useProductListProducts,useProductListSettings,useProductListStyles};
@@ -1,23 +1 @@
1
- const cache = new Map();
2
- const useSuspenseFetch = (key, promise)=>{
3
- const value = cache.get(key) || {
4
- status: 'new',
5
- data: null
6
- };
7
- if (value.status === 'resolved') {
8
- return {
9
- data: value.data
10
- };
11
- }
12
- promise().then((data)=>{
13
- value.status = 'resolved';
14
- value.data = data;
15
- cache.set(key, value);
16
- }).catch(()=>{
17
- value.status = 'error';
18
- value.data = null;
19
- });
20
- throw promise();
21
- };
22
-
23
- export { useSuspenseFetch as default };
1
+ let cache=new Map,useSuspenseFetch=(e,t)=>{let a=cache.get(e)||{status:"new",data:null};if("resolved"===a.status)return{data:a.data};throw t().then(t=>{a.status="resolved",a.data=t,cache.set(e,a)}).catch(()=>{a.status="error",a.data=null}),t()};export{useSuspenseFetch as default};
@@ -1,37 +1 @@
1
- import { useSwatches } from './shop.js';
2
-
3
- const initialSwatchOptionValue = {
4
- label: '',
5
- colors: [],
6
- imageUrl: ''
7
- };
8
- const initialGlobalSwatchesData = {
9
- optionTitle: '',
10
- optionType: '',
11
- optionValues: []
12
- };
13
- const useSwatchesOptions = (options)=>{
14
- const { swatches } = useSwatches();
15
- if (!options) return [];
16
- return options?.map((option)=>{
17
- const swatchOption = swatches?.find((sw)=>sw?.optionTitle === option?.name) || {
18
- ...initialGlobalSwatchesData
19
- };
20
- return {
21
- ...option,
22
- optionType: swatchOption ? swatchOption.optionType : '',
23
- values: option.values?.map((val)=>{
24
- const swatchValue = swatchOption && swatchOption?.optionValues?.find((swatOp)=>swatOp?.label === val?.label) || {
25
- ...initialSwatchOptionValue
26
- };
27
- return {
28
- ...val,
29
- colors: swatchValue?.colors || [],
30
- imageUrl: swatchValue?.imageUrl || ''
31
- };
32
- })
33
- };
34
- });
35
- };
36
-
37
- export { useSwatchesOptions as default };
1
+ import{useSwatches as t}from"./shop.js";let initialSwatchOptionValue={label:"",colors:[],imageUrl:""},initialGlobalSwatchesData={optionTitle:"",optionType:"",optionValues:[]},useSwatchesOptions=a=>{let{swatches:e}=t();return a?a?.map(t=>{let a=e?.find(a=>a?.optionTitle===t?.name)||{...initialGlobalSwatchesData};return{...t,optionType:a?a.optionType:"",values:t.values?.map(t=>{let e=a&&a?.optionValues?.find(a=>a?.label===t?.label)||{...initialSwatchOptionValue};return{...t,colors:e?.colors||[],imageUrl:e?.imageUrl||""}})}}):[]};export{useSwatchesOptions as default};
@@ -0,0 +1 @@
1
+ import{postPurchaseRequiredElements as e,postPurchaseWrapElements as t}from"../components/constant.js";import{useShopStore as r}from"../contexts/ShopContext.js";let usePostPurchase=(n,o)=>{let u=r(e=>e.pageType),c=(e,t)=>{let r=e||o,n=0,u=(t||document).querySelectorAll(`[data-component-tag="${r}"]`);if("PostPurchaseProductOffer"===r)return u.length;let c="";return u.forEach(e=>{let t=e.closest('[data-component-tag="PostPurchaseProductOffer"]'),o=t?.getAttribute("data-uid")||"",u=e.closest('[data-component-tag="Product"]'),l=u?.querySelectorAll(`[data-component-tag="${r}"]`).length||0,a=t?o!==c?l:0:1;t&&(c=o),n+=a}),n},l=()=>{let e=c();return e<=1},a=()=>{let t=document.querySelector(`[data-uid="${n}"]`);if(!t)return!1;for(let r of e){let e=c(r),n=c(r,t);if(n>0&&e-n<1)return!0}return!1},d=()=>e.reduce((e,t)=>{let r=document.querySelector(`[data-uid="${n}"]`);if(!r)return 0;let o=r.querySelectorAll(`[data-component-tag="${t}"]`).length;return e+o},0),s=()=>{if("POST_PURCHASE"!==u)return!1;let r=!1;return e.includes(o)&&(r=l())?r:!!(t.includes(o)&&d()>0)&&a()},i=()=>{if(e.includes(o))return{text:"This element is required <br> and can’t be deleted",width:"175px"};{let e="Section"===o?"section":"element";return{text:`This ${e} contains required <br> elements and cannot be deleted`,width:"206px"}}};return{checkDisableDelete:s,getTooltipText:i,checkDisableDuplicate:()=>"GP_FUNNEL_PAGE"===u&&"ProductList"===o}};export{usePostPurchase};