@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
|
@@ -0,0 +1,132 @@
|
|
|
1
|
+
import { useRef, useMemo, useCallback } from 'react';
|
|
2
|
+
import 'react/jsx-runtime';
|
|
3
|
+
import 'zustand';
|
|
4
|
+
import { usePageStore } from '../../contexts/PageContext.js';
|
|
5
|
+
import 'react-transition-group';
|
|
6
|
+
import '@gem-sdk/core';
|
|
7
|
+
import 'swr';
|
|
8
|
+
import 'swr/infinite';
|
|
9
|
+
import 'classnames';
|
|
10
|
+
import 'dayjs';
|
|
11
|
+
import '../convert.js';
|
|
12
|
+
import '@gem-sdk/adapter-shopify';
|
|
13
|
+
import 'swr/mutation';
|
|
14
|
+
import 'vanilla-lazyload';
|
|
15
|
+
import '../../hooks/useCartUI.js';
|
|
16
|
+
|
|
17
|
+
const useInteraction = ()=>{
|
|
18
|
+
const ref = useRef();
|
|
19
|
+
const setInteractionIsSelectOnPage = usePageStore((s)=>s.setInteractionIsSelectOnPage);
|
|
20
|
+
const sidebarMode = usePageStore((s)=>s.sidebarMode);
|
|
21
|
+
const selectType = usePageStore((s)=>s.interactionData?.selectType);
|
|
22
|
+
const interactionData = usePageStore((s)=>s.interactionData);
|
|
23
|
+
function findElementIncludingSelf(element, selector) {
|
|
24
|
+
if (!(element instanceof Document) && element?.matches(selector)) {
|
|
25
|
+
return element;
|
|
26
|
+
} else {
|
|
27
|
+
return element?.querySelector(selector);
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
const handleOnListener = (element, event, callback)=>{
|
|
31
|
+
const eventListener = (e)=>{
|
|
32
|
+
const customEvent = e;
|
|
33
|
+
const params = customEvent.detail;
|
|
34
|
+
if (callback) callback(params);
|
|
35
|
+
};
|
|
36
|
+
element.addEventListener(event, eventListener);
|
|
37
|
+
return ()=>element.removeEventListener(event, eventListener);
|
|
38
|
+
};
|
|
39
|
+
const onListener = ({ event, selector, elementRef }, callback)=>{
|
|
40
|
+
const element = findElementIncludingSelf(elementRef?.current || ref.current || document, selector);
|
|
41
|
+
if (!element) return;
|
|
42
|
+
return handleOnListener(element, event, callback);
|
|
43
|
+
};
|
|
44
|
+
const trigger = ({ event, data, selector, element: elementParam })=>{
|
|
45
|
+
const element = elementParam || document.body?.querySelector(selector);
|
|
46
|
+
if (!element) return;
|
|
47
|
+
const eventDispatch = new CustomEvent(event, {
|
|
48
|
+
bubbles: false,
|
|
49
|
+
cancelable: true,
|
|
50
|
+
detail: {
|
|
51
|
+
data
|
|
52
|
+
}
|
|
53
|
+
});
|
|
54
|
+
element.dispatchEvent(eventDispatch);
|
|
55
|
+
};
|
|
56
|
+
const saveToElementInteractionData = (element, key, value)=>{
|
|
57
|
+
const interactionData = element.getAttribute('gp-data-interaction');
|
|
58
|
+
const interactionDataJson = JSON.parse(interactionData || '{}');
|
|
59
|
+
element.setAttribute('gp-data-interaction', JSON.stringify({
|
|
60
|
+
...interactionDataJson,
|
|
61
|
+
[key]: value
|
|
62
|
+
}));
|
|
63
|
+
};
|
|
64
|
+
const getInteractionPreviousData = (element, key)=>{
|
|
65
|
+
const interactionData = element.getAttribute('gp-data-interaction');
|
|
66
|
+
const interactionDataJson = JSON.parse(interactionData || '{}');
|
|
67
|
+
return {
|
|
68
|
+
previousData: interactionDataJson[key],
|
|
69
|
+
interactionDataJson
|
|
70
|
+
};
|
|
71
|
+
};
|
|
72
|
+
const closeSelectOnPage = ()=>{
|
|
73
|
+
setInteractionIsSelectOnPage(false);
|
|
74
|
+
const event = new CustomEvent('editor:interaction:change-select-on-page', {
|
|
75
|
+
bubbles: true,
|
|
76
|
+
detail: false
|
|
77
|
+
});
|
|
78
|
+
window.dispatchEvent(event);
|
|
79
|
+
};
|
|
80
|
+
const changeSelectMode = (mode)=>{
|
|
81
|
+
const event = new CustomEvent('editor:interaction:change-select-mode', {
|
|
82
|
+
bubbles: true,
|
|
83
|
+
detail: mode
|
|
84
|
+
});
|
|
85
|
+
window.dispatchEvent(event);
|
|
86
|
+
};
|
|
87
|
+
const selectInteractionElement = ({ componentUid, settingType, $target })=>{
|
|
88
|
+
const event = new CustomEvent('editor:interaction:select-element', {
|
|
89
|
+
bubbles: true,
|
|
90
|
+
detail: {
|
|
91
|
+
componentUid,
|
|
92
|
+
settingType,
|
|
93
|
+
$target
|
|
94
|
+
}
|
|
95
|
+
});
|
|
96
|
+
window.dispatchEvent(event);
|
|
97
|
+
};
|
|
98
|
+
const isInteractionMode = useMemo(()=>sidebarMode === 'interaction' && (!interactionData?.isSelectOnPage || selectType === 'PAGE'), [
|
|
99
|
+
sidebarMode,
|
|
100
|
+
interactionData?.isSelectOnPage,
|
|
101
|
+
selectType
|
|
102
|
+
]);
|
|
103
|
+
const isSelectOnPage = useMemo(()=>interactionData?.isSelectOnPage, [
|
|
104
|
+
interactionData?.isSelectOnPage
|
|
105
|
+
]);
|
|
106
|
+
const interactionListenerLoaded = useCallback((callback)=>{
|
|
107
|
+
//@ts-ignore
|
|
108
|
+
if (window.interactionLoaded) {
|
|
109
|
+
callback();
|
|
110
|
+
return;
|
|
111
|
+
}
|
|
112
|
+
window.addEventListener('gp:flow-actions-loaded', ()=>{
|
|
113
|
+
callback();
|
|
114
|
+
});
|
|
115
|
+
}, []);
|
|
116
|
+
return {
|
|
117
|
+
onListener,
|
|
118
|
+
trigger,
|
|
119
|
+
saveToElementInteractionData,
|
|
120
|
+
closeSelectOnPage,
|
|
121
|
+
ref,
|
|
122
|
+
findElementIncludingSelf,
|
|
123
|
+
getInteractionPreviousData,
|
|
124
|
+
changeSelectMode,
|
|
125
|
+
selectInteractionElement,
|
|
126
|
+
isInteractionMode,
|
|
127
|
+
isSelectOnPage,
|
|
128
|
+
interactionListenerLoaded
|
|
129
|
+
};
|
|
130
|
+
};
|
|
131
|
+
|
|
132
|
+
export { useInteraction };
|
|
@@ -1 +1,10 @@
|
|
|
1
|
-
import{Children
|
|
1
|
+
import { Children } from 'react';
|
|
2
|
+
import ComponentToolbarPreview from '../components/ComponentToolbarPreview.js';
|
|
3
|
+
|
|
4
|
+
const isEmptyChildren = (children)=>{
|
|
5
|
+
let arrChild = Children.toArray(children);
|
|
6
|
+
arrChild = arrChild.filter((child)=>child?.type != ComponentToolbarPreview);
|
|
7
|
+
return Children.count(arrChild) < 1 || !children;
|
|
8
|
+
};
|
|
9
|
+
|
|
10
|
+
export { isEmptyChildren as default, isEmptyChildren };
|
|
@@ -1 +1,5 @@
|
|
|
1
|
-
function isSafari()
|
|
1
|
+
function isSafari() {
|
|
2
|
+
return navigator.userAgent.indexOf('Safari') != -1 && navigator.userAgent.indexOf('Chrome') == -1;
|
|
3
|
+
}
|
|
4
|
+
|
|
5
|
+
export { isSafari as default };
|
|
@@ -1 +1,54 @@
|
|
|
1
|
-
import{devicesMapping
|
|
1
|
+
import { devicesMapping } from './constant.js';
|
|
2
|
+
import { getResponsiveValueByScreen, getResponsiveValue } from './get-resonsive-value.js';
|
|
3
|
+
|
|
4
|
+
const gridToArrayRegex = // eslint-disable-next-line regexp/no-super-linear-backtracking
|
|
5
|
+
/[^\s()]+(?:\([^\s()]+(?:\([^()]+\))?(?:, *[^\s()]+(?:\([^()]+\))?)*\))?/g; // Regex convert css grid to array
|
|
6
|
+
const optionLayoutStyle = (column)=>{
|
|
7
|
+
if (!column) return {};
|
|
8
|
+
const style = {};
|
|
9
|
+
for (const [key, value] of Object.entries(column)){
|
|
10
|
+
Object.assign(style, {
|
|
11
|
+
[`--gtc${devicesMapping?.[key]}`]: `repeat(${parseFloat(value + '') || 1}, minmax(0, 1fr))`
|
|
12
|
+
});
|
|
13
|
+
}
|
|
14
|
+
return style;
|
|
15
|
+
};
|
|
16
|
+
const composeGridLayout = (layout)=>{
|
|
17
|
+
const display = getResponsiveValue(layout, 'display');
|
|
18
|
+
const desktop = (getResponsiveValueByScreen(display, 'desktop') === 'fit' ? layout?.desktop?.cols?.map(()=>`minmax(0, auto)`) : layout?.desktop?.cols?.map((col)=>`minmax(0, ${col}fr)`))?.join(' ');
|
|
19
|
+
const tablet = (getResponsiveValueByScreen(display, 'tablet') === 'fit' ? layout?.tablet?.cols?.map(()=>`minmax(0, auto)`) : layout?.tablet?.cols?.map((col)=>`minmax(0, ${col}fr)`))?.join(' ');
|
|
20
|
+
const mobile = (getResponsiveValueByScreen(display, 'mobile') === 'fit' ? layout?.mobile?.cols?.map(()=>`minmax(0, auto)`) : layout?.mobile?.cols?.map((col)=>`minmax(0, ${col}fr)`))?.join(' ');
|
|
21
|
+
return {
|
|
22
|
+
[`--gtc`]: desktop,
|
|
23
|
+
[`--gtc-tablet`]: tablet,
|
|
24
|
+
[`--gtc-mobile`]: mobile
|
|
25
|
+
};
|
|
26
|
+
};
|
|
27
|
+
const gridToArray = (layout)=>{
|
|
28
|
+
return layout ? layout.match(gridToArrayRegex) ?? [] : [];
|
|
29
|
+
};
|
|
30
|
+
const convertOldLayout = (layout)=>{
|
|
31
|
+
const desktopCol = gridToArray(layout?.desktop).length;
|
|
32
|
+
const tabletCol = gridToArray(layout?.tablet).length;
|
|
33
|
+
const mobileCol = gridToArray(layout?.mobile).length;
|
|
34
|
+
return {
|
|
35
|
+
desktop: {
|
|
36
|
+
cols: desktopCol ? Array.from({
|
|
37
|
+
length: desktopCol
|
|
38
|
+
}, ()=>12 / desktopCol) : undefined,
|
|
39
|
+
display: 'fill'
|
|
40
|
+
},
|
|
41
|
+
tablet: {
|
|
42
|
+
cols: tabletCol ? Array.from({
|
|
43
|
+
length: tabletCol
|
|
44
|
+
}, ()=>12 / tabletCol) : undefined
|
|
45
|
+
},
|
|
46
|
+
mobile: {
|
|
47
|
+
cols: mobileCol ? Array.from({
|
|
48
|
+
length: mobileCol
|
|
49
|
+
}, ()=>12 / mobileCol) : undefined
|
|
50
|
+
}
|
|
51
|
+
};
|
|
52
|
+
};
|
|
53
|
+
|
|
54
|
+
export { composeGridLayout, convertOldLayout, gridToArrayRegex, optionLayoutStyle };
|
|
@@ -1 +1,29 @@
|
|
|
1
|
-
|
|
1
|
+
const SCRIPTS_LOADED = {};
|
|
2
|
+
function loadScript(src, options) {
|
|
3
|
+
const isScriptLoaded = SCRIPTS_LOADED[src];
|
|
4
|
+
if (isScriptLoaded) {
|
|
5
|
+
return isScriptLoaded;
|
|
6
|
+
}
|
|
7
|
+
const promise = new Promise((resolve, reject)=>{
|
|
8
|
+
const script = document.createElement('script');
|
|
9
|
+
if (options?.module) {
|
|
10
|
+
script.type = 'module';
|
|
11
|
+
}
|
|
12
|
+
script.src = src;
|
|
13
|
+
script.onload = ()=>{
|
|
14
|
+
resolve(true);
|
|
15
|
+
};
|
|
16
|
+
script.onerror = ()=>{
|
|
17
|
+
reject(false);
|
|
18
|
+
};
|
|
19
|
+
if (options?.in === 'head') {
|
|
20
|
+
document.head.appendChild(script);
|
|
21
|
+
} else {
|
|
22
|
+
document.body.appendChild(script);
|
|
23
|
+
}
|
|
24
|
+
});
|
|
25
|
+
SCRIPTS_LOADED[src] = promise;
|
|
26
|
+
return promise;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
export { loadScript };
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
function loopComponent(component, callback) {
|
|
2
|
+
if (component) {
|
|
3
|
+
callback(component);
|
|
4
|
+
}
|
|
5
|
+
if (component?.childrens?.length) {
|
|
6
|
+
// eslint-disable-next-line
|
|
7
|
+
for(let i = 0; i < component.childrens.length; i++){
|
|
8
|
+
const children = component.childrens[i];
|
|
9
|
+
loopComponent(children, callback);
|
|
10
|
+
}
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
export { loopComponent };
|
|
@@ -1 +1,149 @@
|
|
|
1
|
-
import{getResponsiveValueByScreen
|
|
1
|
+
import { getResponsiveValueByScreen } from './get-resonsive-value.js';
|
|
2
|
+
|
|
3
|
+
const removeNullUndefined = (obj)=>Object.entries(obj).reduce((a, [k, v])=>{
|
|
4
|
+
if (v === null || v === undefined) return a;
|
|
5
|
+
return {
|
|
6
|
+
...a,
|
|
7
|
+
[k]: v
|
|
8
|
+
};
|
|
9
|
+
}, {});
|
|
10
|
+
const makeStyleKey = (name)=>{
|
|
11
|
+
return [
|
|
12
|
+
name,
|
|
13
|
+
`hvr-${name}`,
|
|
14
|
+
`focus-${name}`,
|
|
15
|
+
`${name}-tablet`,
|
|
16
|
+
`hvr-${name}-tablet`,
|
|
17
|
+
`focus-${name}-tablet`,
|
|
18
|
+
`${name}-mobile`,
|
|
19
|
+
`hvr-${name}-mobile`,
|
|
20
|
+
`focus-${name}-mobile`
|
|
21
|
+
].map((key)=>`--${key}`);
|
|
22
|
+
};
|
|
23
|
+
const makeStyle = (style)=>{
|
|
24
|
+
return removeNullUndefined(Object.fromEntries(Object.entries(style).map(([key, value])=>[
|
|
25
|
+
`--${key}`,
|
|
26
|
+
value
|
|
27
|
+
])));
|
|
28
|
+
};
|
|
29
|
+
const makeStyleState = (name, value)=>{
|
|
30
|
+
if (!value) return {};
|
|
31
|
+
return {
|
|
32
|
+
[`--${name}`]: value?.normal,
|
|
33
|
+
[`--hvr-${name}`]: value?.hover,
|
|
34
|
+
[`--focus-${name}`]: value?.focus
|
|
35
|
+
};
|
|
36
|
+
};
|
|
37
|
+
const makeStyleResponsiveState = (name, value)=>{
|
|
38
|
+
if (!value) return {};
|
|
39
|
+
return {
|
|
40
|
+
[`--${name}`]: value?.desktop?.normal,
|
|
41
|
+
[`--hvr-${name}`]: value?.desktop?.hover,
|
|
42
|
+
[`--focus-${name}`]: value?.desktop?.focus,
|
|
43
|
+
[`--${name}-tablet`]: value?.tablet?.normal,
|
|
44
|
+
[`--hvr-${name}-tablet`]: value?.tablet?.hover,
|
|
45
|
+
[`--focus-${name}-tablet`]: value?.tablet?.focus,
|
|
46
|
+
[`--${name}-mobile`]: value?.mobile?.normal,
|
|
47
|
+
[`--hvr-${name}-mobile`]: value?.mobile?.hover,
|
|
48
|
+
[`--focus-${name}-mobile`]: value?.mobile?.focus
|
|
49
|
+
};
|
|
50
|
+
};
|
|
51
|
+
const makeStyleResponsive = (name, value, unit)=>{
|
|
52
|
+
return {
|
|
53
|
+
[`--${name}`]: unit ? `${value?.desktop}${unit}` : value?.desktop,
|
|
54
|
+
[`--${name}-tablet`]: unit ? `${value?.tablet}${unit}` : value?.tablet,
|
|
55
|
+
[`--${name}-mobile`]: unit ? `${value?.mobile}${unit}` : value?.mobile
|
|
56
|
+
};
|
|
57
|
+
};
|
|
58
|
+
const makeStyleResponsiveByScreen = (name, value, unit)=>{
|
|
59
|
+
return {
|
|
60
|
+
[`--${name}`]: unit ? `${getResponsiveValueByScreen(value, 'desktop')}${unit}` : getResponsiveValueByScreen(value, 'desktop'),
|
|
61
|
+
[`--${name}-tablet`]: unit ? `${getResponsiveValueByScreen(value, 'tablet')}${unit}` : getResponsiveValueByScreen(value, 'tablet'),
|
|
62
|
+
[`--${name}-mobile`]: unit ? `${getResponsiveValueByScreen(value, 'mobile')}${unit}` : getResponsiveValueByScreen(value, 'mobile')
|
|
63
|
+
};
|
|
64
|
+
};
|
|
65
|
+
const makeWidth = (widthValue, fullWidthValue)=>{
|
|
66
|
+
const getVal = (deviceValue, widthValue, fullWidthValue)=>{
|
|
67
|
+
const widthVal = getResponsiveValueByScreen(widthValue, deviceValue);
|
|
68
|
+
const fullWidthVal = fullWidthValue?.[deviceValue] === undefined ? fullWidthValue?.['desktop'] : fullWidthValue?.[deviceValue];
|
|
69
|
+
if (fullWidthVal) {
|
|
70
|
+
return '100%';
|
|
71
|
+
} else if (fullWidthVal === false) {
|
|
72
|
+
return widthVal ?? widthVal;
|
|
73
|
+
} else {
|
|
74
|
+
return widthVal || 'auto';
|
|
75
|
+
}
|
|
76
|
+
};
|
|
77
|
+
return {
|
|
78
|
+
desktop: getVal('desktop', widthValue, fullWidthValue),
|
|
79
|
+
tablet: getVal('tablet', widthValue, fullWidthValue),
|
|
80
|
+
mobile: getVal('mobile', widthValue, fullWidthValue)
|
|
81
|
+
};
|
|
82
|
+
};
|
|
83
|
+
const makeGlobalSizeWidthResponsive = (globalSize)=>{
|
|
84
|
+
return {
|
|
85
|
+
'--w': globalSize?.desktop?.width,
|
|
86
|
+
'--w-tablet': globalSize?.tablet?.width,
|
|
87
|
+
'--w-mobile': globalSize?.mobile?.width
|
|
88
|
+
};
|
|
89
|
+
};
|
|
90
|
+
const makeGlobalSizeHeightResponsive = (globalSize)=>{
|
|
91
|
+
return {
|
|
92
|
+
'--h': globalSize?.desktop?.height,
|
|
93
|
+
'--h-tablet': globalSize?.tablet?.height,
|
|
94
|
+
'--h-mobile': globalSize?.mobile?.height
|
|
95
|
+
};
|
|
96
|
+
};
|
|
97
|
+
const makeHeight = (heighValue, autoHeight)=>{
|
|
98
|
+
const getVal = (deviceValue, heighValue, autoHeight)=>{
|
|
99
|
+
const heightVal = heighValue?.[deviceValue];
|
|
100
|
+
const isAuto = autoHeight?.[deviceValue];
|
|
101
|
+
if (isAuto) {
|
|
102
|
+
return 'auto';
|
|
103
|
+
} else if (isAuto === false) {
|
|
104
|
+
return heightVal ?? heightVal;
|
|
105
|
+
} else {
|
|
106
|
+
return heightVal;
|
|
107
|
+
}
|
|
108
|
+
};
|
|
109
|
+
return {
|
|
110
|
+
desktop: getVal('desktop', heighValue, autoHeight),
|
|
111
|
+
tablet: getVal('tablet', heighValue, autoHeight),
|
|
112
|
+
mobile: getVal('mobile', heighValue, autoHeight)
|
|
113
|
+
};
|
|
114
|
+
};
|
|
115
|
+
const makeAspectRatio = (aspectRatio, aspectWidth, aspectHeight)=>{
|
|
116
|
+
let result = {};
|
|
117
|
+
const DEVICES = [
|
|
118
|
+
'desktop',
|
|
119
|
+
'mobile',
|
|
120
|
+
'tablet'
|
|
121
|
+
];
|
|
122
|
+
DEVICES.forEach((device)=>{
|
|
123
|
+
const aspectRatioDevice = getResponsiveValueByScreen(aspectRatio, device);
|
|
124
|
+
if (aspectRatioDevice !== 'none') {
|
|
125
|
+
result = {
|
|
126
|
+
...result,
|
|
127
|
+
[device]: aspectRatioDevice !== 'custom' ? aspectRatioDevice : `${getResponsiveValueByScreen(aspectWidth, 'desktop')}/${getResponsiveValueByScreen(aspectHeight, 'desktop')}`
|
|
128
|
+
};
|
|
129
|
+
}
|
|
130
|
+
});
|
|
131
|
+
return result;
|
|
132
|
+
};
|
|
133
|
+
const makeLineClamp = (lineClampValue, hasLineClampValue)=>{
|
|
134
|
+
const getVal = (deviceValue, lineClampValue, hasLineClampValue)=>{
|
|
135
|
+
const lineClamp = getResponsiveValueByScreen(lineClampValue, deviceValue);
|
|
136
|
+
const hasLineClamp = getResponsiveValueByScreen(hasLineClampValue, deviceValue);
|
|
137
|
+
if (hasLineClamp || hasLineClamp === undefined) {
|
|
138
|
+
return lineClamp;
|
|
139
|
+
}
|
|
140
|
+
return 'unset';
|
|
141
|
+
};
|
|
142
|
+
return {
|
|
143
|
+
desktop: getVal('desktop', lineClampValue, hasLineClampValue),
|
|
144
|
+
tablet: getVal('tablet', lineClampValue, hasLineClampValue),
|
|
145
|
+
mobile: getVal('mobile', lineClampValue, hasLineClampValue)
|
|
146
|
+
};
|
|
147
|
+
};
|
|
148
|
+
|
|
149
|
+
export { makeAspectRatio, makeGlobalSizeHeightResponsive, makeGlobalSizeWidthResponsive, makeHeight, makeLineClamp, makeStyle, makeStyleKey, makeStyleResponsive, makeStyleResponsiveByScreen, makeStyleResponsiveState, makeStyleState, makeWidth, removeNullUndefined };
|
|
@@ -1 +1,21 @@
|
|
|
1
|
-
function normalizeBuilderData(
|
|
1
|
+
function normalizeBuilderData(data) {
|
|
2
|
+
const result = {};
|
|
3
|
+
function compose(data, res = {}) {
|
|
4
|
+
const childrens = data.childrens;
|
|
5
|
+
const items = childrens?.map((child)=>child.uid) ?? [];
|
|
6
|
+
res[data.uid] = {
|
|
7
|
+
...data,
|
|
8
|
+
childrens: items,
|
|
9
|
+
type: 'component'
|
|
10
|
+
};
|
|
11
|
+
if (childrens) {
|
|
12
|
+
childrens.map((child)=>compose(child, res));
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
compose(data, result);
|
|
16
|
+
return {
|
|
17
|
+
...result
|
|
18
|
+
};
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
export { normalizeBuilderData };
|
|
@@ -1 +1,76 @@
|
|
|
1
|
-
import
|
|
1
|
+
import { unstable_serialize } from 'swr';
|
|
2
|
+
import { getCollection } from './queries/get-collection.js';
|
|
3
|
+
import { getProduct } from './queries/get-product.js';
|
|
4
|
+
import { getProducts } from './queries/get-products.js';
|
|
5
|
+
import { generateCollectionQueryKey, generateProductsQueryKey, generateProductQueryKey } from './query.js';
|
|
6
|
+
|
|
7
|
+
const prefetchQueries = (input, options)=>{
|
|
8
|
+
const queries = [];
|
|
9
|
+
Object.keys(input).forEach((key)=>{
|
|
10
|
+
const item = input[key];
|
|
11
|
+
let data = undefined;
|
|
12
|
+
switch(item.tag){
|
|
13
|
+
case 'Product':
|
|
14
|
+
{
|
|
15
|
+
if (item.settings?.isAuto) break;
|
|
16
|
+
const variables = {
|
|
17
|
+
id: item.settings?.productSetting?.productId ?? 'latest',
|
|
18
|
+
isSample: options?.isSample,
|
|
19
|
+
isStorefront: options?.isStorefront
|
|
20
|
+
};
|
|
21
|
+
data = {
|
|
22
|
+
key: unstable_serialize(generateProductQueryKey(variables)),
|
|
23
|
+
func: getProduct,
|
|
24
|
+
variables
|
|
25
|
+
};
|
|
26
|
+
break;
|
|
27
|
+
}
|
|
28
|
+
case 'ProductList':
|
|
29
|
+
{
|
|
30
|
+
const productSetting = item.settings?.productSetting;
|
|
31
|
+
if (productSetting?.productSrc === 'Collection') {
|
|
32
|
+
const variables = {
|
|
33
|
+
id: productSetting?.collectionId ?? 'latest',
|
|
34
|
+
numberOfProducts: item.settings?.numberOfProducts ?? 4,
|
|
35
|
+
orderBy: item.settings?.orderBy,
|
|
36
|
+
isSample: options?.isSample,
|
|
37
|
+
isStorefront: options?.isStorefront
|
|
38
|
+
};
|
|
39
|
+
data = {
|
|
40
|
+
key: unstable_serialize(generateCollectionQueryKey(variables)),
|
|
41
|
+
func: getCollection,
|
|
42
|
+
variables
|
|
43
|
+
};
|
|
44
|
+
} else {
|
|
45
|
+
const variables = {
|
|
46
|
+
ids: [
|
|
47
|
+
...productSetting?.productIds ?? []
|
|
48
|
+
].sort(),
|
|
49
|
+
isSample: options?.isSample,
|
|
50
|
+
isStorefront: options?.isStorefront
|
|
51
|
+
};
|
|
52
|
+
data = {
|
|
53
|
+
key: unstable_serialize(generateProductsQueryKey(variables)),
|
|
54
|
+
func: getProducts,
|
|
55
|
+
variables
|
|
56
|
+
};
|
|
57
|
+
}
|
|
58
|
+
break;
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
if (data) {
|
|
62
|
+
queries.push(data);
|
|
63
|
+
}
|
|
64
|
+
});
|
|
65
|
+
return queries.reduce((accumulator, current)=>{
|
|
66
|
+
if (!accumulator.some((x)=>x.key === current.key)) {
|
|
67
|
+
return [
|
|
68
|
+
...accumulator,
|
|
69
|
+
current
|
|
70
|
+
];
|
|
71
|
+
}
|
|
72
|
+
return accumulator;
|
|
73
|
+
}, []);
|
|
74
|
+
};
|
|
75
|
+
|
|
76
|
+
export { prefetchQueries };
|
|
@@ -1 +1,44 @@
|
|
|
1
|
-
import{checkInStock
|
|
1
|
+
import { checkInStock } from './variant.js';
|
|
2
|
+
|
|
3
|
+
function getSelectedVariant(variants, choices, variantId) {
|
|
4
|
+
/**
|
|
5
|
+
* Ensure the user has selected all the required options, not just some.
|
|
6
|
+
*/ if (!variants || !variants.length || !choices || variants[0]?.selectedOptions.length !== Object.keys(choices).length) {
|
|
7
|
+
return;
|
|
8
|
+
}
|
|
9
|
+
if (variantId) {
|
|
10
|
+
return variants.find((variant)=>variant?.id === variantId);
|
|
11
|
+
}
|
|
12
|
+
return variants.find((variant)=>{
|
|
13
|
+
return Object.entries(choices).every(([name, value])=>{
|
|
14
|
+
return variant?.selectedOptions.some((option)=>option.name === name && option.value === value);
|
|
15
|
+
});
|
|
16
|
+
});
|
|
17
|
+
}
|
|
18
|
+
function parseSelectedOption(options) {
|
|
19
|
+
if (!options || options && options.length === 0) {
|
|
20
|
+
return;
|
|
21
|
+
}
|
|
22
|
+
return options.reduce((acc, { name, value })=>{
|
|
23
|
+
if (name && value) {
|
|
24
|
+
return {
|
|
25
|
+
...acc,
|
|
26
|
+
[name]: value
|
|
27
|
+
};
|
|
28
|
+
}
|
|
29
|
+
return acc;
|
|
30
|
+
}, {});
|
|
31
|
+
}
|
|
32
|
+
function checkAvailableVariantInStock(variants, optionId, optionValue) {
|
|
33
|
+
return variants ? variants.some((item)=>{
|
|
34
|
+
if (item) {
|
|
35
|
+
const { selectedOptions } = item;
|
|
36
|
+
const opt = selectedOptions?.some((option)=>option?.name === optionId && option.value === optionValue);
|
|
37
|
+
const isInStock = checkInStock(item);
|
|
38
|
+
return opt && isInStock;
|
|
39
|
+
}
|
|
40
|
+
return false;
|
|
41
|
+
}) : false;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
export { checkAvailableVariantInStock, getSelectedVariant, parseSelectedOption };
|