@gem-sdk/core 3.0.0-pre-production.14 → 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 +3 -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 +3 -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,78 +1 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
var useSWR = require('swr');
|
|
4
|
-
var getCollection = require('./queries/get-collection.js');
|
|
5
|
-
var getProduct = require('./queries/get-product.js');
|
|
6
|
-
var getProducts = require('./queries/get-products.js');
|
|
7
|
-
var query = require('./query.js');
|
|
8
|
-
|
|
9
|
-
const prefetchQueries = (input, options)=>{
|
|
10
|
-
const queries = [];
|
|
11
|
-
Object.keys(input).forEach((key)=>{
|
|
12
|
-
const item = input[key];
|
|
13
|
-
let data = undefined;
|
|
14
|
-
switch(item.tag){
|
|
15
|
-
case 'Product':
|
|
16
|
-
{
|
|
17
|
-
if (item.settings?.isAuto) break;
|
|
18
|
-
const variables = {
|
|
19
|
-
id: item.settings?.productSetting?.productId ?? 'latest',
|
|
20
|
-
isSample: options?.isSample,
|
|
21
|
-
isStorefront: options?.isStorefront
|
|
22
|
-
};
|
|
23
|
-
data = {
|
|
24
|
-
key: useSWR.unstable_serialize(query.generateProductQueryKey(variables)),
|
|
25
|
-
func: getProduct.getProduct,
|
|
26
|
-
variables
|
|
27
|
-
};
|
|
28
|
-
break;
|
|
29
|
-
}
|
|
30
|
-
case 'ProductList':
|
|
31
|
-
{
|
|
32
|
-
const productSetting = item.settings?.productSetting;
|
|
33
|
-
if (productSetting?.productSrc === 'Collection') {
|
|
34
|
-
const variables = {
|
|
35
|
-
id: productSetting?.collectionId ?? 'latest',
|
|
36
|
-
numberOfProducts: item.settings?.numberOfProducts ?? 4,
|
|
37
|
-
orderBy: item.settings?.orderBy,
|
|
38
|
-
isSample: options?.isSample,
|
|
39
|
-
isStorefront: options?.isStorefront
|
|
40
|
-
};
|
|
41
|
-
data = {
|
|
42
|
-
key: useSWR.unstable_serialize(query.generateCollectionQueryKey(variables)),
|
|
43
|
-
func: getCollection.getCollection,
|
|
44
|
-
variables
|
|
45
|
-
};
|
|
46
|
-
} else {
|
|
47
|
-
const variables = {
|
|
48
|
-
ids: [
|
|
49
|
-
...productSetting?.productIds ?? []
|
|
50
|
-
].sort(),
|
|
51
|
-
isSample: options?.isSample,
|
|
52
|
-
isStorefront: options?.isStorefront
|
|
53
|
-
};
|
|
54
|
-
data = {
|
|
55
|
-
key: useSWR.unstable_serialize(query.generateProductsQueryKey(variables)),
|
|
56
|
-
func: getProducts.getProducts,
|
|
57
|
-
variables
|
|
58
|
-
};
|
|
59
|
-
}
|
|
60
|
-
break;
|
|
61
|
-
}
|
|
62
|
-
}
|
|
63
|
-
if (data) {
|
|
64
|
-
queries.push(data);
|
|
65
|
-
}
|
|
66
|
-
});
|
|
67
|
-
return queries.reduce((accumulator, current)=>{
|
|
68
|
-
if (!accumulator.some((x)=>x.key === current.key)) {
|
|
69
|
-
return [
|
|
70
|
-
...accumulator,
|
|
71
|
-
current
|
|
72
|
-
];
|
|
73
|
-
}
|
|
74
|
-
return accumulator;
|
|
75
|
-
}, []);
|
|
76
|
-
};
|
|
77
|
-
|
|
78
|
-
exports.prefetchQueries = prefetchQueries;
|
|
1
|
+
"use strict";var useSWR=require("swr"),getCollection=require("./queries/get-collection.js"),getProduct=require("./queries/get-product.js"),getProducts=require("./queries/get-products.js"),query=require("./query.js");const prefetchQueries=(e,t)=>{let r=[];return Object.keys(e).forEach(s=>{let u;let o=e[s];switch(o.tag){case"Product":{if(o.settings?.isAuto)break;let e={id:o.settings?.productSetting?.productId??"latest",isSample:t?.isSample,isStorefront:t?.isStorefront};u={key:useSWR.unstable_serialize(query.generateProductQueryKey(e)),func:getProduct.getProduct,variables:e};break}case"ProductList":{let e=o.settings?.productSetting;if(e?.productSrc==="Collection"){let r={id:e?.collectionId??"latest",numberOfProducts:o.settings?.numberOfProducts??4,orderBy:o.settings?.orderBy,isSample:t?.isSample,isStorefront:t?.isStorefront};u={key:useSWR.unstable_serialize(query.generateCollectionQueryKey(r)),func:getCollection.getCollection,variables:r}}else{let r={ids:[...e?.productIds??[]].sort(),isSample:t?.isSample,isStorefront:t?.isStorefront};u={key:useSWR.unstable_serialize(query.generateProductsQueryKey(r)),func:getProducts.getProducts,variables:r}}}}u&&r.push(u)}),r.reduce((e,t)=>e.some(e=>e.key===t.key)?e:[...e,t],[])};exports.prefetchQueries=prefetchQueries;
|
|
@@ -1,48 +1 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
var variant = require('./variant.js');
|
|
4
|
-
|
|
5
|
-
function getSelectedVariant(variants, choices, variantId) {
|
|
6
|
-
/**
|
|
7
|
-
* Ensure the user has selected all the required options, not just some.
|
|
8
|
-
*/ if (!variants || !variants.length || !choices || variants[0]?.selectedOptions.length !== Object.keys(choices).length) {
|
|
9
|
-
return;
|
|
10
|
-
}
|
|
11
|
-
if (variantId) {
|
|
12
|
-
return variants.find((variant)=>variant?.id === variantId);
|
|
13
|
-
}
|
|
14
|
-
return variants.find((variant)=>{
|
|
15
|
-
return Object.entries(choices).every(([name, value])=>{
|
|
16
|
-
return variant?.selectedOptions.some((option)=>option.name === name && option.value === value);
|
|
17
|
-
});
|
|
18
|
-
});
|
|
19
|
-
}
|
|
20
|
-
function parseSelectedOption(options) {
|
|
21
|
-
if (!options || options && options.length === 0) {
|
|
22
|
-
return;
|
|
23
|
-
}
|
|
24
|
-
return options.reduce((acc, { name, value })=>{
|
|
25
|
-
if (name && value) {
|
|
26
|
-
return {
|
|
27
|
-
...acc,
|
|
28
|
-
[name]: value
|
|
29
|
-
};
|
|
30
|
-
}
|
|
31
|
-
return acc;
|
|
32
|
-
}, {});
|
|
33
|
-
}
|
|
34
|
-
function checkAvailableVariantInStock(variants, optionId, optionValue) {
|
|
35
|
-
return variants ? variants.some((item)=>{
|
|
36
|
-
if (item) {
|
|
37
|
-
const { selectedOptions } = item;
|
|
38
|
-
const opt = selectedOptions?.some((option)=>option?.name === optionId && option.value === optionValue);
|
|
39
|
-
const isInStock = variant.checkInStock(item);
|
|
40
|
-
return opt && isInStock;
|
|
41
|
-
}
|
|
42
|
-
return false;
|
|
43
|
-
}) : false;
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
exports.checkAvailableVariantInStock = checkAvailableVariantInStock;
|
|
47
|
-
exports.getSelectedVariant = getSelectedVariant;
|
|
48
|
-
exports.parseSelectedOption = parseSelectedOption;
|
|
1
|
+
"use strict";var variant=require("./variant.js");function getSelectedVariant(e,t,n){return e&&e.length&&t&&e[0]?.selectedOptions.length===Object.keys(t).length?n?e.find(e=>e?.id===n):e.find(e=>Object.entries(t).every(([t,n])=>e?.selectedOptions.some(e=>e.name===t&&e.value===n))):void 0}function parseSelectedOption(e){if(e&&(!e||0!==e.length))return e.reduce((e,{name:t,value:n})=>t&&n?{...e,[t]:n}:e,{})}function checkAvailableVariantInStock(e,t,n){return!!e&&e.some(e=>{if(e){let{selectedOptions:a}=e,r=a?.some(e=>e?.name===t&&e.value===n),i=variant.checkInStock(e);return r&&i}return!1})}exports.checkAvailableVariantInStock=checkAvailableVariantInStock,exports.getSelectedVariant=getSelectedVariant,exports.parseSelectedOption=parseSelectedOption;
|
|
@@ -1,226 +1 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
var collectionDetailFilter_generated = require('../../graphql/queries/collection-detail-filter.generated.js');
|
|
4
|
-
var productVariants_generated = require('../../graphql/queries/product-variants.generated.js');
|
|
5
|
-
var isDefined = require('../is-defined.js');
|
|
6
|
-
|
|
7
|
-
const PRODUCT_PER_PAGE = 8; // number of products per page
|
|
8
|
-
function productSortedByOrder(key) {
|
|
9
|
-
switch(key){
|
|
10
|
-
case 'TITLE_ASC':
|
|
11
|
-
return {
|
|
12
|
-
direction: 'ASC',
|
|
13
|
-
field: 'TITLE'
|
|
14
|
-
};
|
|
15
|
-
case 'TITLE_DESC':
|
|
16
|
-
return {
|
|
17
|
-
direction: 'DESC',
|
|
18
|
-
field: 'TITLE'
|
|
19
|
-
};
|
|
20
|
-
case 'CREATED_AT_ASC':
|
|
21
|
-
return {
|
|
22
|
-
direction: 'ASC',
|
|
23
|
-
field: 'CREATED_AT'
|
|
24
|
-
};
|
|
25
|
-
case 'CREATED_AT_DESC':
|
|
26
|
-
return {
|
|
27
|
-
direction: 'DESC',
|
|
28
|
-
field: 'CREATED_AT'
|
|
29
|
-
};
|
|
30
|
-
case 'none':
|
|
31
|
-
default:
|
|
32
|
-
return {
|
|
33
|
-
direction: 'ASC',
|
|
34
|
-
field: 'TITLE'
|
|
35
|
-
};
|
|
36
|
-
}
|
|
37
|
-
}
|
|
38
|
-
const getCollection = async (fetcher, arg)=>{
|
|
39
|
-
const collections = await loopFetchCollection(fetcher, arg);
|
|
40
|
-
if (!collections) {
|
|
41
|
-
throw new Error('collections not found');
|
|
42
|
-
}
|
|
43
|
-
// merge product collection variant
|
|
44
|
-
const mergeProducts = await mergeProductCollectionVariant(fetcher, collections, arg.isSample);
|
|
45
|
-
return mergeProducts;
|
|
46
|
-
};
|
|
47
|
-
const fetchCollection = async (fetcher, variables)=>{
|
|
48
|
-
return fetcher([
|
|
49
|
-
collectionDetailFilter_generated.CollectionDetailFilterDocument,
|
|
50
|
-
variables
|
|
51
|
-
]);
|
|
52
|
-
};
|
|
53
|
-
const calculateFirstProduct = (numberOfProducts, currentPage, productsPerPage)=>{
|
|
54
|
-
const remainingProducts = numberOfProducts - productsPerPage * currentPage;
|
|
55
|
-
if (numberOfProducts < productsPerPage) return numberOfProducts;
|
|
56
|
-
return remainingProducts > 0 ? productsPerPage : productsPerPage + remainingProducts;
|
|
57
|
-
};
|
|
58
|
-
const chunkArray = (array, size)=>{
|
|
59
|
-
const chunked_arr = [];
|
|
60
|
-
let index = 0;
|
|
61
|
-
while(index < array.length){
|
|
62
|
-
chunked_arr.push(array.slice(index, size + index));
|
|
63
|
-
index += size;
|
|
64
|
-
}
|
|
65
|
-
return chunked_arr;
|
|
66
|
-
};
|
|
67
|
-
const loopFetchCollection = async (fetcher, arg)=>{
|
|
68
|
-
let variables; // variables of collection query
|
|
69
|
-
let productAfterFetcher; // product after of collection query
|
|
70
|
-
let dataCollection; // data of collection query
|
|
71
|
-
let hasNextPage; //
|
|
72
|
-
let firstCollection;
|
|
73
|
-
let currentPage = 1;
|
|
74
|
-
if (arg.numberOfProducts) {
|
|
75
|
-
const pages = Math.ceil(arg.numberOfProducts / PRODUCT_PER_PAGE);
|
|
76
|
-
while(currentPage <= pages && hasNextPage !== false){
|
|
77
|
-
variables = {
|
|
78
|
-
firstVariant: 1,
|
|
79
|
-
firstMedia: 30,
|
|
80
|
-
orderBy: {
|
|
81
|
-
field: 'PLATFORM_CREATED_AT',
|
|
82
|
-
direction: 'DESC'
|
|
83
|
-
},
|
|
84
|
-
orderByMedia: {
|
|
85
|
-
field: 'POSITION',
|
|
86
|
-
direction: 'ASC'
|
|
87
|
-
},
|
|
88
|
-
firstProduct: calculateFirstProduct(arg.numberOfProducts, currentPage, PRODUCT_PER_PAGE),
|
|
89
|
-
...!arg.id || arg.id.toLowerCase() === 'latest' ? {
|
|
90
|
-
where: {
|
|
91
|
-
hasCollectionProducts: true,
|
|
92
|
-
isSample: arg.isSample
|
|
93
|
-
}
|
|
94
|
-
} : {
|
|
95
|
-
where: {
|
|
96
|
-
baseID: arg.id
|
|
97
|
-
}
|
|
98
|
-
},
|
|
99
|
-
orderByProduct: productSortedByOrder(arg.orderBy),
|
|
100
|
-
whereProduct: {
|
|
101
|
-
status: 'ACTIVE',
|
|
102
|
-
...arg.isStorefront && {
|
|
103
|
-
isStorefront: arg.isStorefront
|
|
104
|
-
},
|
|
105
|
-
isSample: arg.isSample
|
|
106
|
-
},
|
|
107
|
-
...productAfterFetcher ? {
|
|
108
|
-
productsAfter: productAfterFetcher
|
|
109
|
-
} : undefined
|
|
110
|
-
};
|
|
111
|
-
const pageData = await fetchCollection(fetcher, variables);
|
|
112
|
-
productAfterFetcher = pageData?.collections?.edges?.[0]?.node?.products?.pageInfo?.endCursor;
|
|
113
|
-
if (currentPage === 1) {
|
|
114
|
-
dataCollection = pageData; // set data of first page
|
|
115
|
-
firstCollection = dataCollection?.collections?.edges?.[0];
|
|
116
|
-
} else if (firstCollection?.node?.products && pageData?.collections?.edges?.[0]?.node?.products?.edges) {
|
|
117
|
-
// concat new values to the old ones
|
|
118
|
-
firstCollection.node.products = {
|
|
119
|
-
pageInfo: pageData?.collections?.edges?.[0]?.node?.products?.pageInfo,
|
|
120
|
-
edges: firstCollection.node?.products?.edges.concat(pageData?.collections?.edges?.[0]?.node?.products?.edges)
|
|
121
|
-
};
|
|
122
|
-
}
|
|
123
|
-
currentPage++;
|
|
124
|
-
// hasNextPage = false if there is no more pages then break the loop
|
|
125
|
-
if (!firstCollection?.node?.products?.pageInfo?.hasNextPage) {
|
|
126
|
-
hasNextPage = false;
|
|
127
|
-
break;
|
|
128
|
-
}
|
|
129
|
-
}
|
|
130
|
-
return dataCollection;
|
|
131
|
-
}
|
|
132
|
-
};
|
|
133
|
-
const mergeProductCollectionVariant = async (fetcher, collection, isSample)=>{
|
|
134
|
-
const node = collection?.collections?.edges?.[0]?.node;
|
|
135
|
-
if (!node) return collection;
|
|
136
|
-
const productList = node?.products?.edges;
|
|
137
|
-
const listBaseId = productList?.map((product)=>product?.node?.baseID).filter(isDefined.isDefined);
|
|
138
|
-
const ProductListWithVariants = await fetchVariantsByBaseIds(fetcher, {
|
|
139
|
-
ids: listBaseId,
|
|
140
|
-
isSample
|
|
141
|
-
});
|
|
142
|
-
// mapping variant to product list in collections
|
|
143
|
-
const newProductList = productList?.map((product)=>{
|
|
144
|
-
const productVariants = ProductListWithVariants?.variants?.edges?.filter((productV)=>productV?.node?.id === product?.node?.id);
|
|
145
|
-
return {
|
|
146
|
-
...product,
|
|
147
|
-
node: product.node ? {
|
|
148
|
-
...product.node,
|
|
149
|
-
variants: product.node?.variants ? {
|
|
150
|
-
...product.node?.variants,
|
|
151
|
-
edges: productVariants?.[0]?.node?.variants?.edges ?? product.node?.variants.edges ?? []
|
|
152
|
-
} : undefined
|
|
153
|
-
} : undefined
|
|
154
|
-
};
|
|
155
|
-
}) ?? [];
|
|
156
|
-
const newCollection = {
|
|
157
|
-
...collection,
|
|
158
|
-
collections: {
|
|
159
|
-
edges: [
|
|
160
|
-
{
|
|
161
|
-
node: {
|
|
162
|
-
...node,
|
|
163
|
-
products: {
|
|
164
|
-
edges: newProductList
|
|
165
|
-
}
|
|
166
|
-
},
|
|
167
|
-
cursor: undefined
|
|
168
|
-
}
|
|
169
|
-
]
|
|
170
|
-
}
|
|
171
|
-
};
|
|
172
|
-
return newCollection;
|
|
173
|
-
};
|
|
174
|
-
const fetchVariantsByBaseIds = async (fetcher, { ids, isSample, isStorefront })=>{
|
|
175
|
-
const chunkedIds = chunkArray(ids ?? [], 8);
|
|
176
|
-
const defaultEdges = [];
|
|
177
|
-
const query = async (variables)=>{
|
|
178
|
-
try {
|
|
179
|
-
return await fetcher([
|
|
180
|
-
productVariants_generated.ProductVariantsDocument,
|
|
181
|
-
{
|
|
182
|
-
...variables,
|
|
183
|
-
orderByVariant: {
|
|
184
|
-
field: 'POSITION',
|
|
185
|
-
direction: 'ASC'
|
|
186
|
-
}
|
|
187
|
-
}
|
|
188
|
-
]);
|
|
189
|
-
} catch {
|
|
190
|
-
return {};
|
|
191
|
-
}
|
|
192
|
-
};
|
|
193
|
-
const promises = chunkedIds.map((chunkedId)=>{
|
|
194
|
-
const variables = {
|
|
195
|
-
firstVariant: 100,
|
|
196
|
-
first: chunkedId.length,
|
|
197
|
-
orderBy: {
|
|
198
|
-
field: 'TITLE',
|
|
199
|
-
direction: 'ASC'
|
|
200
|
-
},
|
|
201
|
-
where: {
|
|
202
|
-
status: 'ACTIVE',
|
|
203
|
-
isSample,
|
|
204
|
-
...isStorefront && {
|
|
205
|
-
isStorefront
|
|
206
|
-
},
|
|
207
|
-
...chunkedId.length && {
|
|
208
|
-
baseIDIn: chunkedId.sort()
|
|
209
|
-
}
|
|
210
|
-
}
|
|
211
|
-
};
|
|
212
|
-
return query(variables);
|
|
213
|
-
});
|
|
214
|
-
const responses = await Promise.all(promises);
|
|
215
|
-
const edges = responses?.reduce((acc, response)=>{
|
|
216
|
-
return acc.concat(response?.variants?.edges ?? []);
|
|
217
|
-
}, defaultEdges);
|
|
218
|
-
return {
|
|
219
|
-
variants: {
|
|
220
|
-
edges
|
|
221
|
-
}
|
|
222
|
-
};
|
|
223
|
-
};
|
|
224
|
-
|
|
225
|
-
exports.calculateFirstProduct = calculateFirstProduct;
|
|
226
|
-
exports.getCollection = getCollection;
|
|
1
|
+
"use strict";var collectionDetailFilter_generated=require("../../graphql/queries/collection-detail-filter.generated.js"),productVariants_generated=require("../../graphql/queries/product-variants.generated.js"),isDefined=require("../is-defined.js");const PRODUCT_PER_PAGE=8;function productSortedByOrder(e){switch(e){case"TITLE_ASC":case"none":default:return{direction:"ASC",field:"TITLE"};case"TITLE_DESC":return{direction:"DESC",field:"TITLE"};case"CREATED_AT_ASC":return{direction:"ASC",field:"CREATED_AT"};case"CREATED_AT_DESC":return{direction:"DESC",field:"CREATED_AT"}}}const getCollection=async(e,t)=>{let r=await loopFetchCollection(e,t);if(!r)throw Error("collections not found");let o=await mergeProductCollectionVariant(e,r,t.isSample);return o},fetchCollection=async(e,t)=>e([collectionDetailFilter_generated.CollectionDetailFilterDocument,t]),calculateFirstProduct=(e,t,r)=>{let o=e-r*t;return e<r?e:o>0?r:r+o},chunkArray=(e,t)=>{let r=[],o=0;for(;o<e.length;)r.push(e.slice(o,t+o)),o+=t;return r},loopFetchCollection=async(e,t)=>{let r,o,i,n,d;let s=1;if(t.numberOfProducts){let a=Math.ceil(t.numberOfProducts/8);for(;s<=a&&!1!==n;){r={firstVariant:1,firstMedia:30,orderBy:{field:"PLATFORM_CREATED_AT",direction:"DESC"},orderByMedia:{field:"POSITION",direction:"ASC"},firstProduct:calculateFirstProduct(t.numberOfProducts,s,8),...t.id&&"latest"!==t.id.toLowerCase()?{where:{baseID:t.id}}:{where:{hasCollectionProducts:!0,isSample:t.isSample}},orderByProduct:productSortedByOrder(t.orderBy),whereProduct:{status:"ACTIVE",...t.isStorefront&&{isStorefront:t.isStorefront},isSample:t.isSample},...o?{productsAfter:o}:void 0};let a=await fetchCollection(e,r);if(o=a?.collections?.edges?.[0]?.node?.products?.pageInfo?.endCursor,1===s?(i=a,d=i?.collections?.edges?.[0]):d?.node?.products&&a?.collections?.edges?.[0]?.node?.products?.edges&&(d.node.products={pageInfo:a?.collections?.edges?.[0]?.node?.products?.pageInfo,edges:d.node?.products?.edges.concat(a?.collections?.edges?.[0]?.node?.products?.edges)}),s++,!d?.node?.products?.pageInfo?.hasNextPage){n=!1;break}}return i}},mergeProductCollectionVariant=async(e,t,r)=>{let o=t?.collections?.edges?.[0]?.node;if(!o)return t;let i=o?.products?.edges,n=i?.map(e=>e?.node?.baseID).filter(isDefined.isDefined),d=await fetchVariantsByBaseIds(e,{ids:n,isSample:r}),s=i?.map(e=>{let t=d?.variants?.edges?.filter(t=>t?.node?.id===e?.node?.id);return{...e,node:e.node?{...e.node,variants:e.node?.variants?{...e.node?.variants,edges:t?.[0]?.node?.variants?.edges??e.node?.variants.edges??[]}:void 0}:void 0}})??[],a={...t,collections:{edges:[{node:{...o,products:{edges:s}},cursor:void 0}]}};return a},fetchVariantsByBaseIds=async(e,{ids:t,isSample:r,isStorefront:o})=>{let i=chunkArray(t??[],8),n=[],d=async t=>{try{return await e([productVariants_generated.ProductVariantsDocument,{...t,orderByVariant:{field:"POSITION",direction:"ASC"}}])}catch{return{}}},s=i.map(e=>{let t={firstVariant:100,first:e.length,orderBy:{field:"TITLE",direction:"ASC"},where:{status:"ACTIVE",isSample:r,...o&&{isStorefront:o},...e.length&&{baseIDIn:e.sort()}}};return d(t)}),a=await Promise.all(s),c=a?.reduce((e,t)=>e.concat(t?.variants?.edges??[]),n);return{variants:{edges:c}}};exports.calculateFirstProduct=calculateFirstProduct,exports.getCollection=getCollection;
|
|
@@ -1,21 +1 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
var collections_generated = require('../../graphql/queries/collections.generated.js');
|
|
4
|
-
|
|
5
|
-
const getCollections = async (fetcher, variable)=>{
|
|
6
|
-
const collections = await fetchCollections(fetcher, variable ?? {});
|
|
7
|
-
if (!collections) {
|
|
8
|
-
throw new Error('Collection not found');
|
|
9
|
-
}
|
|
10
|
-
return {
|
|
11
|
-
...collections
|
|
12
|
-
};
|
|
13
|
-
};
|
|
14
|
-
const fetchCollections = async (fetcher, variables)=>{
|
|
15
|
-
return fetcher([
|
|
16
|
-
collections_generated.CollectionsDocument,
|
|
17
|
-
variables
|
|
18
|
-
]);
|
|
19
|
-
};
|
|
20
|
-
|
|
21
|
-
exports.getCollections = getCollections;
|
|
1
|
+
"use strict";var collections_generated=require("../../graphql/queries/collections.generated.js");const getCollections=async(e,t)=>{let o=await fetchCollections(e,t??{});if(!o)throw Error("Collection not found");return{...o}},fetchCollections=async(e,t)=>e([collections_generated.CollectionsDocument,t]);exports.getCollections=getCollections;
|
|
@@ -1,125 +1 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
var productLittleDetail_generated = require('../../graphql/queries/product-little-detail.generated.js');
|
|
4
|
-
var productMedias_generated = require('../../graphql/queries/product-medias.generated.js');
|
|
5
|
-
var productVariants_generated = require('../../graphql/queries/product-variants.generated.js');
|
|
6
|
-
|
|
7
|
-
const getProductBySlug = async (fetcher, slug)=>{
|
|
8
|
-
const [product, variants, medias] = await Promise.all([
|
|
9
|
-
fetchProduct(fetcher, slug),
|
|
10
|
-
fetchVariants(fetcher, slug),
|
|
11
|
-
fetchMedias(fetcher, slug)
|
|
12
|
-
]);
|
|
13
|
-
if (!product) {
|
|
14
|
-
throw new Error('Product not found');
|
|
15
|
-
}
|
|
16
|
-
return {
|
|
17
|
-
...product,
|
|
18
|
-
variants: {
|
|
19
|
-
edges: variants
|
|
20
|
-
},
|
|
21
|
-
medias: {
|
|
22
|
-
edges: medias
|
|
23
|
-
}
|
|
24
|
-
};
|
|
25
|
-
};
|
|
26
|
-
const orderBy = {
|
|
27
|
-
field: 'PLATFORM_UPDATED_AT',
|
|
28
|
-
direction: 'DESC'
|
|
29
|
-
};
|
|
30
|
-
const fetchProduct = async (fetcher, handle, isStorefront)=>{
|
|
31
|
-
const variables = {
|
|
32
|
-
orderBy,
|
|
33
|
-
where: {
|
|
34
|
-
status: 'ACTIVE',
|
|
35
|
-
handle,
|
|
36
|
-
...isStorefront && {
|
|
37
|
-
isStorefront
|
|
38
|
-
}
|
|
39
|
-
}
|
|
40
|
-
};
|
|
41
|
-
const response = await fetcher([
|
|
42
|
-
productLittleDetail_generated.ProductLittleDetailDocument,
|
|
43
|
-
variables
|
|
44
|
-
]);
|
|
45
|
-
return response.product?.edges?.[0]?.node;
|
|
46
|
-
};
|
|
47
|
-
const fetchVariants = async (fetcher, handle, isStorefront)=>{
|
|
48
|
-
const initVariables = {
|
|
49
|
-
orderBy,
|
|
50
|
-
orderByVariant: {
|
|
51
|
-
field: 'POSITION',
|
|
52
|
-
direction: 'ASC'
|
|
53
|
-
},
|
|
54
|
-
where: {
|
|
55
|
-
status: 'ACTIVE',
|
|
56
|
-
handle,
|
|
57
|
-
...isStorefront && {
|
|
58
|
-
isStorefront
|
|
59
|
-
}
|
|
60
|
-
}
|
|
61
|
-
};
|
|
62
|
-
const query = async (variables, olds)=>{
|
|
63
|
-
try {
|
|
64
|
-
const response = await fetcher([
|
|
65
|
-
productVariants_generated.ProductVariantsDocument,
|
|
66
|
-
variables
|
|
67
|
-
]);
|
|
68
|
-
const product = response.variants?.edges?.[0];
|
|
69
|
-
const items = olds?.concat(product?.node?.variants?.edges ?? []);
|
|
70
|
-
if (product?.node?.variants?.pageInfo?.hasNextPage) {
|
|
71
|
-
return query({
|
|
72
|
-
...variables,
|
|
73
|
-
afterVariant: product?.node?.variants?.pageInfo.endCursor
|
|
74
|
-
}, items);
|
|
75
|
-
}
|
|
76
|
-
return items ?? [];
|
|
77
|
-
} catch {
|
|
78
|
-
return olds ?? [];
|
|
79
|
-
}
|
|
80
|
-
};
|
|
81
|
-
return query(initVariables, []);
|
|
82
|
-
};
|
|
83
|
-
const fetchMedias = async (fetcher, handle, isStorefront)=>{
|
|
84
|
-
const initVariables = {
|
|
85
|
-
orderBy,
|
|
86
|
-
where: {
|
|
87
|
-
status: 'ACTIVE',
|
|
88
|
-
handle,
|
|
89
|
-
...isStorefront && {
|
|
90
|
-
isStorefront
|
|
91
|
-
}
|
|
92
|
-
},
|
|
93
|
-
orderByMedia: {
|
|
94
|
-
field: 'POSITION',
|
|
95
|
-
direction: 'ASC'
|
|
96
|
-
}
|
|
97
|
-
};
|
|
98
|
-
const query = async (variables)=>{
|
|
99
|
-
try {
|
|
100
|
-
const response = await fetcher([
|
|
101
|
-
productMedias_generated.ProductMediasDocument,
|
|
102
|
-
variables
|
|
103
|
-
]);
|
|
104
|
-
const product = response.medias?.edges?.[0];
|
|
105
|
-
const items = product?.node?.medias?.edges ?? [];
|
|
106
|
-
if (product?.node?.medias?.pageInfo?.hasNextPage) {
|
|
107
|
-
try {
|
|
108
|
-
const newData = await query({
|
|
109
|
-
...variables,
|
|
110
|
-
afterMedia: product?.node?.medias?.pageInfo.endCursor
|
|
111
|
-
});
|
|
112
|
-
return items.concat(newData);
|
|
113
|
-
} catch {
|
|
114
|
-
return items;
|
|
115
|
-
}
|
|
116
|
-
}
|
|
117
|
-
return items;
|
|
118
|
-
} catch {
|
|
119
|
-
return [];
|
|
120
|
-
}
|
|
121
|
-
};
|
|
122
|
-
return query(initVariables);
|
|
123
|
-
};
|
|
124
|
-
|
|
125
|
-
exports.getProductBySlug = getProductBySlug;
|
|
1
|
+
"use strict";var productLittleDetail_generated=require("../../graphql/queries/product-little-detail.generated.js"),productMedias_generated=require("../../graphql/queries/product-medias.generated.js"),productVariants_generated=require("../../graphql/queries/product-variants.generated.js");const getProductBySlug=async(e,t)=>{let[r,a,d]=await Promise.all([fetchProduct(e,t),fetchVariants(e,t),fetchMedias(e,t)]);if(!r)throw Error("Product not found");return{...r,variants:{edges:a},medias:{edges:d}}},orderBy={field:"PLATFORM_UPDATED_AT",direction:"DESC"},fetchProduct=async(e,t,r)=>{let a={orderBy,where:{status:"ACTIVE",handle:t,...r&&{isStorefront:r}}},d=await e([productLittleDetail_generated.ProductLittleDetailDocument,a]);return d.product?.edges?.[0]?.node},fetchVariants=async(e,t,r)=>{let a={orderBy,orderByVariant:{field:"POSITION",direction:"ASC"},where:{status:"ACTIVE",handle:t,...r&&{isStorefront:r}}},d=async(t,r)=>{try{let a=await e([productVariants_generated.ProductVariantsDocument,t]),n=a.variants?.edges?.[0],i=r?.concat(n?.node?.variants?.edges??[]);if(n?.node?.variants?.pageInfo?.hasNextPage)return d({...t,afterVariant:n?.node?.variants?.pageInfo.endCursor},i);return i??[]}catch{return r??[]}};return d(a,[])},fetchMedias=async(e,t,r)=>{let a={orderBy,where:{status:"ACTIVE",handle:t,...r&&{isStorefront:r}},orderByMedia:{field:"POSITION",direction:"ASC"}},d=async t=>{try{let r=await e([productMedias_generated.ProductMediasDocument,t]),a=r.medias?.edges?.[0],n=a?.node?.medias?.edges??[];if(a?.node?.medias?.pageInfo?.hasNextPage)try{let e=await d({...t,afterMedia:a?.node?.medias?.pageInfo.endCursor});return n.concat(e)}catch{}return n}catch{return[]}};return d(a)};exports.getProductBySlug=getProductBySlug;
|
|
@@ -1,154 +1 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
var productLittleDetail_generated = require('../../graphql/queries/product-little-detail.generated.js');
|
|
4
|
-
var productMedias_generated = require('../../graphql/queries/product-medias.generated.js');
|
|
5
|
-
var productVariants_generated = require('../../graphql/queries/product-variants.generated.js');
|
|
6
|
-
|
|
7
|
-
const getProduct = async (fetcher, { id, isSample, isStorefront })=>{
|
|
8
|
-
const [product, variants, medias] = await Promise.all([
|
|
9
|
-
fetchProduct(fetcher, {
|
|
10
|
-
id,
|
|
11
|
-
isSample,
|
|
12
|
-
isStorefront
|
|
13
|
-
}),
|
|
14
|
-
fetchVariants(fetcher, {
|
|
15
|
-
id,
|
|
16
|
-
isSample,
|
|
17
|
-
isStorefront
|
|
18
|
-
}),
|
|
19
|
-
fetchMedias(fetcher, {
|
|
20
|
-
id,
|
|
21
|
-
isSample,
|
|
22
|
-
isStorefront
|
|
23
|
-
})
|
|
24
|
-
]);
|
|
25
|
-
if (!product) {
|
|
26
|
-
throw new Error('Product not found');
|
|
27
|
-
}
|
|
28
|
-
return {
|
|
29
|
-
...product,
|
|
30
|
-
variants: {
|
|
31
|
-
edges: variants
|
|
32
|
-
},
|
|
33
|
-
medias: {
|
|
34
|
-
edges: medias
|
|
35
|
-
}
|
|
36
|
-
};
|
|
37
|
-
};
|
|
38
|
-
const orderBy = {
|
|
39
|
-
field: 'CREATED_AT',
|
|
40
|
-
direction: 'DESC'
|
|
41
|
-
};
|
|
42
|
-
const fetchProduct = async (fetcher, { id, isSample, isStorefront })=>{
|
|
43
|
-
const variables = {
|
|
44
|
-
orderBy,
|
|
45
|
-
where: {
|
|
46
|
-
isSample,
|
|
47
|
-
...isStorefront && {
|
|
48
|
-
isStorefront
|
|
49
|
-
},
|
|
50
|
-
...(!id || id && id.toLowerCase() == 'latest') && {
|
|
51
|
-
status: 'ACTIVE'
|
|
52
|
-
},
|
|
53
|
-
...id && id.toLowerCase() !== 'latest' && {
|
|
54
|
-
baseID: id
|
|
55
|
-
}
|
|
56
|
-
}
|
|
57
|
-
};
|
|
58
|
-
const response = await fetcher([
|
|
59
|
-
productLittleDetail_generated.ProductLittleDetailDocument,
|
|
60
|
-
variables
|
|
61
|
-
]);
|
|
62
|
-
return response.product?.edges?.[0]?.node;
|
|
63
|
-
};
|
|
64
|
-
const fetchVariants = async (fetcher, { id, isSample, isStorefront })=>{
|
|
65
|
-
const initVariables = {
|
|
66
|
-
orderBy,
|
|
67
|
-
where: {
|
|
68
|
-
isSample,
|
|
69
|
-
...isStorefront && {
|
|
70
|
-
isStorefront
|
|
71
|
-
},
|
|
72
|
-
...(!id || id && id.toLowerCase() == 'latest') && {
|
|
73
|
-
status: 'ACTIVE'
|
|
74
|
-
},
|
|
75
|
-
...id && id.toLowerCase() !== 'latest' && {
|
|
76
|
-
baseID: id
|
|
77
|
-
}
|
|
78
|
-
},
|
|
79
|
-
orderByVariant: {
|
|
80
|
-
field: 'POSITION',
|
|
81
|
-
direction: 'ASC'
|
|
82
|
-
}
|
|
83
|
-
};
|
|
84
|
-
const query = async (variables, olds)=>{
|
|
85
|
-
try {
|
|
86
|
-
const response = await fetcher([
|
|
87
|
-
productVariants_generated.ProductVariantsDocument,
|
|
88
|
-
variables
|
|
89
|
-
]);
|
|
90
|
-
const product = response.variants?.edges?.[0];
|
|
91
|
-
const items = olds?.concat(product?.node?.variants?.edges ?? []);
|
|
92
|
-
if (product?.node?.variants?.pageInfo?.hasNextPage) {
|
|
93
|
-
return query({
|
|
94
|
-
...variables,
|
|
95
|
-
afterVariant: product?.node?.variants?.pageInfo.endCursor
|
|
96
|
-
}, items);
|
|
97
|
-
}
|
|
98
|
-
return items ?? [];
|
|
99
|
-
} catch {
|
|
100
|
-
return olds ?? [];
|
|
101
|
-
}
|
|
102
|
-
};
|
|
103
|
-
return query(initVariables, []);
|
|
104
|
-
};
|
|
105
|
-
const fetchMedias = async (fetcher, { id, isSample, isStorefront })=>{
|
|
106
|
-
const initVariables = {
|
|
107
|
-
orderBy,
|
|
108
|
-
where: {
|
|
109
|
-
isSample,
|
|
110
|
-
...isStorefront && {
|
|
111
|
-
isStorefront
|
|
112
|
-
},
|
|
113
|
-
...(!id || id && id.toLowerCase() == 'latest') && {
|
|
114
|
-
status: 'ACTIVE'
|
|
115
|
-
},
|
|
116
|
-
...id && id.toLowerCase() !== 'latest' && {
|
|
117
|
-
baseID: id
|
|
118
|
-
}
|
|
119
|
-
},
|
|
120
|
-
orderByMedia: {
|
|
121
|
-
field: 'POSITION',
|
|
122
|
-
direction: 'ASC'
|
|
123
|
-
}
|
|
124
|
-
};
|
|
125
|
-
const query = async (variables)=>{
|
|
126
|
-
try {
|
|
127
|
-
const response = await fetcher([
|
|
128
|
-
productMedias_generated.ProductMediasDocument,
|
|
129
|
-
variables
|
|
130
|
-
]);
|
|
131
|
-
const product = response.medias?.edges?.[0];
|
|
132
|
-
const items = product?.node?.medias?.edges ?? [];
|
|
133
|
-
if (product?.node?.medias?.pageInfo?.hasNextPage) {
|
|
134
|
-
try {
|
|
135
|
-
const newData = await query({
|
|
136
|
-
...variables,
|
|
137
|
-
afterMedia: product?.node?.medias?.pageInfo.endCursor
|
|
138
|
-
});
|
|
139
|
-
return items.concat(newData);
|
|
140
|
-
} catch {
|
|
141
|
-
return items;
|
|
142
|
-
}
|
|
143
|
-
}
|
|
144
|
-
return items;
|
|
145
|
-
} catch {
|
|
146
|
-
return [];
|
|
147
|
-
}
|
|
148
|
-
};
|
|
149
|
-
return query(initVariables);
|
|
150
|
-
};
|
|
151
|
-
|
|
152
|
-
exports.fetchMedias = fetchMedias;
|
|
153
|
-
exports.fetchVariants = fetchVariants;
|
|
154
|
-
exports.getProduct = getProduct;
|
|
1
|
+
"use strict";var productLittleDetail_generated=require("../../graphql/queries/product-little-detail.generated.js"),productMedias_generated=require("../../graphql/queries/product-medias.generated.js"),productVariants_generated=require("../../graphql/queries/product-variants.generated.js");const getProduct=async(e,{id:t,isSample:r,isStorefront:a})=>{let[s,d,o]=await Promise.all([fetchProduct(e,{id:t,isSample:r,isStorefront:a}),fetchVariants(e,{id:t,isSample:r,isStorefront:a}),fetchMedias(e,{id:t,isSample:r,isStorefront:a})]);if(!s)throw Error("Product not found");return{...s,variants:{edges:d},medias:{edges:o}}},orderBy={field:"CREATED_AT",direction:"DESC"},fetchProduct=async(e,{id:t,isSample:r,isStorefront:a})=>{let s={orderBy,where:{isSample:r,...a&&{isStorefront:a},...(!t||t&&"latest"==t.toLowerCase())&&{status:"ACTIVE"},...t&&"latest"!==t.toLowerCase()&&{baseID:t}}},d=await e([productLittleDetail_generated.ProductLittleDetailDocument,s]);return d.product?.edges?.[0]?.node},fetchVariants=async(e,{id:t,isSample:r,isStorefront:a})=>{let s={orderBy,where:{isSample:r,...a&&{isStorefront:a},...(!t||t&&"latest"==t.toLowerCase())&&{status:"ACTIVE"},...t&&"latest"!==t.toLowerCase()&&{baseID:t}},orderByVariant:{field:"POSITION",direction:"ASC"}},d=async(t,r)=>{try{let a=await e([productVariants_generated.ProductVariantsDocument,t]),s=a.variants?.edges?.[0],o=r?.concat(s?.node?.variants?.edges??[]);if(s?.node?.variants?.pageInfo?.hasNextPage)return d({...t,afterVariant:s?.node?.variants?.pageInfo.endCursor},o);return o??[]}catch{return r??[]}};return d(s,[])},fetchMedias=async(e,{id:t,isSample:r,isStorefront:a})=>{let s={orderBy,where:{isSample:r,...a&&{isStorefront:a},...(!t||t&&"latest"==t.toLowerCase())&&{status:"ACTIVE"},...t&&"latest"!==t.toLowerCase()&&{baseID:t}},orderByMedia:{field:"POSITION",direction:"ASC"}},d=async t=>{try{let r=await e([productMedias_generated.ProductMediasDocument,t]),a=r.medias?.edges?.[0],s=a?.node?.medias?.edges??[];if(a?.node?.medias?.pageInfo?.hasNextPage)try{let e=await d({...t,afterMedia:a?.node?.medias?.pageInfo.endCursor});return s.concat(e)}catch{}return s}catch{return[]}};return d(s)};exports.fetchMedias=fetchMedias,exports.fetchVariants=fetchVariants,exports.getProduct=getProduct;
|