@gem-sdk/core 2.0.0-dev.896 → 2.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/components/AddOn.js +18 -1
- package/dist/cjs/components/ComponentAnimation.js +17 -0
- package/dist/cjs/components/ComponentToolbarPreview.js +752 -1
- package/dist/cjs/components/ComponentWrapper.js +61 -1
- package/dist/cjs/components/ComponentWrapperPreview.js +213 -1
- package/dist/cjs/components/Empty.js +7 -1
- package/dist/cjs/components/InteractionSuffix.js +42 -0
- package/dist/cjs/components/Render.js +75 -1
- package/dist/cjs/components/Render.liquid.js +313 -17
- package/dist/cjs/components/RenderBlock.js +54 -1
- package/dist/cjs/components/RenderCustomCode.js +59 -3
- package/dist/cjs/components/RenderPreview.js +67 -1
- package/dist/cjs/components/RenderSection.js +23 -1
- package/dist/cjs/components/ai-generator/AIContentGenerator.js +252 -1
- package/dist/cjs/components/ai-generator/AIGenContentLoading.js +85 -1
- package/dist/cjs/components/ai-generator/components/PickProduct.js +220 -1
- package/dist/cjs/components/ai-generator/components/ToneAndVoice.js +77 -1
- package/dist/cjs/components/ai-generator/hooks/useCheckingProductInside.js +47 -0
- package/dist/cjs/components/ai-generator/hooks/useFlipPopup.js +110 -0
- package/dist/cjs/components/ai-generator/hooks/useGettingGenerateRequest.js +37 -1
- package/dist/cjs/components/ai-generator/hooks/useListenEventGenerate.js +70 -1
- package/dist/cjs/components/ai-generator/icons/AIIcon.js +67 -1
- package/dist/cjs/components/ai-generator/icons/CloseIcon.js +19 -1
- package/dist/cjs/components/ai-generator/icons/DropdownIcon.js +37 -1
- package/dist/cjs/components/ai-generator/icons/SearchIcon.js +21 -1
- package/dist/cjs/components/ai-generator/icons/ShowMoreIcon.js +21 -1
- package/dist/cjs/components/ai-generator/icons/UpgradeIcon.js +27 -0
- package/dist/cjs/components/ai-generator/icons/WarningIcon.js +31 -0
- package/dist/cjs/components/constant.js +83 -1
- package/dist/cjs/components/resize/Resize.js +16 -1
- package/dist/cjs/components/resize/Spacing.js +260 -1
- package/dist/cjs/components/src/product/helpers/variant-presets.js +56 -1
- package/dist/cjs/components/theme-section/CreateThemeSection.js +123 -1
- package/dist/cjs/components/theme-section/ThemeSectionStatus.js +45 -1
- package/dist/cjs/components/theme-section/ThemeSectionTooltip.js +126 -1
- package/dist/cjs/components/toolbar/Tooltip.js +28 -1
- package/dist/cjs/contexts/AddonContext.js +36 -1
- package/dist/cjs/contexts/ArticleContext.js +39 -1
- package/dist/cjs/contexts/ArticleListContext.js +31 -1
- package/dist/cjs/contexts/BuilderComponent.js +34 -1
- package/dist/cjs/contexts/BuilderContext.js +39 -1
- package/dist/cjs/contexts/BuilderPreviewContext.js +486 -1
- package/dist/cjs/contexts/CartLineContext.js +29 -1
- package/dist/cjs/contexts/CollectionContext.js +38 -1
- package/dist/cjs/contexts/ModalContext.js +47 -1
- package/dist/cjs/contexts/PageContext.js +104 -1
- package/dist/cjs/contexts/ProductContext.js +177 -1
- package/dist/cjs/contexts/ProductListContext.js +32 -1
- package/dist/cjs/contexts/SectionContext.js +53 -1
- package/dist/cjs/contexts/ShopContext.js +107 -1
- package/dist/cjs/graphql/fragments/analytic.generated.js +6 -2
- package/dist/cjs/graphql/fragments/collection-detail.generated.js +6 -2
- package/dist/cjs/graphql/fragments/collection-product.generated.js +6 -2
- package/dist/cjs/graphql/fragments/collection.generated.js +6 -2
- package/dist/cjs/graphql/fragments/custom-code.generated.js +6 -2
- package/dist/cjs/graphql/fragments/custom-font.generated.js +6 -2
- package/dist/cjs/graphql/fragments/data-seo.generated.js +6 -2
- package/dist/cjs/graphql/fragments/media.generated.js +6 -2
- package/dist/cjs/graphql/fragments/preview-theme-page.generated.js +39 -0
- package/dist/cjs/graphql/fragments/product-little.generated.js +7 -2
- package/dist/cjs/graphql/fragments/product-option-value.generated.js +6 -2
- package/dist/cjs/graphql/fragments/product-option.generated.js +6 -2
- package/dist/cjs/graphql/fragments/product.generated.js +6 -2
- package/dist/cjs/graphql/fragments/published-custom-section.generated.js +6 -2
- package/dist/cjs/graphql/fragments/published-page-section.generated.js +6 -2
- package/dist/cjs/graphql/fragments/published-theme-page.generated.js +10 -28
- package/dist/cjs/graphql/fragments/published-theme-style.generated.js +6 -2
- package/dist/cjs/graphql/fragments/selected-option.generated.js +6 -2
- package/dist/cjs/graphql/fragments/variant.generated.js +6 -2
- package/dist/cjs/graphql/mutations/page-view-up.generated.js +8 -4
- package/dist/cjs/graphql/queries/articles.generated.js +61 -0
- package/dist/cjs/graphql/queries/blogs.generated.js +69 -0
- package/dist/cjs/graphql/queries/collection-detail-filter.generated.js +16 -2
- package/dist/cjs/graphql/queries/collection.generated.js +14 -2
- package/dist/cjs/graphql/queries/collections.generated.js +9 -2
- package/dist/cjs/graphql/queries/preview-page.generated.js +16 -8
- package/dist/cjs/graphql/queries/product-little-detail.generated.js +11 -2
- package/dist/cjs/graphql/queries/product-medias.generated.js +8 -2
- package/dist/cjs/graphql/queries/product-value-label.generated.js +6 -2
- package/dist/cjs/graphql/queries/product-variants.generated.js +10 -2
- package/dist/cjs/graphql/queries/products.generated.js +17 -3
- package/dist/cjs/graphql/queries/published-shop-metas.js +15 -0
- package/dist/cjs/graphql/queries/published-theme-pages.generated.js +15 -2
- package/dist/cjs/graphql/queries/store-property.generated.js +6 -2
- package/dist/cjs/graphql-app-api/queries/LibrarySaleFunnelDiscount.generated.js +6 -2
- package/dist/cjs/graphql-app-api/queries/LibraryTemplate.generated.js +6 -2
- package/dist/cjs/graphql-app-api/queries/SaleFunnelDiscounts.generated.js +6 -2
- package/dist/cjs/graphql-app-api/queries/ShopLibraryPage.generated.js +17 -0
- package/dist/cjs/graphql-app-api/queries/ThemePage.generated.js +6 -2
- package/dist/cjs/helpers/GlobalEvent.js +19 -1
- package/dist/cjs/helpers/align.js +19 -0
- package/dist/cjs/helpers/animations.js +222 -1
- package/dist/cjs/helpers/background.js +235 -1
- package/dist/cjs/helpers/borders.js +198 -4
- package/dist/cjs/helpers/carousel.js +55 -1
- package/dist/cjs/helpers/clone-deep.js +5 -1
- package/dist/cjs/helpers/cls.js +16 -1
- package/dist/cjs/helpers/colors.js +184 -1
- package/dist/cjs/helpers/compose-advance-style.js +327 -1
- package/dist/cjs/helpers/constant.js +23 -1
- package/dist/cjs/helpers/convert.js +7 -1
- package/dist/cjs/helpers/covert-entities-html.js +19 -1
- package/dist/cjs/helpers/css-variable.js +7 -1
- package/dist/cjs/helpers/email.js +11 -1
- package/dist/cjs/helpers/filter-toolbar-preview.js +14 -1
- package/dist/cjs/helpers/flatten-connection.js +9 -1
- package/dist/cjs/helpers/get-resonsive-value.js +36 -1
- package/dist/cjs/helpers/get-shortname.js +92 -1
- package/dist/cjs/helpers/icon-list.js +61 -1
- package/dist/cjs/helpers/interaction/index.js +134 -0
- package/dist/cjs/helpers/is-browser.js +9 -1
- package/dist/cjs/helpers/is-defined.js +7 -1
- package/dist/cjs/helpers/is-empty-children.js +15 -1
- package/dist/cjs/helpers/is-safari.js +9 -1
- package/dist/cjs/helpers/layout.js +59 -1
- package/dist/cjs/helpers/load-script.js +31 -1
- package/dist/cjs/helpers/loop-component.js +16 -0
- package/dist/cjs/helpers/make-style.js +163 -1
- package/dist/cjs/helpers/normalize-builder-data.js +23 -1
- package/dist/cjs/helpers/pascal-to-kebab-case.js +7 -0
- package/dist/cjs/helpers/prefetch-queries.js +78 -1
- package/dist/cjs/helpers/product.js +48 -1
- package/dist/cjs/helpers/queries/get-collection.js +226 -1
- package/dist/cjs/helpers/queries/get-collections.js +21 -1
- package/dist/cjs/helpers/queries/get-product-by-slug.js +125 -1
- package/dist/cjs/helpers/queries/get-product.js +154 -1
- package/dist/cjs/helpers/queries/get-products.js +214 -1
- package/dist/cjs/helpers/query.js +29 -1
- package/dist/cjs/helpers/radius.js +140 -6
- package/dist/cjs/helpers/render.js +78 -1
- package/dist/cjs/helpers/shadow.js +69 -1
- package/dist/cjs/helpers/size.js +206 -4
- package/dist/cjs/helpers/spacing.js +43 -1
- package/dist/cjs/helpers/third-party/addAppBlockId.js +20 -0
- package/dist/cjs/helpers/third-party/appConfig.js +234 -0
- package/dist/cjs/helpers/third-party/appSetting.js +661 -0
- package/dist/cjs/helpers/third-party/composeAppBlockId.js +11 -0
- package/dist/cjs/helpers/third-party/constant.js +43 -0
- package/dist/cjs/helpers/third-party/generateAppBlockConfigs.js +34 -0
- package/dist/cjs/helpers/third-party/getAppBlockConfig.js +47 -0
- package/dist/cjs/helpers/third-party/getAppBlockType.js +12 -0
- package/dist/cjs/helpers/third-party/getAppBlocks.js +30 -0
- package/dist/cjs/helpers/third-party/mergeBlock.js +19 -0
- package/dist/cjs/helpers/third-party/mergeBlockOrder.js +47 -0
- package/dist/cjs/helpers/third-party/removeGPAppItems.js +18 -0
- package/dist/cjs/helpers/tracking/fpixel.js +28 -1
- package/dist/cjs/helpers/tracking/gtag.js +93 -1
- package/dist/cjs/helpers/tracking/tiktokpixel.js +17 -1
- package/dist/cjs/helpers/typography.js +160 -17
- package/dist/cjs/helpers/variant.js +11 -1
- package/dist/cjs/hooks/animation/useAnimationActions.js +39 -1
- package/dist/cjs/hooks/animation/useAnimationConfig.js +30 -1
- package/dist/cjs/hooks/animation/useAnimationPreview.js +31 -1
- package/dist/cjs/hooks/animation/useAnimationTarget.js +122 -1
- package/dist/cjs/hooks/animation/useApplyAnimation.js +89 -1
- package/dist/cjs/hooks/articles/useArticlesQuery.js +33 -1
- package/dist/cjs/hooks/cart/use-add-to-cart.js +20 -1
- package/dist/cjs/hooks/cart/use-cart-data.js +28 -1
- package/dist/cjs/hooks/cart/use-cart-discount-codes-update.js +20 -1
- package/dist/cjs/hooks/cart/use-cart-note-update.js +20 -1
- package/dist/cjs/hooks/cart/use-create-cart.js +22 -1
- package/dist/cjs/hooks/cart/use-remove-cart-item.js +20 -1
- package/dist/cjs/hooks/cart/use-update-cart-item.js +20 -1
- package/dist/cjs/hooks/shop/use-collection-query.js +22 -1
- package/dist/cjs/hooks/shop/use-collections-query.js +17 -1
- package/dist/cjs/hooks/shop/use-product-query.js +22 -1
- package/dist/cjs/hooks/shop/use-products-query.js +63 -1
- package/dist/cjs/hooks/shop.js +126 -1
- package/dist/cjs/hooks/use-current-device.js +30 -1
- package/dist/cjs/hooks/use-lazy-video.js +15 -1
- package/dist/cjs/hooks/useAnimations.js +29 -1
- package/dist/cjs/hooks/useCartId.js +44 -1
- package/dist/cjs/hooks/useCartLine.js +11 -1
- package/dist/cjs/hooks/useCartUI.js +48 -1
- package/dist/cjs/hooks/useCollection.js +9 -1
- package/dist/cjs/hooks/useFetchHandle.js +13 -1
- package/dist/cjs/hooks/useFormatMoney.js +75 -1
- package/dist/cjs/hooks/useInitialSwatchesOptions.js +128 -1
- package/dist/cjs/hooks/useInteraction.js +19 -0
- package/dist/cjs/hooks/useIsomorphicLayoutEffect.js +10 -1
- package/dist/cjs/hooks/useLoadScript.js +32 -1
- package/dist/cjs/hooks/useMoney.js +84 -1
- package/dist/cjs/hooks/usePrevious.js +19 -1
- package/dist/cjs/hooks/useProduct.js +245 -1
- package/dist/cjs/hooks/useProductList.js +21 -1
- package/dist/cjs/hooks/useSuspenseFetch.js +27 -1
- package/dist/cjs/hooks/useSwatchesOptions.js +41 -1
- package/dist/cjs/hooks/useToolbarPostPurchase.js +89 -1
- package/dist/cjs/index.js +416 -1
- package/dist/cjs/types/animations.js +49 -1
- package/dist/cjs/types/appAPI.js +2 -1
- package/dist/cjs/types/custom.js +52 -0
- package/dist/cjs/types/global-style.js +15 -1
- package/dist/cjs/types/shop.js +2 -1
- package/dist/cjs/web-components/src/helpers/styles/constant.js +9 -1
- package/dist/esm/components/AddOn.js +14 -1
- package/dist/esm/components/ComponentAnimation.js +13 -0
- package/dist/esm/components/ComponentToolbarPreview.js +748 -1
- package/dist/esm/components/ComponentWrapper.js +57 -1
- package/dist/esm/components/ComponentWrapperPreview.js +209 -1
- package/dist/esm/components/Empty.js +3 -1
- package/dist/esm/components/InteractionSuffix.js +40 -0
- package/dist/esm/components/Render.js +71 -1
- package/dist/esm/components/Render.liquid.js +307 -17
- package/dist/esm/components/RenderBlock.js +50 -1
- package/dist/esm/components/RenderCustomCode.js +55 -3
- package/dist/esm/components/RenderPreview.js +63 -1
- package/dist/esm/components/RenderSection.js +19 -1
- package/dist/esm/components/ai-generator/AIContentGenerator.js +250 -1
- package/dist/esm/components/ai-generator/AIGenContentLoading.js +83 -1
- package/dist/esm/components/ai-generator/components/PickProduct.js +218 -1
- package/dist/esm/components/ai-generator/components/ToneAndVoice.js +75 -1
- package/dist/esm/components/ai-generator/hooks/useCheckingProductInside.js +45 -0
- package/dist/esm/components/ai-generator/hooks/useFlipPopup.js +108 -0
- package/dist/esm/components/ai-generator/hooks/useGettingGenerateRequest.js +35 -1
- package/dist/esm/components/ai-generator/hooks/useListenEventGenerate.js +68 -1
- package/dist/esm/components/ai-generator/icons/AIIcon.js +65 -1
- package/dist/esm/components/ai-generator/icons/CloseIcon.js +17 -1
- package/dist/esm/components/ai-generator/icons/DropdownIcon.js +34 -1
- package/dist/esm/components/ai-generator/icons/SearchIcon.js +19 -1
- package/dist/esm/components/ai-generator/icons/ShowMoreIcon.js +19 -1
- package/dist/esm/components/ai-generator/icons/UpgradeIcon.js +25 -0
- package/dist/esm/components/ai-generator/icons/WarningIcon.js +29 -0
- package/dist/esm/components/constant.js +76 -1
- package/dist/esm/components/resize/Resize.js +12 -1
- package/dist/esm/components/resize/Spacing.js +256 -1
- package/dist/esm/components/src/product/helpers/variant-presets.js +54 -1
- package/dist/esm/components/theme-section/CreateThemeSection.js +121 -1
- package/dist/esm/components/theme-section/ThemeSectionStatus.js +43 -1
- package/dist/esm/components/theme-section/ThemeSectionTooltip.js +124 -1
- package/dist/esm/components/toolbar/Tooltip.js +24 -1
- package/dist/esm/contexts/AddonContext.js +32 -1
- package/dist/esm/contexts/ArticleContext.js +36 -1
- package/dist/esm/contexts/ArticleListContext.js +27 -1
- package/dist/esm/contexts/BuilderComponent.js +31 -1
- package/dist/esm/contexts/BuilderContext.js +36 -1
- package/dist/esm/contexts/BuilderPreviewContext.js +483 -1
- package/dist/esm/contexts/CartLineContext.js +26 -1
- package/dist/esm/contexts/CollectionContext.js +35 -1
- package/dist/esm/contexts/ModalContext.js +44 -1
- package/dist/esm/contexts/PageContext.js +101 -1
- package/dist/esm/contexts/ProductContext.js +174 -1
- package/dist/esm/contexts/ProductListContext.js +28 -1
- package/dist/esm/contexts/SectionContext.js +49 -1
- package/dist/esm/contexts/ShopContext.js +104 -1
- package/dist/esm/graphql/fragments/analytic.generated.js +4 -2
- package/dist/esm/graphql/fragments/collection-detail.generated.js +4 -2
- package/dist/esm/graphql/fragments/collection-product.generated.js +4 -2
- package/dist/esm/graphql/fragments/collection.generated.js +4 -2
- package/dist/esm/graphql/fragments/custom-code.generated.js +4 -2
- package/dist/esm/graphql/fragments/custom-font.generated.js +4 -2
- package/dist/esm/graphql/fragments/data-seo.generated.js +4 -2
- package/dist/esm/graphql/fragments/media.generated.js +4 -2
- package/dist/esm/graphql/fragments/preview-theme-page.generated.js +37 -0
- package/dist/esm/graphql/fragments/product-little.generated.js +5 -2
- package/dist/esm/graphql/fragments/product-option-value.generated.js +4 -2
- package/dist/esm/graphql/fragments/product-option.generated.js +4 -2
- package/dist/esm/graphql/fragments/product.generated.js +4 -2
- package/dist/esm/graphql/fragments/published-custom-section.generated.js +4 -2
- package/dist/esm/graphql/fragments/published-page-section.generated.js +4 -2
- package/dist/esm/graphql/fragments/published-theme-page.generated.js +8 -28
- package/dist/esm/graphql/fragments/published-theme-style.generated.js +4 -2
- package/dist/esm/graphql/fragments/selected-option.generated.js +4 -2
- package/dist/esm/graphql/fragments/variant.generated.js +4 -2
- package/dist/esm/graphql/mutations/page-view-up.generated.js +6 -4
- package/dist/esm/graphql/queries/articles.generated.js +59 -0
- package/dist/esm/graphql/queries/blogs.generated.js +67 -0
- package/dist/esm/graphql/queries/collection-detail-filter.generated.js +22 -10
- package/dist/esm/graphql/queries/collection.generated.js +18 -8
- package/dist/esm/graphql/queries/collections.generated.js +8 -3
- package/dist/esm/graphql/queries/preview-page.generated.js +16 -10
- package/dist/esm/graphql/queries/product-little-detail.generated.js +12 -5
- package/dist/esm/graphql/queries/product-medias.generated.js +6 -2
- package/dist/esm/graphql/queries/product-value-label.generated.js +4 -2
- package/dist/esm/graphql/queries/product-variants.generated.js +10 -4
- package/dist/esm/graphql/queries/products.generated.js +20 -9
- package/dist/esm/graphql/queries/published-shop-metas.js +13 -0
- package/dist/esm/graphql/queries/published-theme-pages.generated.js +20 -9
- package/dist/esm/graphql/queries/store-property.generated.js +4 -2
- package/dist/esm/graphql-app-api/queries/LibrarySaleFunnelDiscount.generated.js +4 -2
- package/dist/esm/graphql-app-api/queries/LibraryTemplate.generated.js +4 -2
- package/dist/esm/graphql-app-api/queries/SaleFunnelDiscounts.generated.js +4 -2
- package/dist/esm/graphql-app-api/queries/ShopLibraryPage.generated.js +15 -0
- package/dist/esm/graphql-app-api/queries/ThemePage.generated.js +4 -2
- package/dist/esm/helpers/GlobalEvent.js +15 -1
- package/dist/esm/helpers/align.js +17 -0
- package/dist/esm/helpers/animations.js +220 -1
- package/dist/esm/helpers/background.js +226 -1
- package/dist/esm/helpers/borders.js +189 -4
- package/dist/esm/helpers/carousel.js +51 -1
- package/dist/esm/helpers/clone-deep.js +3 -1
- package/dist/esm/helpers/cls.js +14 -1
- package/dist/esm/helpers/colors.js +169 -1
- package/dist/esm/helpers/compose-advance-style.js +319 -1
- package/dist/esm/helpers/constant.js +19 -1
- package/dist/esm/helpers/convert.js +4 -1
- package/dist/esm/helpers/covert-entities-html.js +17 -1
- package/dist/esm/helpers/css-variable.js +5 -1
- package/dist/esm/helpers/email.js +6 -1
- package/dist/esm/helpers/filter-toolbar-preview.js +9 -1
- package/dist/esm/helpers/flatten-connection.js +7 -1
- package/dist/esm/helpers/get-resonsive-value.js +31 -1
- package/dist/esm/helpers/get-shortname.js +90 -1
- package/dist/esm/helpers/icon-list.js +58 -1
- package/dist/esm/helpers/interaction/index.js +132 -0
- package/dist/esm/helpers/is-browser.js +5 -1
- package/dist/esm/helpers/is-defined.js +5 -1
- package/dist/esm/helpers/is-empty-children.js +10 -1
- package/dist/esm/helpers/is-safari.js +5 -1
- package/dist/esm/helpers/layout.js +54 -1
- package/dist/esm/helpers/load-script.js +29 -1
- package/dist/esm/helpers/loop-component.js +14 -0
- package/dist/esm/helpers/make-style.js +149 -1
- package/dist/esm/helpers/normalize-builder-data.js +21 -1
- package/dist/esm/helpers/pascal-to-kebab-case.js +5 -0
- package/dist/esm/helpers/prefetch-queries.js +76 -1
- package/dist/esm/helpers/product.js +44 -1
- package/dist/esm/helpers/queries/get-collection.js +223 -1
- package/dist/esm/helpers/queries/get-collections.js +19 -1
- package/dist/esm/helpers/queries/get-product-by-slug.js +123 -1
- package/dist/esm/helpers/queries/get-product.js +150 -1
- package/dist/esm/helpers/queries/get-products.js +210 -1
- package/dist/esm/helpers/query.js +25 -1
- package/dist/esm/helpers/radius.js +132 -6
- package/dist/esm/helpers/render.js +70 -1
- package/dist/esm/helpers/shadow.js +63 -1
- package/dist/esm/helpers/size.js +192 -4
- package/dist/esm/helpers/spacing.js +40 -1
- package/dist/esm/helpers/third-party/addAppBlockId.js +18 -0
- package/dist/esm/helpers/third-party/appConfig.js +200 -0
- package/dist/esm/helpers/third-party/appSetting.js +658 -0
- package/dist/esm/helpers/third-party/composeAppBlockId.js +9 -0
- package/dist/esm/helpers/third-party/constant.js +40 -0
- package/dist/esm/helpers/third-party/generateAppBlockConfigs.js +32 -0
- package/dist/esm/helpers/third-party/getAppBlockConfig.js +45 -0
- package/dist/esm/helpers/third-party/getAppBlockType.js +10 -0
- package/dist/esm/helpers/third-party/getAppBlocks.js +28 -0
- package/dist/esm/helpers/third-party/mergeBlock.js +17 -0
- package/dist/esm/helpers/third-party/mergeBlockOrder.js +45 -0
- package/dist/esm/helpers/third-party/removeGPAppItems.js +15 -0
- package/dist/esm/helpers/tracking/fpixel.js +24 -1
- package/dist/esm/helpers/tracking/gtag.js +87 -1
- package/dist/esm/helpers/tracking/tiktokpixel.js +15 -1
- package/dist/esm/helpers/typography.js +149 -17
- package/dist/esm/helpers/variant.js +9 -1
- package/dist/esm/hooks/animation/useAnimationActions.js +37 -1
- package/dist/esm/hooks/animation/useAnimationConfig.js +28 -1
- package/dist/esm/hooks/animation/useAnimationPreview.js +29 -1
- package/dist/esm/hooks/animation/useAnimationTarget.js +120 -1
- package/dist/esm/hooks/animation/useApplyAnimation.js +85 -1
- package/dist/esm/hooks/articles/useArticlesQuery.js +30 -1
- package/dist/esm/hooks/cart/use-add-to-cart.js +18 -1
- package/dist/esm/hooks/cart/use-cart-data.js +26 -1
- package/dist/esm/hooks/cart/use-cart-discount-codes-update.js +18 -1
- package/dist/esm/hooks/cart/use-cart-note-update.js +18 -1
- package/dist/esm/hooks/cart/use-create-cart.js +20 -1
- package/dist/esm/hooks/cart/use-remove-cart-item.js +18 -1
- package/dist/esm/hooks/cart/use-update-cart-item.js +18 -1
- package/dist/esm/hooks/shop/use-collection-query.js +20 -1
- package/dist/esm/hooks/shop/use-collections-query.js +15 -1
- package/dist/esm/hooks/shop/use-product-query.js +20 -1
- package/dist/esm/hooks/shop/use-products-query.js +59 -1
- package/dist/esm/hooks/shop.js +111 -1
- package/dist/esm/hooks/use-current-device.js +28 -1
- package/dist/esm/hooks/use-lazy-video.js +13 -1
- package/dist/esm/hooks/useAnimations.js +27 -1
- package/dist/esm/hooks/useCartId.js +40 -1
- package/dist/esm/hooks/useCartLine.js +7 -1
- package/dist/esm/hooks/useCartUI.js +44 -1
- package/dist/esm/hooks/useCollection.js +7 -1
- package/dist/esm/hooks/useFetchHandle.js +11 -1
- package/dist/esm/hooks/useFormatMoney.js +71 -1
- package/dist/esm/hooks/useInitialSwatchesOptions.js +124 -1
- package/dist/esm/hooks/useInteraction.js +17 -0
- package/dist/esm/hooks/useIsomorphicLayoutEffect.js +6 -1
- package/dist/esm/hooks/useLoadScript.js +28 -1
- package/dist/esm/hooks/useMoney.js +80 -1
- package/dist/esm/hooks/usePrevious.js +17 -1
- package/dist/esm/hooks/useProduct.js +228 -1
- package/dist/esm/hooks/useProductList.js +16 -1
- package/dist/esm/hooks/useSuspenseFetch.js +23 -1
- package/dist/esm/hooks/useSwatchesOptions.js +37 -1
- package/dist/esm/hooks/useToolbarPostPurchase.js +87 -1
- package/dist/esm/index.js +117 -1
- package/dist/esm/types/animations.js +49 -1
- package/dist/esm/types/custom.js +52 -0
- package/dist/esm/types/global-style.js +12 -1
- package/dist/esm/web-components/src/helpers/styles/constant.js +7 -1
- package/dist/types/index.d.ts +23183 -17335
- package/package.json +5 -3
- package/dist/cjs/components/animation/AnimationWrapper.js +0 -1
- package/dist/cjs/hooks/animation/animations.js +0 -1
- package/dist/cjs/hooks/animation/useLivePageAnimation.js +0 -1
- package/dist/esm/components/animation/AnimationWrapper.js +0 -1
- package/dist/esm/hooks/animation/animations.js +0 -1
- package/dist/esm/hooks/animation/useLivePageAnimation.js +0 -1
|
@@ -1 +1,223 @@
|
|
|
1
|
-
import{CollectionDetailFilterDocument
|
|
1
|
+
import { CollectionDetailFilterDocument } from '../../graphql/queries/collection-detail-filter.generated.js';
|
|
2
|
+
import { ProductVariantsDocument } from '../../graphql/queries/product-variants.generated.js';
|
|
3
|
+
import { isDefined } from '../is-defined.js';
|
|
4
|
+
|
|
5
|
+
const PRODUCT_PER_PAGE = 8; // number of products per page
|
|
6
|
+
function productSortedByOrder(key) {
|
|
7
|
+
switch(key){
|
|
8
|
+
case 'TITLE_ASC':
|
|
9
|
+
return {
|
|
10
|
+
direction: 'ASC',
|
|
11
|
+
field: 'TITLE'
|
|
12
|
+
};
|
|
13
|
+
case 'TITLE_DESC':
|
|
14
|
+
return {
|
|
15
|
+
direction: 'DESC',
|
|
16
|
+
field: 'TITLE'
|
|
17
|
+
};
|
|
18
|
+
case 'CREATED_AT_ASC':
|
|
19
|
+
return {
|
|
20
|
+
direction: 'ASC',
|
|
21
|
+
field: 'CREATED_AT'
|
|
22
|
+
};
|
|
23
|
+
case 'CREATED_AT_DESC':
|
|
24
|
+
return {
|
|
25
|
+
direction: 'DESC',
|
|
26
|
+
field: 'CREATED_AT'
|
|
27
|
+
};
|
|
28
|
+
case 'none':
|
|
29
|
+
default:
|
|
30
|
+
return {
|
|
31
|
+
direction: 'ASC',
|
|
32
|
+
field: 'TITLE'
|
|
33
|
+
};
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
const getCollection = async (fetcher, arg)=>{
|
|
37
|
+
const collections = await loopFetchCollection(fetcher, arg);
|
|
38
|
+
if (!collections) {
|
|
39
|
+
throw new Error('collections not found');
|
|
40
|
+
}
|
|
41
|
+
// merge product collection variant
|
|
42
|
+
const mergeProducts = await mergeProductCollectionVariant(fetcher, collections, arg.isSample);
|
|
43
|
+
return mergeProducts;
|
|
44
|
+
};
|
|
45
|
+
const fetchCollection = async (fetcher, variables)=>{
|
|
46
|
+
return fetcher([
|
|
47
|
+
CollectionDetailFilterDocument,
|
|
48
|
+
variables
|
|
49
|
+
]);
|
|
50
|
+
};
|
|
51
|
+
const calculateFirstProduct = (numberOfProducts, currentPage, productsPerPage)=>{
|
|
52
|
+
const remainingProducts = numberOfProducts - productsPerPage * currentPage;
|
|
53
|
+
if (numberOfProducts < productsPerPage) return numberOfProducts;
|
|
54
|
+
return remainingProducts > 0 ? productsPerPage : productsPerPage + remainingProducts;
|
|
55
|
+
};
|
|
56
|
+
const chunkArray = (array, size)=>{
|
|
57
|
+
const chunked_arr = [];
|
|
58
|
+
let index = 0;
|
|
59
|
+
while(index < array.length){
|
|
60
|
+
chunked_arr.push(array.slice(index, size + index));
|
|
61
|
+
index += size;
|
|
62
|
+
}
|
|
63
|
+
return chunked_arr;
|
|
64
|
+
};
|
|
65
|
+
const loopFetchCollection = async (fetcher, arg)=>{
|
|
66
|
+
let variables; // variables of collection query
|
|
67
|
+
let productAfterFetcher; // product after of collection query
|
|
68
|
+
let dataCollection; // data of collection query
|
|
69
|
+
let hasNextPage; //
|
|
70
|
+
let firstCollection;
|
|
71
|
+
let currentPage = 1;
|
|
72
|
+
if (arg.numberOfProducts) {
|
|
73
|
+
const pages = Math.ceil(arg.numberOfProducts / PRODUCT_PER_PAGE);
|
|
74
|
+
while(currentPage <= pages && hasNextPage !== false){
|
|
75
|
+
variables = {
|
|
76
|
+
firstVariant: 1,
|
|
77
|
+
firstMedia: 30,
|
|
78
|
+
orderBy: {
|
|
79
|
+
field: 'PLATFORM_CREATED_AT',
|
|
80
|
+
direction: 'DESC'
|
|
81
|
+
},
|
|
82
|
+
orderByMedia: {
|
|
83
|
+
field: 'POSITION',
|
|
84
|
+
direction: 'ASC'
|
|
85
|
+
},
|
|
86
|
+
firstProduct: calculateFirstProduct(arg.numberOfProducts, currentPage, PRODUCT_PER_PAGE),
|
|
87
|
+
...!arg.id || arg.id.toLowerCase() === 'latest' ? {
|
|
88
|
+
where: {
|
|
89
|
+
hasCollectionProducts: true,
|
|
90
|
+
isSample: arg.isSample
|
|
91
|
+
}
|
|
92
|
+
} : {
|
|
93
|
+
where: {
|
|
94
|
+
baseID: arg.id
|
|
95
|
+
}
|
|
96
|
+
},
|
|
97
|
+
orderByProduct: productSortedByOrder(arg.orderBy),
|
|
98
|
+
whereProduct: {
|
|
99
|
+
status: 'ACTIVE',
|
|
100
|
+
...arg.isStorefront && {
|
|
101
|
+
isStorefront: arg.isStorefront
|
|
102
|
+
},
|
|
103
|
+
isSample: arg.isSample
|
|
104
|
+
},
|
|
105
|
+
...productAfterFetcher ? {
|
|
106
|
+
productsAfter: productAfterFetcher
|
|
107
|
+
} : undefined
|
|
108
|
+
};
|
|
109
|
+
const pageData = await fetchCollection(fetcher, variables);
|
|
110
|
+
productAfterFetcher = pageData?.collections?.edges?.[0]?.node?.products?.pageInfo?.endCursor;
|
|
111
|
+
if (currentPage === 1) {
|
|
112
|
+
dataCollection = pageData; // set data of first page
|
|
113
|
+
firstCollection = dataCollection?.collections?.edges?.[0];
|
|
114
|
+
} else if (firstCollection?.node?.products && pageData?.collections?.edges?.[0]?.node?.products?.edges) {
|
|
115
|
+
// concat new values to the old ones
|
|
116
|
+
firstCollection.node.products = {
|
|
117
|
+
pageInfo: pageData?.collections?.edges?.[0]?.node?.products?.pageInfo,
|
|
118
|
+
edges: firstCollection.node?.products?.edges.concat(pageData?.collections?.edges?.[0]?.node?.products?.edges)
|
|
119
|
+
};
|
|
120
|
+
}
|
|
121
|
+
currentPage++;
|
|
122
|
+
// hasNextPage = false if there is no more pages then break the loop
|
|
123
|
+
if (!firstCollection?.node?.products?.pageInfo?.hasNextPage) {
|
|
124
|
+
hasNextPage = false;
|
|
125
|
+
break;
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
return dataCollection;
|
|
129
|
+
}
|
|
130
|
+
};
|
|
131
|
+
const mergeProductCollectionVariant = async (fetcher, collection, isSample)=>{
|
|
132
|
+
const node = collection?.collections?.edges?.[0]?.node;
|
|
133
|
+
if (!node) return collection;
|
|
134
|
+
const productList = node?.products?.edges;
|
|
135
|
+
const listBaseId = productList?.map((product)=>product?.node?.baseID).filter(isDefined);
|
|
136
|
+
const ProductListWithVariants = await fetchVariantsByBaseIds(fetcher, {
|
|
137
|
+
ids: listBaseId,
|
|
138
|
+
isSample
|
|
139
|
+
});
|
|
140
|
+
// mapping variant to product list in collections
|
|
141
|
+
const newProductList = productList?.map((product)=>{
|
|
142
|
+
const productVariants = ProductListWithVariants?.variants?.edges?.filter((productV)=>productV?.node?.id === product?.node?.id);
|
|
143
|
+
return {
|
|
144
|
+
...product,
|
|
145
|
+
node: product.node ? {
|
|
146
|
+
...product.node,
|
|
147
|
+
variants: product.node?.variants ? {
|
|
148
|
+
...product.node?.variants,
|
|
149
|
+
edges: productVariants?.[0]?.node?.variants?.edges ?? product.node?.variants.edges ?? []
|
|
150
|
+
} : undefined
|
|
151
|
+
} : undefined
|
|
152
|
+
};
|
|
153
|
+
}) ?? [];
|
|
154
|
+
const newCollection = {
|
|
155
|
+
...collection,
|
|
156
|
+
collections: {
|
|
157
|
+
edges: [
|
|
158
|
+
{
|
|
159
|
+
node: {
|
|
160
|
+
...node,
|
|
161
|
+
products: {
|
|
162
|
+
edges: newProductList
|
|
163
|
+
}
|
|
164
|
+
},
|
|
165
|
+
cursor: undefined
|
|
166
|
+
}
|
|
167
|
+
]
|
|
168
|
+
}
|
|
169
|
+
};
|
|
170
|
+
return newCollection;
|
|
171
|
+
};
|
|
172
|
+
const fetchVariantsByBaseIds = async (fetcher, { ids, isSample, isStorefront })=>{
|
|
173
|
+
const chunkedIds = chunkArray(ids ?? [], 8);
|
|
174
|
+
const defaultEdges = [];
|
|
175
|
+
const query = async (variables)=>{
|
|
176
|
+
try {
|
|
177
|
+
return await fetcher([
|
|
178
|
+
ProductVariantsDocument,
|
|
179
|
+
{
|
|
180
|
+
...variables,
|
|
181
|
+
orderByVariant: {
|
|
182
|
+
field: 'POSITION',
|
|
183
|
+
direction: 'ASC'
|
|
184
|
+
}
|
|
185
|
+
}
|
|
186
|
+
]);
|
|
187
|
+
} catch {
|
|
188
|
+
return {};
|
|
189
|
+
}
|
|
190
|
+
};
|
|
191
|
+
const promises = chunkedIds.map((chunkedId)=>{
|
|
192
|
+
const variables = {
|
|
193
|
+
firstVariant: 100,
|
|
194
|
+
first: chunkedId.length,
|
|
195
|
+
orderBy: {
|
|
196
|
+
field: 'TITLE',
|
|
197
|
+
direction: 'ASC'
|
|
198
|
+
},
|
|
199
|
+
where: {
|
|
200
|
+
status: 'ACTIVE',
|
|
201
|
+
isSample,
|
|
202
|
+
...isStorefront && {
|
|
203
|
+
isStorefront
|
|
204
|
+
},
|
|
205
|
+
...chunkedId.length && {
|
|
206
|
+
baseIDIn: chunkedId.sort()
|
|
207
|
+
}
|
|
208
|
+
}
|
|
209
|
+
};
|
|
210
|
+
return query(variables);
|
|
211
|
+
});
|
|
212
|
+
const responses = await Promise.all(promises);
|
|
213
|
+
const edges = responses?.reduce((acc, response)=>{
|
|
214
|
+
return acc.concat(response?.variants?.edges ?? []);
|
|
215
|
+
}, defaultEdges);
|
|
216
|
+
return {
|
|
217
|
+
variants: {
|
|
218
|
+
edges
|
|
219
|
+
}
|
|
220
|
+
};
|
|
221
|
+
};
|
|
222
|
+
|
|
223
|
+
export { calculateFirstProduct, getCollection };
|
|
@@ -1 +1,19 @@
|
|
|
1
|
-
import{CollectionsDocument
|
|
1
|
+
import { CollectionsDocument } from '../../graphql/queries/collections.generated.js';
|
|
2
|
+
|
|
3
|
+
const getCollections = async (fetcher, variable)=>{
|
|
4
|
+
const collections = await fetchCollections(fetcher, variable ?? {});
|
|
5
|
+
if (!collections) {
|
|
6
|
+
throw new Error('Collection not found');
|
|
7
|
+
}
|
|
8
|
+
return {
|
|
9
|
+
...collections
|
|
10
|
+
};
|
|
11
|
+
};
|
|
12
|
+
const fetchCollections = async (fetcher, variables)=>{
|
|
13
|
+
return fetcher([
|
|
14
|
+
CollectionsDocument,
|
|
15
|
+
variables
|
|
16
|
+
]);
|
|
17
|
+
};
|
|
18
|
+
|
|
19
|
+
export { getCollections };
|
|
@@ -1 +1,123 @@
|
|
|
1
|
-
import{ProductLittleDetailDocument
|
|
1
|
+
import { ProductLittleDetailDocument } from '../../graphql/queries/product-little-detail.generated.js';
|
|
2
|
+
import { ProductMediasDocument } from '../../graphql/queries/product-medias.generated.js';
|
|
3
|
+
import { ProductVariantsDocument } from '../../graphql/queries/product-variants.generated.js';
|
|
4
|
+
|
|
5
|
+
const getProductBySlug = async (fetcher, slug)=>{
|
|
6
|
+
const [product, variants, medias] = await Promise.all([
|
|
7
|
+
fetchProduct(fetcher, slug),
|
|
8
|
+
fetchVariants(fetcher, slug),
|
|
9
|
+
fetchMedias(fetcher, slug)
|
|
10
|
+
]);
|
|
11
|
+
if (!product) {
|
|
12
|
+
throw new Error('Product not found');
|
|
13
|
+
}
|
|
14
|
+
return {
|
|
15
|
+
...product,
|
|
16
|
+
variants: {
|
|
17
|
+
edges: variants
|
|
18
|
+
},
|
|
19
|
+
medias: {
|
|
20
|
+
edges: medias
|
|
21
|
+
}
|
|
22
|
+
};
|
|
23
|
+
};
|
|
24
|
+
const orderBy = {
|
|
25
|
+
field: 'PLATFORM_UPDATED_AT',
|
|
26
|
+
direction: 'DESC'
|
|
27
|
+
};
|
|
28
|
+
const fetchProduct = async (fetcher, handle, isStorefront)=>{
|
|
29
|
+
const variables = {
|
|
30
|
+
orderBy,
|
|
31
|
+
where: {
|
|
32
|
+
status: 'ACTIVE',
|
|
33
|
+
handle,
|
|
34
|
+
...isStorefront && {
|
|
35
|
+
isStorefront
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
};
|
|
39
|
+
const response = await fetcher([
|
|
40
|
+
ProductLittleDetailDocument,
|
|
41
|
+
variables
|
|
42
|
+
]);
|
|
43
|
+
return response.product?.edges?.[0]?.node;
|
|
44
|
+
};
|
|
45
|
+
const fetchVariants = async (fetcher, handle, isStorefront)=>{
|
|
46
|
+
const initVariables = {
|
|
47
|
+
orderBy,
|
|
48
|
+
orderByVariant: {
|
|
49
|
+
field: 'POSITION',
|
|
50
|
+
direction: 'ASC'
|
|
51
|
+
},
|
|
52
|
+
where: {
|
|
53
|
+
status: 'ACTIVE',
|
|
54
|
+
handle,
|
|
55
|
+
...isStorefront && {
|
|
56
|
+
isStorefront
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
};
|
|
60
|
+
const query = async (variables, olds)=>{
|
|
61
|
+
try {
|
|
62
|
+
const response = await fetcher([
|
|
63
|
+
ProductVariantsDocument,
|
|
64
|
+
variables
|
|
65
|
+
]);
|
|
66
|
+
const product = response.variants?.edges?.[0];
|
|
67
|
+
const items = olds?.concat(product?.node?.variants?.edges ?? []);
|
|
68
|
+
if (product?.node?.variants?.pageInfo?.hasNextPage) {
|
|
69
|
+
return query({
|
|
70
|
+
...variables,
|
|
71
|
+
afterVariant: product?.node?.variants?.pageInfo.endCursor
|
|
72
|
+
}, items);
|
|
73
|
+
}
|
|
74
|
+
return items ?? [];
|
|
75
|
+
} catch {
|
|
76
|
+
return olds ?? [];
|
|
77
|
+
}
|
|
78
|
+
};
|
|
79
|
+
return query(initVariables, []);
|
|
80
|
+
};
|
|
81
|
+
const fetchMedias = async (fetcher, handle, isStorefront)=>{
|
|
82
|
+
const initVariables = {
|
|
83
|
+
orderBy,
|
|
84
|
+
where: {
|
|
85
|
+
status: 'ACTIVE',
|
|
86
|
+
handle,
|
|
87
|
+
...isStorefront && {
|
|
88
|
+
isStorefront
|
|
89
|
+
}
|
|
90
|
+
},
|
|
91
|
+
orderByMedia: {
|
|
92
|
+
field: 'POSITION',
|
|
93
|
+
direction: 'ASC'
|
|
94
|
+
}
|
|
95
|
+
};
|
|
96
|
+
const query = async (variables)=>{
|
|
97
|
+
try {
|
|
98
|
+
const response = await fetcher([
|
|
99
|
+
ProductMediasDocument,
|
|
100
|
+
variables
|
|
101
|
+
]);
|
|
102
|
+
const product = response.medias?.edges?.[0];
|
|
103
|
+
const items = product?.node?.medias?.edges ?? [];
|
|
104
|
+
if (product?.node?.medias?.pageInfo?.hasNextPage) {
|
|
105
|
+
try {
|
|
106
|
+
const newData = await query({
|
|
107
|
+
...variables,
|
|
108
|
+
afterMedia: product?.node?.medias?.pageInfo.endCursor
|
|
109
|
+
});
|
|
110
|
+
return items.concat(newData);
|
|
111
|
+
} catch {
|
|
112
|
+
return items;
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
return items;
|
|
116
|
+
} catch {
|
|
117
|
+
return [];
|
|
118
|
+
}
|
|
119
|
+
};
|
|
120
|
+
return query(initVariables);
|
|
121
|
+
};
|
|
122
|
+
|
|
123
|
+
export { getProductBySlug };
|
|
@@ -1 +1,150 @@
|
|
|
1
|
-
import{ProductLittleDetailDocument
|
|
1
|
+
import { ProductLittleDetailDocument } from '../../graphql/queries/product-little-detail.generated.js';
|
|
2
|
+
import { ProductMediasDocument } from '../../graphql/queries/product-medias.generated.js';
|
|
3
|
+
import { ProductVariantsDocument } from '../../graphql/queries/product-variants.generated.js';
|
|
4
|
+
|
|
5
|
+
const getProduct = async (fetcher, { id, isSample, isStorefront })=>{
|
|
6
|
+
const [product, variants, medias] = await Promise.all([
|
|
7
|
+
fetchProduct(fetcher, {
|
|
8
|
+
id,
|
|
9
|
+
isSample,
|
|
10
|
+
isStorefront
|
|
11
|
+
}),
|
|
12
|
+
fetchVariants(fetcher, {
|
|
13
|
+
id,
|
|
14
|
+
isSample,
|
|
15
|
+
isStorefront
|
|
16
|
+
}),
|
|
17
|
+
fetchMedias(fetcher, {
|
|
18
|
+
id,
|
|
19
|
+
isSample,
|
|
20
|
+
isStorefront
|
|
21
|
+
})
|
|
22
|
+
]);
|
|
23
|
+
if (!product) {
|
|
24
|
+
throw new Error('Product not found');
|
|
25
|
+
}
|
|
26
|
+
return {
|
|
27
|
+
...product,
|
|
28
|
+
variants: {
|
|
29
|
+
edges: variants
|
|
30
|
+
},
|
|
31
|
+
medias: {
|
|
32
|
+
edges: medias
|
|
33
|
+
}
|
|
34
|
+
};
|
|
35
|
+
};
|
|
36
|
+
const orderBy = {
|
|
37
|
+
field: 'CREATED_AT',
|
|
38
|
+
direction: 'DESC'
|
|
39
|
+
};
|
|
40
|
+
const fetchProduct = async (fetcher, { id, isSample, isStorefront })=>{
|
|
41
|
+
const variables = {
|
|
42
|
+
orderBy,
|
|
43
|
+
where: {
|
|
44
|
+
isSample,
|
|
45
|
+
...isStorefront && {
|
|
46
|
+
isStorefront
|
|
47
|
+
},
|
|
48
|
+
...(!id || id && id.toLowerCase() == 'latest') && {
|
|
49
|
+
status: 'ACTIVE'
|
|
50
|
+
},
|
|
51
|
+
...id && id.toLowerCase() !== 'latest' && {
|
|
52
|
+
baseID: id
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
};
|
|
56
|
+
const response = await fetcher([
|
|
57
|
+
ProductLittleDetailDocument,
|
|
58
|
+
variables
|
|
59
|
+
]);
|
|
60
|
+
return response.product?.edges?.[0]?.node;
|
|
61
|
+
};
|
|
62
|
+
const fetchVariants = async (fetcher, { id, isSample, isStorefront })=>{
|
|
63
|
+
const initVariables = {
|
|
64
|
+
orderBy,
|
|
65
|
+
where: {
|
|
66
|
+
isSample,
|
|
67
|
+
...isStorefront && {
|
|
68
|
+
isStorefront
|
|
69
|
+
},
|
|
70
|
+
...(!id || id && id.toLowerCase() == 'latest') && {
|
|
71
|
+
status: 'ACTIVE'
|
|
72
|
+
},
|
|
73
|
+
...id && id.toLowerCase() !== 'latest' && {
|
|
74
|
+
baseID: id
|
|
75
|
+
}
|
|
76
|
+
},
|
|
77
|
+
orderByVariant: {
|
|
78
|
+
field: 'POSITION',
|
|
79
|
+
direction: 'ASC'
|
|
80
|
+
}
|
|
81
|
+
};
|
|
82
|
+
const query = async (variables, olds)=>{
|
|
83
|
+
try {
|
|
84
|
+
const response = await fetcher([
|
|
85
|
+
ProductVariantsDocument,
|
|
86
|
+
variables
|
|
87
|
+
]);
|
|
88
|
+
const product = response.variants?.edges?.[0];
|
|
89
|
+
const items = olds?.concat(product?.node?.variants?.edges ?? []);
|
|
90
|
+
if (product?.node?.variants?.pageInfo?.hasNextPage) {
|
|
91
|
+
return query({
|
|
92
|
+
...variables,
|
|
93
|
+
afterVariant: product?.node?.variants?.pageInfo.endCursor
|
|
94
|
+
}, items);
|
|
95
|
+
}
|
|
96
|
+
return items ?? [];
|
|
97
|
+
} catch {
|
|
98
|
+
return olds ?? [];
|
|
99
|
+
}
|
|
100
|
+
};
|
|
101
|
+
return query(initVariables, []);
|
|
102
|
+
};
|
|
103
|
+
const fetchMedias = async (fetcher, { id, isSample, isStorefront })=>{
|
|
104
|
+
const initVariables = {
|
|
105
|
+
orderBy,
|
|
106
|
+
where: {
|
|
107
|
+
isSample,
|
|
108
|
+
...isStorefront && {
|
|
109
|
+
isStorefront
|
|
110
|
+
},
|
|
111
|
+
...(!id || id && id.toLowerCase() == 'latest') && {
|
|
112
|
+
status: 'ACTIVE'
|
|
113
|
+
},
|
|
114
|
+
...id && id.toLowerCase() !== 'latest' && {
|
|
115
|
+
baseID: id
|
|
116
|
+
}
|
|
117
|
+
},
|
|
118
|
+
orderByMedia: {
|
|
119
|
+
field: 'POSITION',
|
|
120
|
+
direction: 'ASC'
|
|
121
|
+
}
|
|
122
|
+
};
|
|
123
|
+
const query = async (variables)=>{
|
|
124
|
+
try {
|
|
125
|
+
const response = await fetcher([
|
|
126
|
+
ProductMediasDocument,
|
|
127
|
+
variables
|
|
128
|
+
]);
|
|
129
|
+
const product = response.medias?.edges?.[0];
|
|
130
|
+
const items = product?.node?.medias?.edges ?? [];
|
|
131
|
+
if (product?.node?.medias?.pageInfo?.hasNextPage) {
|
|
132
|
+
try {
|
|
133
|
+
const newData = await query({
|
|
134
|
+
...variables,
|
|
135
|
+
afterMedia: product?.node?.medias?.pageInfo.endCursor
|
|
136
|
+
});
|
|
137
|
+
return items.concat(newData);
|
|
138
|
+
} catch {
|
|
139
|
+
return items;
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
return items;
|
|
143
|
+
} catch {
|
|
144
|
+
return [];
|
|
145
|
+
}
|
|
146
|
+
};
|
|
147
|
+
return query(initVariables);
|
|
148
|
+
};
|
|
149
|
+
|
|
150
|
+
export { fetchMedias, fetchVariants, getProduct };
|