@gem-sdk/core 3.0.0-pre-production.15 → 3.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/README.md +1 -1
- package/dist/cjs/components/AddOn.js +2 -18
- package/dist/cjs/components/ComponentAnimation.js +2 -17
- package/dist/cjs/components/ComponentToolbarPreview.js +2 -752
- package/dist/cjs/components/ComponentWrapper.js +2 -61
- package/dist/cjs/components/ComponentWrapperPreview.js +2 -213
- package/dist/cjs/components/Empty.js +2 -7
- package/dist/cjs/components/InteractionSuffix.js +2 -42
- package/dist/cjs/components/Render.js +2 -75
- package/dist/cjs/components/Render.liquid.js +16 -307
- package/dist/cjs/components/RenderBlock.js +2 -54
- package/dist/cjs/components/RenderCustomCode.js +4 -59
- package/dist/cjs/components/RenderPreview.js +2 -67
- package/dist/cjs/components/RenderSection.js +2 -23
- package/dist/cjs/components/ai-generator/AIContentGenerator.js +2 -252
- package/dist/cjs/components/ai-generator/AIGenContentLoading.js +2 -85
- package/dist/cjs/components/ai-generator/components/PickProduct.js +2 -220
- package/dist/cjs/components/ai-generator/components/ToneAndVoice.js +2 -77
- package/dist/cjs/components/ai-generator/hooks/useCheckingProductInside.js +1 -47
- package/dist/cjs/components/ai-generator/hooks/useFlipPopup.js +1 -110
- package/dist/cjs/components/ai-generator/hooks/useGettingGenerateRequest.js +1 -37
- package/dist/cjs/components/ai-generator/hooks/useListenEventGenerate.js +1 -70
- package/dist/cjs/components/ai-generator/icons/AIIcon.js +2 -67
- package/dist/cjs/components/ai-generator/icons/CloseIcon.js +2 -19
- package/dist/cjs/components/ai-generator/icons/DropdownIcon.js +2 -37
- package/dist/cjs/components/ai-generator/icons/SearchIcon.js +2 -21
- package/dist/cjs/components/ai-generator/icons/ShowMoreIcon.js +2 -21
- package/dist/cjs/components/ai-generator/icons/UpgradeIcon.js +2 -27
- package/dist/cjs/components/ai-generator/icons/WarningIcon.js +2 -31
- package/dist/cjs/components/constant.js +1 -82
- package/dist/cjs/components/resize/Resize.js +2 -16
- package/dist/cjs/components/resize/Spacing.js +2 -260
- package/dist/cjs/components/src/product/helpers/variant-presets.js +1 -56
- package/dist/cjs/components/theme-section/CreateThemeSection.js +2 -123
- package/dist/cjs/components/theme-section/ThemeSectionStatus.js +2 -45
- package/dist/cjs/components/theme-section/ThemeSectionTooltip.js +2 -126
- package/dist/cjs/components/toolbar/Tooltip.js +2 -28
- package/dist/cjs/constants/device.js +1 -0
- package/dist/cjs/contexts/AddonContext.js +2 -36
- package/dist/cjs/contexts/ArticleContext.js +2 -39
- package/dist/cjs/contexts/ArticleListContext.js +2 -31
- package/dist/cjs/contexts/BuilderComponent.js +2 -34
- package/dist/cjs/contexts/BuilderContext.js +2 -39
- package/dist/cjs/contexts/BuilderPreviewContext.js +2 -482
- package/dist/cjs/contexts/CartLineContext.js +2 -29
- package/dist/cjs/contexts/CollectionContext.js +2 -38
- package/dist/cjs/contexts/I18nContext.js +2 -0
- package/dist/cjs/contexts/ModalContext.js +2 -47
- package/dist/cjs/contexts/PageContext.js +2 -111
- package/dist/cjs/contexts/ProductContext.js +2 -182
- package/dist/cjs/contexts/ProductListContext.js +2 -32
- package/dist/cjs/contexts/SectionContext.js +2 -53
- package/dist/cjs/contexts/ShopContext.js +2 -107
- package/dist/cjs/graphql/fragments/analytic.generated.js +2 -6
- package/dist/cjs/graphql/fragments/collection-detail.generated.js +2 -6
- package/dist/cjs/graphql/fragments/collection-product.generated.js +2 -6
- package/dist/cjs/graphql/fragments/collection.generated.js +2 -6
- package/dist/cjs/graphql/fragments/custom-code.generated.js +2 -6
- package/dist/cjs/graphql/fragments/custom-font.generated.js +7 -7
- package/dist/cjs/graphql/fragments/data-seo.generated.js +2 -6
- package/dist/cjs/graphql/fragments/media.generated.js +2 -6
- package/dist/cjs/graphql/fragments/preview-theme-page.generated.js +6 -6
- package/dist/cjs/graphql/fragments/product-little.generated.js +2 -6
- package/dist/cjs/graphql/fragments/product-option-value.generated.js +2 -6
- package/dist/cjs/graphql/fragments/product-option.generated.js +2 -6
- package/dist/cjs/graphql/fragments/product.generated.js +2 -6
- package/dist/cjs/graphql/fragments/published-custom-section.generated.js +2 -6
- package/dist/cjs/graphql/fragments/published-page-section.generated.js +2 -6
- package/dist/cjs/graphql/fragments/published-theme-page.generated.js +4 -18
- package/dist/cjs/graphql/fragments/published-theme-style.generated.js +2 -6
- package/dist/cjs/graphql/fragments/selected-option.generated.js +2 -6
- package/dist/cjs/graphql/fragments/variant.generated.js +2 -6
- package/dist/cjs/graphql/mutations/page-view-up.generated.js +2 -6
- package/dist/cjs/graphql/queries/articles.generated.js +2 -6
- package/dist/cjs/graphql/queries/blogs.generated.js +2 -6
- package/dist/cjs/graphql/queries/collection-detail-filter.generated.js +2 -16
- package/dist/cjs/graphql/queries/collection.generated.js +2 -14
- package/dist/cjs/graphql/queries/collections.generated.js +2 -9
- package/dist/cjs/graphql/queries/preview-page.generated.js +2 -12
- package/dist/cjs/graphql/queries/product-little-detail.generated.js +2 -11
- package/dist/cjs/graphql/queries/product-medias.generated.js +2 -8
- package/dist/cjs/graphql/queries/product-value-label.generated.js +2 -6
- package/dist/cjs/graphql/queries/product-variants.generated.js +3 -11
- package/dist/cjs/graphql/queries/products.generated.js +3 -17
- package/dist/cjs/graphql/queries/{published-shop-metas.js → published-shop-metas.generated.js} +2 -6
- package/dist/cjs/graphql/queries/published-theme-pages.generated.js +3 -19
- package/dist/cjs/graphql/queries/shop-shopify.generated.js +2 -6
- package/dist/cjs/graphql/queries/store-property.generated.js +2 -6
- package/dist/cjs/graphql-app-api/queries/LibrarySaleFunnelDiscount.generated.js +2 -6
- package/dist/cjs/graphql-app-api/queries/LibraryTemplate.generated.js +2 -6
- package/dist/cjs/graphql-app-api/queries/SaleFunnelDiscounts.generated.js +2 -6
- package/dist/cjs/graphql-app-api/queries/SaleFunnelOffer.generated.js +2 -6
- package/dist/cjs/graphql-app-api/queries/ShopLibraryPage.generated.js +2 -6
- package/dist/cjs/graphql-app-api/queries/ThemePage.generated.js +2 -6
- package/dist/cjs/helpers/GlobalEvent.js +1 -19
- package/dist/cjs/helpers/align.js +1 -37
- package/dist/cjs/helpers/animations.js +1 -222
- package/dist/cjs/helpers/background.js +1 -236
- package/dist/cjs/helpers/backgroundImage.js +1 -0
- package/dist/cjs/helpers/borders.js +4 -198
- package/dist/cjs/helpers/carousel.js +1 -55
- package/dist/cjs/helpers/clone-deep.js +1 -5
- package/dist/cjs/helpers/cls.js +1 -16
- package/dist/cjs/helpers/colors.js +1 -184
- package/dist/cjs/helpers/compose-advance-style.js +1 -323
- package/dist/cjs/helpers/composeClasses.js +1 -0
- package/dist/cjs/helpers/const.js +1 -0
- package/dist/cjs/helpers/constant.js +1 -23
- package/dist/cjs/helpers/convert.js +1 -7
- package/dist/cjs/helpers/covert-entities-html.js +1 -19
- package/dist/cjs/helpers/css-variable.js +1 -7
- package/dist/cjs/helpers/email.js +1 -11
- package/dist/cjs/helpers/filter-styles.js +1 -0
- package/dist/cjs/helpers/filter-toolbar-preview.js +2 -14
- package/dist/cjs/helpers/flatten-connection.js +1 -9
- package/dist/cjs/helpers/get-resonsive-value.js +1 -36
- package/dist/cjs/helpers/get-shortname.js +1 -92
- package/dist/cjs/helpers/icon-list.js +1 -61
- package/dist/cjs/helpers/interaction/index.js +2 -134
- package/dist/cjs/helpers/is-browser.js +1 -9
- package/dist/cjs/helpers/is-defined.js +1 -7
- package/dist/cjs/helpers/is-empty-children.js +2 -15
- package/dist/cjs/helpers/is-safari.js +1 -9
- package/dist/cjs/helpers/layout.js +1 -76
- package/dist/cjs/helpers/load-script.js +1 -31
- package/dist/cjs/helpers/loop-component.js +1 -16
- package/dist/cjs/helpers/make-style.js +1 -163
- package/dist/cjs/helpers/normalize-builder-data.js +1 -23
- package/dist/cjs/helpers/pascal-to-kebab-case.js +1 -7
- package/dist/cjs/helpers/prefetch-queries.js +1 -78
- package/dist/cjs/helpers/product.js +1 -48
- package/dist/cjs/helpers/queries/get-collection.js +1 -226
- package/dist/cjs/helpers/queries/get-collections.js +1 -21
- package/dist/cjs/helpers/queries/get-product-by-slug.js +1 -125
- package/dist/cjs/helpers/queries/get-product.js +1 -154
- package/dist/cjs/helpers/queries/get-products.js +1 -214
- package/dist/cjs/helpers/query.js +1 -29
- package/dist/cjs/helpers/radius.js +6 -140
- package/dist/cjs/helpers/render.js +1 -91
- package/dist/cjs/helpers/shadow.js +1 -69
- package/dist/cjs/helpers/size.js +4 -228
- package/dist/cjs/helpers/spacing.js +1 -43
- package/dist/cjs/helpers/third-party/addAppBlockId.js +1 -20
- package/dist/cjs/helpers/third-party/appConfig.js +1 -416
- package/dist/cjs/helpers/third-party/appSetting.js +1 -1324
- package/dist/cjs/helpers/third-party/composeAppBlockId.js +1 -11
- package/dist/cjs/helpers/third-party/constant.js +1 -69
- package/dist/cjs/helpers/third-party/generateAppBlockConfigs.js +1 -34
- package/dist/cjs/helpers/third-party/getAppBlockConfig.js +1 -55
- package/dist/cjs/helpers/third-party/getAppBlockType.js +1 -12
- package/dist/cjs/helpers/third-party/getAppBlocks.js +1 -30
- package/dist/cjs/helpers/third-party/mergeBlock.js +1 -19
- package/dist/cjs/helpers/third-party/mergeBlockOrder.js +1 -47
- package/dist/cjs/helpers/third-party/removeGPAppItems.js +1 -18
- package/dist/cjs/helpers/tracking/fpixel.js +1 -28
- package/dist/cjs/helpers/tracking/gtag.js +1 -93
- package/dist/cjs/helpers/tracking/tiktokpixel.js +1 -17
- package/dist/cjs/helpers/typography.js +19 -160
- package/dist/cjs/helpers/variant.js +1 -11
- package/dist/cjs/hooks/animation/useAnimationActions.js +2 -39
- package/dist/cjs/hooks/animation/useAnimationConfig.js +2 -30
- package/dist/cjs/hooks/animation/useAnimationPreview.js +2 -31
- package/dist/cjs/hooks/animation/useAnimationTarget.js +2 -122
- package/dist/cjs/hooks/animation/useApplyAnimation.js +2 -89
- package/dist/cjs/hooks/articles/useArticlesQuery.js +2 -33
- package/dist/cjs/hooks/cart/use-add-to-cart.js +2 -20
- package/dist/cjs/hooks/cart/use-cart-data.js +2 -28
- package/dist/cjs/hooks/cart/use-cart-discount-codes-update.js +2 -20
- package/dist/cjs/hooks/cart/use-cart-note-update.js +2 -20
- package/dist/cjs/hooks/cart/use-create-cart.js +2 -22
- package/dist/cjs/hooks/cart/use-remove-cart-item.js +2 -20
- package/dist/cjs/hooks/cart/use-update-cart-item.js +2 -20
- package/dist/cjs/hooks/shop/use-collection-query.js +2 -22
- package/dist/cjs/hooks/shop/use-collections-query.js +2 -17
- package/dist/cjs/hooks/shop/use-product-query.js +2 -22
- package/dist/cjs/hooks/shop/use-products-query.js +2 -63
- package/dist/cjs/hooks/shop/useShopifyLink.js +2 -0
- package/dist/cjs/hooks/shop.js +2 -135
- package/dist/cjs/hooks/use-current-device.js +2 -30
- package/dist/cjs/hooks/use-lazy-video.js +2 -15
- package/dist/cjs/hooks/useAnimations.js +2 -29
- package/dist/cjs/hooks/useCartId.js +2 -44
- package/dist/cjs/hooks/useCartLine.js +2 -11
- package/dist/cjs/hooks/useCartUI.js +2 -48
- package/dist/cjs/hooks/useCollection.js +2 -9
- package/dist/cjs/hooks/useFetchHandle.js +2 -13
- package/dist/cjs/hooks/useFormatMoney.js +2 -75
- package/dist/cjs/hooks/useI18n.js +2 -0
- package/dist/cjs/hooks/useInitialSwatchesOptions.js +2 -127
- package/dist/cjs/hooks/useInteraction.js +2 -19
- package/dist/cjs/hooks/useIsomorphicLayoutEffect.js +2 -10
- package/dist/cjs/hooks/useLoadScript.js +2 -32
- package/dist/cjs/hooks/useMoney.js +2 -84
- package/dist/cjs/hooks/usePrevious.js +2 -19
- package/dist/cjs/hooks/useProduct.js +2 -250
- package/dist/cjs/hooks/useProductList.js +2 -21
- package/dist/cjs/hooks/useStickyStore.js +1 -0
- package/dist/cjs/hooks/useSuspenseFetch.js +2 -27
- package/dist/cjs/hooks/useSwatchesOptions.js +2 -41
- package/dist/cjs/hooks/useToolbarPostPurchase.js +2 -89
- package/dist/cjs/index.js +1 -425
- package/dist/cjs/types/animations.js +1 -49
- package/dist/cjs/types/appAPI.js +1 -2
- package/dist/cjs/types/custom.js +1 -52
- package/dist/cjs/types/global-style.js +1 -15
- package/dist/cjs/types/shop.js +1 -2
- package/dist/esm/components/AddOn.js +2 -14
- package/dist/esm/components/ComponentAnimation.js +2 -13
- package/dist/esm/components/ComponentToolbarPreview.js +2 -748
- package/dist/esm/components/ComponentWrapper.js +2 -57
- package/dist/esm/components/ComponentWrapperPreview.js +2 -209
- package/dist/esm/components/Empty.js +2 -3
- package/dist/esm/components/InteractionSuffix.js +2 -40
- package/dist/esm/components/Render.js +2 -71
- package/dist/esm/components/Render.liquid.js +16 -301
- package/dist/esm/components/RenderBlock.js +2 -50
- package/dist/esm/components/RenderCustomCode.js +4 -55
- package/dist/esm/components/RenderPreview.js +2 -63
- package/dist/esm/components/RenderSection.js +2 -19
- package/dist/esm/components/ai-generator/AIContentGenerator.js +2 -250
- package/dist/esm/components/ai-generator/AIGenContentLoading.js +2 -83
- package/dist/esm/components/ai-generator/components/PickProduct.js +2 -218
- package/dist/esm/components/ai-generator/components/ToneAndVoice.js +2 -75
- package/dist/esm/components/ai-generator/hooks/useCheckingProductInside.js +1 -45
- package/dist/esm/components/ai-generator/hooks/useFlipPopup.js +1 -108
- package/dist/esm/components/ai-generator/hooks/useGettingGenerateRequest.js +1 -35
- package/dist/esm/components/ai-generator/hooks/useListenEventGenerate.js +1 -68
- package/dist/esm/components/ai-generator/icons/AIIcon.js +2 -65
- package/dist/esm/components/ai-generator/icons/CloseIcon.js +2 -17
- package/dist/esm/components/ai-generator/icons/DropdownIcon.js +2 -34
- package/dist/esm/components/ai-generator/icons/SearchIcon.js +2 -19
- package/dist/esm/components/ai-generator/icons/ShowMoreIcon.js +2 -19
- package/dist/esm/components/ai-generator/icons/UpgradeIcon.js +2 -25
- package/dist/esm/components/ai-generator/icons/WarningIcon.js +2 -29
- package/dist/esm/components/constant.js +1 -75
- package/dist/esm/components/resize/Resize.js +2 -12
- package/dist/esm/components/resize/Spacing.js +2 -256
- package/dist/esm/components/src/product/helpers/variant-presets.js +1 -54
- package/dist/esm/components/theme-section/CreateThemeSection.js +2 -121
- package/dist/esm/components/theme-section/ThemeSectionStatus.js +2 -43
- package/dist/esm/components/theme-section/ThemeSectionTooltip.js +2 -124
- package/dist/esm/components/toolbar/Tooltip.js +2 -24
- package/dist/esm/constants/device.js +1 -0
- package/dist/esm/contexts/AddonContext.js +2 -32
- package/dist/esm/contexts/ArticleContext.js +2 -36
- package/dist/esm/contexts/ArticleListContext.js +2 -27
- package/dist/esm/contexts/BuilderComponent.js +2 -31
- package/dist/esm/contexts/BuilderContext.js +2 -36
- package/dist/esm/contexts/BuilderPreviewContext.js +2 -479
- package/dist/esm/contexts/CartLineContext.js +2 -26
- package/dist/esm/contexts/CollectionContext.js +2 -35
- package/dist/esm/contexts/I18nContext.js +2 -0
- package/dist/esm/contexts/ModalContext.js +2 -44
- package/dist/esm/contexts/PageContext.js +2 -108
- package/dist/esm/contexts/ProductContext.js +2 -179
- package/dist/esm/contexts/ProductListContext.js +2 -28
- package/dist/esm/contexts/SectionContext.js +2 -49
- package/dist/esm/contexts/ShopContext.js +2 -104
- package/dist/esm/graphql/fragments/analytic.generated.js +2 -4
- package/dist/esm/graphql/fragments/collection-detail.generated.js +2 -4
- package/dist/esm/graphql/fragments/collection-product.generated.js +2 -4
- package/dist/esm/graphql/fragments/collection.generated.js +2 -4
- package/dist/esm/graphql/fragments/custom-code.generated.js +2 -4
- package/dist/esm/graphql/fragments/custom-font.generated.js +7 -5
- package/dist/esm/graphql/fragments/data-seo.generated.js +2 -4
- package/dist/esm/graphql/fragments/media.generated.js +2 -4
- package/dist/esm/graphql/fragments/preview-theme-page.generated.js +6 -4
- package/dist/esm/graphql/fragments/product-little.generated.js +2 -4
- package/dist/esm/graphql/fragments/product-option-value.generated.js +2 -4
- package/dist/esm/graphql/fragments/product-option.generated.js +2 -4
- package/dist/esm/graphql/fragments/product.generated.js +2 -4
- package/dist/esm/graphql/fragments/published-custom-section.generated.js +2 -4
- package/dist/esm/graphql/fragments/published-page-section.generated.js +2 -4
- package/dist/esm/graphql/fragments/published-theme-page.generated.js +4 -16
- package/dist/esm/graphql/fragments/published-theme-style.generated.js +2 -4
- package/dist/esm/graphql/fragments/selected-option.generated.js +2 -4
- package/dist/esm/graphql/fragments/variant.generated.js +2 -4
- package/dist/esm/graphql/mutations/page-view-up.generated.js +2 -4
- package/dist/esm/graphql/queries/articles.generated.js +2 -4
- package/dist/esm/graphql/queries/blogs.generated.js +2 -4
- package/dist/esm/graphql/queries/collection-detail-filter.generated.js +10 -22
- package/dist/esm/graphql/queries/collection.generated.js +8 -18
- package/dist/esm/graphql/queries/collections.generated.js +3 -8
- package/dist/esm/graphql/queries/preview-page.generated.js +6 -14
- package/dist/esm/graphql/queries/product-little-detail.generated.js +5 -12
- package/dist/esm/graphql/queries/product-medias.generated.js +2 -6
- package/dist/esm/graphql/queries/product-value-label.generated.js +2 -4
- package/dist/esm/graphql/queries/product-variants.generated.js +5 -11
- package/dist/esm/graphql/queries/products.generated.js +9 -20
- package/dist/esm/graphql/queries/{published-shop-metas.js → published-shop-metas.generated.js} +2 -4
- package/dist/esm/graphql/queries/published-theme-pages.generated.js +6 -20
- package/dist/esm/graphql/queries/shop-shopify.generated.js +2 -4
- package/dist/esm/graphql/queries/store-property.generated.js +2 -4
- package/dist/esm/graphql-app-api/queries/LibrarySaleFunnelDiscount.generated.js +2 -4
- package/dist/esm/graphql-app-api/queries/LibraryTemplate.generated.js +2 -4
- package/dist/esm/graphql-app-api/queries/SaleFunnelDiscounts.generated.js +2 -4
- package/dist/esm/graphql-app-api/queries/SaleFunnelOffer.generated.js +2 -4
- package/dist/esm/graphql-app-api/queries/ShopLibraryPage.generated.js +2 -4
- package/dist/esm/graphql-app-api/queries/ThemePage.generated.js +2 -4
- package/dist/esm/helpers/GlobalEvent.js +1 -15
- package/dist/esm/helpers/align.js +1 -34
- package/dist/esm/helpers/animations.js +1 -220
- package/dist/esm/helpers/background.js +1 -227
- package/dist/esm/helpers/backgroundImage.js +1 -0
- package/dist/esm/helpers/borders.js +4 -189
- package/dist/esm/helpers/carousel.js +1 -51
- package/dist/esm/helpers/clone-deep.js +1 -3
- package/dist/esm/helpers/cls.js +1 -14
- package/dist/esm/helpers/colors.js +1 -169
- package/dist/esm/helpers/compose-advance-style.js +1 -315
- package/dist/esm/helpers/composeClasses.js +1 -0
- package/dist/esm/helpers/const.js +1 -0
- package/dist/esm/helpers/constant.js +1 -19
- package/dist/esm/helpers/convert.js +1 -4
- package/dist/esm/helpers/covert-entities-html.js +1 -17
- package/dist/esm/helpers/css-variable.js +1 -5
- package/dist/esm/helpers/email.js +1 -6
- package/dist/esm/helpers/filter-styles.js +1 -0
- package/dist/esm/helpers/filter-toolbar-preview.js +2 -9
- package/dist/esm/helpers/flatten-connection.js +1 -7
- package/dist/esm/helpers/get-resonsive-value.js +1 -31
- package/dist/esm/helpers/get-shortname.js +1 -90
- package/dist/esm/helpers/icon-list.js +1 -58
- package/dist/esm/helpers/interaction/index.js +2 -132
- package/dist/esm/helpers/is-browser.js +1 -5
- package/dist/esm/helpers/is-defined.js +1 -5
- package/dist/esm/helpers/is-empty-children.js +2 -10
- package/dist/esm/helpers/is-safari.js +1 -5
- package/dist/esm/helpers/layout.js +1 -70
- package/dist/esm/helpers/load-script.js +1 -29
- package/dist/esm/helpers/loop-component.js +1 -14
- package/dist/esm/helpers/make-style.js +1 -149
- package/dist/esm/helpers/normalize-builder-data.js +1 -21
- package/dist/esm/helpers/pascal-to-kebab-case.js +1 -5
- package/dist/esm/helpers/prefetch-queries.js +1 -76
- package/dist/esm/helpers/product.js +1 -44
- package/dist/esm/helpers/queries/get-collection.js +1 -223
- package/dist/esm/helpers/queries/get-collections.js +1 -19
- package/dist/esm/helpers/queries/get-product-by-slug.js +1 -123
- package/dist/esm/helpers/queries/get-product.js +1 -150
- package/dist/esm/helpers/queries/get-products.js +1 -210
- package/dist/esm/helpers/query.js +1 -25
- package/dist/esm/helpers/radius.js +6 -132
- package/dist/esm/helpers/render.js +1 -82
- package/dist/esm/helpers/shadow.js +1 -63
- package/dist/esm/helpers/size.js +4 -213
- package/dist/esm/helpers/spacing.js +1 -40
- package/dist/esm/helpers/third-party/addAppBlockId.js +1 -18
- package/dist/esm/helpers/third-party/appConfig.js +1 -356
- package/dist/esm/helpers/third-party/appSetting.js +1 -1321
- package/dist/esm/helpers/third-party/composeAppBlockId.js +1 -9
- package/dist/esm/helpers/third-party/constant.js +1 -66
- package/dist/esm/helpers/third-party/generateAppBlockConfigs.js +1 -32
- package/dist/esm/helpers/third-party/getAppBlockConfig.js +1 -53
- package/dist/esm/helpers/third-party/getAppBlockType.js +1 -10
- package/dist/esm/helpers/third-party/getAppBlocks.js +1 -28
- package/dist/esm/helpers/third-party/mergeBlock.js +1 -17
- package/dist/esm/helpers/third-party/mergeBlockOrder.js +1 -45
- package/dist/esm/helpers/third-party/removeGPAppItems.js +1 -15
- package/dist/esm/helpers/tracking/fpixel.js +1 -24
- package/dist/esm/helpers/tracking/gtag.js +1 -87
- package/dist/esm/helpers/tracking/tiktokpixel.js +1 -15
- package/dist/esm/helpers/typography.js +19 -149
- package/dist/esm/helpers/variant.js +1 -9
- package/dist/esm/hooks/animation/useAnimationActions.js +2 -37
- package/dist/esm/hooks/animation/useAnimationConfig.js +2 -28
- package/dist/esm/hooks/animation/useAnimationPreview.js +2 -29
- package/dist/esm/hooks/animation/useAnimationTarget.js +2 -120
- package/dist/esm/hooks/animation/useApplyAnimation.js +2 -85
- package/dist/esm/hooks/articles/useArticlesQuery.js +2 -30
- package/dist/esm/hooks/cart/use-add-to-cart.js +2 -18
- package/dist/esm/hooks/cart/use-cart-data.js +2 -26
- package/dist/esm/hooks/cart/use-cart-discount-codes-update.js +2 -18
- package/dist/esm/hooks/cart/use-cart-note-update.js +2 -18
- package/dist/esm/hooks/cart/use-create-cart.js +2 -20
- package/dist/esm/hooks/cart/use-remove-cart-item.js +2 -18
- package/dist/esm/hooks/cart/use-update-cart-item.js +2 -18
- package/dist/esm/hooks/shop/use-collection-query.js +2 -20
- package/dist/esm/hooks/shop/use-collections-query.js +2 -15
- package/dist/esm/hooks/shop/use-product-query.js +2 -20
- package/dist/esm/hooks/shop/use-products-query.js +2 -59
- package/dist/esm/hooks/shop/useShopifyLink.js +2 -0
- package/dist/esm/hooks/shop.js +2 -119
- package/dist/esm/hooks/use-current-device.js +2 -28
- package/dist/esm/hooks/use-lazy-video.js +2 -13
- package/dist/esm/hooks/useAnimations.js +2 -27
- package/dist/esm/hooks/useCartId.js +2 -40
- package/dist/esm/hooks/useCartLine.js +2 -7
- package/dist/esm/hooks/useCartUI.js +2 -44
- package/dist/esm/hooks/useCollection.js +2 -7
- package/dist/esm/hooks/useFetchHandle.js +2 -11
- package/dist/esm/hooks/useFormatMoney.js +2 -71
- package/dist/esm/hooks/useI18n.js +2 -0
- package/dist/esm/hooks/useInitialSwatchesOptions.js +2 -123
- package/dist/esm/hooks/useInteraction.js +2 -17
- package/dist/esm/hooks/useIsomorphicLayoutEffect.js +2 -6
- package/dist/esm/hooks/useLoadScript.js +2 -28
- package/dist/esm/hooks/useMoney.js +2 -80
- package/dist/esm/hooks/usePrevious.js +2 -17
- package/dist/esm/hooks/useProduct.js +2 -233
- package/dist/esm/hooks/useProductList.js +2 -16
- package/dist/esm/hooks/useStickyStore.js +1 -0
- package/dist/esm/hooks/useSuspenseFetch.js +2 -23
- package/dist/esm/hooks/useSwatchesOptions.js +2 -37
- package/dist/esm/hooks/useToolbarPostPurchase.js +2 -87
- package/dist/esm/index.js +1 -119
- package/dist/esm/types/animations.js +1 -49
- package/dist/esm/types/custom.js +1 -52
- package/dist/esm/types/global-style.js +1 -12
- package/dist/types/index.d.ts +12025 -8969
- package/package.json +6 -6
- package/dist/cjs/web-components/src/helpers/styles/constant.js +0 -9
- package/dist/esm/web-components/src/helpers/styles/constant.js +0 -7
|
@@ -1,19 +1,2 @@
|
|
|
1
|
-
'use
|
|
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
|
+
'use client';
|
|
2
|
+
"use strict";var PageContext=require("../contexts/PageContext.js");const useInteraction=()=>{let t=PageContext.usePageStore(t=>t.interactionData),{item:e}=t||{},n=t=>{let n=e?.targets,a=n?.find(e=>e.uid===t),i=a?.events?.find(t=>t.condition?.metaData?.animation);return i?.condition?.metaData?.animation};return{getAnimationByUid:n}};exports.useInteraction=useInteraction;
|
|
@@ -1,10 +1,2 @@
|
|
|
1
|
-
'use
|
|
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
|
+
'use client';
|
|
2
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var react=require("react");const useIsomorphicLayoutEffect=react.useLayoutEffect;exports.default=useIsomorphicLayoutEffect;
|
|
@@ -1,32 +1,2 @@
|
|
|
1
|
-
'use
|
|
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;
|
|
1
|
+
'use client';
|
|
2
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var react=require("react"),loadScript=require("../helpers/load-script.js");function useLoadScript(e,r){let[t,a]=react.useState("loading"),c=JSON.stringify(r);return react.useEffect(()=>{(async function(){try{a("loading"),await loadScript.loadScript(e,r),a("done")}catch(e){a("error")}})()},[e,c,r]),t}exports.default=useLoadScript;
|
|
@@ -1,84 +1,2 @@
|
|
|
1
|
-
'use
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
-
|
|
5
|
-
var react = require('react');
|
|
6
|
-
var shop = require('./shop.js');
|
|
7
|
-
|
|
8
|
-
const useMoney = (amount)=>{
|
|
9
|
-
const { locale } = shop.useLocale();
|
|
10
|
-
const { currency } = shop.useCurrency();
|
|
11
|
-
const options = react.useMemo(()=>({
|
|
12
|
-
style: 'currency',
|
|
13
|
-
currency: currency
|
|
14
|
-
}), [
|
|
15
|
-
currency
|
|
16
|
-
]);
|
|
17
|
-
const defaultFormatter = useLazyFormatter(locale, options);
|
|
18
|
-
const nameFormatter = useLazyFormatter(locale, {
|
|
19
|
-
...options,
|
|
20
|
-
currencyDisplay: 'name'
|
|
21
|
-
});
|
|
22
|
-
const narrowSymbolFormatter = useLazyFormatter(locale, {
|
|
23
|
-
...options,
|
|
24
|
-
currencyDisplay: 'narrowSymbol'
|
|
25
|
-
});
|
|
26
|
-
const withoutTrailingZerosFormatter = useLazyFormatter(locale, {
|
|
27
|
-
...options,
|
|
28
|
-
minimumFractionDigits: 0,
|
|
29
|
-
maximumFractionDigits: 0
|
|
30
|
-
});
|
|
31
|
-
const withoutCurrencyFormatter = useLazyFormatter(locale);
|
|
32
|
-
const withoutTrailingZerosOrCurrencyFormatter = useLazyFormatter(locale, {
|
|
33
|
-
minimumFractionDigits: 0,
|
|
34
|
-
maximumFractionDigits: 0
|
|
35
|
-
});
|
|
36
|
-
const isPartCurrency = (part)=>part.type === 'currency';
|
|
37
|
-
// By wrapping these properties in functions, we only
|
|
38
|
-
// create formatters if they are going to be used.
|
|
39
|
-
const lazyFormatters = react.useMemo(()=>({
|
|
40
|
-
currencyCode: ()=>currency,
|
|
41
|
-
localizedString: ()=>defaultFormatter().format(amount),
|
|
42
|
-
parts: ()=>defaultFormatter().formatToParts(amount),
|
|
43
|
-
withoutTrailingZeros: ()=>amount % 1 === 0 ? withoutTrailingZerosFormatter().format(amount) : defaultFormatter().format(amount),
|
|
44
|
-
withoutTrailingZerosAndCurrency: ()=>amount % 1 === 0 ? withoutTrailingZerosOrCurrencyFormatter().format(amount) : withoutCurrencyFormatter().format(amount),
|
|
45
|
-
currencyName: ()=>nameFormatter().formatToParts(amount).find(isPartCurrency)?.value ?? currency,
|
|
46
|
-
currencySymbol: ()=>defaultFormatter().formatToParts(amount).find(isPartCurrency)?.value ?? currency,
|
|
47
|
-
currencyNarrowSymbol: ()=>narrowSymbolFormatter().formatToParts(amount).find(isPartCurrency)?.value ?? '',
|
|
48
|
-
amount: ()=>defaultFormatter().formatToParts(amount).filter((part)=>[
|
|
49
|
-
'decimal',
|
|
50
|
-
'fraction',
|
|
51
|
-
'group',
|
|
52
|
-
'integer',
|
|
53
|
-
'literal'
|
|
54
|
-
].includes(part.type)).map((part)=>part.value).join('')
|
|
55
|
-
}), [
|
|
56
|
-
currency,
|
|
57
|
-
amount,
|
|
58
|
-
nameFormatter,
|
|
59
|
-
defaultFormatter,
|
|
60
|
-
narrowSymbolFormatter,
|
|
61
|
-
withoutCurrencyFormatter,
|
|
62
|
-
withoutTrailingZerosFormatter,
|
|
63
|
-
withoutTrailingZerosOrCurrencyFormatter
|
|
64
|
-
]);
|
|
65
|
-
// Call functions automatically when the properties are accessed
|
|
66
|
-
// to keep these functions as an implementation detail.
|
|
67
|
-
return react.useMemo(()=>new Proxy(lazyFormatters, {
|
|
68
|
-
// eslint-disable-next-line @typescript-eslint/no-unsafe-return, @typescript-eslint/no-unsafe-member-access, @typescript-eslint/no-unsafe-call
|
|
69
|
-
get: (target, key)=>Reflect.get(target, key)?.call(null)
|
|
70
|
-
}), [
|
|
71
|
-
lazyFormatters
|
|
72
|
-
]);
|
|
73
|
-
};
|
|
74
|
-
function useLazyFormatter(locale, options) {
|
|
75
|
-
return react.useMemo(()=>{
|
|
76
|
-
let memoized;
|
|
77
|
-
return ()=>memoized ??= new Intl.NumberFormat(locale, options);
|
|
78
|
-
}, [
|
|
79
|
-
locale,
|
|
80
|
-
options
|
|
81
|
-
]);
|
|
82
|
-
}
|
|
83
|
-
|
|
84
|
-
exports.default = useMoney;
|
|
1
|
+
'use client';
|
|
2
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var react=require("react"),shop=require("./shop.js");const useMoney=r=>{let{locale:e}=shop.useLocale(),{currency:t}=shop.useCurrency(),a=react.useMemo(()=>({style:"currency",currency:t}),[t]),o=useLazyFormatter(e,a),u=useLazyFormatter(e,{...a,currencyDisplay:"name"}),n=useLazyFormatter(e,{...a,currencyDisplay:"narrowSymbol"}),i=useLazyFormatter(e,{...a,minimumFractionDigits:0,maximumFractionDigits:0}),m=useLazyFormatter(e),s=useLazyFormatter(e,{minimumFractionDigits:0,maximumFractionDigits:0}),c=r=>"currency"===r.type,l=react.useMemo(()=>({currencyCode:()=>t,localizedString:()=>o().format(r),parts:()=>o().formatToParts(r),withoutTrailingZeros:()=>r%1==0?i().format(r):o().format(r),withoutTrailingZerosAndCurrency:()=>r%1==0?s().format(r):m().format(r),currencyName:()=>u().formatToParts(r).find(c)?.value??t,currencySymbol:()=>o().formatToParts(r).find(c)?.value??t,currencyNarrowSymbol:()=>n().formatToParts(r).find(c)?.value??"",amount:()=>o().formatToParts(r).filter(r=>["decimal","fraction","group","integer","literal"].includes(r.type)).map(r=>r.value).join("")}),[t,r,u,o,n,m,i,s]);return react.useMemo(()=>new Proxy(l,{get:(r,e)=>Reflect.get(r,e)?.call(null)}),[l])};function useLazyFormatter(r,e){return react.useMemo(()=>{let t;return()=>t??(t=new Intl.NumberFormat(r,e))},[r,e])}exports.default=useMoney;
|
|
@@ -1,19 +1,2 @@
|
|
|
1
|
-
'use
|
|
2
|
-
|
|
3
|
-
var react = require('react');
|
|
4
|
-
|
|
5
|
-
const usePrevious = (value)=>{
|
|
6
|
-
// The ref object is a generic container whose current property is mutable ...
|
|
7
|
-
// ... and can hold any value, similar to an instance property on a class
|
|
8
|
-
const ref = react.useRef();
|
|
9
|
-
// Store current value in ref
|
|
10
|
-
react.useEffect(()=>{
|
|
11
|
-
ref.current = value;
|
|
12
|
-
}, [
|
|
13
|
-
value
|
|
14
|
-
]); // Only re-run if value changes
|
|
15
|
-
// Return previous value (happens before update in useEffect above)
|
|
16
|
-
return ref.current;
|
|
17
|
-
};
|
|
18
|
-
|
|
19
|
-
exports.usePrevious = usePrevious;
|
|
1
|
+
'use client';
|
|
2
|
+
"use strict";var react=require("react");const usePrevious=e=>{let r=react.useRef();return react.useEffect(()=>{r.current=e},[e]),r.current};exports.usePrevious=usePrevious;
|
|
@@ -1,250 +1,2 @@
|
|
|
1
|
-
'use
|
|
2
|
-
|
|
3
|
-
var react = require('react');
|
|
4
|
-
var ProductContext = require('../contexts/ProductContext.js');
|
|
5
|
-
require('react/jsx-runtime');
|
|
6
|
-
require('zustand');
|
|
7
|
-
var PageContext = require('../contexts/PageContext.js');
|
|
8
|
-
require('swr');
|
|
9
|
-
require('@gem-sdk/adapter-shopify');
|
|
10
|
-
require('swr/mutation');
|
|
11
|
-
require('swr/infinite');
|
|
12
|
-
require('vanilla-lazyload');
|
|
13
|
-
require('./useCartUI.js');
|
|
14
|
-
var variant = require('../helpers/variant.js');
|
|
15
|
-
require('react-transition-group');
|
|
16
|
-
require('@gem-sdk/core');
|
|
17
|
-
require('classnames');
|
|
18
|
-
require('dayjs');
|
|
19
|
-
var flattenConnection = require('../helpers/flatten-connection.js');
|
|
20
|
-
require('../helpers/convert.js');
|
|
21
|
-
var product = require('../helpers/product.js');
|
|
22
|
-
|
|
23
|
-
const useUniqProductID = ()=>{
|
|
24
|
-
return ProductContext.useProductStore((s)=>s.uiqueId);
|
|
25
|
-
};
|
|
26
|
-
const useProduct = ()=>{
|
|
27
|
-
return ProductContext.useProductStore((s)=>s.product);
|
|
28
|
-
};
|
|
29
|
-
const useFeaturedImageGlobal = ()=>{
|
|
30
|
-
return ProductContext.useProductStore((s)=>s.featuredImageGlobal);
|
|
31
|
-
};
|
|
32
|
-
const useProductProperties = ()=>{
|
|
33
|
-
return ProductContext.useProductStore((s)=>s.properties);
|
|
34
|
-
};
|
|
35
|
-
const useIsSyncProduct = ()=>{
|
|
36
|
-
return ProductContext.useProductStore((s)=>s.isSyncProduct);
|
|
37
|
-
};
|
|
38
|
-
const useProductBundleDiscount = ()=>{
|
|
39
|
-
const useProductCompareAtPrice = ProductContext.useProductStore((s)=>s.useProductCompareAtPrice);
|
|
40
|
-
const seUseProductCompareAtPrice = ProductContext.useProductStore((s)=>s.setUseProductCompareAtPrice);
|
|
41
|
-
return {
|
|
42
|
-
useProductCompareAtPrice,
|
|
43
|
-
seUseProductCompareAtPrice
|
|
44
|
-
};
|
|
45
|
-
};
|
|
46
|
-
const useQuantity = ()=>{
|
|
47
|
-
const quantity = ProductContext.useProductStore((s)=>s.quantity);
|
|
48
|
-
const hasUpdatePrice = ProductContext.useProductStore((s)=>s.updatePrice);
|
|
49
|
-
const decrement = ProductContext.useProductStore((s)=>s.decrementQuantity);
|
|
50
|
-
const increment = ProductContext.useProductStore((s)=>s.incrementQuantity);
|
|
51
|
-
const updateQuantity = ProductContext.useProductStore((s)=>s.setQuantity);
|
|
52
|
-
const updatePrice = ProductContext.useProductStore((s)=>s.setHasUpdatePriceFollowQuantity);
|
|
53
|
-
const isSyncProduct = ProductContext.useProductStore((s)=>s.isSyncProduct);
|
|
54
|
-
const product = ProductContext.useProductStore((s)=>s.product);
|
|
55
|
-
const productId = product?.id;
|
|
56
|
-
const reset = react.useCallback(()=>{
|
|
57
|
-
updateQuantity(1);
|
|
58
|
-
}, [
|
|
59
|
-
updateQuantity
|
|
60
|
-
]);
|
|
61
|
-
react.useEffect(()=>{
|
|
62
|
-
if (isSyncProduct) {
|
|
63
|
-
const setOption = new CustomEvent('set-product-quantity', {
|
|
64
|
-
bubbles: true,
|
|
65
|
-
cancelable: true,
|
|
66
|
-
composed: true,
|
|
67
|
-
detail: {
|
|
68
|
-
quantity,
|
|
69
|
-
productId
|
|
70
|
-
}
|
|
71
|
-
});
|
|
72
|
-
window.dispatchEvent(setOption);
|
|
73
|
-
}
|
|
74
|
-
}, [
|
|
75
|
-
quantity,
|
|
76
|
-
isSyncProduct,
|
|
77
|
-
productId
|
|
78
|
-
]);
|
|
79
|
-
return react.useMemo(()=>({
|
|
80
|
-
quantity,
|
|
81
|
-
hasUpdatePrice,
|
|
82
|
-
increment,
|
|
83
|
-
decrement,
|
|
84
|
-
reset,
|
|
85
|
-
setQuantity: updateQuantity,
|
|
86
|
-
setUpdatePrice: updatePrice
|
|
87
|
-
}), [
|
|
88
|
-
decrement,
|
|
89
|
-
increment,
|
|
90
|
-
quantity,
|
|
91
|
-
reset,
|
|
92
|
-
updateQuantity,
|
|
93
|
-
updatePrice,
|
|
94
|
-
hasUpdatePrice
|
|
95
|
-
]);
|
|
96
|
-
};
|
|
97
|
-
const useHasPreSelected = ()=>{
|
|
98
|
-
const hasPreSelected = ProductContext.useProductStore((s)=>s.hasPreSelected);
|
|
99
|
-
const setHasPreSelected = ProductContext.useProductStore((s)=>s.setHasPreSelected);
|
|
100
|
-
return react.useMemo(()=>({
|
|
101
|
-
hasPreSelected,
|
|
102
|
-
setHasPreSelected
|
|
103
|
-
}), [
|
|
104
|
-
hasPreSelected,
|
|
105
|
-
setHasPreSelected
|
|
106
|
-
]);
|
|
107
|
-
};
|
|
108
|
-
const useSelectedOption = ()=>{
|
|
109
|
-
const setSelectedOption = ProductContext.useProductStore((s)=>s.setSelectedOption);
|
|
110
|
-
const selectedOptions = ProductContext.useProductStore((s)=>s.selectedOptions);
|
|
111
|
-
const forceSelectedOption = ProductContext.useProductStore((s)=>s.forceSelectedOption);
|
|
112
|
-
const isSyncProduct = ProductContext.useProductStore((s)=>s.isSyncProduct);
|
|
113
|
-
const isChangeSelectedOption = ProductContext.useProductStore((s)=>s.isChangeSelectedOption);
|
|
114
|
-
const setIsChangeSelectedOption = ProductContext.useProductStore((s)=>s.setIsChangeSelectedOption);
|
|
115
|
-
const updateOption = react.useCallback((optionId, optionValue, productId, noEmit)=>{
|
|
116
|
-
if (!noEmit && isSyncProduct) {
|
|
117
|
-
const setOption = new CustomEvent('set-selected-option', {
|
|
118
|
-
bubbles: true,
|
|
119
|
-
cancelable: true,
|
|
120
|
-
composed: true,
|
|
121
|
-
detail: {
|
|
122
|
-
optionId,
|
|
123
|
-
optionValue,
|
|
124
|
-
productId
|
|
125
|
-
}
|
|
126
|
-
});
|
|
127
|
-
window.dispatchEvent(setOption);
|
|
128
|
-
}
|
|
129
|
-
setSelectedOption(optionId, optionValue);
|
|
130
|
-
setIsChangeSelectedOption(true);
|
|
131
|
-
}, [
|
|
132
|
-
isSyncProduct,
|
|
133
|
-
setSelectedOption,
|
|
134
|
-
setIsChangeSelectedOption
|
|
135
|
-
]);
|
|
136
|
-
const forceOption = react.useCallback((selectedOption, productId, noEmit)=>{
|
|
137
|
-
if (!noEmit && isSyncProduct) {
|
|
138
|
-
const forceOption = new CustomEvent('force-selected-option', {
|
|
139
|
-
bubbles: true,
|
|
140
|
-
cancelable: true,
|
|
141
|
-
composed: true,
|
|
142
|
-
detail: {
|
|
143
|
-
selectedOption,
|
|
144
|
-
productId
|
|
145
|
-
}
|
|
146
|
-
});
|
|
147
|
-
window.dispatchEvent(forceOption);
|
|
148
|
-
}
|
|
149
|
-
forceSelectedOption(selectedOption);
|
|
150
|
-
}, [
|
|
151
|
-
forceSelectedOption,
|
|
152
|
-
isSyncProduct
|
|
153
|
-
]);
|
|
154
|
-
return react.useMemo(()=>({
|
|
155
|
-
isChangeSelectedOption,
|
|
156
|
-
selectedOptions,
|
|
157
|
-
setSelectedOption: updateOption,
|
|
158
|
-
forceSelectedOption: forceOption
|
|
159
|
-
}), [
|
|
160
|
-
selectedOptions,
|
|
161
|
-
updateOption,
|
|
162
|
-
forceOption
|
|
163
|
-
]);
|
|
164
|
-
};
|
|
165
|
-
const useVariants = ()=>{
|
|
166
|
-
const variants = ProductContext.useProductStore((s)=>s.product?.variants);
|
|
167
|
-
return flattenConnection.flattenConnection(variants);
|
|
168
|
-
};
|
|
169
|
-
const useVariant = (id)=>{
|
|
170
|
-
const variants = useVariants();
|
|
171
|
-
return react.useMemo(()=>variants?.find((v)=>v?.id === id), [
|
|
172
|
-
id,
|
|
173
|
-
variants
|
|
174
|
-
]);
|
|
175
|
-
};
|
|
176
|
-
const useCurrentVariant = ()=>{
|
|
177
|
-
const { selectedOptions } = useSelectedOption();
|
|
178
|
-
const variants = useVariants();
|
|
179
|
-
return react.useMemo(()=>product.getSelectedVariant(variants, selectedOptions), [
|
|
180
|
-
selectedOptions,
|
|
181
|
-
variants
|
|
182
|
-
]);
|
|
183
|
-
};
|
|
184
|
-
const useCurrentVariantInStock = ()=>{
|
|
185
|
-
const currentVariant = useCurrentVariant();
|
|
186
|
-
const currentProduct = useProduct();
|
|
187
|
-
return variant.checkInStock(currentVariant, currentProduct);
|
|
188
|
-
};
|
|
189
|
-
const useVariantOutStock = (optionId, optionValue, options)=>{
|
|
190
|
-
const { selectedOptions } = useSelectedOption();
|
|
191
|
-
const variants = useVariants();
|
|
192
|
-
const lastPos = options.optionNumber - 1;
|
|
193
|
-
if (options.position < lastPos) {
|
|
194
|
-
return variants.some((variant$1)=>{
|
|
195
|
-
if (variant$1) {
|
|
196
|
-
const { selectedOptions } = variant$1;
|
|
197
|
-
const opt = selectedOptions?.some((option)=>option?.name === optionId && option.value === optionValue);
|
|
198
|
-
const isInStock = variant.checkInStock(variant$1);
|
|
199
|
-
return opt && isInStock;
|
|
200
|
-
}
|
|
201
|
-
});
|
|
202
|
-
}
|
|
203
|
-
const matchedVariant = product.getSelectedVariant(variants, {
|
|
204
|
-
...selectedOptions,
|
|
205
|
-
[optionId]: optionValue
|
|
206
|
-
});
|
|
207
|
-
return variant.checkInStock(matchedVariant);
|
|
208
|
-
};
|
|
209
|
-
const useCheckAvailableVariantInStock = (optionId, optionValue)=>{
|
|
210
|
-
const variants = useVariants();
|
|
211
|
-
return variants ? variants.some((item)=>{
|
|
212
|
-
if (item) {
|
|
213
|
-
const { selectedOptions } = item;
|
|
214
|
-
const opt = selectedOptions?.some((option)=>option?.name === optionId && option.value === optionValue);
|
|
215
|
-
const isInStock = variant.checkInStock(item);
|
|
216
|
-
return opt && isInStock;
|
|
217
|
-
}
|
|
218
|
-
return false;
|
|
219
|
-
}) : false;
|
|
220
|
-
};
|
|
221
|
-
const useProductOfferDiscount = ()=>{
|
|
222
|
-
const productOffers = PageContext.usePageStore((s)=>s.productOffers);
|
|
223
|
-
const currentProduct = useProduct();
|
|
224
|
-
const currentVariant = useCurrentVariant();
|
|
225
|
-
const currentOffer = productOffers?.find((item)=>item?.node?.objectBaseID === currentProduct?.baseID)?.node;
|
|
226
|
-
if (!currentOffer || !currentOffer.isEnabled) return 0;
|
|
227
|
-
let currentDiscount = currentOffer?.value;
|
|
228
|
-
if (currentOffer && currentOffer.valueType === 'PERCENTAGE' && currentDiscount) {
|
|
229
|
-
const price = currentVariant?.price || 0;
|
|
230
|
-
currentDiscount = currentDiscount * price / 100;
|
|
231
|
-
}
|
|
232
|
-
return currentDiscount || 0;
|
|
233
|
-
};
|
|
234
|
-
|
|
235
|
-
exports.useCheckAvailableVariantInStock = useCheckAvailableVariantInStock;
|
|
236
|
-
exports.useCurrentVariant = useCurrentVariant;
|
|
237
|
-
exports.useCurrentVariantInStock = useCurrentVariantInStock;
|
|
238
|
-
exports.useFeaturedImageGlobal = useFeaturedImageGlobal;
|
|
239
|
-
exports.useHasPreSelected = useHasPreSelected;
|
|
240
|
-
exports.useIsSyncProduct = useIsSyncProduct;
|
|
241
|
-
exports.useProduct = useProduct;
|
|
242
|
-
exports.useProductBundleDiscount = useProductBundleDiscount;
|
|
243
|
-
exports.useProductOfferDiscount = useProductOfferDiscount;
|
|
244
|
-
exports.useProductProperties = useProductProperties;
|
|
245
|
-
exports.useQuantity = useQuantity;
|
|
246
|
-
exports.useSelectedOption = useSelectedOption;
|
|
247
|
-
exports.useUniqProductID = useUniqProductID;
|
|
248
|
-
exports.useVariant = useVariant;
|
|
249
|
-
exports.useVariantOutStock = useVariantOutStock;
|
|
250
|
-
exports.useVariants = useVariants;
|
|
1
|
+
'use client';
|
|
2
|
+
"use strict";var react=require("react"),ProductContext=require("../contexts/ProductContext.js");require("react/jsx-runtime"),require("zustand");var PageContext=require("../contexts/PageContext.js");require("swr"),require("@gem-sdk/adapter-shopify"),require("swr/mutation"),require("swr/infinite"),require("vanilla-lazyload"),require("./useCartUI.js"),require("./useStickyStore.js");var variant=require("../helpers/variant.js"),useShopifyLink=require("./shop/useShopifyLink.js");require("react-transition-group"),require("@gem-sdk/core"),require("classnames"),require("dayjs");var flattenConnection=require("../helpers/flatten-connection.js");require("../helpers/convert.js");var product=require("../helpers/product.js");const useUniqProductID=()=>ProductContext.useProductStore(e=>e.uiqueId),useProduct=()=>ProductContext.useProductStore(e=>e.product),useFeaturedImageGlobal=()=>ProductContext.useProductStore(e=>e.featuredImageGlobal),useProductProperties=()=>ProductContext.useProductStore(e=>e.properties),useIsSyncProduct=()=>ProductContext.useProductStore(e=>e.isSyncProduct),useProductBundleDiscount=()=>{let e=ProductContext.useProductStore(e=>e.useProductCompareAtPrice),t=ProductContext.useProductStore(e=>e.setUseProductCompareAtPrice);return{useProductCompareAtPrice:e,seUseProductCompareAtPrice:t}},useProductShopifyEditLink=()=>{let e=ProductContext.useProductStore(e=>e.product),t=e?.baseID?.replace("gid://shopify/Product/",""),{linkEditProduct:r}=useShopifyLink.useShopifyLink({productId:t}),u=()=>{r&&window.open(r,"_blank")};return{linkEditProduct:r,redirectProductShopifyLink:u}},useQuantity=()=>{let e=ProductContext.useProductStore(e=>e.quantity),t=ProductContext.useProductStore(e=>e.updatePrice),r=ProductContext.useProductStore(e=>e.decrementQuantity),u=ProductContext.useProductStore(e=>e.incrementQuantity),o=ProductContext.useProductStore(e=>e.setQuantity),s=ProductContext.useProductStore(e=>e.setHasUpdatePriceFollowQuantity),n=ProductContext.useProductStore(e=>e.isSyncProduct),c=ProductContext.useProductStore(e=>e.product),a=c?.id,i=react.useCallback(()=>{o(1)},[o]);return react.useEffect(()=>{if(n){let t=new CustomEvent("set-product-quantity",{bubbles:!0,cancelable:!0,composed:!0,detail:{quantity:e,productId:a}});window.dispatchEvent(t)}},[e,n,a]),react.useMemo(()=>({quantity:e,hasUpdatePrice:t,increment:u,decrement:r,reset:i,setQuantity:o,setUpdatePrice:s}),[r,u,e,i,o,s,t])},useHasPreSelected=()=>{let e=ProductContext.useProductStore(e=>e.hasPreSelected),t=ProductContext.useProductStore(e=>e.setHasPreSelected);return react.useMemo(()=>({hasPreSelected:e,setHasPreSelected:t}),[e,t])},useSelectedOption=()=>{let e=ProductContext.useProductStore(e=>e.setSelectedOption),t=ProductContext.useProductStore(e=>e.selectedOptions),r=ProductContext.useProductStore(e=>e.forceSelectedOption),u=ProductContext.useProductStore(e=>e.isSyncProduct),o=ProductContext.useProductStore(e=>e.isChangeSelectedOption),s=ProductContext.useProductStore(e=>e.setIsChangeSelectedOption),n=react.useCallback((t,r,o,n)=>{if(!n&&u){let e=new CustomEvent("set-selected-option",{bubbles:!0,cancelable:!0,composed:!0,detail:{optionId:t,optionValue:r,productId:o,isManualChange:!0}});window.dispatchEvent(e)}e(t,r),s(!0)},[u,e,s]),c=react.useCallback((e,t,o,s)=>{if(!o&&u){let r=new CustomEvent("force-selected-option",{bubbles:!0,cancelable:!0,composed:!0,detail:{selectedOption:e,productId:t,isManualChange:s}});window.dispatchEvent(r)}r(e)},[r,u]);return react.useMemo(()=>({isChangeSelectedOption:o,selectedOptions:t,setSelectedOption:n,forceSelectedOption:c}),[t,n,c])},useVariants=()=>{let e=ProductContext.useProductStore(e=>e.product?.variants);return flattenConnection.flattenConnection(e)},useVariant=e=>{let t=useVariants();return react.useMemo(()=>t?.find(t=>t?.id===e),[e,t])},useCurrentVariant=()=>{let{selectedOptions:e}=useSelectedOption(),t=useVariants();return react.useMemo(()=>product.getSelectedVariant(t,e),[e,t])},useCurrentVariantInStock=()=>{let e=useCurrentVariant(),t=useProduct();return variant.checkInStock(e,t)},useVariantOutStock=(e,t,r)=>{let{selectedOptions:u}=useSelectedOption(),o=useVariants(),s=r.optionNumber-1;if(r.position<s)return o.some(r=>{if(r){let{selectedOptions:u}=r,o=u?.some(r=>r?.name===e&&r.value===t),s=variant.checkInStock(r);return o&&s}});let n=product.getSelectedVariant(o,{...u,[e]:t});return variant.checkInStock(n)},useCheckAvailableVariantInStock=(e,t)=>{let r=useVariants();return!!r&&r.some(r=>{if(r){let{selectedOptions:u}=r,o=u?.some(r=>r?.name===e&&r.value===t),s=variant.checkInStock(r);return o&&s}return!1})},useProductOfferDiscount=()=>{let e=PageContext.usePageStore(e=>e.productOffers),t=useProduct(),r=useCurrentVariant(),u=e?.find(e=>e?.node?.objectBaseID===t?.baseID)?.node;if(!u||!u.isEnabled)return 0;let o=u?.value;if(u&&"PERCENTAGE"===u.valueType&&o){let e=r?.price||0;o=o*e/100}return o||0};exports.useCheckAvailableVariantInStock=useCheckAvailableVariantInStock,exports.useCurrentVariant=useCurrentVariant,exports.useCurrentVariantInStock=useCurrentVariantInStock,exports.useFeaturedImageGlobal=useFeaturedImageGlobal,exports.useHasPreSelected=useHasPreSelected,exports.useIsSyncProduct=useIsSyncProduct,exports.useProduct=useProduct,exports.useProductBundleDiscount=useProductBundleDiscount,exports.useProductOfferDiscount=useProductOfferDiscount,exports.useProductProperties=useProductProperties,exports.useProductShopifyEditLink=useProductShopifyEditLink,exports.useQuantity=useQuantity,exports.useSelectedOption=useSelectedOption,exports.useUniqProductID=useUniqProductID,exports.useVariant=useVariant,exports.useVariantOutStock=useVariantOutStock,exports.useVariants=useVariants;
|
|
@@ -1,21 +1,2 @@
|
|
|
1
|
-
'use
|
|
2
|
-
|
|
3
|
-
var ProductListContext = require('../contexts/ProductListContext.js');
|
|
4
|
-
|
|
5
|
-
const useProductList = ()=>{
|
|
6
|
-
return ProductListContext.useProductListStore((s)=>s.collection);
|
|
7
|
-
};
|
|
8
|
-
const useProductListProducts = ()=>{
|
|
9
|
-
return ProductListContext.useProductListStore((s)=>s.products);
|
|
10
|
-
};
|
|
11
|
-
const useProductListSettings = ()=>{
|
|
12
|
-
return ProductListContext.useProductListStore((s)=>s.settings);
|
|
13
|
-
};
|
|
14
|
-
const useProductListStyles = ()=>{
|
|
15
|
-
return ProductListContext.useProductListStore((s)=>s.styles);
|
|
16
|
-
};
|
|
17
|
-
|
|
18
|
-
exports.useProductList = useProductList;
|
|
19
|
-
exports.useProductListProducts = useProductListProducts;
|
|
20
|
-
exports.useProductListSettings = useProductListSettings;
|
|
21
|
-
exports.useProductListStyles = useProductListStyles;
|
|
1
|
+
'use client';
|
|
2
|
+
"use strict";var ProductListContext=require("../contexts/ProductListContext.js");const useProductList=()=>ProductListContext.useProductListStore(t=>t.collection),useProductListProducts=()=>ProductListContext.useProductListStore(t=>t.products),useProductListSettings=()=>ProductListContext.useProductListStore(t=>t.settings),useProductListStyles=()=>ProductListContext.useProductListStore(t=>t.styles);exports.useProductList=useProductList,exports.useProductListProducts=useProductListProducts,exports.useProductListSettings=useProductListSettings,exports.useProductListStyles=useProductListStyles;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";var zustand=require("zustand");const useStickyStore=zustand.create(t=>({isStickyVisible:!1,setStickyVisible:e=>t({isStickyVisible:e})}));exports.useStickyStore=useStickyStore;
|
|
@@ -1,27 +1,2 @@
|
|
|
1
|
-
'use
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
-
|
|
5
|
-
const cache = new Map();
|
|
6
|
-
const useSuspenseFetch = (key, promise)=>{
|
|
7
|
-
const value = cache.get(key) || {
|
|
8
|
-
status: 'new',
|
|
9
|
-
data: null
|
|
10
|
-
};
|
|
11
|
-
if (value.status === 'resolved') {
|
|
12
|
-
return {
|
|
13
|
-
data: value.data
|
|
14
|
-
};
|
|
15
|
-
}
|
|
16
|
-
promise().then((data)=>{
|
|
17
|
-
value.status = 'resolved';
|
|
18
|
-
value.data = data;
|
|
19
|
-
cache.set(key, value);
|
|
20
|
-
}).catch(()=>{
|
|
21
|
-
value.status = 'error';
|
|
22
|
-
value.data = null;
|
|
23
|
-
});
|
|
24
|
-
throw promise();
|
|
25
|
-
};
|
|
26
|
-
|
|
27
|
-
exports.default = useSuspenseFetch;
|
|
1
|
+
'use client';
|
|
2
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});const cache=new Map,useSuspenseFetch=(e,t)=>{let s=cache.get(e)||{status:"new",data:null};if("resolved"===s.status)return{data:s.data};throw t().then(t=>{s.status="resolved",s.data=t,cache.set(e,s)}).catch(()=>{s.status="error",s.data=null}),t()};exports.default=useSuspenseFetch;
|
|
@@ -1,41 +1,2 @@
|
|
|
1
|
-
'use
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
-
|
|
5
|
-
var shop = require('./shop.js');
|
|
6
|
-
|
|
7
|
-
const initialSwatchOptionValue = {
|
|
8
|
-
label: '',
|
|
9
|
-
colors: [],
|
|
10
|
-
imageUrl: ''
|
|
11
|
-
};
|
|
12
|
-
const initialGlobalSwatchesData = {
|
|
13
|
-
optionTitle: '',
|
|
14
|
-
optionType: '',
|
|
15
|
-
optionValues: []
|
|
16
|
-
};
|
|
17
|
-
const useSwatchesOptions = (options)=>{
|
|
18
|
-
const { swatches } = shop.useSwatches();
|
|
19
|
-
if (!options) return [];
|
|
20
|
-
return options?.map((option)=>{
|
|
21
|
-
const swatchOption = swatches?.find((sw)=>sw?.optionTitle === option?.name) || {
|
|
22
|
-
...initialGlobalSwatchesData
|
|
23
|
-
};
|
|
24
|
-
return {
|
|
25
|
-
...option,
|
|
26
|
-
optionType: swatchOption ? swatchOption.optionType : '',
|
|
27
|
-
values: option.values?.map((val)=>{
|
|
28
|
-
const swatchValue = swatchOption && swatchOption?.optionValues?.find((swatOp)=>swatOp?.label === val?.label) || {
|
|
29
|
-
...initialSwatchOptionValue
|
|
30
|
-
};
|
|
31
|
-
return {
|
|
32
|
-
...val,
|
|
33
|
-
colors: swatchValue?.colors || [],
|
|
34
|
-
imageUrl: swatchValue?.imageUrl || ''
|
|
35
|
-
};
|
|
36
|
-
})
|
|
37
|
-
};
|
|
38
|
-
});
|
|
39
|
-
};
|
|
40
|
-
|
|
41
|
-
exports.default = useSwatchesOptions;
|
|
1
|
+
'use client';
|
|
2
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var shop=require("./shop.js");const initialSwatchOptionValue={label:"",colors:[],imageUrl:""},initialGlobalSwatchesData={optionTitle:"",optionType:"",optionValues:[]},useSwatchesOptions=e=>{let{swatches:t}=shop.useSwatches();return e?e?.map(e=>{let a=t?.find(t=>t?.optionTitle===e?.name)||{...initialGlobalSwatchesData};return{...e,optionType:a?a.optionType:"",values:e.values?.map(e=>{let t=a&&a?.optionValues?.find(t=>t?.label===e?.label)||{...initialSwatchOptionValue};return{...e,colors:t?.colors||[],imageUrl:t?.imageUrl||""}})}}):[]};exports.default=useSwatchesOptions;
|
|
@@ -1,89 +1,2 @@
|
|
|
1
|
-
'use
|
|
2
|
-
|
|
3
|
-
var constant = require('../components/constant.js');
|
|
4
|
-
var ShopContext = require('../contexts/ShopContext.js');
|
|
5
|
-
|
|
6
|
-
const usePostPurchase = (uid, tag)=>{
|
|
7
|
-
const editingPageType = ShopContext.useShopStore((s)=>s.pageType);
|
|
8
|
-
const getElementCountInPage = (tagParam, root)=>{
|
|
9
|
-
const tagUsed = tagParam || tag;
|
|
10
|
-
let count = 0;
|
|
11
|
-
const elements = (root || document).querySelectorAll(`[data-component-tag="${tagUsed}"]`);
|
|
12
|
-
if (tagUsed === 'PostPurchaseProductOffer') {
|
|
13
|
-
return elements.length;
|
|
14
|
-
}
|
|
15
|
-
let isCountedWrapper = '';
|
|
16
|
-
elements.forEach((element)=>{
|
|
17
|
-
const isWrappedByProductOffer = element.closest('[data-component-tag="PostPurchaseProductOffer"]');
|
|
18
|
-
const productId = isWrappedByProductOffer?.getAttribute('data-uid') || '';
|
|
19
|
-
const productWrapper = element.closest('[data-component-tag="Product"]');
|
|
20
|
-
const elementCounted = productWrapper?.querySelectorAll(`[data-component-tag="${tagUsed}"]`).length || 0;
|
|
21
|
-
const offset = isWrappedByProductOffer ? productId !== isCountedWrapper ? elementCounted : 0 : 1;
|
|
22
|
-
if (isWrappedByProductOffer) {
|
|
23
|
-
isCountedWrapper = productId;
|
|
24
|
-
}
|
|
25
|
-
count += offset;
|
|
26
|
-
});
|
|
27
|
-
return count;
|
|
28
|
-
};
|
|
29
|
-
const verifyRequireElement = ()=>{
|
|
30
|
-
const count = getElementCountInPage();
|
|
31
|
-
return count <= 1;
|
|
32
|
-
};
|
|
33
|
-
const verifyWrapContainsRequireElement = ()=>{
|
|
34
|
-
const $component = document.body.querySelector('#storefront')?.querySelector(`[data-uid="${uid}"]`);
|
|
35
|
-
if (!$component) return false;
|
|
36
|
-
for (const requiredElementTag of constant.postPurchaseRequiredElements){
|
|
37
|
-
const countElementInsidePage = getElementCountInPage(requiredElementTag);
|
|
38
|
-
const countElementInsideWrap = getElementCountInPage(requiredElementTag, $component);
|
|
39
|
-
if (countElementInsideWrap > 0 && countElementInsidePage - countElementInsideWrap < 1) {
|
|
40
|
-
return true;
|
|
41
|
-
}
|
|
42
|
-
}
|
|
43
|
-
return false;
|
|
44
|
-
};
|
|
45
|
-
const countRequiredElement = ()=>{
|
|
46
|
-
return constant.postPurchaseRequiredElements.reduce((acc, requiredElementTag)=>{
|
|
47
|
-
const $component = document.body.querySelector('#storefront')?.querySelector(`[data-uid="${uid}"]`);
|
|
48
|
-
if (!$component) return 0;
|
|
49
|
-
const count = $component.querySelectorAll(`[data-component-tag="${requiredElementTag}"]`).length;
|
|
50
|
-
return acc + count;
|
|
51
|
-
}, 0);
|
|
52
|
-
};
|
|
53
|
-
const checkDisableDelete = ()=>{
|
|
54
|
-
if (editingPageType !== 'POST_PURCHASE') return false;
|
|
55
|
-
let isUnable = false;
|
|
56
|
-
if (constant.postPurchaseRequiredElements.includes(tag)) {
|
|
57
|
-
isUnable = verifyRequireElement();
|
|
58
|
-
if (isUnable) return isUnable;
|
|
59
|
-
}
|
|
60
|
-
if (constant.postPurchaseWrapElements.includes(tag) && countRequiredElement() > 0) {
|
|
61
|
-
return verifyWrapContainsRequireElement();
|
|
62
|
-
}
|
|
63
|
-
return false;
|
|
64
|
-
};
|
|
65
|
-
const checkDisableDuplicate = ()=>{
|
|
66
|
-
return editingPageType === 'GP_FUNNEL_PAGE' && tag === 'ProductList';
|
|
67
|
-
};
|
|
68
|
-
const getTooltipText = ()=>{
|
|
69
|
-
if (constant.postPurchaseRequiredElements.includes(tag)) {
|
|
70
|
-
return {
|
|
71
|
-
text: 'This element is required <br> and can’t be deleted',
|
|
72
|
-
width: '175px'
|
|
73
|
-
};
|
|
74
|
-
} else {
|
|
75
|
-
const elmName = tag === 'Section' ? 'section' : 'element';
|
|
76
|
-
return {
|
|
77
|
-
text: `This ${elmName} contains required <br> elements and cannot be deleted`,
|
|
78
|
-
width: '206px'
|
|
79
|
-
};
|
|
80
|
-
}
|
|
81
|
-
};
|
|
82
|
-
return {
|
|
83
|
-
checkDisableDelete,
|
|
84
|
-
getTooltipText,
|
|
85
|
-
checkDisableDuplicate
|
|
86
|
-
};
|
|
87
|
-
};
|
|
88
|
-
|
|
89
|
-
exports.usePostPurchase = usePostPurchase;
|
|
1
|
+
'use client';
|
|
2
|
+
"use strict";var constant=require("../components/constant.js"),ShopContext=require("../contexts/ShopContext.js");const usePostPurchase=(e,t)=>{let r=ShopContext.useShopStore(e=>e.pageType),n=(e,r)=>{let n=e||t,o=0,s=(r||document).querySelectorAll(`[data-component-tag="${n}"]`);if("PostPurchaseProductOffer"===n)return s.length;let u="";return s.forEach(e=>{let t=e.closest('[data-component-tag="PostPurchaseProductOffer"]'),r=t?.getAttribute("data-uid")||"",s=e.closest('[data-component-tag="Product"]'),c=s?.querySelectorAll(`[data-component-tag="${n}"]`).length||0,a=t?r!==u?c:0:1;t&&(u=r),o+=a}),o},o=()=>{let e=n();return e<=1},s=()=>{let t=document.body.querySelector("#storefront")?.querySelector(`[data-uid="${e}"]`);if(!t)return!1;for(let e of constant.postPurchaseRequiredElements){let r=n(e),o=n(e,t);if(o>0&&r-o<1)return!0}return!1},u=()=>constant.postPurchaseRequiredElements.reduce((t,r)=>{let n=document.body.querySelector("#storefront")?.querySelector(`[data-uid="${e}"]`);if(!n)return 0;let o=n.querySelectorAll(`[data-component-tag="${r}"]`).length;return t+o},0),c=()=>{if("POST_PURCHASE"!==r)return!1;let e=!1;return constant.postPurchaseRequiredElements.includes(t)&&(e=o())?e:!!(constant.postPurchaseWrapElements.includes(t)&&u()>0)&&s()},a=()=>{if(constant.postPurchaseRequiredElements.includes(t))return{text:"This element is required <br> and can’t be deleted",width:"175px"};{let e="Section"===t?"section":"element";return{text:`This ${e} contains required <br> elements and cannot be deleted`,width:"206px"}}};return{checkDisableDelete:c,getTooltipText:a,checkDisableDuplicate:()=>"GP_FUNNEL_PAGE"===r&&"ProductList"===t}};exports.usePostPurchase=usePostPurchase;
|