@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,63 +1,2 @@
|
|
|
1
|
-
'use
|
|
2
|
-
|
|
3
|
-
var useSWR = require('swr');
|
|
4
|
-
var useSWRInfinite = require('swr/infinite');
|
|
5
|
-
var getProducts = require('../../helpers/queries/get-products.js');
|
|
6
|
-
var query = require('../../helpers/query.js');
|
|
7
|
-
var shop = require('../shop.js');
|
|
8
|
-
var useFetchHandle = require('../useFetchHandle.js');
|
|
9
|
-
|
|
10
|
-
const useProductsQuery = (ids, options, params)=>{
|
|
11
|
-
const fetcher = useFetchHandle.useFetchHandle();
|
|
12
|
-
const isSample = shop.useIsSampleProduct();
|
|
13
|
-
const isStorefront = shop.useIsStorefrontProduct();
|
|
14
|
-
return useSWR(ids ? query.generateProductsQueryKey({
|
|
15
|
-
ids,
|
|
16
|
-
isSample,
|
|
17
|
-
isStorefront,
|
|
18
|
-
defaultSelectedProductCount: params?.defaultSelectedProductCount,
|
|
19
|
-
allStatus: params?.allStatus
|
|
20
|
-
}) : null, async ([, arg])=>{
|
|
21
|
-
return getProducts.getProducts(params?.fetcher || fetcher, arg);
|
|
22
|
-
}, options);
|
|
23
|
-
};
|
|
24
|
-
const getKey = (variable)=>{
|
|
25
|
-
return (pageIndex, previousPageData)=>{
|
|
26
|
-
if (!variable || previousPageData && !previousPageData.products?.pageInfo?.hasNextPage) {
|
|
27
|
-
return null;
|
|
28
|
-
}
|
|
29
|
-
if (pageIndex === 0) {
|
|
30
|
-
return [
|
|
31
|
-
'query/products',
|
|
32
|
-
variable
|
|
33
|
-
];
|
|
34
|
-
}
|
|
35
|
-
return [
|
|
36
|
-
'query/products',
|
|
37
|
-
{
|
|
38
|
-
...variable,
|
|
39
|
-
after: previousPageData.products?.pageInfo?.endCursor
|
|
40
|
-
}
|
|
41
|
-
];
|
|
42
|
-
};
|
|
43
|
-
};
|
|
44
|
-
const useListProductQuery = (variable, options)=>{
|
|
45
|
-
const fetcher = useFetchHandle.useFetchHandle();
|
|
46
|
-
const data = useSWRInfinite(getKey(variable), async ([, arg])=>{
|
|
47
|
-
return getProducts.getListProductByVariables(fetcher, arg);
|
|
48
|
-
}, options);
|
|
49
|
-
return data;
|
|
50
|
-
};
|
|
51
|
-
const useProductsQueryAll = (variable, options)=>{
|
|
52
|
-
const fetcher = useFetchHandle.useFetchHandle();
|
|
53
|
-
return useSWR(variable ? [
|
|
54
|
-
'query/products',
|
|
55
|
-
variable
|
|
56
|
-
] : null, async ([, arg])=>{
|
|
57
|
-
return getProducts.getProductQueryAll(fetcher, arg);
|
|
58
|
-
}, options);
|
|
59
|
-
};
|
|
60
|
-
|
|
61
|
-
exports.useListProductQuery = useListProductQuery;
|
|
62
|
-
exports.useProductsQuery = useProductsQuery;
|
|
63
|
-
exports.useProductsQueryAll = useProductsQueryAll;
|
|
1
|
+
'use client';
|
|
2
|
+
"use strict";var useSWR=require("swr"),useSWRInfinite=require("swr/infinite"),getProducts=require("../../helpers/queries/get-products.js"),query=require("../../helpers/query.js"),shop=require("../shop.js"),useFetchHandle=require("../useFetchHandle.js");const useProductsQuery=(e,u,r)=>{let t=useFetchHandle.useFetchHandle(),s=shop.useIsSampleProduct(),c=shop.useIsStorefrontProduct();return useSWR(e?query.generateProductsQueryKey({ids:e,isSample:s,isStorefront:c,defaultSelectedProductCount:r?.defaultSelectedProductCount,allStatus:r?.allStatus}):null,async([,e])=>getProducts.getProducts(r?.fetcher||t,e),u)},getKey=e=>(u,r)=>e&&(!r||r.products?.pageInfo?.hasNextPage)?0===u?["query/products",e]:["query/products",{...e,after:r.products?.pageInfo?.endCursor}]:null,useListProductQuery=(e,u)=>{let r=useFetchHandle.useFetchHandle(),t=useSWRInfinite(getKey(e),async([,e])=>getProducts.getListProductByVariables(r,e),u);return t},useProductsQueryAll=(e,u)=>{let r=useFetchHandle.useFetchHandle();return useSWR(e?["query/products",e]:null,async([,e])=>getProducts.getProductQueryAll(r,e),u)};exports.useListProductQuery=useListProductQuery,exports.useProductsQuery=useProductsQuery,exports.useProductsQueryAll=useProductsQueryAll;
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
"use strict";var react=require("react"),ShopContext=require("../../contexts/ShopContext.js");const useShopifyLink=({productId:e,articleId:t})=>{let o=ShopContext.useShopStore(e=>e.storefrontUrl),r=react.useMemo(()=>{let e=/^(?:https?:\/\/)?([^/]+)\.myshopify\.com/;return o?o.match(e)?.[1]:""},[o]),s=react.useMemo(()=>`https://admin.shopify.com/store/${r}`,[r]),c=react.useMemo(()=>e?`${s}/products/${e}`:"",[s,e]),u=react.useMemo(()=>t?`${s}/articles/${t}`:"",[t,s]);return{linkShopDefault:s,linkEditProduct:c,linkEditArticle:u}};exports.useShopifyLink=useShopifyLink;
|
package/dist/cjs/hooks/shop.js
CHANGED
|
@@ -1,135 +1,2 @@
|
|
|
1
|
-
'use
|
|
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 useTimezone = ()=>{
|
|
30
|
-
const timezone = ShopContext.useShopStore((state)=>state.timezone);
|
|
31
|
-
return react.useMemo(()=>({
|
|
32
|
-
timezone
|
|
33
|
-
}), [
|
|
34
|
-
timezone
|
|
35
|
-
]);
|
|
36
|
-
};
|
|
37
|
-
const useMoneyFormat = ()=>{
|
|
38
|
-
const moneyFormat = ShopContext.useShopStore((state)=>state.moneyFormat);
|
|
39
|
-
const moneyWithCurrencyFormat = ShopContext.useShopStore((state)=>state.moneyWithCurrencyFormat);
|
|
40
|
-
return react.useMemo(()=>({
|
|
41
|
-
moneyFormat,
|
|
42
|
-
moneyWithCurrencyFormat
|
|
43
|
-
}), [
|
|
44
|
-
moneyFormat,
|
|
45
|
-
moneyWithCurrencyFormat
|
|
46
|
-
]);
|
|
47
|
-
};
|
|
48
|
-
const useSwatches = ()=>{
|
|
49
|
-
const swatches = ShopContext.useShopStore((state)=>state.swatches);
|
|
50
|
-
const changeSwatches = ShopContext.useShopStore((state)=>state.changeSwatches);
|
|
51
|
-
return react.useMemo(()=>({
|
|
52
|
-
swatches,
|
|
53
|
-
changeSwatches
|
|
54
|
-
}), [
|
|
55
|
-
swatches,
|
|
56
|
-
changeSwatches
|
|
57
|
-
]);
|
|
58
|
-
};
|
|
59
|
-
const usePageType = ()=>{
|
|
60
|
-
const pageType = ShopContext.useShopStore((state)=>state.pageType);
|
|
61
|
-
return react.useMemo(()=>pageType || 'STATIC', [
|
|
62
|
-
pageType
|
|
63
|
-
]);
|
|
64
|
-
};
|
|
65
|
-
const useStoreFront = ()=>{
|
|
66
|
-
const provider = ShopContext.useShopStore((state)=>state.provider);
|
|
67
|
-
const storefrontToken = ShopContext.useShopStore((state)=>state.storefrontToken);
|
|
68
|
-
const storefrontUrl = ShopContext.useShopStore((state)=>state.storefrontUrl);
|
|
69
|
-
return {
|
|
70
|
-
provider,
|
|
71
|
-
storefrontToken,
|
|
72
|
-
storefrontUrl
|
|
73
|
-
};
|
|
74
|
-
};
|
|
75
|
-
const usePluginEnable = ()=>{
|
|
76
|
-
return ShopContext.useShopStore((state)=>state.plugins);
|
|
77
|
-
};
|
|
78
|
-
const useEditorMode = ()=>{
|
|
79
|
-
return ShopContext.useShopStore((state)=>state.mode);
|
|
80
|
-
};
|
|
81
|
-
const useMobileOnly = ()=>{
|
|
82
|
-
return ShopContext.useShopStore((state)=>state.mobileOnly);
|
|
83
|
-
};
|
|
84
|
-
const useMatchMutate = ()=>{
|
|
85
|
-
const { cache, mutate } = useSWR.useSWRConfig();
|
|
86
|
-
return (matcher, opts)=>{
|
|
87
|
-
if (!(cache instanceof Map)) {
|
|
88
|
-
throw new Error('matchMutate requires the cache provider to be a Map instance');
|
|
89
|
-
}
|
|
90
|
-
const keys = [];
|
|
91
|
-
cache.forEach((_, key)=>{
|
|
92
|
-
if (matcher.test(key)) {
|
|
93
|
-
keys.push(key);
|
|
94
|
-
}
|
|
95
|
-
});
|
|
96
|
-
const mutations = keys.map((key)=>{
|
|
97
|
-
const cacheData = cache.get(key);
|
|
98
|
-
return mutate(key, cacheData?.data, opts);
|
|
99
|
-
});
|
|
100
|
-
return Promise.all(mutations);
|
|
101
|
-
};
|
|
102
|
-
};
|
|
103
|
-
function useConnectedShopify() {
|
|
104
|
-
const { storefrontToken } = useStoreFront();
|
|
105
|
-
return !!storefrontToken;
|
|
106
|
-
}
|
|
107
|
-
function useIsSampleProduct() {
|
|
108
|
-
const { storefrontToken } = useStoreFront();
|
|
109
|
-
const isStorefront = ShopContext.useShopStore((state)=>state.isStorefront);
|
|
110
|
-
return isStorefront && !storefrontToken;
|
|
111
|
-
}
|
|
112
|
-
function useIsStorefrontProduct() {
|
|
113
|
-
return ShopContext.useShopStore((state)=>state.isStorefront);
|
|
114
|
-
}
|
|
115
|
-
function useCheckoutUrl(url) {
|
|
116
|
-
const { storefrontToken } = useStoreFront();
|
|
117
|
-
if (!url) return undefined;
|
|
118
|
-
return storefrontToken ? `${url}?access_token=${storefrontToken}` : url;
|
|
119
|
-
}
|
|
120
|
-
|
|
121
|
-
exports.useCheckoutUrl = useCheckoutUrl;
|
|
122
|
-
exports.useConnectedShopify = useConnectedShopify;
|
|
123
|
-
exports.useCurrency = useCurrency;
|
|
124
|
-
exports.useEditorMode = useEditorMode;
|
|
125
|
-
exports.useIsSampleProduct = useIsSampleProduct;
|
|
126
|
-
exports.useIsStorefrontProduct = useIsStorefrontProduct;
|
|
127
|
-
exports.useLocale = useLocale;
|
|
128
|
-
exports.useMatchMutate = useMatchMutate;
|
|
129
|
-
exports.useMobileOnly = useMobileOnly;
|
|
130
|
-
exports.useMoneyFormat = useMoneyFormat;
|
|
131
|
-
exports.usePageType = usePageType;
|
|
132
|
-
exports.usePluginEnable = usePluginEnable;
|
|
133
|
-
exports.useStoreFront = useStoreFront;
|
|
134
|
-
exports.useSwatches = useSwatches;
|
|
135
|
-
exports.useTimezone = useTimezone;
|
|
1
|
+
'use client';
|
|
2
|
+
"use strict";var react=require("react"),useSWR=require("swr"),ShopContext=require("../contexts/ShopContext.js");const useLocale=()=>{let e=ShopContext.useShopStore(e=>e.locale),t=ShopContext.useShopStore(e=>e.changeLocale);return react.useMemo(()=>({locale:e,changeLocale:t}),[e,t])},useCurrency=()=>{let e=ShopContext.useShopStore(e=>e.currency),t=ShopContext.useShopStore(e=>e.changeCurrency);return react.useMemo(()=>({currency:e,changeCurrency:t}),[e,t])},useTimezone=()=>{let e=ShopContext.useShopStore(e=>e.timezone);return react.useMemo(()=>({timezone:e}),[e])},useMoneyFormat=()=>{let e=ShopContext.useShopStore(e=>e.moneyFormat),t=ShopContext.useShopStore(e=>e.moneyWithCurrencyFormat);return react.useMemo(()=>({moneyFormat:e,moneyWithCurrencyFormat:t}),[e,t])},useSwatches=()=>{let e=ShopContext.useShopStore(e=>e.swatches),t=ShopContext.useShopStore(e=>e.changeSwatches);return react.useMemo(()=>({swatches:e,changeSwatches:t}),[e,t])},usePageType=()=>{let e=ShopContext.useShopStore(e=>e.pageType);return react.useMemo(()=>e||"STATIC",[e])},useStoreFront=()=>{let e=ShopContext.useShopStore(e=>e.provider),t=ShopContext.useShopStore(e=>e.storefrontToken),o=ShopContext.useShopStore(e=>e.storefrontUrl);return{provider:e,storefrontToken:t,storefrontUrl:o}},usePluginEnable=()=>ShopContext.useShopStore(e=>e.plugins),useEditorMode=()=>ShopContext.useShopStore(e=>e.mode),useMobileOnly=()=>ShopContext.useShopStore(e=>e.mobileOnly),useMatchMutate=()=>{let{cache:e,mutate:t}=useSWR.useSWRConfig();return(o,r)=>{if(!(e instanceof Map))throw Error("matchMutate requires the cache provider to be a Map instance");let u=[];e.forEach((e,t)=>{o.test(t)&&u.push(t)});let s=u.map(o=>{let u=e.get(o);return t(o,u?.data,r)});return Promise.all(s)}};function useConnectedShopify(){let{storefrontToken:e}=useStoreFront();return!!e}function useIsSampleProduct(){let{storefrontToken:e}=useStoreFront(),t=ShopContext.useShopStore(e=>e.isStorefront);return t&&!e}function useIsStorefrontProduct(){return ShopContext.useShopStore(e=>e.isStorefront)}function useCheckoutUrl(e){let{storefrontToken:t}=useStoreFront();if(e)return t?`${e}?access_token=${t}`:e}exports.useCheckoutUrl=useCheckoutUrl,exports.useConnectedShopify=useConnectedShopify,exports.useCurrency=useCurrency,exports.useEditorMode=useEditorMode,exports.useIsSampleProduct=useIsSampleProduct,exports.useIsStorefrontProduct=useIsStorefrontProduct,exports.useLocale=useLocale,exports.useMatchMutate=useMatchMutate,exports.useMobileOnly=useMobileOnly,exports.useMoneyFormat=useMoneyFormat,exports.usePageType=usePageType,exports.usePluginEnable=usePluginEnable,exports.useStoreFront=useStoreFront,exports.useSwatches=useSwatches,exports.useTimezone=useTimezone;
|
|
@@ -1,30 +1,2 @@
|
|
|
1
|
-
'use
|
|
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
|
+
'use client';
|
|
2
|
+
"use strict";var react=require("react");function debounce(e,t){let n;return function(...r){clearTimeout(n),n=setTimeout(()=>e.apply(this,r),t)}}function subscribe(e){let t=debounce(e,200);return window.addEventListener("resize",t),()=>window.removeEventListener("resize",t)}const useCurrentDevice=()=>react.useSyncExternalStore(subscribe,()=>window.innerWidth<768?"mobile":window.innerWidth>=768&&window.innerWidth<1025?"tablet":"desktop",()=>"desktop");exports.useCurrentDevice=useCurrentDevice;
|
|
@@ -1,15 +1,2 @@
|
|
|
1
|
-
'use
|
|
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
|
+
'use client';
|
|
2
|
+
"use strict";var react=require("react"),LazyLoad=require("vanilla-lazyload");const useLazyVideo=()=>{react.useEffect(()=>{let e=new LazyLoad({use_native:!0});e.update()},[])};exports.useLazyVideo=useLazyVideo;
|
|
@@ -1,29 +1,2 @@
|
|
|
1
|
-
'use
|
|
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
|
+
'use client';
|
|
2
|
+
"use strict";var animations=require("../helpers/animations.js");require("react"),require("react/jsx-runtime"),require("zustand"),require("swr"),require("@gem-sdk/adapter-shopify"),require("swr/mutation"),require("swr/infinite"),require("vanilla-lazyload"),require("./useCartUI.js"),require("./useStickyStore.js"),require("react-transition-group"),require("@gem-sdk/core"),require("classnames"),require("dayjs"),require("../helpers/convert.js");const useAnimations=()=>{let{zoom:e,shake:r,fade:i,slide:s}=animations.animations();return{zoom:e,shake:r,fade:i,slide:s}};exports.useAnimations=useAnimations;
|
|
@@ -1,44 +1,2 @@
|
|
|
1
|
-
'use
|
|
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
|
+
'use client';
|
|
2
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var react=require("react");const cartKey="cart-id",getCartId=()=>window.localStorage.getItem(cartKey),writeCartId=e=>{e&&window.localStorage.setItem(cartKey,e)},removeCartId=()=>{window.localStorage.removeItem(cartKey)},subscribeStorage=e=>(window.addEventListener("storage",e),()=>{window.removeEventListener("storage",e)}),useCartId=()=>{let e=react.useSyncExternalStore(subscribeStorage,getCartId,()=>void 0),t=react.useCallback(e=>{writeCartId(e)},[]),r=react.useCallback(()=>{removeCartId()},[]);return react.useMemo(()=>({cartId:e,updateCartId:t,clearCartId:r}),[e,r,t])};exports.default=useCartId;
|
|
@@ -1,11 +1,2 @@
|
|
|
1
|
-
'use
|
|
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
|
+
'use client';
|
|
2
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var CartLineContext=require("../contexts/CartLineContext.js");const useCartLine=()=>CartLineContext.useCartLineStore(e=>e.line);exports.default=useCartLine;
|
|
@@ -1,48 +1,2 @@
|
|
|
1
|
-
'use
|
|
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
|
+
'use client';
|
|
2
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var react=require("react"),zustand=require("zustand"),shop=require("./shop.js");const useStore=zustand.create(e=>({isCartOpen:!1,setOpen:t=>{let r=window.innerWidth-document.documentElement.clientWidth,d=parseInt(window.getComputedStyle(document.body).getPropertyValue("padding-right"),10);t?(document.body.style.overflow="hidden",document.body.style.paddingRight=`${d+r}px`):(document.body.style.overflow="",document.body.style.paddingRight=""),e({isCartOpen:t})}}));function useCartUI(){let e=shop.usePluginEnable(),t=useStore(e=>e.isCartOpen),r=useStore(e=>e.setOpen),d=react.useCallback(()=>{e?.includes("cart-drawer")&&r(!0)},[e,r]),n=react.useCallback(()=>r(!1),[r]);return{isCartOpen:t,openCart:d,closeCart:n}}exports.default=useCartUI;
|
|
@@ -1,9 +1,2 @@
|
|
|
1
|
-
'use
|
|
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
|
+
'use client';
|
|
2
|
+
"use strict";var CollectionContext=require("../contexts/CollectionContext.js");const useCollection=()=>CollectionContext.useCollectionStore(o=>o.collection);exports.useCollection=useCollection;
|
|
@@ -1,13 +1,2 @@
|
|
|
1
|
-
'use
|
|
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
|
+
'use client';
|
|
2
|
+
"use strict";var useSWR=require("swr");const useFetchHandle=()=>{let{fetcher:e}=useSWR.useSWRConfig();if(!e)throw Error("Application must be init within a fetcher");return e};exports.useFetchHandle=useFetchHandle;
|
|
@@ -1,75 +1,2 @@
|
|
|
1
|
-
'use
|
|
2
|
-
|
|
3
|
-
var shop = require('./shop.js');
|
|
4
|
-
|
|
5
|
-
const shopifyPriceRounding = (amount, precision)=>{
|
|
6
|
-
return parseFloat(`${amount}`).toFixed(Number(precision));
|
|
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
|
+
'use client';
|
|
2
|
+
"use strict";var shop=require("./shop.js");const shopifyPriceRounding=(e,a)=>parseFloat(`${e}`).toFixed(Number(a)),formatMoney=function(e,a){let o="",r=/\{\{\s*(\w+)\s*\}\}/,t=a||"${{amount}}";function s(e,a){return void 0===e?a:e}function n(e,a,o,r){if(a=s(a,2),o=s(o,","),r=s(r,"."),isNaN(e)||null==e)return 0;e=shopifyPriceRounding(e,Number(a));let t=e.split("."),n=t[0]?.replace(/(\d)(?=(\d\d\d)+(?!\d))/g,"$1"+o),i=t[1]?r+t[1]:"";return n+i}switch(t.match(r)[1]){case"amount":o=n(e,2);break;case"amount_no_decimals":o=n(e,0);break;case"amount_with_comma_separator":o=n(e,2,".",",");break;case"amount_no_decimals_with_comma_separator":o=n(e,0,".",",");break;case"amount_with_apostrophe_separator":o=n(e,2,"'",".");break;case"amount_no_decimals_with_space_separator":o=n(e,0," ");break;case"amount_with_space_separator":o=n(e,2," ",",");break;case"amount_with_period_and_space_separator":o=n(e,2," ",".")}return t.replace(r,o)},useFormatMoney=(e,a)=>{let{moneyFormat:o,moneyWithCurrencyFormat:r}=shop.useMoneyFormat();return a?formatMoney(`${e}`,r||o):formatMoney(`${e}`,o)};exports.formatMoney=formatMoney,exports.shopifyPriceRounding=shopifyPriceRounding,exports.useFormatMoney=useFormatMoney;
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
'use client';
|
|
2
|
+
"use strict";var react=require("react");const useI18n=()=>{let[e,t]=react.useState(null),a=e=>{let a=e.detail;a&&t(a)},r=react.useCallback(t=>e?e?.t(t):t,[e]);return react.useEffect(()=>(window.addEventListener("editor:change-language",a),()=>{window.removeEventListener("editor:change-language",a)}),[]),{t:r}};exports.useI18n=useI18n;
|
|
@@ -1,127 +1,2 @@
|
|
|
1
|
-
'use
|
|
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
|
-
if (val.label && !labels.includes(val.label)) labels.push(val.label);
|
|
79
|
-
});
|
|
80
|
-
return labels;
|
|
81
|
-
};
|
|
82
|
-
const getSwatchesOptionsLabel = (options)=>{
|
|
83
|
-
const labels = [];
|
|
84
|
-
options.forEach((op)=>{
|
|
85
|
-
if (op.label && !labels.includes(op.label)) labels.push(op.label);
|
|
86
|
-
});
|
|
87
|
-
return labels;
|
|
88
|
-
};
|
|
89
|
-
const setDefaultSwatches = (swatches, options)=>{
|
|
90
|
-
if (swatches) {
|
|
91
|
-
swatches?.map((sw)=>{
|
|
92
|
-
const productLabels = getProductOptionsLabelByName(options, sw.optionTitle);
|
|
93
|
-
const swLabels = getSwatchesOptionsLabel(sw.optionValues);
|
|
94
|
-
productLabels.forEach((label)=>{
|
|
95
|
-
if (!swLabels.includes(label)) {
|
|
96
|
-
sw.optionValues.push({
|
|
97
|
-
label,
|
|
98
|
-
colors: getColorDefault(label),
|
|
99
|
-
imageUrl: ''
|
|
100
|
-
});
|
|
101
|
-
}
|
|
102
|
-
});
|
|
103
|
-
sw.optionValues = sw.optionValues.map((op)=>{
|
|
104
|
-
if (op.imageUrl === undefined) swatchChange = true;
|
|
105
|
-
return {
|
|
106
|
-
label: op.label ?? '',
|
|
107
|
-
colors: getColorDefault(op.label, op.colors),
|
|
108
|
-
imageUrl: op.imageUrl ?? ''
|
|
109
|
-
};
|
|
110
|
-
});
|
|
111
|
-
});
|
|
112
|
-
}
|
|
113
|
-
return swatches;
|
|
114
|
-
};
|
|
115
|
-
const fetchProductValueLabel = async (fetcher)=>{
|
|
116
|
-
const initVariables = {};
|
|
117
|
-
const query = async (variables)=>{
|
|
118
|
-
const response = await fetcher([
|
|
119
|
-
productValueLabel_generated.ProductOptionNameDocument,
|
|
120
|
-
variables
|
|
121
|
-
]);
|
|
122
|
-
return response;
|
|
123
|
-
};
|
|
124
|
-
return query(initVariables);
|
|
125
|
-
};
|
|
126
|
-
|
|
127
|
-
exports.default = useInitialSwatchesOptions;
|
|
1
|
+
'use client';
|
|
2
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var useSWR=require("swr"),productValueLabel_generated=require("../graphql/queries/product-value-label.generated.js"),variantPresets=require("../components/src/product/helpers/variant-presets.js"),shop=require("./shop.js"),useFetchHandle=require("./useFetchHandle.js"),ShopContext=require("../contexts/ShopContext.js");require("react"),require("react/jsx-runtime"),require("zustand"),require("@gem-sdk/adapter-shopify"),require("swr/mutation"),require("swr/infinite"),require("vanilla-lazyload"),require("./useCartUI.js"),require("./useStickyStore.js"),require("react-transition-group"),require("@gem-sdk/core"),require("classnames"),require("dayjs");var isBrowser=require("../helpers/is-browser.js");require("../helpers/convert.js");let swatchChange=!1,colorChange=!1;const useInitialSwatchesOptions=e=>{let t=useFetchHandle.useFetchHandle(),r=ShopContext.useShopStore(e=>e.changeSwatches),{swatches:a}=shop.useSwatches(),{data:s}=useSWR(["/query/productOptionName",{}],async()=>fetchProductValueLabel(t),{revalidateOnMount:!0}),o=[];if(a?.forEach(e=>{o.push(e.optionTitle)}),s?.productOptionName?.forEach(e=>{o.includes(e)||(swatchChange=!0,a?.push({optionTitle:e,optionType:"rectangle_list",optionValues:[]}))}),!e)return[];setDefaultSwatches(a,e),isBrowser.default()&&a?.length&&(swatchChange||colorChange)&&(window?.parent?.postMessage?.(JSON.stringify({type:"update-swatches",swatches:a}),"*"),r(a)),swatchChange=!1},getColorDefault=(e,t)=>{let r=e?variantPresets.colorPreset[e.toLocaleLowerCase()]:void 0,a=r?[r]:[],s=t?.[0];return!s&&a.length&&(colorChange=!0),s?[s]:a},getProductOptionsLabelByName=(e,t)=>{let r=[],a=e.find(e=>e.name===t);return a?.values.forEach(e=>{e.label&&!r.includes(e.label)&&r.push(e.label)}),r},getSwatchesOptionsLabel=e=>{let t=[];return e.forEach(e=>{e.label&&!t.includes(e.label)&&t.push(e.label)}),t},setDefaultSwatches=(e,t)=>(e&&e?.map(e=>{let r=getProductOptionsLabelByName(t,e.optionTitle),a=getSwatchesOptionsLabel(e.optionValues);r.forEach(t=>{a.includes(t)||e.optionValues.push({label:t,colors:getColorDefault(t),imageUrl:""})}),e.optionValues=e.optionValues.map(e=>(void 0===e.imageUrl&&(swatchChange=!0),{label:e.label??"",colors:getColorDefault(e.label,e.colors),imageUrl:e.imageUrl??""}))}),e),fetchProductValueLabel=async e=>{let t={},r=async t=>{let r=await e([productValueLabel_generated.ProductOptionNameDocument,t]);return r};return r(t)};exports.default=useInitialSwatchesOptions;
|