@gem-sdk/core 1.37.5 → 2.0.0-dev.832
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 +1 -18
- package/dist/cjs/components/ComponentToolbarPreview.js +1 -465
- package/dist/cjs/components/ComponentWrapper.js +1 -46
- package/dist/cjs/components/ComponentWrapperPreview.js +1 -136
- package/dist/cjs/components/Empty.js +1 -7
- package/dist/cjs/components/Render.js +1 -65
- package/dist/cjs/components/Render.liquid.js +14 -288
- package/dist/cjs/components/RenderBlock.js +1 -54
- package/dist/cjs/components/RenderCustomCode.js +3 -56
- package/dist/cjs/components/RenderPreview.js +1 -66
- package/dist/cjs/components/RenderSection.js +1 -23
- package/dist/cjs/components/ai-generator/AIContentGenerator.js +1 -0
- package/dist/cjs/components/ai-generator/AIGenContentLoading.js +1 -0
- package/dist/cjs/components/ai-generator/components/PickProduct.js +1 -0
- package/dist/cjs/components/ai-generator/components/ToneAndVoice.js +1 -0
- package/dist/cjs/components/ai-generator/hooks/useGettingGenerateRequest.js +1 -0
- package/dist/cjs/components/ai-generator/hooks/useListenEventGenerate.js +1 -0
- package/dist/cjs/components/ai-generator/icons/AIIcon.js +1 -0
- package/dist/cjs/components/ai-generator/icons/CloseIcon.js +1 -0
- package/dist/cjs/components/ai-generator/icons/DropdownIcon.js +1 -0
- package/dist/cjs/components/ai-generator/icons/ShowMoreIcon.js +1 -0
- package/dist/cjs/components/animation/AnimationWrapper.js +1 -0
- package/dist/cjs/components/constant.js +1 -54
- package/dist/cjs/components/resize/Resize.js +1 -16
- package/dist/cjs/components/resize/Spacing.js +1 -248
- package/dist/cjs/components/src/product/helpers/variant-presets.js +1 -56
- package/dist/cjs/components/theme-section/CreateThemeSection.js +1 -117
- package/dist/cjs/components/theme-section/ThemeSectionStatus.js +1 -36
- package/dist/cjs/components/theme-section/ThemeSectionTooltip.js +1 -102
- package/dist/cjs/components/toolbar/Tooltip.js +1 -22
- package/dist/cjs/contexts/AddonContext.js +1 -36
- package/dist/cjs/contexts/BuilderComponent.js +1 -34
- package/dist/cjs/contexts/BuilderContext.js +1 -35
- package/dist/cjs/contexts/BuilderPreviewContext.js +1 -479
- package/dist/cjs/contexts/CartLineContext.js +1 -29
- package/dist/cjs/contexts/CollectionContext.js +1 -38
- package/dist/cjs/contexts/ModalContext.js +1 -47
- package/dist/cjs/contexts/PageContext.js +1 -44
- package/dist/cjs/contexts/ProductContext.js +1 -156
- package/dist/cjs/contexts/ProductListContext.js +1 -32
- package/dist/cjs/contexts/SectionContext.js +1 -53
- package/dist/cjs/contexts/ShopContext.js +1 -80
- 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 +2 -6
- 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/product-little.generated.js +11 -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 +11 -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 +3 -9
- 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 +3 -7
- 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 -14
- 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 +2 -10
- package/dist/cjs/graphql/queries/products.generated.js +12 -17
- package/dist/cjs/graphql/queries/published-theme-pages.generated.js +2 -15
- package/dist/cjs/graphql/queries/store-property.generated.js +2 -6
- package/dist/cjs/graphql-app-api/queries/LibraryTemplate.generated.js +13 -0
- package/dist/cjs/graphql-app-api/queries/SaleFunnelDiscounts.generated.js +34 -0
- package/dist/cjs/graphql-app-api/queries/ThemePage.generated.js +22 -0
- package/dist/cjs/helpers/GlobalEvent.js +1 -19
- package/dist/cjs/helpers/animations.js +1 -213
- package/dist/cjs/helpers/background.js +1 -230
- package/dist/cjs/helpers/borders.js +4 -183
- package/dist/cjs/helpers/carousel.js +1 -58
- 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 -268
- 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-toolbar-preview.js +1 -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/is-browser.js +1 -9
- package/dist/cjs/helpers/is-defined.js +1 -7
- package/dist/cjs/helpers/is-empty-children.js +1 -15
- package/dist/cjs/helpers/is-safari.js +1 -9
- package/dist/cjs/helpers/layout.js +1 -59
- package/dist/cjs/helpers/load-script.js +1 -31
- package/dist/cjs/helpers/make-style.js +1 -163
- package/dist/cjs/helpers/normalize-builder-data.js +1 -23
- 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 -163
- package/dist/cjs/helpers/query.js +1 -29
- package/dist/cjs/helpers/radius.js +6 -140
- package/dist/cjs/helpers/render.js +1 -76
- package/dist/cjs/helpers/shadow.js +1 -57
- package/dist/cjs/helpers/size.js +4 -183
- package/dist/cjs/helpers/spacing.js +1 -43
- 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 +17 -126
- package/dist/cjs/helpers/variant.js +1 -11
- package/dist/cjs/hooks/animation/animations.js +1 -0
- package/dist/cjs/hooks/animation/useAnimationActions.js +1 -39
- package/dist/cjs/hooks/animation/useAnimationConfig.js +1 -29
- package/dist/cjs/hooks/animation/useAnimationPreview.js +1 -31
- package/dist/cjs/hooks/animation/useAnimationTarget.js +1 -120
- package/dist/cjs/hooks/animation/useApplyAnimation.js +1 -87
- package/dist/cjs/hooks/animation/useLivePageAnimation.js +1 -0
- package/dist/cjs/hooks/cart/use-add-to-cart.js +1 -20
- package/dist/cjs/hooks/cart/use-cart-data.js +1 -28
- package/dist/cjs/hooks/cart/use-cart-discount-codes-update.js +1 -20
- package/dist/cjs/hooks/cart/use-cart-note-update.js +1 -20
- package/dist/cjs/hooks/cart/use-create-cart.js +1 -22
- package/dist/cjs/hooks/cart/use-remove-cart-item.js +1 -20
- package/dist/cjs/hooks/cart/use-update-cart-item.js +1 -20
- package/dist/cjs/hooks/shop/use-collection-query.js +1 -22
- package/dist/cjs/hooks/shop/use-collections-query.js +1 -17
- package/dist/cjs/hooks/shop/use-product-query.js +1 -22
- package/dist/cjs/hooks/shop/use-products-query.js +1 -23
- package/dist/cjs/hooks/shop.js +1 -126
- package/dist/cjs/hooks/use-current-device.js +1 -21
- package/dist/cjs/hooks/use-lazy-video.js +1 -15
- package/dist/cjs/hooks/useAnimations.js +1 -26
- package/dist/cjs/hooks/useCartId.js +1 -44
- package/dist/cjs/hooks/useCartLine.js +1 -11
- package/dist/cjs/hooks/useCartUI.js +1 -48
- package/dist/cjs/hooks/useCollection.js +1 -9
- package/dist/cjs/hooks/useFetchHandle.js +1 -13
- package/dist/cjs/hooks/useFormatMoney.js +1 -58
- package/dist/cjs/hooks/useInitialSwatchesOptions.js +1 -113
- package/dist/cjs/hooks/useIsomorphicLayoutEffect.js +1 -10
- package/dist/cjs/hooks/useLoadScript.js +1 -32
- package/dist/cjs/hooks/useMoney.js +1 -84
- package/dist/cjs/hooks/usePrevious.js +1 -19
- package/dist/cjs/hooks/useProduct.js +1 -206
- package/dist/cjs/hooks/useProductList.js +1 -21
- package/dist/cjs/hooks/useSuspenseFetch.js +1 -27
- package/dist/cjs/hooks/useSwatchesOptions.js +1 -41
- package/dist/cjs/hooks/useToolbarPostPurchase.js +1 -0
- package/dist/cjs/index.js +1 -361
- package/dist/cjs/types/animations.js +1 -47
- package/dist/cjs/types/appAPI.js +1 -0
- package/dist/cjs/types/global-style.js +1 -15
- package/dist/cjs/types/shop.js +1 -2
- package/dist/cjs/web-components/src/helpers/styles/constant.js +1 -9
- package/dist/esm/components/AddOn.js +1 -14
- package/dist/esm/components/ComponentToolbarPreview.js +1 -463
- package/dist/esm/components/ComponentWrapper.js +1 -42
- package/dist/esm/components/ComponentWrapperPreview.js +1 -132
- package/dist/esm/components/Empty.js +1 -3
- package/dist/esm/components/Render.js +1 -61
- package/dist/esm/components/Render.liquid.js +14 -282
- package/dist/esm/components/RenderBlock.js +1 -50
- package/dist/esm/components/RenderCustomCode.js +3 -52
- package/dist/esm/components/RenderPreview.js +1 -62
- package/dist/esm/components/RenderSection.js +1 -19
- package/dist/esm/components/ai-generator/AIContentGenerator.js +1 -0
- package/dist/esm/components/ai-generator/AIGenContentLoading.js +1 -0
- package/dist/esm/components/ai-generator/components/PickProduct.js +1 -0
- package/dist/esm/components/ai-generator/components/ToneAndVoice.js +1 -0
- package/dist/esm/components/ai-generator/hooks/useGettingGenerateRequest.js +1 -0
- package/dist/esm/components/ai-generator/hooks/useListenEventGenerate.js +1 -0
- package/dist/esm/components/ai-generator/icons/AIIcon.js +1 -0
- package/dist/esm/components/ai-generator/icons/CloseIcon.js +1 -0
- package/dist/esm/components/ai-generator/icons/DropdownIcon.js +1 -0
- package/dist/esm/components/ai-generator/icons/ShowMoreIcon.js +1 -0
- package/dist/esm/components/animation/AnimationWrapper.js +1 -0
- package/dist/esm/components/constant.js +1 -50
- package/dist/esm/components/resize/Resize.js +1 -12
- package/dist/esm/components/resize/Spacing.js +1 -244
- package/dist/esm/components/src/product/helpers/variant-presets.js +1 -54
- package/dist/esm/components/theme-section/CreateThemeSection.js +1 -115
- package/dist/esm/components/theme-section/ThemeSectionStatus.js +1 -34
- package/dist/esm/components/theme-section/ThemeSectionTooltip.js +1 -100
- package/dist/esm/components/toolbar/Tooltip.js +1 -18
- package/dist/esm/contexts/AddonContext.js +1 -32
- package/dist/esm/contexts/BuilderComponent.js +1 -31
- package/dist/esm/contexts/BuilderContext.js +1 -32
- package/dist/esm/contexts/BuilderPreviewContext.js +1 -476
- package/dist/esm/contexts/CartLineContext.js +1 -26
- package/dist/esm/contexts/CollectionContext.js +1 -35
- package/dist/esm/contexts/ModalContext.js +1 -44
- package/dist/esm/contexts/PageContext.js +1 -41
- package/dist/esm/contexts/ProductContext.js +1 -153
- package/dist/esm/contexts/ProductListContext.js +1 -28
- package/dist/esm/contexts/SectionContext.js +1 -49
- package/dist/esm/contexts/ShopContext.js +1 -77
- 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 +2 -4
- 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/product-little.generated.js +11 -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 +11 -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 +3 -6
- 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 +3 -5
- 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 +8 -18
- 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 +4 -10
- package/dist/esm/graphql/queries/products.generated.js +18 -20
- package/dist/esm/graphql/queries/published-theme-pages.generated.js +9 -20
- package/dist/esm/graphql/queries/store-property.generated.js +2 -4
- package/dist/esm/graphql-app-api/queries/LibraryTemplate.generated.js +13 -0
- package/dist/esm/graphql-app-api/queries/SaleFunnelDiscounts.generated.js +34 -0
- package/dist/esm/graphql-app-api/queries/ThemePage.generated.js +22 -0
- package/dist/esm/helpers/GlobalEvent.js +1 -15
- package/dist/esm/helpers/animations.js +1 -211
- package/dist/esm/helpers/background.js +1 -222
- package/dist/esm/helpers/borders.js +4 -175
- package/dist/esm/helpers/carousel.js +1 -54
- 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 -261
- 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-toolbar-preview.js +1 -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/is-browser.js +1 -5
- package/dist/esm/helpers/is-defined.js +1 -5
- package/dist/esm/helpers/is-empty-children.js +1 -10
- package/dist/esm/helpers/is-safari.js +1 -5
- package/dist/esm/helpers/layout.js +1 -54
- package/dist/esm/helpers/load-script.js +1 -29
- package/dist/esm/helpers/make-style.js +1 -149
- package/dist/esm/helpers/normalize-builder-data.js +1 -21
- 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 -161
- package/dist/esm/helpers/query.js +1 -25
- package/dist/esm/helpers/radius.js +6 -132
- package/dist/esm/helpers/render.js +1 -68
- package/dist/esm/helpers/shadow.js +1 -52
- package/dist/esm/helpers/size.js +4 -171
- package/dist/esm/helpers/spacing.js +1 -40
- 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 +17 -116
- package/dist/esm/helpers/variant.js +1 -9
- package/dist/esm/hooks/animation/animations.js +1 -0
- package/dist/esm/hooks/animation/useAnimationActions.js +1 -37
- package/dist/esm/hooks/animation/useAnimationConfig.js +1 -27
- package/dist/esm/hooks/animation/useAnimationPreview.js +1 -29
- package/dist/esm/hooks/animation/useAnimationTarget.js +1 -118
- package/dist/esm/hooks/animation/useApplyAnimation.js +1 -83
- package/dist/esm/hooks/animation/useLivePageAnimation.js +1 -0
- package/dist/esm/hooks/cart/use-add-to-cart.js +1 -18
- package/dist/esm/hooks/cart/use-cart-data.js +1 -26
- package/dist/esm/hooks/cart/use-cart-discount-codes-update.js +1 -18
- package/dist/esm/hooks/cart/use-cart-note-update.js +1 -18
- package/dist/esm/hooks/cart/use-create-cart.js +1 -20
- package/dist/esm/hooks/cart/use-remove-cart-item.js +1 -18
- package/dist/esm/hooks/cart/use-update-cart-item.js +1 -18
- package/dist/esm/hooks/shop/use-collection-query.js +1 -20
- package/dist/esm/hooks/shop/use-collections-query.js +1 -15
- package/dist/esm/hooks/shop/use-product-query.js +1 -20
- package/dist/esm/hooks/shop/use-products-query.js +1 -21
- package/dist/esm/hooks/shop.js +1 -111
- package/dist/esm/hooks/use-current-device.js +1 -19
- package/dist/esm/hooks/use-lazy-video.js +1 -13
- package/dist/esm/hooks/useAnimations.js +1 -24
- package/dist/esm/hooks/useCartId.js +1 -40
- package/dist/esm/hooks/useCartLine.js +1 -7
- package/dist/esm/hooks/useCartUI.js +1 -44
- package/dist/esm/hooks/useCollection.js +1 -7
- package/dist/esm/hooks/useFetchHandle.js +1 -11
- package/dist/esm/hooks/useFormatMoney.js +1 -56
- package/dist/esm/hooks/useInitialSwatchesOptions.js +1 -109
- package/dist/esm/hooks/useIsomorphicLayoutEffect.js +1 -6
- package/dist/esm/hooks/useLoadScript.js +1 -28
- package/dist/esm/hooks/useMoney.js +1 -80
- package/dist/esm/hooks/usePrevious.js +1 -17
- package/dist/esm/hooks/useProduct.js +1 -192
- package/dist/esm/hooks/useProductList.js +1 -16
- package/dist/esm/hooks/useSuspenseFetch.js +1 -23
- package/dist/esm/hooks/useSwatchesOptions.js +1 -37
- package/dist/esm/hooks/useToolbarPostPurchase.js +1 -0
- package/dist/esm/index.js +1 -100
- package/dist/esm/types/animations.js +1 -47
- package/dist/esm/types/appAPI.js +1 -0
- package/dist/esm/types/global-style.js +1 -12
- package/dist/esm/web-components/src/helpers/styles/constant.js +1 -7
- package/dist/types/index.d.ts +24802 -6237
- package/package.json +8 -3
|
@@ -1,40 +1 @@
|
|
|
1
|
-
import
|
|
2
|
-
|
|
3
|
-
function getSpacingCSSByType(key, device) {
|
|
4
|
-
if (!key) return {};
|
|
5
|
-
const suffix = device ? devicesMapping?.[device] ?? '' : '';
|
|
6
|
-
return {
|
|
7
|
-
[`--p${suffix}`]: `var(--g-s-${key})`
|
|
8
|
-
};
|
|
9
|
-
}
|
|
10
|
-
function getSpacingVariable(key) {
|
|
11
|
-
if (!key) return '';
|
|
12
|
-
return `var(--g-s-${key})`;
|
|
13
|
-
}
|
|
14
|
-
const composeSpacing = (spacingValue)=>{
|
|
15
|
-
const style = {};
|
|
16
|
-
switch(spacingValue?.desktop){
|
|
17
|
-
case 'm':
|
|
18
|
-
case 'l':
|
|
19
|
-
case 's':
|
|
20
|
-
Object.assign(style, getSpacingCSSByType(spacingValue.desktop));
|
|
21
|
-
break;
|
|
22
|
-
}
|
|
23
|
-
switch(spacingValue?.tablet){
|
|
24
|
-
case 'm':
|
|
25
|
-
case 'l':
|
|
26
|
-
case 's':
|
|
27
|
-
Object.assign(style, getSpacingCSSByType(spacingValue.tablet, 'tablet'));
|
|
28
|
-
break;
|
|
29
|
-
}
|
|
30
|
-
switch(spacingValue?.mobile){
|
|
31
|
-
case 'm':
|
|
32
|
-
case 'l':
|
|
33
|
-
case 's':
|
|
34
|
-
Object.assign(style, getSpacingCSSByType(spacingValue.mobile, 'mobile'));
|
|
35
|
-
break;
|
|
36
|
-
}
|
|
37
|
-
return style;
|
|
38
|
-
};
|
|
39
|
-
|
|
40
|
-
export { composeSpacing, getSpacingVariable };
|
|
1
|
+
import{devicesMapping as e}from"./constant.js";function getSpacingCSSByType(t,a){if(!t)return{};let s=a?e?.[a]??"":"";return{[`--p${s}`]:`var(--g-s-${t})`}}function getSpacingVariable(e){return e?`var(--g-s-${e})`:""}let composeSpacing=e=>{let t={};switch(e?.desktop){case"m":case"l":case"s":Object.assign(t,getSpacingCSSByType(e.desktop))}switch(e?.tablet){case"m":case"l":case"s":Object.assign(t,getSpacingCSSByType(e.tablet,"tablet"))}switch(e?.mobile){case"m":case"l":case"s":Object.assign(t,getSpacingCSSByType(e.mobile,"mobile"))}return t};export{composeSpacing,getSpacingVariable};
|
|
@@ -1,24 +1 @@
|
|
|
1
|
-
|
|
2
|
-
if (!window.fbq) return;
|
|
3
|
-
window.fbq('track', 'PageView');
|
|
4
|
-
};
|
|
5
|
-
// https://developers.facebook.com/docs/facebook-pixel/advanced/
|
|
6
|
-
const event = (name, options = {})=>{
|
|
7
|
-
if (!window.fbq) return;
|
|
8
|
-
window.fbq('track', name, options);
|
|
9
|
-
};
|
|
10
|
-
const addToCart = (product)=>{
|
|
11
|
-
if (!window.fbq) return;
|
|
12
|
-
window.fbq('track', 'AddToCart', {
|
|
13
|
-
content_ids: [
|
|
14
|
-
product.id
|
|
15
|
-
],
|
|
16
|
-
content_name: product.name,
|
|
17
|
-
content_category: product.category,
|
|
18
|
-
content_type: 'product',
|
|
19
|
-
value: product.price,
|
|
20
|
-
currency: product.currency
|
|
21
|
-
});
|
|
22
|
-
};
|
|
23
|
-
|
|
24
|
-
export { addToCart, event, pageview };
|
|
1
|
+
let pageview=()=>{window.fbq&&window.fbq("track","PageView")},event=(e,t={})=>{window.fbq&&window.fbq("track",e,t)},addToCart=e=>{window.fbq&&window.fbq("track","AddToCart",{content_ids:[e.id],content_name:e.name,content_category:e.category,content_type:"product",value:e.price,currency:e.currency})};export{addToCart,event,pageview};
|
|
@@ -1,87 +1 @@
|
|
|
1
|
-
|
|
2
|
-
const pageview = (url, trackingId)=>{
|
|
3
|
-
// GA 4
|
|
4
|
-
if (window.gtag && trackingId) {
|
|
5
|
-
window.gtag('config', trackingId, {
|
|
6
|
-
page_path: url
|
|
7
|
-
});
|
|
8
|
-
}
|
|
9
|
-
// GA 3
|
|
10
|
-
if (window.ga) {
|
|
11
|
-
window.ga('send', 'pageview', url);
|
|
12
|
-
}
|
|
13
|
-
};
|
|
14
|
-
/** Addition to cart events
|
|
15
|
-
* https://developers.google.com/analytics/devguides/collection/analyticsjs/enhanced-ecommerce#add-remove-cart
|
|
16
|
-
*/ const addToCart = (product)=>{
|
|
17
|
-
// GA 3
|
|
18
|
-
if (!window.ga || !product) {
|
|
19
|
-
return;
|
|
20
|
-
}
|
|
21
|
-
window.ga('ec:addProduct', {
|
|
22
|
-
...product,
|
|
23
|
-
id: product.sku,
|
|
24
|
-
name: product.variant === 'Default Title' ? product.name : `${product.name} - ${product.variant}`,
|
|
25
|
-
variant: product.variant === 'Default Title' ? product.name : product.variant
|
|
26
|
-
});
|
|
27
|
-
window.ga('ec:setAction', 'add');
|
|
28
|
-
window.ga('send', 'event', {
|
|
29
|
-
eventCategory: 'EnhancedEcommerce',
|
|
30
|
-
eventAction: 'Added Product',
|
|
31
|
-
nonInteraction: true
|
|
32
|
-
});
|
|
33
|
-
};
|
|
34
|
-
/** Product clicked event
|
|
35
|
-
* https://developers.google.com/analytics/devguides/collection/analyticsjs/enhanced-ecommerce#product-click
|
|
36
|
-
*/ const productClick = (product)=>{
|
|
37
|
-
if (!window.ga) {
|
|
38
|
-
return;
|
|
39
|
-
}
|
|
40
|
-
ga('ec:addProduct', {
|
|
41
|
-
id: product.id,
|
|
42
|
-
name: product.name,
|
|
43
|
-
category: product.category,
|
|
44
|
-
brand: product.brand,
|
|
45
|
-
variant: product.variant
|
|
46
|
-
});
|
|
47
|
-
ga('ec:setAction', 'click');
|
|
48
|
-
ga('send', 'event', {
|
|
49
|
-
eventAction: 'Click',
|
|
50
|
-
eventCategory: 'Product'
|
|
51
|
-
});
|
|
52
|
-
};
|
|
53
|
-
/** Product viewed event
|
|
54
|
-
* https://developers.google.com/analytics/devguides/collection/analyticsjs/enhanced-ecommerce#measuring-actvities
|
|
55
|
-
*/ const productDetail = (product)=>{
|
|
56
|
-
if (!product || !window.ga) return;
|
|
57
|
-
ga('ec:addProduct', {
|
|
58
|
-
brand: product.brand,
|
|
59
|
-
category: product.category,
|
|
60
|
-
id: product.id,
|
|
61
|
-
name: product.name,
|
|
62
|
-
variant: product.variant
|
|
63
|
-
});
|
|
64
|
-
ga('ec:setAction', 'detail');
|
|
65
|
-
ga('send', 'event', {
|
|
66
|
-
eventAction: 'Detail',
|
|
67
|
-
eventCategory: 'Ecommerce',
|
|
68
|
-
nonInteraction: 1
|
|
69
|
-
});
|
|
70
|
-
};
|
|
71
|
-
/** Removal from cart events
|
|
72
|
-
* https://developers.google.com/analytics/devguides/collection/analyticsjs/enhanced-ecommerce#add-remove-cart
|
|
73
|
-
*/ const removeFromCart = (product, price)=>{
|
|
74
|
-
if (!product || !window.ga) return;
|
|
75
|
-
ga('ec:addProduct', {
|
|
76
|
-
id: product.id,
|
|
77
|
-
name: product.name,
|
|
78
|
-
price
|
|
79
|
-
});
|
|
80
|
-
ga('ec:setAction', 'remove');
|
|
81
|
-
ga('send', 'event', {
|
|
82
|
-
eventAction: 'Click',
|
|
83
|
-
eventCategory: 'Remove from cart'
|
|
84
|
-
});
|
|
85
|
-
};
|
|
86
|
-
|
|
87
|
-
export { addToCart, pageview, productClick, productDetail, removeFromCart };
|
|
1
|
+
let pageview=(e,a)=>{window.gtag&&a&&window.gtag("config",a,{page_path:e}),window.ga&&window.ga("send","pageview",e)},addToCart=e=>{window.ga&&e&&(window.ga("ec:addProduct",{...e,id:e.sku,name:"Default Title"===e.variant?e.name:`${e.name} - ${e.variant}`,variant:"Default Title"===e.variant?e.name:e.variant}),window.ga("ec:setAction","add"),window.ga("send","event",{eventCategory:"EnhancedEcommerce",eventAction:"Added Product",nonInteraction:!0}))},productClick=e=>{window.ga&&(ga("ec:addProduct",{id:e.id,name:e.name,category:e.category,brand:e.brand,variant:e.variant}),ga("ec:setAction","click"),ga("send","event",{eventAction:"Click",eventCategory:"Product"}))},productDetail=e=>{e&&window.ga&&(ga("ec:addProduct",{brand:e.brand,category:e.category,id:e.id,name:e.name,variant:e.variant}),ga("ec:setAction","detail"),ga("send","event",{eventAction:"Detail",eventCategory:"Ecommerce",nonInteraction:1}))},removeFromCart=(e,a)=>{e&&window.ga&&(ga("ec:addProduct",{id:e.id,name:e.name,price:a}),ga("ec:setAction","remove"),ga("send","event",{eventAction:"Click",eventCategory:"Remove from cart"}))};export{addToCart,pageview,productClick,productDetail,removeFromCart};
|
|
@@ -1,15 +1 @@
|
|
|
1
|
-
|
|
2
|
-
const addToCart = (product)=>{
|
|
3
|
-
if (!window?.ttq?.track) return;
|
|
4
|
-
window.ttq.track('AddToCart', {
|
|
5
|
-
content_id: product.id,
|
|
6
|
-
content_type: 'product',
|
|
7
|
-
content_name: product.name,
|
|
8
|
-
quantity: product.quantity,
|
|
9
|
-
price: product.price,
|
|
10
|
-
value: (product.price ?? 0) * (product.quantity ?? 0),
|
|
11
|
-
currency: product.currency
|
|
12
|
-
});
|
|
13
|
-
};
|
|
14
|
-
|
|
15
|
-
export { addToCart };
|
|
1
|
+
let addToCart=t=>{window?.ttq?.track&&window.ttq.track("AddToCart",{content_id:t.id,content_type:"product",content_name:t.name,quantity:t.quantity,price:t.price,value:(t.price??0)*(t.quantity??0),currency:t.currency})};export{addToCart};
|
|
@@ -1,116 +1,17 @@
|
|
|
1
|
-
import
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
}
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
${
|
|
12
|
-
${
|
|
13
|
-
${
|
|
14
|
-
${
|
|
15
|
-
${
|
|
16
|
-
${
|
|
17
|
-
|
|
18
|
-
};
|
|
19
|
-
const composeTypographyV2Css = (typography, isImportant)=>{
|
|
20
|
-
const typographyCustom = typography?.custom;
|
|
21
|
-
const { fontFamily, fontSize, fontWeight, lineHeight, letterSpacing } = typographyCustom ?? {};
|
|
22
|
-
const typographyAttrs = typography?.attrs;
|
|
23
|
-
const { bold, italic, underline, transform } = typographyAttrs ?? {};
|
|
24
|
-
const composeImportant = isImportant ? '!important' : '';
|
|
25
|
-
return `
|
|
26
|
-
${fontFamily ? `font-family: var(--g-font-${fontFamily}, ${fontFamily}) ${composeImportant};` : ''}
|
|
27
|
-
${fontSize?.desktop ? `font-size: ${fontSize?.desktop} ${composeImportant};` : ''}
|
|
28
|
-
${bold ? `font-weight: bold ${composeImportant};` : fontWeight ? `font-weight: ${fontWeight} ${composeImportant};` : ''}
|
|
29
|
-
${letterSpacing ? `letter-spacing: ${letterSpacing} ${composeImportant};` : ''}
|
|
30
|
-
${lineHeight ? `line-height: ${lineHeight} ${composeImportant};` : ''}
|
|
31
|
-
${italic ? `font-style: italic ${composeImportant};` : ''}
|
|
32
|
-
${underline ? `text-decoration-line: underline ${composeImportant};` : ''}
|
|
33
|
-
${transform ? `text-transform: ${transform} ${composeImportant};` : ''}
|
|
34
|
-
`;
|
|
35
|
-
};
|
|
36
|
-
function getCustomCSSByDevice(typography, device) {
|
|
37
|
-
if (!typography || !device) return {};
|
|
38
|
-
const suffix = device === 'desktop' || !device ? '' : `-${device}`;
|
|
39
|
-
const { fontFamily } = typography?.[device] ?? {};
|
|
40
|
-
return {
|
|
41
|
-
[`--size${suffix}`]: typography?.[device]?.fontSize,
|
|
42
|
-
[`--lh${suffix}`]: typography?.[device]?.lineHeight,
|
|
43
|
-
[`--fs${suffix}`]: typography?.[device]?.fontStyle,
|
|
44
|
-
[`--ff${suffix}`]: fontFamily ? `var(--g-font-${fontFamily}, ${fontFamily})` : undefined,
|
|
45
|
-
[`--weight${suffix}`]: typography?.[device]?.fontWeight,
|
|
46
|
-
[`--ls${suffix}`]: typography?.[device]?.letterSpacing
|
|
47
|
-
};
|
|
48
|
-
}
|
|
49
|
-
const composeTypography = (typography)=>{
|
|
50
|
-
if (!typography) return {};
|
|
51
|
-
return removeNullUndefined({
|
|
52
|
-
...getCustomCSSByDevice(typography, 'desktop'),
|
|
53
|
-
...getCustomCSSByDevice(typography, 'tablet'),
|
|
54
|
-
...getCustomCSSByDevice(typography, 'mobile')
|
|
55
|
-
});
|
|
56
|
-
};
|
|
57
|
-
const composeTypographyV2 = (value, attrs)=>{
|
|
58
|
-
if (!value) return {};
|
|
59
|
-
return removeNullUndefined({
|
|
60
|
-
...makeStyle({
|
|
61
|
-
fs: !attrs?.italic ? value?.fontStyle : undefined,
|
|
62
|
-
ff: value?.fontFamily ? `var(--g-font-${value.fontFamily.replace(/ /g, '-')}, '${value.fontFamily}'), ${value.fallbackFontFamily}` : undefined,
|
|
63
|
-
weight: !attrs?.bold ? value?.fontWeight : undefined,
|
|
64
|
-
ls: value?.letterSpacing,
|
|
65
|
-
lh: value?.lineHeight
|
|
66
|
-
}),
|
|
67
|
-
...makeStyleResponsive('size', value?.fontSize)
|
|
68
|
-
});
|
|
69
|
-
};
|
|
70
|
-
const composeTypographyAttr = (attrs)=>{
|
|
71
|
-
if (!attrs) return {};
|
|
72
|
-
return removeNullUndefined({
|
|
73
|
-
...makeStyle({
|
|
74
|
-
fs: attrs?.italic ? 'italic' : undefined,
|
|
75
|
-
weight: attrs?.bold ? 'bold' : undefined,
|
|
76
|
-
c: getSingleColorVariable(attrs?.color),
|
|
77
|
-
tt: attrs?.transform,
|
|
78
|
-
tdl: attrs?.underline ? 'underline' : undefined
|
|
79
|
-
})
|
|
80
|
-
});
|
|
81
|
-
};
|
|
82
|
-
const composeTypographyClassName = (typo, typography)=>{
|
|
83
|
-
return typo ? typo?.type && !typo.custom ? genTypoClass(typo.type) : '' : typography?.type && genTypoClass(typography?.type);
|
|
84
|
-
};
|
|
85
|
-
const composeFallbackTypographyStyle = (tag)=>{
|
|
86
|
-
if ([
|
|
87
|
-
'heading',
|
|
88
|
-
'heading-1',
|
|
89
|
-
'heading-2',
|
|
90
|
-
'heading-3',
|
|
91
|
-
'heading-4',
|
|
92
|
-
'heading-5',
|
|
93
|
-
'heading-6'
|
|
94
|
-
].includes(tag)) {
|
|
95
|
-
return 'var(--g-font-heading, heading)';
|
|
96
|
-
}
|
|
97
|
-
return 'var(--g-font-body, body)';
|
|
98
|
-
};
|
|
99
|
-
const composeTypographyStyle = (typo, typography, disableAttr)=>{
|
|
100
|
-
if (typo) {
|
|
101
|
-
const fallbackFontFamily = composeFallbackTypographyStyle(typo.type ?? 'heading');
|
|
102
|
-
const customTypo = {
|
|
103
|
-
...typo.custom,
|
|
104
|
-
fallbackFontFamily: fallbackFontFamily
|
|
105
|
-
};
|
|
106
|
-
return {
|
|
107
|
-
...composeTypographyV2(customTypo, typo.attrs),
|
|
108
|
-
...!disableAttr && composeTypographyAttr(typo.attrs)
|
|
109
|
-
};
|
|
110
|
-
}
|
|
111
|
-
return {
|
|
112
|
-
...!typography?.type ? composeTypography(typography?.custom) : {}
|
|
113
|
-
};
|
|
114
|
-
};
|
|
115
|
-
|
|
116
|
-
export { composeFallbackTypographyStyle, composeTypography, composeTypographyAttr, composeTypographyClassName, composeTypographyCss, composeTypographyStyle, composeTypographyV2, composeTypographyV2Css, genTypoClass };
|
|
1
|
+
import{getSingleColorVariable as o}from"./colors.js";import{removeNullUndefined as e,makeStyle as t,makeStyleResponsive as p}from"./make-style.js";let genTypoClass=o=>`gp-g-${o}`,composeTypographyCss=o=>{let e=o?.custom,{fontFamily:t,fontSize:p,fontStyle:a,fontWeight:s,lineHeight:i,letterSpacing:y}=e?.desktop??{};return`
|
|
2
|
+
${t?`font-family: var(--g-font-${t}, ${t});`:""}
|
|
3
|
+
${p?`font-size: ${p};`:""}
|
|
4
|
+
${a?`font-style: ${a};`:""}
|
|
5
|
+
${s?`font-weight: ${s};`:""}
|
|
6
|
+
${y?`letter-spacing: ${y};`:""}
|
|
7
|
+
${i?`line-height: ${i};`:""}
|
|
8
|
+
`},composeTypographyV2Css=(o,e)=>{let t=o?.custom,{fontFamily:p,fontSize:a,fontWeight:s,lineHeight:i,letterSpacing:y}=t??{},l=o?.attrs,{bold:n,italic:r,underline:g,transform:$}=l??{},c=e?"!important":"";return`
|
|
9
|
+
${p?`font-family: var(--g-font-${p}, ${p}) ${c};`:""}
|
|
10
|
+
${a?.desktop?`font-size: ${a?.desktop} ${c};`:""}
|
|
11
|
+
${n?`font-weight: bold ${c};`:s?`font-weight: ${s} ${c};`:""}
|
|
12
|
+
${y?`letter-spacing: ${y} ${c};`:""}
|
|
13
|
+
${i?.desktop?`line-height: ${i?.desktop} ${c};`:""}
|
|
14
|
+
${r?`font-style: italic ${c};`:""}
|
|
15
|
+
${g?`text-decoration-line: underline ${c};`:""}
|
|
16
|
+
${$?`text-transform: ${$} ${c};`:""}
|
|
17
|
+
`};function getCustomCSSByDevice(o,e){if(!o||!e)return{};let t="desktop"!==e&&e?`-${e}`:"",{fontFamily:p}=o?.[e]??{};return{[`--size${t}`]:o?.[e]?.fontSize,[`--lh${t}`]:o?.[e]?.lineHeight,[`--fs${t}`]:o?.[e]?.fontStyle,[`--ff${t}`]:p?`var(--g-font-${p}, ${p})`:void 0,[`--weight${t}`]:o?.[e]?.fontWeight,[`--ls${t}`]:o?.[e]?.letterSpacing}}let composeTypography=o=>o?e({...getCustomCSSByDevice(o,"desktop"),...getCustomCSSByDevice(o,"tablet"),...getCustomCSSByDevice(o,"mobile")}):{},composeTypographyV2=(o,a)=>o?e({...t({fs:a?.italic?void 0:o?.fontStyle,ff:o?.fontFamily?`var(--g-font-${o.fontFamily.replace(/ /g,"-")}, '${o.fontFamily}'), ${o.fallbackFontFamily}`:void 0,weight:a?.bold?void 0:o?.fontWeight,ls:o?.letterSpacing}),...p("size",o?.fontSize),...p("lh",o?.lineHeight)}):{},composeTypographyAttr=p=>p?e({...t({fs:p?.italic?"italic":void 0,weight:p?.bold?"bold":void 0,c:o(p?.color),tt:p?.transform,tdl:p?.underline?"underline":void 0})}):{},composeTypographyClassName=(o,e)=>o?o?.type&&!o.custom?genTypoClass(o.type):"":e?.type&&genTypoClass(e?.type),composeFallbackTypographyStyle=o=>["heading","heading-1","heading-2","heading-3","heading-4","heading-5","heading-6"].includes(o)?"var(--g-font-heading, heading)":"var(--g-font-body, body)",composeTypographyStyle=(o,e,t)=>{if(o){let e=composeFallbackTypographyStyle(o.type??"heading"),p={...o.custom,fallbackFontFamily:e};return{...composeTypographyV2(p,o.attrs),...!t&&composeTypographyAttr(o.attrs)}}return{...e?.type?{}:composeTypography(e?.custom)}};export{composeFallbackTypographyStyle,composeTypography,composeTypographyAttr,composeTypographyClassName,composeTypographyCss,composeTypographyStyle,composeTypographyV2,composeTypographyV2Css,genTypoClass};
|
|
@@ -1,9 +1 @@
|
|
|
1
|
-
function checkInStock(
|
|
2
|
-
if (!variant) return false;
|
|
3
|
-
return variant?.inventoryQuantity && variant.inventoryQuantity > 0 && !isDefaultVariant(variant, product) || !variant?.manageInventory || variant.inventoryPolicy === 'CONTINUE';
|
|
4
|
-
}
|
|
5
|
-
function isDefaultVariant(variant, product) {
|
|
6
|
-
return Boolean(variant?.title === 'Default Title' && product?.options?.some((option)=>option.values.length > 1));
|
|
7
|
-
}
|
|
8
|
-
|
|
9
|
-
export { checkInStock };
|
|
1
|
+
function checkInStock(t,n){return!!t&&(t?.inventoryQuantity&&t.inventoryQuantity>0&&!isDefaultVariant(t,n)||!t?.manageInventory||"CONTINUE"===t.inventoryPolicy)}function isDefaultVariant(t,n){return(n?.[0]?.selectedOptions.length??0)>1&&t?.title==="Default Title"}export{checkInStock};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
let EASING={ease:"cubic-bezier(0.46,0.03,0.52,0.96)","ease-in":"cubic-bezier(0.55,0.08,0.68,0.53)","ease-out":"cubic-bezier(0.46,0.03,0.52,0.96)",linear:"linear"},animations=()=>{let t=t=>{let e=JSON.parse(JSON.stringify(t)),r=["delay","speed","scale","intensity"];return r.forEach(t=>{if(!e?.[t])return;if("scale"===t){if(!e?.zoomDirection)throw TypeError("zoomDirection not found on zoom preset");let[r,a]=e?.scale?.in??[1,1],[n,o]=e?.scale?.out??[1,1];e[t]={in:[Number(r)/100,Number(a)/100],out:[Number(n)/100,Number(o)/100]};return}let r=Number(e?.[t]);if("delay"===t?e[t]=1e3*r:e[t]=r,!isFinite(r))throw TypeError(`${t} must be a number`)}),e},e=(e,r)=>{let n=t(r),{direction:l,distance:s}=n,p=["left","right"].includes(l??"")?"X":"Y",u=["left","down"].includes(l??"")?"-":"",f=o(e),y=[{display:f,opacity:0,transform:`translate${p}(${u}${s??50}%)`},{display:f,opacity:i(e),transform:`translate${p}(0)`}];return c(e,y,{...a(n,500),fill:"forwards"})},r=(e,r)=>{let n=t(r),o=[{opacity:0},{opacity:i(e)}];return c(e,o,{...a(n,500)})},a=(t,e)=>{let r=t=>t?1.5/t*1e3:e,{loop:a,delay:n,speed:o,easing:i}=t??{},l=r(o),s=n??0,c=a?l+s:l;return{iterations:a?1/0:1,duration:c,delay:s,easing:EASING[i??"linear"]}},n=(e,r)=>{let n=t(r),{scale:l,zoomDirection:s,isFade:p}=n,[u,f]=l.in,[y,m]=l.out,d=o(e),b=i(e),$=[{display:d,transform:`scale(${u}, ${u})`,opacity:p?0:1},{display:d,transform:`scale(${f??1.2}, ${f??1.2})`,opacity:b}],w=[{display:d,transform:`scale(${y}, ${y})`,opacity:p?0:1},{display:d,transform:`scale(${m??.8}, ${m??.8})`,opacity:b}],x="in"===s?$:w;return c(e,x,{...a(n,700),fill:"forwards"})},o=t=>{let e="inline"===window.getComputedStyle(t,null).getPropertyValue("display");return e?"block":void 0},i=t=>window.getComputedStyle(t,null).getPropertyValue("opacity"),l=(t,e,r)=>{if(!e)return t;let a=e/r,n=[...t].pop();return[...t,{...n,offset:1-a}]},s=(e,r)=>{let n=t(r),{intensity:l}=n??{},s=o(e),p=i(e),u=[{transform:"translate3d(0, 0, 0)",opacity:p,display:s}],f=[{transform:"translate3d(4px, 0, 0)",opacity:p,display:s},{transform:"translate3d(-4px, 0, 0)",opacity:p,display:s},{transform:"translate3d(4px, 0, 0)",opacity:p,display:s}],y=[];Array.from(Array(l??1).keys()).forEach(()=>{y=[...y,...f]});let m=[{transform:"translate3d(-1px, 0, 0)",opacity:p,display:s},{transform:"translate3d(2px, 0, 0)",opacity:p,display:s},{transform:"translate3d(-4px, 0, 0)",opacity:p,display:s},...y,{transform:"translate3d(-4px, 0, 0)",opacity:p,display:s},{transform:"translate3d(2px, 0, 0)",opacity:p,display:s},{transform:"translate3d(-1px, 0, 0)",opacity:p,display:s}];return c(e,l?m:u,{...a(n??{},820)})},c=(t,e,r)=>{let a=new KeyframeEffect(t,r.iterations&&1===r.iterations?e:l(e,r?.delay??0,r?.duration??0),{...r});return new Animation(a,document.timeline)};return{zoom:n,shake:s,fade:r,slide:e}};export{animations};
|
|
@@ -1,37 +1 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
const useAnimationActions = ()=>{
|
|
4
|
-
const listAnimations = useRef();
|
|
5
|
-
const setAnimation = useCallback((newListAnimations)=>{
|
|
6
|
-
listAnimations.current = newListAnimations;
|
|
7
|
-
}, [
|
|
8
|
-
listAnimations
|
|
9
|
-
]);
|
|
10
|
-
const playAnimation = useCallback(()=>{
|
|
11
|
-
if (!listAnimations.current) return;
|
|
12
|
-
for (const animation of listAnimations.current){
|
|
13
|
-
animation.play();
|
|
14
|
-
}
|
|
15
|
-
}, []);
|
|
16
|
-
const cancelAnimation = useCallback(()=>{
|
|
17
|
-
if (!listAnimations.current) return;
|
|
18
|
-
for (const animation of listAnimations.current){
|
|
19
|
-
animation.cancel();
|
|
20
|
-
}
|
|
21
|
-
}, []);
|
|
22
|
-
const setAnimationOnFinish = useCallback((onFinish)=>{
|
|
23
|
-
if (!listAnimations.current) return;
|
|
24
|
-
for (const animation of listAnimations.current){
|
|
25
|
-
animation.onfinish = onFinish;
|
|
26
|
-
}
|
|
27
|
-
}, []);
|
|
28
|
-
return {
|
|
29
|
-
currentAnimation: listAnimations.current,
|
|
30
|
-
setAnimation,
|
|
31
|
-
playAnimation,
|
|
32
|
-
cancelAnimation,
|
|
33
|
-
setAnimationOnFinish
|
|
34
|
-
};
|
|
35
|
-
};
|
|
36
|
-
|
|
37
|
-
export { useAnimationActions };
|
|
1
|
+
import{useRef as r,useCallback as t}from"react";let useAnimationActions=()=>{let n=r(),e=t(r=>{n.current=r},[n]),o=t(()=>{if(n.current)for(let r of n.current)r.play()},[]),c=t(()=>{if(n.current)for(let r of n.current)r.cancel()},[]),i=t(r=>{if(n.current)for(let t of n.current)t.onfinish=r},[]);return{currentAnimation:n.current,setAnimation:e,playAnimation:o,cancelAnimation:c,setAnimationOnFinish:i}};export{useAnimationActions};
|
|
@@ -1,27 +1 @@
|
|
|
1
|
-
import
|
|
2
|
-
import { useCurrentDevice } from '../use-current-device.js';
|
|
3
|
-
|
|
4
|
-
const useAnimationConfig = (props)=>{
|
|
5
|
-
const currentDevice = useCurrentDevice();
|
|
6
|
-
const configByDevices = useMemo(()=>props?.advanced?.animation?.[currentDevice], [
|
|
7
|
-
currentDevice,
|
|
8
|
-
props?.advanced?.animation
|
|
9
|
-
]);
|
|
10
|
-
const getAnimationConfig = useCallback(()=>{
|
|
11
|
-
const { trigger, triggerConfig } = configByDevices;
|
|
12
|
-
const { animation, setting } = triggerConfig[trigger];
|
|
13
|
-
return {
|
|
14
|
-
type: animation,
|
|
15
|
-
setting: setting[animation]
|
|
16
|
-
};
|
|
17
|
-
}, [
|
|
18
|
-
configByDevices
|
|
19
|
-
]);
|
|
20
|
-
const isEnabledAnimation = configByDevices?.enabled;
|
|
21
|
-
return {
|
|
22
|
-
isEnabledAnimation,
|
|
23
|
-
getAnimationConfig
|
|
24
|
-
};
|
|
25
|
-
};
|
|
26
|
-
|
|
27
|
-
export { useAnimationConfig };
|
|
1
|
+
import{useMemo as e,useCallback as n}from"react";import{useCurrentDevice as t}from"../use-current-device.js";let useAnimationConfig=i=>{let a=t(),r=e(()=>i?.advanced?.animation?.[a],[a,i?.advanced?.animation]),o=n(()=>{let{trigger:e,triggerConfig:n}=r,{animation:t,setting:i}=n[e];return{type:t,setting:i[t]}},[r]),m=r?.enabled;return{isEnabledAnimation:m,getAnimationConfig:o}};export{useAnimationConfig};
|
|
@@ -1,29 +1 @@
|
|
|
1
|
-
import
|
|
2
|
-
|
|
3
|
-
const useAnimationPreview = ({ props, playAnimation, cancelAnimation, setAnimationOnFinish, setToolbarActive })=>{
|
|
4
|
-
const previewAnimation = useCallback((e)=>{
|
|
5
|
-
const { uid, isCancel } = e.detail;
|
|
6
|
-
if (props.uid !== uid) return;
|
|
7
|
-
cancelAnimation();
|
|
8
|
-
if (isCancel) {
|
|
9
|
-
setToolbarActive(true);
|
|
10
|
-
return;
|
|
11
|
-
}
|
|
12
|
-
playAnimation();
|
|
13
|
-
setToolbarActive(false);
|
|
14
|
-
setAnimationOnFinish(()=>{
|
|
15
|
-
setToolbarActive(true);
|
|
16
|
-
});
|
|
17
|
-
}, [
|
|
18
|
-
props.uid,
|
|
19
|
-
cancelAnimation,
|
|
20
|
-
playAnimation,
|
|
21
|
-
setToolbarActive,
|
|
22
|
-
setAnimationOnFinish
|
|
23
|
-
]);
|
|
24
|
-
return {
|
|
25
|
-
previewAnimation
|
|
26
|
-
};
|
|
27
|
-
};
|
|
28
|
-
|
|
29
|
-
export { useAnimationPreview };
|
|
1
|
+
import{useCallback as e}from"react";let useAnimationPreview=({props:i,playAnimation:t,cancelAnimation:r,setAnimationOnFinish:n,setToolbarActive:u})=>{let o=e(e=>{let{uid:o,isCancel:a}=e.detail;if(i.uid===o){if(r(),a){u(!0);return}t(),u(!1),n(()=>{u(!0)})}},[i.uid,r,t,u,n]);return{previewAnimation:o}};export{useAnimationPreview};
|
|
@@ -1,118 +1 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { useAnimationConfig } from './useAnimationConfig.js';
|
|
3
|
-
|
|
4
|
-
const SPACING_ACTIVE_ATTRIBUTE = 'data-spacing';
|
|
5
|
-
const TOOLBAR_ACTIVE_ATTRIBUTE = 'data-toolbar-active';
|
|
6
|
-
const OUTLINE_ACTIVE_ATTRIBUTE = 'data-outline-active';
|
|
7
|
-
const TOOLBAR_ADD_SECTION_ACTIVE_ATTRIBUTE = 'data-toolbar-add-active';
|
|
8
|
-
const useAnimationTarget = (props)=>{
|
|
9
|
-
const { isEnabledAnimation } = useAnimationConfig(props);
|
|
10
|
-
const componentTag = props.tag;
|
|
11
|
-
const componentUid = props.uid;
|
|
12
|
-
const targets = useRef(null);
|
|
13
|
-
const targetObjects = useRef([]);
|
|
14
|
-
const setToolbarActive = (isActive)=>{
|
|
15
|
-
if (!targetObjects.current) return;
|
|
16
|
-
for (const item of targetObjects.current){
|
|
17
|
-
if (isActive) {
|
|
18
|
-
item.toolbar?.setAttribute(TOOLBAR_ACTIVE_ATTRIBUTE, 'true');
|
|
19
|
-
item.outline?.setAttribute(OUTLINE_ACTIVE_ATTRIBUTE, 'true');
|
|
20
|
-
item.spacing?.setAttribute(SPACING_ACTIVE_ATTRIBUTE, 'true');
|
|
21
|
-
item.addSectionTop?.setAttribute(TOOLBAR_ADD_SECTION_ACTIVE_ATTRIBUTE, 'true');
|
|
22
|
-
item.addSectionBottom?.setAttribute(TOOLBAR_ADD_SECTION_ACTIVE_ATTRIBUTE, 'true');
|
|
23
|
-
} else {
|
|
24
|
-
item.toolbar?.removeAttribute(TOOLBAR_ACTIVE_ATTRIBUTE);
|
|
25
|
-
item.outline?.removeAttribute(OUTLINE_ACTIVE_ATTRIBUTE);
|
|
26
|
-
item.spacing?.removeAttribute(SPACING_ACTIVE_ATTRIBUTE);
|
|
27
|
-
item.addSectionTop?.removeAttribute(TOOLBAR_ADD_SECTION_ACTIVE_ATTRIBUTE);
|
|
28
|
-
item.addSectionBottom?.removeAttribute(TOOLBAR_ADD_SECTION_ACTIVE_ATTRIBUTE);
|
|
29
|
-
}
|
|
30
|
-
}
|
|
31
|
-
};
|
|
32
|
-
const getSectionProperties = (target)=>{
|
|
33
|
-
const sectionAddTop = target.querySelector('[data-toolbar-add-top]');
|
|
34
|
-
const sectionAddBottom = target.querySelector('[data-toolbar-add-bottom]');
|
|
35
|
-
const sectionChild = Array.from(target.children);
|
|
36
|
-
const sectionToolbar = sectionChild.find((child)=>child.getAttribute('data-toolbar') !== null);
|
|
37
|
-
const sectionOutline = sectionChild.find((child)=>child.getAttribute('data-outline') !== null);
|
|
38
|
-
return {
|
|
39
|
-
sectionToolbar,
|
|
40
|
-
sectionOutline,
|
|
41
|
-
sectionAddTop,
|
|
42
|
-
sectionAddBottom
|
|
43
|
-
};
|
|
44
|
-
};
|
|
45
|
-
const getUpdatedTargetObjects = useCallback((targets)=>{
|
|
46
|
-
return targets.reduce((accumulator, $rootTarget)=>{
|
|
47
|
-
let addSectionTop = null;
|
|
48
|
-
let addSectionBottom = null;
|
|
49
|
-
let target = $rootTarget;
|
|
50
|
-
let toolbar = $rootTarget.querySelector('[data-toolbar][data-toolbar-active]');
|
|
51
|
-
let outline = $rootTarget.querySelector('[data-outline][data-outline-active]');
|
|
52
|
-
const targetChild = Array.from(target.children);
|
|
53
|
-
const spacing = targetChild.find((child)=>child.getAttribute('data-spacing') !== null);
|
|
54
|
-
switch(componentTag){
|
|
55
|
-
case 'Button':
|
|
56
|
-
case 'SubmitButton':
|
|
57
|
-
case 'ProductButton':
|
|
58
|
-
case 'DynamicCheckout':
|
|
59
|
-
target = $rootTarget.querySelector('.gp-button-base');
|
|
60
|
-
break;
|
|
61
|
-
case 'ProductProperties':
|
|
62
|
-
target = $rootTarget.querySelector('input');
|
|
63
|
-
break;
|
|
64
|
-
case 'Icon':
|
|
65
|
-
target = $rootTarget.firstElementChild;
|
|
66
|
-
break;
|
|
67
|
-
case 'ProductTag':
|
|
68
|
-
target = $rootTarget?.children[0]?.children[0];
|
|
69
|
-
break;
|
|
70
|
-
case 'Section':
|
|
71
|
-
{
|
|
72
|
-
target = $rootTarget;
|
|
73
|
-
const { sectionOutline, sectionToolbar, sectionAddTop, sectionAddBottom } = getSectionProperties(target);
|
|
74
|
-
outline = sectionOutline;
|
|
75
|
-
toolbar = sectionToolbar;
|
|
76
|
-
addSectionTop = sectionAddTop;
|
|
77
|
-
addSectionBottom = sectionAddBottom;
|
|
78
|
-
break;
|
|
79
|
-
}
|
|
80
|
-
default:
|
|
81
|
-
target = $rootTarget;
|
|
82
|
-
}
|
|
83
|
-
const newTargetObject = {
|
|
84
|
-
target,
|
|
85
|
-
toolbar,
|
|
86
|
-
outline,
|
|
87
|
-
spacing,
|
|
88
|
-
addSectionTop,
|
|
89
|
-
addSectionBottom
|
|
90
|
-
};
|
|
91
|
-
accumulator.push(newTargetObject);
|
|
92
|
-
return accumulator;
|
|
93
|
-
}, []);
|
|
94
|
-
}, [
|
|
95
|
-
componentTag
|
|
96
|
-
]);
|
|
97
|
-
const initListOfTargets = useCallback(()=>{
|
|
98
|
-
if (!isEnabledAnimation) return;
|
|
99
|
-
if (!targets.current) {
|
|
100
|
-
targets.current = document.querySelectorAll(`[data-uid="${componentUid}"]`);
|
|
101
|
-
}
|
|
102
|
-
const targetsArray = Array.from(targets.current);
|
|
103
|
-
if (!targetsArray.length) return;
|
|
104
|
-
const updatedTargetObjects = getUpdatedTargetObjects(targetsArray);
|
|
105
|
-
targetObjects.current = updatedTargetObjects;
|
|
106
|
-
}, [
|
|
107
|
-
componentUid,
|
|
108
|
-
getUpdatedTargetObjects,
|
|
109
|
-
isEnabledAnimation
|
|
110
|
-
]);
|
|
111
|
-
return {
|
|
112
|
-
targetObjects,
|
|
113
|
-
setToolbarActive,
|
|
114
|
-
initListOfTargets
|
|
115
|
-
};
|
|
116
|
-
};
|
|
117
|
-
|
|
118
|
-
export { useAnimationTarget };
|
|
1
|
+
import{useRef as t,useCallback as e}from"react";import{useAnimationConfig as r}from"./useAnimationConfig.js";let SPACING_ACTIVE_ATTRIBUTE="data-spacing-margin-bottom-active",TOOLBAR_ACTIVE_ATTRIBUTE="data-toolbar-active",OUTLINE_ACTIVE_ATTRIBUTE="data-outline-active",TOOLBAR_ADD_SECTION_ACTIVE_ATTRIBUTE="data-toolbar-add-active",useAnimationTarget=a=>{let{isEnabledAnimation:o}=r(a),T=a.tag,u=a.uid,i=t(null),A=t([]),n=t=>{if(A.current)for(let e of A.current)t?(e.toolbar?.setAttribute(TOOLBAR_ACTIVE_ATTRIBUTE,"true"),e.outline?.setAttribute(OUTLINE_ACTIVE_ATTRIBUTE,"true"),e.spacing?.setAttribute(SPACING_ACTIVE_ATTRIBUTE,"true"),e.addSectionTop?.setAttribute(TOOLBAR_ADD_SECTION_ACTIVE_ATTRIBUTE,"true"),e.addSectionBottom?.setAttribute(TOOLBAR_ADD_SECTION_ACTIVE_ATTRIBUTE,"true")):(e.toolbar?.removeAttribute(TOOLBAR_ACTIVE_ATTRIBUTE),e.outline?.removeAttribute(OUTLINE_ACTIVE_ATTRIBUTE),e.spacing?.removeAttribute(SPACING_ACTIVE_ATTRIBUTE),e.addSectionTop?.removeAttribute(TOOLBAR_ADD_SECTION_ACTIVE_ATTRIBUTE),e.addSectionBottom?.removeAttribute(TOOLBAR_ADD_SECTION_ACTIVE_ATTRIBUTE))},l=t=>{let e=t.querySelector("[data-toolbar-add-top]"),r=t.querySelector("[data-toolbar-add-bottom]"),a=Array.from(t.children),o=a.find(t=>null!==t.getAttribute("data-toolbar")),T=a.find(t=>null!==t.getAttribute("data-outline"));return{sectionToolbar:o,sectionOutline:T,sectionAddTop:e,sectionAddBottom:r}},c=e(t=>t.reduce((t,e)=>{let r=null,a=null,o=e,u=e.querySelector("[data-toolbar][data-toolbar-active]"),i=e.querySelector("[data-outline][data-outline-active]"),A=Array.from(o.children),n=A.find(t=>{let e=t.getAttribute("data-spacing");return null!==e&&t.querySelector("[data-spacing-margin-bottom")});switch(T){case"Button":case"SubmitButton":case"ProductButton":case"DynamicCheckout":o=e.querySelector(".gp-button-base");break;case"ProductProperties":o=e.querySelector("input");break;case"Icon":o=e.firstElementChild;break;case"ProductTag":o=e?.children[0]?.children[0];break;case"Section":{o=e;let{sectionOutline:t,sectionToolbar:T,sectionAddTop:A,sectionAddBottom:n}=l(o);i=t,u=T,r=A,a=n;break}default:o=e}let c={target:o,toolbar:u,outline:i,spacing:n,addSectionTop:r,addSectionBottom:a};return t.push(c),t},[]),[T]),d=e(()=>{if(!o)return;i.current||(i.current=document.querySelectorAll(`[data-uid="${u}"]`));let t=Array.from(i.current);if(!t.length)return;let e=c(t);A.current=e},[u,c,o]);return{targetObjects:A,setToolbarActive:n,initListOfTargets:d}};export{useAnimationTarget};
|
|
@@ -1,83 +1 @@
|
|
|
1
|
-
import
|
|
2
|
-
import { useAnimations } from '../useAnimations.js';
|
|
3
|
-
import { useAnimationTarget } from './useAnimationTarget.js';
|
|
4
|
-
import { useAnimationConfig } from './useAnimationConfig.js';
|
|
5
|
-
import { useAnimationActions } from './useAnimationActions.js';
|
|
6
|
-
import { useAnimationPreview } from './useAnimationPreview.js';
|
|
7
|
-
import { AnimationType } from '../../types/animations.js';
|
|
8
|
-
|
|
9
|
-
const useApplyAnimation = ({ props })=>{
|
|
10
|
-
const currentProps = props;
|
|
11
|
-
const { uid: componentUid } = currentProps;
|
|
12
|
-
const animation = useAnimations();
|
|
13
|
-
const { initListOfTargets, targetObjects, setToolbarActive } = useAnimationTarget(currentProps);
|
|
14
|
-
const { isEnabledAnimation, getAnimationConfig } = useAnimationConfig(currentProps);
|
|
15
|
-
const { setAnimation, cancelAnimation, playAnimation, setAnimationOnFinish } = useAnimationActions();
|
|
16
|
-
const { previewAnimation } = useAnimationPreview({
|
|
17
|
-
props: currentProps,
|
|
18
|
-
playAnimation,
|
|
19
|
-
cancelAnimation,
|
|
20
|
-
setAnimationOnFinish,
|
|
21
|
-
setToolbarActive
|
|
22
|
-
});
|
|
23
|
-
const generateAnimation = useCallback(({ target, setting, type })=>{
|
|
24
|
-
return animation[type](target, setting);
|
|
25
|
-
}, [
|
|
26
|
-
animation
|
|
27
|
-
]);
|
|
28
|
-
const initListAnimations = useCallback(()=>{
|
|
29
|
-
const { type, setting } = getAnimationConfig();
|
|
30
|
-
if (!type || type === AnimationType.None || !targetObjects.current.length) {
|
|
31
|
-
cancelAnimation();
|
|
32
|
-
return;
|
|
33
|
-
}
|
|
34
|
-
const listAnimations = targetObjects.current.map((item)=>generateAnimation({
|
|
35
|
-
type,
|
|
36
|
-
setting,
|
|
37
|
-
target: item.target
|
|
38
|
-
}));
|
|
39
|
-
cancelAnimation();
|
|
40
|
-
setAnimation(listAnimations);
|
|
41
|
-
}, [
|
|
42
|
-
getAnimationConfig,
|
|
43
|
-
targetObjects,
|
|
44
|
-
cancelAnimation,
|
|
45
|
-
setAnimation,
|
|
46
|
-
generateAnimation
|
|
47
|
-
]);
|
|
48
|
-
useEffect(()=>{
|
|
49
|
-
if (isEnabledAnimation) {
|
|
50
|
-
initListOfTargets();
|
|
51
|
-
initListAnimations();
|
|
52
|
-
} else {
|
|
53
|
-
cancelAnimation();
|
|
54
|
-
}
|
|
55
|
-
return ()=>{
|
|
56
|
-
cancelAnimation();
|
|
57
|
-
};
|
|
58
|
-
}, [
|
|
59
|
-
componentUid,
|
|
60
|
-
initListAnimations,
|
|
61
|
-
cancelAnimation,
|
|
62
|
-
isEnabledAnimation,
|
|
63
|
-
initListOfTargets
|
|
64
|
-
]);
|
|
65
|
-
useEffect(()=>{
|
|
66
|
-
window.addEventListener('preview-animation', previewAnimation);
|
|
67
|
-
return ()=>{
|
|
68
|
-
window.removeEventListener('preview-animation', previewAnimation);
|
|
69
|
-
};
|
|
70
|
-
}, [
|
|
71
|
-
previewAnimation
|
|
72
|
-
]);
|
|
73
|
-
useEffect(()=>{
|
|
74
|
-
window.addEventListener('init-animation-target', initListOfTargets);
|
|
75
|
-
return ()=>{
|
|
76
|
-
window.removeEventListener('init-animation-target', initListOfTargets);
|
|
77
|
-
};
|
|
78
|
-
}, [
|
|
79
|
-
initListOfTargets
|
|
80
|
-
]);
|
|
81
|
-
};
|
|
82
|
-
|
|
83
|
-
export { useApplyAnimation as default };
|
|
1
|
+
import{useCallback as t,useEffect as i}from"react";import{useAnimations as e}from"../useAnimations.js";import{useAnimationTarget as n}from"./useAnimationTarget.js";import{useAnimationConfig as o}from"./useAnimationConfig.js";import{useAnimationActions as r}from"./useAnimationActions.js";import{useAnimationPreview as m}from"./useAnimationPreview.js";import{AnimationType as a}from"../../types/animations.js";let useApplyAnimation=({props:s})=>{let{uid:p}=s,u=e(),{initListOfTargets:w,targetObjects:d,setToolbarActive:f}=n(s),{isEnabledAnimation:A,getAnimationConfig:v}=o(s),{setAnimation:l,cancelAnimation:g,playAnimation:j,setAnimationOnFinish:c}=r(),{previewAnimation:E}=m({props:s,playAnimation:j,cancelAnimation:g,setAnimationOnFinish:c,setToolbarActive:f}),L=t(({target:t,setting:i,type:e})=>u[e](t,i),[u]),y=t(()=>{let{type:t,setting:i}=v();if(!t||t===a.None||!d.current.length){g();return}let e=d.current.map(e=>L({type:t,setting:i,target:e.target}));g(),l(e)},[v,d,g,l,L]);i(()=>(A?(w(),y()):g(),()=>{g()}),[p,y,g,A,w]),i(()=>(window.addEventListener("preview-animation",E),()=>{window.removeEventListener("preview-animation",E)}),[E]),i(()=>(window.addEventListener("init-animation-target",w),()=>{window.removeEventListener("init-animation-target",w)}),[w])};export{useApplyAnimation as default};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{useState as r,useRef as e,useCallback as t,useEffect as n}from"react";import{animations as u}from"./animations.js";let TAGS_SELECTOR={Button:".gp-button-base",ProductButton:".gp-button-base",Sticky:"gp-sticky",Dialog:"div[role=dialog]",Icon:"div div",ProductTag:"div div div",Product:"product-form form div"},useLivePageAnimation=(c,o,i)=>{let a=u(),[l,s]=r(!1),d=e(void 0),p=e(void 0),m=e(null),v=e("none"),g=e("none"),b=e(null),f=e(null),y=e(null),h=e("animation-wrapper-"),k=t(r=>{b.current&&(b.current.playbackRate=r??1,b.current.play())},[b]),E=t(r=>{f.current&&(f.current.playbackRate=r??1,f.current.play())},[f]),L=t(()=>{c.current&&(c.current.style.opacity="1"),m.current&&(m.current.style.opacity="1")},[c]),S=t(()=>{c.current&&(c.current.style.opacity="1"),m.current&&(m.current.style.opacity="0")},[c]),T=t(r=>{r&&r.stopPropagation(),"shake"!==v.current&&S(),b.current&&(f.current?.cancel(),k(),b.current.finished.then(()=>{m.current&&L()}),m.current&&d?.current?.unobserve(m.current))},[S,k,L]),P=t(()=>{L(),b.current&&b.current.cancel()},[L,b]),R=t(r=>{r&&r.stopPropagation(),f.current&&(P(),E())},[f,P,E]),C=t(()=>{if(f.current){if("zoom"===g.current){if(E(-1),!l)return;f.current.finished.then(()=>{clearTimeout(p.current),p.current=setTimeout(()=>{T()},100)});return}f.current.cancel(),l&&T()}},[E,l,T]),w=t(()=>{if("desktop"===y.current);else if("tablet"===y.current)return o?.tablet??o?.desktop;else if("mobile"===y.current)return o?.mobile??o?.tablet??o?.desktop;return o?.desktop},[o?.desktop,o?.mobile,o?.tablet]),A=(r,e)=>r?.triggerConfig?.[e]?.animation??"none",O=t(r=>{if("none"===v.current)return;let e=r?.triggerConfig?.appear?.setting?.[v.current];s(e.loop),b.current=a?.[v.current]?.(m.current,e)},[a]),B=t(r=>{if("none"===g.current)return;let e=r?.triggerConfig?.hover?.setting?.[g.current];f.current=a?.[g.current]?.(m.current,e)},[a]),$=t(()=>{b.current&&(b.current=null,m.current&&d.current?.unobserve(m.current)),f&&(f.current=null,m.current&&(m.current.removeEventListener("mouseenter",R),m.current.removeEventListener("mouseleave",C)))},[C,R]),q=t(r=>{if($(),m.current){if(!r?.enabled){L();return}v.current=A(r,"appear"),g.current=A(r,"hover"),"none"===v.current&&L(),"none"!==g.current&&"desktop"===y.current&&(B(r),m.current.addEventListener("mouseenter",R),m.current.addEventListener("mouseleave",C)),"none"!==v.current?(O(r),d.current=new IntersectionObserver(r=>{r.forEach(r=>{r.intersectionRatio>.1&&T()})},{root:null,rootMargin:"0px",threshold:[.1]}),d.current.observe(m.current)):L()}},[C,O,B,T,R,L,$]),x=t(()=>{let r=document.querySelector("html");if(!m.current||!r)return;let e=new ResizeObserver(([r])=>{let e;let t=r?.target.getBoundingClientRect().width??0;e=t>=1024?"desktop":t>=768?"tablet":"mobile",y.current!==e&&(y.current=e,q(w()))});return e.observe(r),()=>e.disconnect()},[w,q]);return n(()=>{setTimeout(()=>{if(o&&c.current)return h.current=`animation-wrapper-${Math.random().toString(36).substr(2,5)}`,c.current.setAttribute("data-animationid",h.current),m.current=document.querySelector(`[data-animationid='${h.current}'] ${TAGS_SELECTOR?.[i]??""}`),x()},100)},[x,o,i,c]),{initAnimation:q}};export{useLivePageAnimation};
|