@gem-sdk/core 2.0.0-dev.896 → 2.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/components/AddOn.js +18 -1
- package/dist/cjs/components/ComponentAnimation.js +17 -0
- package/dist/cjs/components/ComponentToolbarPreview.js +752 -1
- package/dist/cjs/components/ComponentWrapper.js +61 -1
- package/dist/cjs/components/ComponentWrapperPreview.js +213 -1
- package/dist/cjs/components/Empty.js +7 -1
- package/dist/cjs/components/InteractionSuffix.js +42 -0
- package/dist/cjs/components/Render.js +75 -1
- package/dist/cjs/components/Render.liquid.js +313 -17
- package/dist/cjs/components/RenderBlock.js +54 -1
- package/dist/cjs/components/RenderCustomCode.js +59 -3
- package/dist/cjs/components/RenderPreview.js +67 -1
- package/dist/cjs/components/RenderSection.js +23 -1
- package/dist/cjs/components/ai-generator/AIContentGenerator.js +252 -1
- package/dist/cjs/components/ai-generator/AIGenContentLoading.js +85 -1
- package/dist/cjs/components/ai-generator/components/PickProduct.js +220 -1
- package/dist/cjs/components/ai-generator/components/ToneAndVoice.js +77 -1
- package/dist/cjs/components/ai-generator/hooks/useCheckingProductInside.js +47 -0
- package/dist/cjs/components/ai-generator/hooks/useFlipPopup.js +110 -0
- package/dist/cjs/components/ai-generator/hooks/useGettingGenerateRequest.js +37 -1
- package/dist/cjs/components/ai-generator/hooks/useListenEventGenerate.js +70 -1
- package/dist/cjs/components/ai-generator/icons/AIIcon.js +67 -1
- package/dist/cjs/components/ai-generator/icons/CloseIcon.js +19 -1
- package/dist/cjs/components/ai-generator/icons/DropdownIcon.js +37 -1
- package/dist/cjs/components/ai-generator/icons/SearchIcon.js +21 -1
- package/dist/cjs/components/ai-generator/icons/ShowMoreIcon.js +21 -1
- package/dist/cjs/components/ai-generator/icons/UpgradeIcon.js +27 -0
- package/dist/cjs/components/ai-generator/icons/WarningIcon.js +31 -0
- package/dist/cjs/components/constant.js +83 -1
- package/dist/cjs/components/resize/Resize.js +16 -1
- package/dist/cjs/components/resize/Spacing.js +260 -1
- package/dist/cjs/components/src/product/helpers/variant-presets.js +56 -1
- package/dist/cjs/components/theme-section/CreateThemeSection.js +123 -1
- package/dist/cjs/components/theme-section/ThemeSectionStatus.js +45 -1
- package/dist/cjs/components/theme-section/ThemeSectionTooltip.js +126 -1
- package/dist/cjs/components/toolbar/Tooltip.js +28 -1
- package/dist/cjs/contexts/AddonContext.js +36 -1
- package/dist/cjs/contexts/ArticleContext.js +39 -1
- package/dist/cjs/contexts/ArticleListContext.js +31 -1
- package/dist/cjs/contexts/BuilderComponent.js +34 -1
- package/dist/cjs/contexts/BuilderContext.js +39 -1
- package/dist/cjs/contexts/BuilderPreviewContext.js +486 -1
- package/dist/cjs/contexts/CartLineContext.js +29 -1
- package/dist/cjs/contexts/CollectionContext.js +38 -1
- package/dist/cjs/contexts/ModalContext.js +47 -1
- package/dist/cjs/contexts/PageContext.js +104 -1
- package/dist/cjs/contexts/ProductContext.js +177 -1
- package/dist/cjs/contexts/ProductListContext.js +32 -1
- package/dist/cjs/contexts/SectionContext.js +53 -1
- package/dist/cjs/contexts/ShopContext.js +107 -1
- package/dist/cjs/graphql/fragments/analytic.generated.js +6 -2
- package/dist/cjs/graphql/fragments/collection-detail.generated.js +6 -2
- package/dist/cjs/graphql/fragments/collection-product.generated.js +6 -2
- package/dist/cjs/graphql/fragments/collection.generated.js +6 -2
- package/dist/cjs/graphql/fragments/custom-code.generated.js +6 -2
- package/dist/cjs/graphql/fragments/custom-font.generated.js +6 -2
- package/dist/cjs/graphql/fragments/data-seo.generated.js +6 -2
- package/dist/cjs/graphql/fragments/media.generated.js +6 -2
- package/dist/cjs/graphql/fragments/preview-theme-page.generated.js +39 -0
- package/dist/cjs/graphql/fragments/product-little.generated.js +7 -2
- package/dist/cjs/graphql/fragments/product-option-value.generated.js +6 -2
- package/dist/cjs/graphql/fragments/product-option.generated.js +6 -2
- package/dist/cjs/graphql/fragments/product.generated.js +6 -2
- package/dist/cjs/graphql/fragments/published-custom-section.generated.js +6 -2
- package/dist/cjs/graphql/fragments/published-page-section.generated.js +6 -2
- package/dist/cjs/graphql/fragments/published-theme-page.generated.js +10 -28
- package/dist/cjs/graphql/fragments/published-theme-style.generated.js +6 -2
- package/dist/cjs/graphql/fragments/selected-option.generated.js +6 -2
- package/dist/cjs/graphql/fragments/variant.generated.js +6 -2
- package/dist/cjs/graphql/mutations/page-view-up.generated.js +8 -4
- package/dist/cjs/graphql/queries/articles.generated.js +61 -0
- package/dist/cjs/graphql/queries/blogs.generated.js +69 -0
- package/dist/cjs/graphql/queries/collection-detail-filter.generated.js +16 -2
- package/dist/cjs/graphql/queries/collection.generated.js +14 -2
- package/dist/cjs/graphql/queries/collections.generated.js +9 -2
- package/dist/cjs/graphql/queries/preview-page.generated.js +16 -8
- package/dist/cjs/graphql/queries/product-little-detail.generated.js +11 -2
- package/dist/cjs/graphql/queries/product-medias.generated.js +8 -2
- package/dist/cjs/graphql/queries/product-value-label.generated.js +6 -2
- package/dist/cjs/graphql/queries/product-variants.generated.js +10 -2
- package/dist/cjs/graphql/queries/products.generated.js +17 -3
- package/dist/cjs/graphql/queries/published-shop-metas.js +15 -0
- package/dist/cjs/graphql/queries/published-theme-pages.generated.js +15 -2
- package/dist/cjs/graphql/queries/store-property.generated.js +6 -2
- package/dist/cjs/graphql-app-api/queries/LibrarySaleFunnelDiscount.generated.js +6 -2
- package/dist/cjs/graphql-app-api/queries/LibraryTemplate.generated.js +6 -2
- package/dist/cjs/graphql-app-api/queries/SaleFunnelDiscounts.generated.js +6 -2
- package/dist/cjs/graphql-app-api/queries/ShopLibraryPage.generated.js +17 -0
- package/dist/cjs/graphql-app-api/queries/ThemePage.generated.js +6 -2
- package/dist/cjs/helpers/GlobalEvent.js +19 -1
- package/dist/cjs/helpers/align.js +19 -0
- package/dist/cjs/helpers/animations.js +222 -1
- package/dist/cjs/helpers/background.js +235 -1
- package/dist/cjs/helpers/borders.js +198 -4
- package/dist/cjs/helpers/carousel.js +55 -1
- package/dist/cjs/helpers/clone-deep.js +5 -1
- package/dist/cjs/helpers/cls.js +16 -1
- package/dist/cjs/helpers/colors.js +184 -1
- package/dist/cjs/helpers/compose-advance-style.js +327 -1
- package/dist/cjs/helpers/constant.js +23 -1
- package/dist/cjs/helpers/convert.js +7 -1
- package/dist/cjs/helpers/covert-entities-html.js +19 -1
- package/dist/cjs/helpers/css-variable.js +7 -1
- package/dist/cjs/helpers/email.js +11 -1
- package/dist/cjs/helpers/filter-toolbar-preview.js +14 -1
- package/dist/cjs/helpers/flatten-connection.js +9 -1
- package/dist/cjs/helpers/get-resonsive-value.js +36 -1
- package/dist/cjs/helpers/get-shortname.js +92 -1
- package/dist/cjs/helpers/icon-list.js +61 -1
- package/dist/cjs/helpers/interaction/index.js +134 -0
- package/dist/cjs/helpers/is-browser.js +9 -1
- package/dist/cjs/helpers/is-defined.js +7 -1
- package/dist/cjs/helpers/is-empty-children.js +15 -1
- package/dist/cjs/helpers/is-safari.js +9 -1
- package/dist/cjs/helpers/layout.js +59 -1
- package/dist/cjs/helpers/load-script.js +31 -1
- package/dist/cjs/helpers/loop-component.js +16 -0
- package/dist/cjs/helpers/make-style.js +163 -1
- package/dist/cjs/helpers/normalize-builder-data.js +23 -1
- package/dist/cjs/helpers/pascal-to-kebab-case.js +7 -0
- package/dist/cjs/helpers/prefetch-queries.js +78 -1
- package/dist/cjs/helpers/product.js +48 -1
- package/dist/cjs/helpers/queries/get-collection.js +226 -1
- package/dist/cjs/helpers/queries/get-collections.js +21 -1
- package/dist/cjs/helpers/queries/get-product-by-slug.js +125 -1
- package/dist/cjs/helpers/queries/get-product.js +154 -1
- package/dist/cjs/helpers/queries/get-products.js +214 -1
- package/dist/cjs/helpers/query.js +29 -1
- package/dist/cjs/helpers/radius.js +140 -6
- package/dist/cjs/helpers/render.js +78 -1
- package/dist/cjs/helpers/shadow.js +69 -1
- package/dist/cjs/helpers/size.js +206 -4
- package/dist/cjs/helpers/spacing.js +43 -1
- package/dist/cjs/helpers/third-party/addAppBlockId.js +20 -0
- package/dist/cjs/helpers/third-party/appConfig.js +234 -0
- package/dist/cjs/helpers/third-party/appSetting.js +661 -0
- package/dist/cjs/helpers/third-party/composeAppBlockId.js +11 -0
- package/dist/cjs/helpers/third-party/constant.js +43 -0
- package/dist/cjs/helpers/third-party/generateAppBlockConfigs.js +34 -0
- package/dist/cjs/helpers/third-party/getAppBlockConfig.js +47 -0
- package/dist/cjs/helpers/third-party/getAppBlockType.js +12 -0
- package/dist/cjs/helpers/third-party/getAppBlocks.js +30 -0
- package/dist/cjs/helpers/third-party/mergeBlock.js +19 -0
- package/dist/cjs/helpers/third-party/mergeBlockOrder.js +47 -0
- package/dist/cjs/helpers/third-party/removeGPAppItems.js +18 -0
- package/dist/cjs/helpers/tracking/fpixel.js +28 -1
- package/dist/cjs/helpers/tracking/gtag.js +93 -1
- package/dist/cjs/helpers/tracking/tiktokpixel.js +17 -1
- package/dist/cjs/helpers/typography.js +160 -17
- package/dist/cjs/helpers/variant.js +11 -1
- package/dist/cjs/hooks/animation/useAnimationActions.js +39 -1
- package/dist/cjs/hooks/animation/useAnimationConfig.js +30 -1
- package/dist/cjs/hooks/animation/useAnimationPreview.js +31 -1
- package/dist/cjs/hooks/animation/useAnimationTarget.js +122 -1
- package/dist/cjs/hooks/animation/useApplyAnimation.js +89 -1
- package/dist/cjs/hooks/articles/useArticlesQuery.js +33 -1
- package/dist/cjs/hooks/cart/use-add-to-cart.js +20 -1
- package/dist/cjs/hooks/cart/use-cart-data.js +28 -1
- package/dist/cjs/hooks/cart/use-cart-discount-codes-update.js +20 -1
- package/dist/cjs/hooks/cart/use-cart-note-update.js +20 -1
- package/dist/cjs/hooks/cart/use-create-cart.js +22 -1
- package/dist/cjs/hooks/cart/use-remove-cart-item.js +20 -1
- package/dist/cjs/hooks/cart/use-update-cart-item.js +20 -1
- package/dist/cjs/hooks/shop/use-collection-query.js +22 -1
- package/dist/cjs/hooks/shop/use-collections-query.js +17 -1
- package/dist/cjs/hooks/shop/use-product-query.js +22 -1
- package/dist/cjs/hooks/shop/use-products-query.js +63 -1
- package/dist/cjs/hooks/shop.js +126 -1
- package/dist/cjs/hooks/use-current-device.js +30 -1
- package/dist/cjs/hooks/use-lazy-video.js +15 -1
- package/dist/cjs/hooks/useAnimations.js +29 -1
- package/dist/cjs/hooks/useCartId.js +44 -1
- package/dist/cjs/hooks/useCartLine.js +11 -1
- package/dist/cjs/hooks/useCartUI.js +48 -1
- package/dist/cjs/hooks/useCollection.js +9 -1
- package/dist/cjs/hooks/useFetchHandle.js +13 -1
- package/dist/cjs/hooks/useFormatMoney.js +75 -1
- package/dist/cjs/hooks/useInitialSwatchesOptions.js +128 -1
- package/dist/cjs/hooks/useInteraction.js +19 -0
- package/dist/cjs/hooks/useIsomorphicLayoutEffect.js +10 -1
- package/dist/cjs/hooks/useLoadScript.js +32 -1
- package/dist/cjs/hooks/useMoney.js +84 -1
- package/dist/cjs/hooks/usePrevious.js +19 -1
- package/dist/cjs/hooks/useProduct.js +245 -1
- package/dist/cjs/hooks/useProductList.js +21 -1
- package/dist/cjs/hooks/useSuspenseFetch.js +27 -1
- package/dist/cjs/hooks/useSwatchesOptions.js +41 -1
- package/dist/cjs/hooks/useToolbarPostPurchase.js +89 -1
- package/dist/cjs/index.js +416 -1
- package/dist/cjs/types/animations.js +49 -1
- package/dist/cjs/types/appAPI.js +2 -1
- package/dist/cjs/types/custom.js +52 -0
- package/dist/cjs/types/global-style.js +15 -1
- package/dist/cjs/types/shop.js +2 -1
- package/dist/cjs/web-components/src/helpers/styles/constant.js +9 -1
- package/dist/esm/components/AddOn.js +14 -1
- package/dist/esm/components/ComponentAnimation.js +13 -0
- package/dist/esm/components/ComponentToolbarPreview.js +748 -1
- package/dist/esm/components/ComponentWrapper.js +57 -1
- package/dist/esm/components/ComponentWrapperPreview.js +209 -1
- package/dist/esm/components/Empty.js +3 -1
- package/dist/esm/components/InteractionSuffix.js +40 -0
- package/dist/esm/components/Render.js +71 -1
- package/dist/esm/components/Render.liquid.js +307 -17
- package/dist/esm/components/RenderBlock.js +50 -1
- package/dist/esm/components/RenderCustomCode.js +55 -3
- package/dist/esm/components/RenderPreview.js +63 -1
- package/dist/esm/components/RenderSection.js +19 -1
- package/dist/esm/components/ai-generator/AIContentGenerator.js +250 -1
- package/dist/esm/components/ai-generator/AIGenContentLoading.js +83 -1
- package/dist/esm/components/ai-generator/components/PickProduct.js +218 -1
- package/dist/esm/components/ai-generator/components/ToneAndVoice.js +75 -1
- package/dist/esm/components/ai-generator/hooks/useCheckingProductInside.js +45 -0
- package/dist/esm/components/ai-generator/hooks/useFlipPopup.js +108 -0
- package/dist/esm/components/ai-generator/hooks/useGettingGenerateRequest.js +35 -1
- package/dist/esm/components/ai-generator/hooks/useListenEventGenerate.js +68 -1
- package/dist/esm/components/ai-generator/icons/AIIcon.js +65 -1
- package/dist/esm/components/ai-generator/icons/CloseIcon.js +17 -1
- package/dist/esm/components/ai-generator/icons/DropdownIcon.js +34 -1
- package/dist/esm/components/ai-generator/icons/SearchIcon.js +19 -1
- package/dist/esm/components/ai-generator/icons/ShowMoreIcon.js +19 -1
- package/dist/esm/components/ai-generator/icons/UpgradeIcon.js +25 -0
- package/dist/esm/components/ai-generator/icons/WarningIcon.js +29 -0
- package/dist/esm/components/constant.js +76 -1
- package/dist/esm/components/resize/Resize.js +12 -1
- package/dist/esm/components/resize/Spacing.js +256 -1
- package/dist/esm/components/src/product/helpers/variant-presets.js +54 -1
- package/dist/esm/components/theme-section/CreateThemeSection.js +121 -1
- package/dist/esm/components/theme-section/ThemeSectionStatus.js +43 -1
- package/dist/esm/components/theme-section/ThemeSectionTooltip.js +124 -1
- package/dist/esm/components/toolbar/Tooltip.js +24 -1
- package/dist/esm/contexts/AddonContext.js +32 -1
- package/dist/esm/contexts/ArticleContext.js +36 -1
- package/dist/esm/contexts/ArticleListContext.js +27 -1
- package/dist/esm/contexts/BuilderComponent.js +31 -1
- package/dist/esm/contexts/BuilderContext.js +36 -1
- package/dist/esm/contexts/BuilderPreviewContext.js +483 -1
- package/dist/esm/contexts/CartLineContext.js +26 -1
- package/dist/esm/contexts/CollectionContext.js +35 -1
- package/dist/esm/contexts/ModalContext.js +44 -1
- package/dist/esm/contexts/PageContext.js +101 -1
- package/dist/esm/contexts/ProductContext.js +174 -1
- package/dist/esm/contexts/ProductListContext.js +28 -1
- package/dist/esm/contexts/SectionContext.js +49 -1
- package/dist/esm/contexts/ShopContext.js +104 -1
- package/dist/esm/graphql/fragments/analytic.generated.js +4 -2
- package/dist/esm/graphql/fragments/collection-detail.generated.js +4 -2
- package/dist/esm/graphql/fragments/collection-product.generated.js +4 -2
- package/dist/esm/graphql/fragments/collection.generated.js +4 -2
- package/dist/esm/graphql/fragments/custom-code.generated.js +4 -2
- package/dist/esm/graphql/fragments/custom-font.generated.js +4 -2
- package/dist/esm/graphql/fragments/data-seo.generated.js +4 -2
- package/dist/esm/graphql/fragments/media.generated.js +4 -2
- package/dist/esm/graphql/fragments/preview-theme-page.generated.js +37 -0
- package/dist/esm/graphql/fragments/product-little.generated.js +5 -2
- package/dist/esm/graphql/fragments/product-option-value.generated.js +4 -2
- package/dist/esm/graphql/fragments/product-option.generated.js +4 -2
- package/dist/esm/graphql/fragments/product.generated.js +4 -2
- package/dist/esm/graphql/fragments/published-custom-section.generated.js +4 -2
- package/dist/esm/graphql/fragments/published-page-section.generated.js +4 -2
- package/dist/esm/graphql/fragments/published-theme-page.generated.js +8 -28
- package/dist/esm/graphql/fragments/published-theme-style.generated.js +4 -2
- package/dist/esm/graphql/fragments/selected-option.generated.js +4 -2
- package/dist/esm/graphql/fragments/variant.generated.js +4 -2
- package/dist/esm/graphql/mutations/page-view-up.generated.js +6 -4
- package/dist/esm/graphql/queries/articles.generated.js +59 -0
- package/dist/esm/graphql/queries/blogs.generated.js +67 -0
- package/dist/esm/graphql/queries/collection-detail-filter.generated.js +22 -10
- package/dist/esm/graphql/queries/collection.generated.js +18 -8
- package/dist/esm/graphql/queries/collections.generated.js +8 -3
- package/dist/esm/graphql/queries/preview-page.generated.js +16 -10
- package/dist/esm/graphql/queries/product-little-detail.generated.js +12 -5
- package/dist/esm/graphql/queries/product-medias.generated.js +6 -2
- package/dist/esm/graphql/queries/product-value-label.generated.js +4 -2
- package/dist/esm/graphql/queries/product-variants.generated.js +10 -4
- package/dist/esm/graphql/queries/products.generated.js +20 -9
- package/dist/esm/graphql/queries/published-shop-metas.js +13 -0
- package/dist/esm/graphql/queries/published-theme-pages.generated.js +20 -9
- package/dist/esm/graphql/queries/store-property.generated.js +4 -2
- package/dist/esm/graphql-app-api/queries/LibrarySaleFunnelDiscount.generated.js +4 -2
- package/dist/esm/graphql-app-api/queries/LibraryTemplate.generated.js +4 -2
- package/dist/esm/graphql-app-api/queries/SaleFunnelDiscounts.generated.js +4 -2
- package/dist/esm/graphql-app-api/queries/ShopLibraryPage.generated.js +15 -0
- package/dist/esm/graphql-app-api/queries/ThemePage.generated.js +4 -2
- package/dist/esm/helpers/GlobalEvent.js +15 -1
- package/dist/esm/helpers/align.js +17 -0
- package/dist/esm/helpers/animations.js +220 -1
- package/dist/esm/helpers/background.js +226 -1
- package/dist/esm/helpers/borders.js +189 -4
- package/dist/esm/helpers/carousel.js +51 -1
- package/dist/esm/helpers/clone-deep.js +3 -1
- package/dist/esm/helpers/cls.js +14 -1
- package/dist/esm/helpers/colors.js +169 -1
- package/dist/esm/helpers/compose-advance-style.js +319 -1
- package/dist/esm/helpers/constant.js +19 -1
- package/dist/esm/helpers/convert.js +4 -1
- package/dist/esm/helpers/covert-entities-html.js +17 -1
- package/dist/esm/helpers/css-variable.js +5 -1
- package/dist/esm/helpers/email.js +6 -1
- package/dist/esm/helpers/filter-toolbar-preview.js +9 -1
- package/dist/esm/helpers/flatten-connection.js +7 -1
- package/dist/esm/helpers/get-resonsive-value.js +31 -1
- package/dist/esm/helpers/get-shortname.js +90 -1
- package/dist/esm/helpers/icon-list.js +58 -1
- package/dist/esm/helpers/interaction/index.js +132 -0
- package/dist/esm/helpers/is-browser.js +5 -1
- package/dist/esm/helpers/is-defined.js +5 -1
- package/dist/esm/helpers/is-empty-children.js +10 -1
- package/dist/esm/helpers/is-safari.js +5 -1
- package/dist/esm/helpers/layout.js +54 -1
- package/dist/esm/helpers/load-script.js +29 -1
- package/dist/esm/helpers/loop-component.js +14 -0
- package/dist/esm/helpers/make-style.js +149 -1
- package/dist/esm/helpers/normalize-builder-data.js +21 -1
- package/dist/esm/helpers/pascal-to-kebab-case.js +5 -0
- package/dist/esm/helpers/prefetch-queries.js +76 -1
- package/dist/esm/helpers/product.js +44 -1
- package/dist/esm/helpers/queries/get-collection.js +223 -1
- package/dist/esm/helpers/queries/get-collections.js +19 -1
- package/dist/esm/helpers/queries/get-product-by-slug.js +123 -1
- package/dist/esm/helpers/queries/get-product.js +150 -1
- package/dist/esm/helpers/queries/get-products.js +210 -1
- package/dist/esm/helpers/query.js +25 -1
- package/dist/esm/helpers/radius.js +132 -6
- package/dist/esm/helpers/render.js +70 -1
- package/dist/esm/helpers/shadow.js +63 -1
- package/dist/esm/helpers/size.js +192 -4
- package/dist/esm/helpers/spacing.js +40 -1
- package/dist/esm/helpers/third-party/addAppBlockId.js +18 -0
- package/dist/esm/helpers/third-party/appConfig.js +200 -0
- package/dist/esm/helpers/third-party/appSetting.js +658 -0
- package/dist/esm/helpers/third-party/composeAppBlockId.js +9 -0
- package/dist/esm/helpers/third-party/constant.js +40 -0
- package/dist/esm/helpers/third-party/generateAppBlockConfigs.js +32 -0
- package/dist/esm/helpers/third-party/getAppBlockConfig.js +45 -0
- package/dist/esm/helpers/third-party/getAppBlockType.js +10 -0
- package/dist/esm/helpers/third-party/getAppBlocks.js +28 -0
- package/dist/esm/helpers/third-party/mergeBlock.js +17 -0
- package/dist/esm/helpers/third-party/mergeBlockOrder.js +45 -0
- package/dist/esm/helpers/third-party/removeGPAppItems.js +15 -0
- package/dist/esm/helpers/tracking/fpixel.js +24 -1
- package/dist/esm/helpers/tracking/gtag.js +87 -1
- package/dist/esm/helpers/tracking/tiktokpixel.js +15 -1
- package/dist/esm/helpers/typography.js +149 -17
- package/dist/esm/helpers/variant.js +9 -1
- package/dist/esm/hooks/animation/useAnimationActions.js +37 -1
- package/dist/esm/hooks/animation/useAnimationConfig.js +28 -1
- package/dist/esm/hooks/animation/useAnimationPreview.js +29 -1
- package/dist/esm/hooks/animation/useAnimationTarget.js +120 -1
- package/dist/esm/hooks/animation/useApplyAnimation.js +85 -1
- package/dist/esm/hooks/articles/useArticlesQuery.js +30 -1
- package/dist/esm/hooks/cart/use-add-to-cart.js +18 -1
- package/dist/esm/hooks/cart/use-cart-data.js +26 -1
- package/dist/esm/hooks/cart/use-cart-discount-codes-update.js +18 -1
- package/dist/esm/hooks/cart/use-cart-note-update.js +18 -1
- package/dist/esm/hooks/cart/use-create-cart.js +20 -1
- package/dist/esm/hooks/cart/use-remove-cart-item.js +18 -1
- package/dist/esm/hooks/cart/use-update-cart-item.js +18 -1
- package/dist/esm/hooks/shop/use-collection-query.js +20 -1
- package/dist/esm/hooks/shop/use-collections-query.js +15 -1
- package/dist/esm/hooks/shop/use-product-query.js +20 -1
- package/dist/esm/hooks/shop/use-products-query.js +59 -1
- package/dist/esm/hooks/shop.js +111 -1
- package/dist/esm/hooks/use-current-device.js +28 -1
- package/dist/esm/hooks/use-lazy-video.js +13 -1
- package/dist/esm/hooks/useAnimations.js +27 -1
- package/dist/esm/hooks/useCartId.js +40 -1
- package/dist/esm/hooks/useCartLine.js +7 -1
- package/dist/esm/hooks/useCartUI.js +44 -1
- package/dist/esm/hooks/useCollection.js +7 -1
- package/dist/esm/hooks/useFetchHandle.js +11 -1
- package/dist/esm/hooks/useFormatMoney.js +71 -1
- package/dist/esm/hooks/useInitialSwatchesOptions.js +124 -1
- package/dist/esm/hooks/useInteraction.js +17 -0
- package/dist/esm/hooks/useIsomorphicLayoutEffect.js +6 -1
- package/dist/esm/hooks/useLoadScript.js +28 -1
- package/dist/esm/hooks/useMoney.js +80 -1
- package/dist/esm/hooks/usePrevious.js +17 -1
- package/dist/esm/hooks/useProduct.js +228 -1
- package/dist/esm/hooks/useProductList.js +16 -1
- package/dist/esm/hooks/useSuspenseFetch.js +23 -1
- package/dist/esm/hooks/useSwatchesOptions.js +37 -1
- package/dist/esm/hooks/useToolbarPostPurchase.js +87 -1
- package/dist/esm/index.js +117 -1
- package/dist/esm/types/animations.js +49 -1
- package/dist/esm/types/custom.js +52 -0
- package/dist/esm/types/global-style.js +12 -1
- package/dist/esm/web-components/src/helpers/styles/constant.js +7 -1
- package/dist/types/index.d.ts +23183 -17335
- package/package.json +5 -3
- package/dist/cjs/components/animation/AnimationWrapper.js +0 -1
- package/dist/cjs/hooks/animation/animations.js +0 -1
- package/dist/cjs/hooks/animation/useLivePageAnimation.js +0 -1
- package/dist/esm/components/animation/AnimationWrapper.js +0 -1
- package/dist/esm/hooks/animation/animations.js +0 -1
- package/dist/esm/hooks/animation/useLivePageAnimation.js +0 -1
package/dist/cjs/hooks/shop.js
CHANGED
|
@@ -1 +1,126 @@
|
|
|
1
|
-
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var react = require('react');
|
|
4
|
+
var useSWR = require('swr');
|
|
5
|
+
var ShopContext = require('../contexts/ShopContext.js');
|
|
6
|
+
|
|
7
|
+
const useLocale = ()=>{
|
|
8
|
+
const locale = ShopContext.useShopStore((state)=>state.locale);
|
|
9
|
+
const changeLocale = ShopContext.useShopStore((state)=>state.changeLocale);
|
|
10
|
+
return react.useMemo(()=>({
|
|
11
|
+
locale,
|
|
12
|
+
changeLocale
|
|
13
|
+
}), [
|
|
14
|
+
locale,
|
|
15
|
+
changeLocale
|
|
16
|
+
]);
|
|
17
|
+
};
|
|
18
|
+
const useCurrency = ()=>{
|
|
19
|
+
const currency = ShopContext.useShopStore((state)=>state.currency);
|
|
20
|
+
const changeCurrency = ShopContext.useShopStore((state)=>state.changeCurrency);
|
|
21
|
+
return react.useMemo(()=>({
|
|
22
|
+
currency,
|
|
23
|
+
changeCurrency
|
|
24
|
+
}), [
|
|
25
|
+
currency,
|
|
26
|
+
changeCurrency
|
|
27
|
+
]);
|
|
28
|
+
};
|
|
29
|
+
const useMoneyFormat = ()=>{
|
|
30
|
+
const moneyFormat = ShopContext.useShopStore((state)=>state.moneyFormat);
|
|
31
|
+
const moneyWithCurrencyFormat = ShopContext.useShopStore((state)=>state.moneyWithCurrencyFormat);
|
|
32
|
+
return react.useMemo(()=>({
|
|
33
|
+
moneyFormat,
|
|
34
|
+
moneyWithCurrencyFormat
|
|
35
|
+
}), [
|
|
36
|
+
moneyFormat,
|
|
37
|
+
moneyWithCurrencyFormat
|
|
38
|
+
]);
|
|
39
|
+
};
|
|
40
|
+
const useSwatches = ()=>{
|
|
41
|
+
const swatches = ShopContext.useShopStore((state)=>state.swatches);
|
|
42
|
+
const changeSwatches = ShopContext.useShopStore((state)=>state.changeSwatches);
|
|
43
|
+
return react.useMemo(()=>({
|
|
44
|
+
swatches,
|
|
45
|
+
changeSwatches
|
|
46
|
+
}), [
|
|
47
|
+
swatches,
|
|
48
|
+
changeSwatches
|
|
49
|
+
]);
|
|
50
|
+
};
|
|
51
|
+
const usePageType = ()=>{
|
|
52
|
+
const pageType = ShopContext.useShopStore((state)=>state.pageType);
|
|
53
|
+
return react.useMemo(()=>pageType || 'STATIC', [
|
|
54
|
+
pageType
|
|
55
|
+
]);
|
|
56
|
+
};
|
|
57
|
+
const useStoreFront = ()=>{
|
|
58
|
+
const provider = ShopContext.useShopStore((state)=>state.provider);
|
|
59
|
+
const storefrontToken = ShopContext.useShopStore((state)=>state.storefrontToken);
|
|
60
|
+
const storefrontUrl = ShopContext.useShopStore((state)=>state.storefrontUrl);
|
|
61
|
+
return {
|
|
62
|
+
provider,
|
|
63
|
+
storefrontToken,
|
|
64
|
+
storefrontUrl
|
|
65
|
+
};
|
|
66
|
+
};
|
|
67
|
+
const usePluginEnable = ()=>{
|
|
68
|
+
return ShopContext.useShopStore((state)=>state.plugins);
|
|
69
|
+
};
|
|
70
|
+
const useEditorMode = ()=>{
|
|
71
|
+
return ShopContext.useShopStore((state)=>state.mode);
|
|
72
|
+
};
|
|
73
|
+
const useMobileOnly = ()=>{
|
|
74
|
+
return ShopContext.useShopStore((state)=>state.mobileOnly);
|
|
75
|
+
};
|
|
76
|
+
const useMatchMutate = ()=>{
|
|
77
|
+
const { cache, mutate } = useSWR.useSWRConfig();
|
|
78
|
+
return (matcher, opts)=>{
|
|
79
|
+
if (!(cache instanceof Map)) {
|
|
80
|
+
throw new Error('matchMutate requires the cache provider to be a Map instance');
|
|
81
|
+
}
|
|
82
|
+
const keys = [];
|
|
83
|
+
cache.forEach((_, key)=>{
|
|
84
|
+
if (matcher.test(key)) {
|
|
85
|
+
keys.push(key);
|
|
86
|
+
}
|
|
87
|
+
});
|
|
88
|
+
const mutations = keys.map((key)=>{
|
|
89
|
+
const cacheData = cache.get(key);
|
|
90
|
+
return mutate(key, cacheData?.data, opts);
|
|
91
|
+
});
|
|
92
|
+
return Promise.all(mutations);
|
|
93
|
+
};
|
|
94
|
+
};
|
|
95
|
+
function useConnectedShopify() {
|
|
96
|
+
const { storefrontToken } = useStoreFront();
|
|
97
|
+
return !!storefrontToken;
|
|
98
|
+
}
|
|
99
|
+
function useIsSampleProduct() {
|
|
100
|
+
const { storefrontToken } = useStoreFront();
|
|
101
|
+
const isStorefront = ShopContext.useShopStore((state)=>state.isStorefront);
|
|
102
|
+
return isStorefront && !storefrontToken;
|
|
103
|
+
}
|
|
104
|
+
function useIsStorefrontProduct() {
|
|
105
|
+
return ShopContext.useShopStore((state)=>state.isStorefront);
|
|
106
|
+
}
|
|
107
|
+
function useCheckoutUrl(url) {
|
|
108
|
+
const { storefrontToken } = useStoreFront();
|
|
109
|
+
if (!url) return undefined;
|
|
110
|
+
return storefrontToken ? `${url}?access_token=${storefrontToken}` : url;
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
exports.useCheckoutUrl = useCheckoutUrl;
|
|
114
|
+
exports.useConnectedShopify = useConnectedShopify;
|
|
115
|
+
exports.useCurrency = useCurrency;
|
|
116
|
+
exports.useEditorMode = useEditorMode;
|
|
117
|
+
exports.useIsSampleProduct = useIsSampleProduct;
|
|
118
|
+
exports.useIsStorefrontProduct = useIsStorefrontProduct;
|
|
119
|
+
exports.useLocale = useLocale;
|
|
120
|
+
exports.useMatchMutate = useMatchMutate;
|
|
121
|
+
exports.useMobileOnly = useMobileOnly;
|
|
122
|
+
exports.useMoneyFormat = useMoneyFormat;
|
|
123
|
+
exports.usePageType = usePageType;
|
|
124
|
+
exports.usePluginEnable = usePluginEnable;
|
|
125
|
+
exports.useStoreFront = useStoreFront;
|
|
126
|
+
exports.useSwatches = useSwatches;
|
|
@@ -1 +1,30 @@
|
|
|
1
|
-
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var react = require('react');
|
|
4
|
+
|
|
5
|
+
// Hàm debounce với TypeScript
|
|
6
|
+
function debounce(func, wait) {
|
|
7
|
+
let timeout;
|
|
8
|
+
return function(...args) {
|
|
9
|
+
clearTimeout(timeout);
|
|
10
|
+
timeout = setTimeout(()=>func.apply(this, args), wait);
|
|
11
|
+
};
|
|
12
|
+
}
|
|
13
|
+
function subscribe(callback) {
|
|
14
|
+
const debouncedCallback = debounce(callback, 200); // Debounce với thời gian chờ 200ms
|
|
15
|
+
window.addEventListener('resize', debouncedCallback);
|
|
16
|
+
return ()=>window.removeEventListener('resize', debouncedCallback);
|
|
17
|
+
}
|
|
18
|
+
const useCurrentDevice = ()=>{
|
|
19
|
+
return react.useSyncExternalStore(subscribe, ()=>{
|
|
20
|
+
if (window.innerWidth < 768) {
|
|
21
|
+
return 'mobile';
|
|
22
|
+
} else if (window.innerWidth >= 768 && window.innerWidth < 1025) {
|
|
23
|
+
return 'tablet';
|
|
24
|
+
} else {
|
|
25
|
+
return 'desktop';
|
|
26
|
+
}
|
|
27
|
+
}, ()=>'desktop');
|
|
28
|
+
};
|
|
29
|
+
|
|
30
|
+
exports.useCurrentDevice = useCurrentDevice;
|
|
@@ -1 +1,15 @@
|
|
|
1
|
-
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var react = require('react');
|
|
4
|
+
var LazyLoad = require('vanilla-lazyload');
|
|
5
|
+
|
|
6
|
+
const useLazyVideo = ()=>{
|
|
7
|
+
react.useEffect(()=>{
|
|
8
|
+
const lazyLoadInstance = new LazyLoad({
|
|
9
|
+
use_native: true
|
|
10
|
+
});
|
|
11
|
+
lazyLoadInstance.update();
|
|
12
|
+
}, []);
|
|
13
|
+
};
|
|
14
|
+
|
|
15
|
+
exports.useLazyVideo = useLazyVideo;
|
|
@@ -1 +1,29 @@
|
|
|
1
|
-
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var animations = require('../helpers/animations.js');
|
|
4
|
+
require('react');
|
|
5
|
+
require('react/jsx-runtime');
|
|
6
|
+
require('zustand');
|
|
7
|
+
require('swr');
|
|
8
|
+
require('@gem-sdk/adapter-shopify');
|
|
9
|
+
require('swr/mutation');
|
|
10
|
+
require('swr/infinite');
|
|
11
|
+
require('vanilla-lazyload');
|
|
12
|
+
require('./useCartUI.js');
|
|
13
|
+
require('react-transition-group');
|
|
14
|
+
require('@gem-sdk/core');
|
|
15
|
+
require('classnames');
|
|
16
|
+
require('dayjs');
|
|
17
|
+
require('../helpers/convert.js');
|
|
18
|
+
|
|
19
|
+
const useAnimations = ()=>{
|
|
20
|
+
const { zoom, shake, fade, slide } = animations.animations();
|
|
21
|
+
return {
|
|
22
|
+
zoom,
|
|
23
|
+
shake,
|
|
24
|
+
fade,
|
|
25
|
+
slide
|
|
26
|
+
};
|
|
27
|
+
};
|
|
28
|
+
|
|
29
|
+
exports.useAnimations = useAnimations;
|
|
@@ -1 +1,44 @@
|
|
|
1
|
-
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
+
|
|
5
|
+
var react = require('react');
|
|
6
|
+
|
|
7
|
+
const cartKey = 'cart-id';
|
|
8
|
+
const getCartId = ()=>{
|
|
9
|
+
return window.localStorage.getItem(cartKey);
|
|
10
|
+
};
|
|
11
|
+
const writeCartId = (value)=>{
|
|
12
|
+
if (value) {
|
|
13
|
+
window.localStorage.setItem(cartKey, value);
|
|
14
|
+
}
|
|
15
|
+
};
|
|
16
|
+
const removeCartId = ()=>{
|
|
17
|
+
window.localStorage.removeItem(cartKey);
|
|
18
|
+
};
|
|
19
|
+
const subscribeStorage = (callback)=>{
|
|
20
|
+
window.addEventListener('storage', callback);
|
|
21
|
+
return ()=>{
|
|
22
|
+
window.removeEventListener('storage', callback);
|
|
23
|
+
};
|
|
24
|
+
};
|
|
25
|
+
const useCartId = ()=>{
|
|
26
|
+
const cartId = react.useSyncExternalStore(subscribeStorage, getCartId, ()=>undefined);
|
|
27
|
+
const updateCartId = react.useCallback((val)=>{
|
|
28
|
+
writeCartId(val);
|
|
29
|
+
}, []);
|
|
30
|
+
const clearCartId = react.useCallback(()=>{
|
|
31
|
+
removeCartId();
|
|
32
|
+
}, []);
|
|
33
|
+
return react.useMemo(()=>({
|
|
34
|
+
cartId,
|
|
35
|
+
updateCartId,
|
|
36
|
+
clearCartId
|
|
37
|
+
}), [
|
|
38
|
+
cartId,
|
|
39
|
+
clearCartId,
|
|
40
|
+
updateCartId
|
|
41
|
+
]);
|
|
42
|
+
};
|
|
43
|
+
|
|
44
|
+
exports.default = useCartId;
|
|
@@ -1 +1,11 @@
|
|
|
1
|
-
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
+
|
|
5
|
+
var CartLineContext = require('../contexts/CartLineContext.js');
|
|
6
|
+
|
|
7
|
+
const useCartLine = ()=>{
|
|
8
|
+
return CartLineContext.useCartLineStore((s)=>s.line);
|
|
9
|
+
};
|
|
10
|
+
|
|
11
|
+
exports.default = useCartLine;
|
|
@@ -1 +1,48 @@
|
|
|
1
|
-
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
+
|
|
5
|
+
var react = require('react');
|
|
6
|
+
var zustand = require('zustand');
|
|
7
|
+
var shop = require('./shop.js');
|
|
8
|
+
|
|
9
|
+
const useStore = zustand.create((set)=>({
|
|
10
|
+
isCartOpen: false,
|
|
11
|
+
setOpen: (isCartOpen)=>{
|
|
12
|
+
const scrollBarGap = window.innerWidth - document.documentElement.clientWidth;
|
|
13
|
+
const computedBodyPaddingRight = parseInt(window.getComputedStyle(document.body).getPropertyValue('padding-right'), 10);
|
|
14
|
+
if (isCartOpen) {
|
|
15
|
+
document.body.style.overflow = `hidden`;
|
|
16
|
+
document.body.style.paddingRight = `${computedBodyPaddingRight + scrollBarGap}px`;
|
|
17
|
+
} else {
|
|
18
|
+
document.body.style.overflow = '';
|
|
19
|
+
document.body.style.paddingRight = '';
|
|
20
|
+
}
|
|
21
|
+
set({
|
|
22
|
+
isCartOpen
|
|
23
|
+
});
|
|
24
|
+
}
|
|
25
|
+
}));
|
|
26
|
+
function useCartUI() {
|
|
27
|
+
const plugins = shop.usePluginEnable();
|
|
28
|
+
const isCartOpen = useStore((s)=>s.isCartOpen);
|
|
29
|
+
const setOpen = useStore((s)=>s.setOpen);
|
|
30
|
+
const openCart = react.useCallback(()=>{
|
|
31
|
+
if (plugins?.includes('cart-drawer')) {
|
|
32
|
+
setOpen(true);
|
|
33
|
+
}
|
|
34
|
+
}, [
|
|
35
|
+
plugins,
|
|
36
|
+
setOpen
|
|
37
|
+
]);
|
|
38
|
+
const closeCart = react.useCallback(()=>setOpen(false), [
|
|
39
|
+
setOpen
|
|
40
|
+
]);
|
|
41
|
+
return {
|
|
42
|
+
isCartOpen,
|
|
43
|
+
openCart,
|
|
44
|
+
closeCart
|
|
45
|
+
};
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
exports.default = useCartUI;
|
|
@@ -1 +1,9 @@
|
|
|
1
|
-
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var CollectionContext = require('../contexts/CollectionContext.js');
|
|
4
|
+
|
|
5
|
+
const useCollection = ()=>{
|
|
6
|
+
return CollectionContext.useCollectionStore((s)=>s.collection);
|
|
7
|
+
};
|
|
8
|
+
|
|
9
|
+
exports.useCollection = useCollection;
|
|
@@ -1 +1,13 @@
|
|
|
1
|
-
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var useSWR = require('swr');
|
|
4
|
+
|
|
5
|
+
const useFetchHandle = ()=>{
|
|
6
|
+
const { fetcher } = useSWR.useSWRConfig();
|
|
7
|
+
if (!fetcher) {
|
|
8
|
+
throw new Error('Application must be init within a fetcher');
|
|
9
|
+
}
|
|
10
|
+
return fetcher;
|
|
11
|
+
};
|
|
12
|
+
|
|
13
|
+
exports.useFetchHandle = useFetchHandle;
|
|
@@ -1 +1,75 @@
|
|
|
1
|
-
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var shop = require('./shop.js');
|
|
4
|
+
|
|
5
|
+
const shopifyPriceRounding = (amount, precision)=>{
|
|
6
|
+
return parseFloat(`${amount}`).toFixed(Number(precision) + 1).slice(0, -1);
|
|
7
|
+
};
|
|
8
|
+
const formatMoney = function(cents, format) {
|
|
9
|
+
let value = '';
|
|
10
|
+
const placeholderRegex = /\{\{\s*(\w+)\s*\}\}/;
|
|
11
|
+
const formatString = format || '${{amount}}';
|
|
12
|
+
/**
|
|
13
|
+
* check default
|
|
14
|
+
* @param opt opt
|
|
15
|
+
* @param def def
|
|
16
|
+
* @returns any
|
|
17
|
+
*/ function defaultOption(opt, def) {
|
|
18
|
+
return typeof opt == 'undefined' ? def : opt;
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* formatWithDelimiters
|
|
22
|
+
* @param number number
|
|
23
|
+
* @param precision precision
|
|
24
|
+
* @param thousands thousands
|
|
25
|
+
* @param decimal decimal
|
|
26
|
+
* @returns any
|
|
27
|
+
*/ // eslint-disable-next-line max-params
|
|
28
|
+
function formatWithDelimiters(number, precision, thousands, decimal) {
|
|
29
|
+
precision = defaultOption(precision, 2);
|
|
30
|
+
thousands = defaultOption(thousands, ',');
|
|
31
|
+
decimal = defaultOption(decimal, '.');
|
|
32
|
+
if (isNaN(number) || number == null) {
|
|
33
|
+
return 0;
|
|
34
|
+
}
|
|
35
|
+
// shopify làm tròn bằng cách cắt đi các số ở đằng sau chứ không sử dụng toFixed để làm tròn như toán học
|
|
36
|
+
number = shopifyPriceRounding(number, Number(precision));
|
|
37
|
+
const parts = number.split('.'), dollars = parts[0]?.replace(/(\d)(?=(\d\d\d)+(?!\d))/g, '$1' + thousands), cents = parts[1] ? decimal + parts[1] : '';
|
|
38
|
+
return dollars + cents;
|
|
39
|
+
}
|
|
40
|
+
switch(formatString.match(placeholderRegex)[1]){
|
|
41
|
+
case 'amount':
|
|
42
|
+
value = formatWithDelimiters(cents, 2);
|
|
43
|
+
break;
|
|
44
|
+
case 'amount_no_decimals':
|
|
45
|
+
value = formatWithDelimiters(cents, 0);
|
|
46
|
+
break;
|
|
47
|
+
case 'amount_with_comma_separator':
|
|
48
|
+
value = formatWithDelimiters(cents, 2, '.', ',');
|
|
49
|
+
break;
|
|
50
|
+
case 'amount_no_decimals_with_comma_separator':
|
|
51
|
+
value = formatWithDelimiters(cents, 0, '.', ',');
|
|
52
|
+
break;
|
|
53
|
+
case 'amount_with_apostrophe_separator':
|
|
54
|
+
value = formatWithDelimiters(cents, 2, "'", '.');
|
|
55
|
+
break;
|
|
56
|
+
case 'amount_no_decimals_with_space_separator':
|
|
57
|
+
value = formatWithDelimiters(cents, 0, ' ');
|
|
58
|
+
break;
|
|
59
|
+
case 'amount_with_space_separator':
|
|
60
|
+
value = formatWithDelimiters(cents, 2, ' ', ',');
|
|
61
|
+
break;
|
|
62
|
+
case 'amount_with_period_and_space_separator':
|
|
63
|
+
value = formatWithDelimiters(cents, 2, ' ', '.');
|
|
64
|
+
break;
|
|
65
|
+
}
|
|
66
|
+
return formatString.replace(placeholderRegex, value);
|
|
67
|
+
};
|
|
68
|
+
const useFormatMoney = (amount, withCurrency)=>{
|
|
69
|
+
const { moneyFormat, moneyWithCurrencyFormat } = shop.useMoneyFormat();
|
|
70
|
+
return withCurrency ? formatMoney(`${amount}`, moneyWithCurrencyFormat || moneyFormat) : formatMoney(`${amount}`, moneyFormat);
|
|
71
|
+
};
|
|
72
|
+
|
|
73
|
+
exports.formatMoney = formatMoney;
|
|
74
|
+
exports.shopifyPriceRounding = shopifyPriceRounding;
|
|
75
|
+
exports.useFormatMoney = useFormatMoney;
|
|
@@ -1 +1,128 @@
|
|
|
1
|
-
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
+
|
|
5
|
+
var useSWR = require('swr');
|
|
6
|
+
var productValueLabel_generated = require('../graphql/queries/product-value-label.generated.js');
|
|
7
|
+
var variantPresets = require('../components/src/product/helpers/variant-presets.js');
|
|
8
|
+
var shop = require('./shop.js');
|
|
9
|
+
var useFetchHandle = require('./useFetchHandle.js');
|
|
10
|
+
var ShopContext = require('../contexts/ShopContext.js');
|
|
11
|
+
require('react');
|
|
12
|
+
require('react/jsx-runtime');
|
|
13
|
+
require('zustand');
|
|
14
|
+
require('@gem-sdk/adapter-shopify');
|
|
15
|
+
require('swr/mutation');
|
|
16
|
+
require('swr/infinite');
|
|
17
|
+
require('vanilla-lazyload');
|
|
18
|
+
require('./useCartUI.js');
|
|
19
|
+
require('react-transition-group');
|
|
20
|
+
require('@gem-sdk/core');
|
|
21
|
+
require('classnames');
|
|
22
|
+
require('dayjs');
|
|
23
|
+
var isBrowser = require('../helpers/is-browser.js');
|
|
24
|
+
require('../helpers/convert.js');
|
|
25
|
+
|
|
26
|
+
let swatchChange = false;
|
|
27
|
+
let colorChange = false;
|
|
28
|
+
const useInitialSwatchesOptions = (options)=>{
|
|
29
|
+
const fetcher = useFetchHandle.useFetchHandle();
|
|
30
|
+
const changeSwatches = ShopContext.useShopStore((s)=>s.changeSwatches);
|
|
31
|
+
const { swatches } = shop.useSwatches();
|
|
32
|
+
const { data: productOptionName } = useSWR([
|
|
33
|
+
'/query/productOptionName',
|
|
34
|
+
{}
|
|
35
|
+
], async ()=>fetchProductValueLabel(fetcher), {
|
|
36
|
+
revalidateOnMount: true
|
|
37
|
+
});
|
|
38
|
+
const swatchesTitleList = [];
|
|
39
|
+
swatches?.forEach((el)=>{
|
|
40
|
+
swatchesTitleList.push(el.optionTitle);
|
|
41
|
+
});
|
|
42
|
+
productOptionName?.productOptionName?.forEach((el)=>{
|
|
43
|
+
if (!swatchesTitleList.includes(el)) {
|
|
44
|
+
swatchChange = true;
|
|
45
|
+
swatches?.push({
|
|
46
|
+
optionTitle: el,
|
|
47
|
+
optionType: 'rectangle_list',
|
|
48
|
+
optionValues: []
|
|
49
|
+
});
|
|
50
|
+
}
|
|
51
|
+
});
|
|
52
|
+
if (!options) return [];
|
|
53
|
+
setDefaultSwatches(swatches, options);
|
|
54
|
+
if (isBrowser.default() && swatches?.length && (swatchChange || colorChange)) {
|
|
55
|
+
window?.parent?.postMessage?.(JSON.stringify({
|
|
56
|
+
type: 'update-swatches',
|
|
57
|
+
swatches
|
|
58
|
+
}), '*');
|
|
59
|
+
changeSwatches(swatches);
|
|
60
|
+
}
|
|
61
|
+
swatchChange = false;
|
|
62
|
+
};
|
|
63
|
+
const getColorDefault = (label, color)=>{
|
|
64
|
+
const colorByLabel = label ? variantPresets.colorPreset[label.toLocaleLowerCase()] : undefined;
|
|
65
|
+
const colorArray = colorByLabel ? [
|
|
66
|
+
colorByLabel
|
|
67
|
+
] : [];
|
|
68
|
+
const firstColor = color?.[0];
|
|
69
|
+
if (!firstColor && colorArray.length) colorChange = true;
|
|
70
|
+
return firstColor ? [
|
|
71
|
+
firstColor
|
|
72
|
+
] : colorArray;
|
|
73
|
+
};
|
|
74
|
+
const getProductOptionsLabelByName = (options, name)=>{
|
|
75
|
+
const labels = [];
|
|
76
|
+
const optionByName = options.find((op)=>op.name === name);
|
|
77
|
+
optionByName?.values.forEach((val)=>{
|
|
78
|
+
labels.push(val.label ?? '');
|
|
79
|
+
});
|
|
80
|
+
return labels;
|
|
81
|
+
};
|
|
82
|
+
const getSwatchesOptionsLabel = (options)=>{
|
|
83
|
+
const labels = [];
|
|
84
|
+
options.forEach((op)=>{
|
|
85
|
+
labels.push(op.label ?? '');
|
|
86
|
+
return;
|
|
87
|
+
});
|
|
88
|
+
return labels;
|
|
89
|
+
};
|
|
90
|
+
const setDefaultSwatches = (swatches, options)=>{
|
|
91
|
+
if (swatches) {
|
|
92
|
+
swatches?.map((sw)=>{
|
|
93
|
+
const productLabels = getProductOptionsLabelByName(options, sw.optionTitle);
|
|
94
|
+
const swLabels = getSwatchesOptionsLabel(sw.optionValues);
|
|
95
|
+
productLabels.forEach((label)=>{
|
|
96
|
+
if (!swLabels.includes(label)) {
|
|
97
|
+
sw.optionValues.push({
|
|
98
|
+
label,
|
|
99
|
+
colors: getColorDefault(label),
|
|
100
|
+
imageUrl: ''
|
|
101
|
+
});
|
|
102
|
+
}
|
|
103
|
+
});
|
|
104
|
+
sw.optionValues = sw.optionValues.map((op)=>{
|
|
105
|
+
if (op.imageUrl === undefined) swatchChange = true;
|
|
106
|
+
return {
|
|
107
|
+
label: op.label ?? '',
|
|
108
|
+
colors: getColorDefault(op.label, op.colors),
|
|
109
|
+
imageUrl: op.imageUrl ?? ''
|
|
110
|
+
};
|
|
111
|
+
});
|
|
112
|
+
});
|
|
113
|
+
}
|
|
114
|
+
return swatches;
|
|
115
|
+
};
|
|
116
|
+
const fetchProductValueLabel = async (fetcher)=>{
|
|
117
|
+
const initVariables = {};
|
|
118
|
+
const query = async (variables)=>{
|
|
119
|
+
const response = await fetcher([
|
|
120
|
+
productValueLabel_generated.ProductOptionNameDocument,
|
|
121
|
+
variables
|
|
122
|
+
]);
|
|
123
|
+
return response;
|
|
124
|
+
};
|
|
125
|
+
return query(initVariables);
|
|
126
|
+
};
|
|
127
|
+
|
|
128
|
+
exports.default = useInitialSwatchesOptions;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var PageContext = require('../contexts/PageContext.js');
|
|
4
|
+
|
|
5
|
+
const useInteraction = ()=>{
|
|
6
|
+
const interactionData = PageContext.usePageStore((state)=>state.interactionData);
|
|
7
|
+
const { item } = interactionData || {};
|
|
8
|
+
const getAnimationByUid = (uid)=>{
|
|
9
|
+
const targets = item?.targets;
|
|
10
|
+
const targetByUid = targets?.find((target)=>target.uid === uid);
|
|
11
|
+
const metaDataContainsAnimation = targetByUid?.events?.find((it)=>it.condition?.metaData?.animation);
|
|
12
|
+
return metaDataContainsAnimation?.condition?.metaData?.animation;
|
|
13
|
+
};
|
|
14
|
+
return {
|
|
15
|
+
getAnimationByUid
|
|
16
|
+
};
|
|
17
|
+
};
|
|
18
|
+
|
|
19
|
+
exports.useInteraction = useInteraction;
|
|
@@ -1 +1,10 @@
|
|
|
1
|
-
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
+
|
|
5
|
+
var react = require('react');
|
|
6
|
+
|
|
7
|
+
// const isBrowser = typeof window !== 'undefined';
|
|
8
|
+
const useIsomorphicLayoutEffect = react.useLayoutEffect;
|
|
9
|
+
|
|
10
|
+
exports.default = useIsomorphicLayoutEffect;
|
|
@@ -1 +1,32 @@
|
|
|
1
|
-
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
+
|
|
5
|
+
var react = require('react');
|
|
6
|
+
var loadScript = require('../helpers/load-script.js');
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* The `useLoadScript` hook loads an external script tag on the client-side.
|
|
10
|
+
*/ function useLoadScript(url, options) {
|
|
11
|
+
const [status, setStatus] = react.useState('loading');
|
|
12
|
+
const stringifiedOptions = JSON.stringify(options);
|
|
13
|
+
react.useEffect(()=>{
|
|
14
|
+
async function loadScriptWrapper() {
|
|
15
|
+
try {
|
|
16
|
+
setStatus('loading');
|
|
17
|
+
await loadScript.loadScript(url, options);
|
|
18
|
+
setStatus('done');
|
|
19
|
+
} catch (error) {
|
|
20
|
+
setStatus('error');
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
loadScriptWrapper();
|
|
24
|
+
}, [
|
|
25
|
+
url,
|
|
26
|
+
stringifiedOptions,
|
|
27
|
+
options
|
|
28
|
+
]);
|
|
29
|
+
return status;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
exports.default = useLoadScript;
|