@gem-sdk/core 1.38.0 → 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 +24803 -6239
- package/package.json +8 -3
|
@@ -1,15 +1 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
var react = require('react');
|
|
4
|
-
var LazyLoad = require('vanilla-lazyload');
|
|
5
|
-
|
|
6
|
-
const useLazyVideo = ()=>{
|
|
7
|
-
react.useEffect(()=>{
|
|
8
|
-
const lazyLoadInstance = new LazyLoad({
|
|
9
|
-
use_native: true
|
|
10
|
-
});
|
|
11
|
-
lazyLoadInstance.update();
|
|
12
|
-
}, []);
|
|
13
|
-
};
|
|
14
|
-
|
|
15
|
-
exports.useLazyVideo = useLazyVideo;
|
|
1
|
+
"use strict";var react=require("react"),LazyLoad=require("vanilla-lazyload");const useLazyVideo=()=>{react.useEffect(()=>{let e=new LazyLoad({use_native:!0});e.update()},[])};exports.useLazyVideo=useLazyVideo;
|
|
@@ -1,26 +1 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
var animations = require('../helpers/animations.js');
|
|
4
|
-
require('react');
|
|
5
|
-
require('react/jsx-runtime');
|
|
6
|
-
require('zustand');
|
|
7
|
-
require('swr');
|
|
8
|
-
require('@gem-sdk/adapter-shopify');
|
|
9
|
-
require('swr/mutation');
|
|
10
|
-
require('vanilla-lazyload');
|
|
11
|
-
require('./useCartUI.js');
|
|
12
|
-
require('react-transition-group');
|
|
13
|
-
require('@gem-sdk/core');
|
|
14
|
-
require('../helpers/convert.js');
|
|
15
|
-
|
|
16
|
-
const useAnimations = ()=>{
|
|
17
|
-
const { zoom, shake, fade, slide } = animations.animations();
|
|
18
|
-
return {
|
|
19
|
-
zoom,
|
|
20
|
-
shake,
|
|
21
|
-
fade,
|
|
22
|
-
slide
|
|
23
|
-
};
|
|
24
|
-
};
|
|
25
|
-
|
|
26
|
-
exports.useAnimations = useAnimations;
|
|
1
|
+
"use strict";var animations=require("../helpers/animations.js");require("react"),require("react/jsx-runtime"),require("zustand"),require("swr"),require("@gem-sdk/adapter-shopify"),require("swr/mutation"),require("vanilla-lazyload"),require("./useCartUI.js"),require("react-transition-group"),require("@gem-sdk/core"),require("classnames"),require("../helpers/convert.js");const useAnimations=()=>{let{zoom:e,shake:r,fade:i,slide:s}=animations.animations();return{zoom:e,shake:r,fade:i,slide:s}};exports.useAnimations=useAnimations;
|
|
@@ -1,44 +1 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
-
|
|
5
|
-
var react = require('react');
|
|
6
|
-
|
|
7
|
-
const cartKey = 'cart-id';
|
|
8
|
-
const getCartId = ()=>{
|
|
9
|
-
return window.localStorage.getItem(cartKey);
|
|
10
|
-
};
|
|
11
|
-
const writeCartId = (value)=>{
|
|
12
|
-
if (value) {
|
|
13
|
-
window.localStorage.setItem(cartKey, value);
|
|
14
|
-
}
|
|
15
|
-
};
|
|
16
|
-
const removeCartId = ()=>{
|
|
17
|
-
window.localStorage.removeItem(cartKey);
|
|
18
|
-
};
|
|
19
|
-
const subscribeStorage = (callback)=>{
|
|
20
|
-
window.addEventListener('storage', callback);
|
|
21
|
-
return ()=>{
|
|
22
|
-
window.removeEventListener('storage', callback);
|
|
23
|
-
};
|
|
24
|
-
};
|
|
25
|
-
const useCartId = ()=>{
|
|
26
|
-
const cartId = react.useSyncExternalStore(subscribeStorage, getCartId, ()=>undefined);
|
|
27
|
-
const updateCartId = react.useCallback((val)=>{
|
|
28
|
-
writeCartId(val);
|
|
29
|
-
}, []);
|
|
30
|
-
const clearCartId = react.useCallback(()=>{
|
|
31
|
-
removeCartId();
|
|
32
|
-
}, []);
|
|
33
|
-
return react.useMemo(()=>({
|
|
34
|
-
cartId,
|
|
35
|
-
updateCartId,
|
|
36
|
-
clearCartId
|
|
37
|
-
}), [
|
|
38
|
-
cartId,
|
|
39
|
-
clearCartId,
|
|
40
|
-
updateCartId
|
|
41
|
-
]);
|
|
42
|
-
};
|
|
43
|
-
|
|
44
|
-
exports.default = useCartId;
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var react=require("react");const cartKey="cart-id",getCartId=()=>window.localStorage.getItem(cartKey),writeCartId=e=>{e&&window.localStorage.setItem(cartKey,e)},removeCartId=()=>{window.localStorage.removeItem(cartKey)},subscribeStorage=e=>(window.addEventListener("storage",e),()=>{window.removeEventListener("storage",e)}),useCartId=()=>{let e=react.useSyncExternalStore(subscribeStorage,getCartId,()=>void 0),t=react.useCallback(e=>{writeCartId(e)},[]),r=react.useCallback(()=>{removeCartId()},[]);return react.useMemo(()=>({cartId:e,updateCartId:t,clearCartId:r}),[e,r,t])};exports.default=useCartId;
|
|
@@ -1,11 +1 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
-
|
|
5
|
-
var CartLineContext = require('../contexts/CartLineContext.js');
|
|
6
|
-
|
|
7
|
-
const useCartLine = ()=>{
|
|
8
|
-
return CartLineContext.useCartLineStore((s)=>s.line);
|
|
9
|
-
};
|
|
10
|
-
|
|
11
|
-
exports.default = useCartLine;
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var CartLineContext=require("../contexts/CartLineContext.js");const useCartLine=()=>CartLineContext.useCartLineStore(e=>e.line);exports.default=useCartLine;
|
|
@@ -1,48 +1 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
-
|
|
5
|
-
var react = require('react');
|
|
6
|
-
var zustand = require('zustand');
|
|
7
|
-
var shop = require('./shop.js');
|
|
8
|
-
|
|
9
|
-
const useStore = zustand.create((set)=>({
|
|
10
|
-
isCartOpen: false,
|
|
11
|
-
setOpen: (isCartOpen)=>{
|
|
12
|
-
const scrollBarGap = window.innerWidth - document.documentElement.clientWidth;
|
|
13
|
-
const computedBodyPaddingRight = parseInt(window.getComputedStyle(document.body).getPropertyValue('padding-right'), 10);
|
|
14
|
-
if (isCartOpen) {
|
|
15
|
-
document.body.style.overflow = `hidden`;
|
|
16
|
-
document.body.style.paddingRight = `${computedBodyPaddingRight + scrollBarGap}px`;
|
|
17
|
-
} else {
|
|
18
|
-
document.body.style.overflow = '';
|
|
19
|
-
document.body.style.paddingRight = '';
|
|
20
|
-
}
|
|
21
|
-
set({
|
|
22
|
-
isCartOpen
|
|
23
|
-
});
|
|
24
|
-
}
|
|
25
|
-
}));
|
|
26
|
-
function useCartUI() {
|
|
27
|
-
const plugins = shop.usePluginEnable();
|
|
28
|
-
const isCartOpen = useStore((s)=>s.isCartOpen);
|
|
29
|
-
const setOpen = useStore((s)=>s.setOpen);
|
|
30
|
-
const openCart = react.useCallback(()=>{
|
|
31
|
-
if (plugins?.includes('cart-drawer')) {
|
|
32
|
-
setOpen(true);
|
|
33
|
-
}
|
|
34
|
-
}, [
|
|
35
|
-
plugins,
|
|
36
|
-
setOpen
|
|
37
|
-
]);
|
|
38
|
-
const closeCart = react.useCallback(()=>setOpen(false), [
|
|
39
|
-
setOpen
|
|
40
|
-
]);
|
|
41
|
-
return {
|
|
42
|
-
isCartOpen,
|
|
43
|
-
openCart,
|
|
44
|
-
closeCart
|
|
45
|
-
};
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
exports.default = useCartUI;
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var react=require("react"),zustand=require("zustand"),shop=require("./shop.js");const useStore=zustand.create(e=>({isCartOpen:!1,setOpen:t=>{let r=window.innerWidth-document.documentElement.clientWidth,d=parseInt(window.getComputedStyle(document.body).getPropertyValue("padding-right"),10);t?(document.body.style.overflow="hidden",document.body.style.paddingRight=`${d+r}px`):(document.body.style.overflow="",document.body.style.paddingRight=""),e({isCartOpen:t})}}));function useCartUI(){let e=shop.usePluginEnable(),t=useStore(e=>e.isCartOpen),r=useStore(e=>e.setOpen),d=react.useCallback(()=>{e?.includes("cart-drawer")&&r(!0)},[e,r]),n=react.useCallback(()=>r(!1),[r]);return{isCartOpen:t,openCart:d,closeCart:n}}exports.default=useCartUI;
|
|
@@ -1,9 +1 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
var CollectionContext = require('../contexts/CollectionContext.js');
|
|
4
|
-
|
|
5
|
-
const useCollection = ()=>{
|
|
6
|
-
return CollectionContext.useCollectionStore((s)=>s.collection);
|
|
7
|
-
};
|
|
8
|
-
|
|
9
|
-
exports.useCollection = useCollection;
|
|
1
|
+
"use strict";var CollectionContext=require("../contexts/CollectionContext.js");const useCollection=()=>CollectionContext.useCollectionStore(o=>o.collection);exports.useCollection=useCollection;
|
|
@@ -1,13 +1 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
var useSWR = require('swr');
|
|
4
|
-
|
|
5
|
-
const useFetchHandle = ()=>{
|
|
6
|
-
const { fetcher } = useSWR.useSWRConfig();
|
|
7
|
-
if (!fetcher) {
|
|
8
|
-
throw new Error('Application must be init within a fetcher');
|
|
9
|
-
}
|
|
10
|
-
return fetcher;
|
|
11
|
-
};
|
|
12
|
-
|
|
13
|
-
exports.useFetchHandle = useFetchHandle;
|
|
1
|
+
"use strict";var useSWR=require("swr");const useFetchHandle=()=>{let{fetcher:e}=useSWR.useSWRConfig();if(!e)throw Error("Application must be init within a fetcher");return e};exports.useFetchHandle=useFetchHandle;
|
|
@@ -1,58 +1 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
var shop = require('./shop.js');
|
|
4
|
-
|
|
5
|
-
const useFormatMoney = (amount, withCurrency)=>{
|
|
6
|
-
const { moneyFormat, moneyWithCurrencyFormat } = shop.useMoneyFormat();
|
|
7
|
-
const formatMoney = function(cents, format) {
|
|
8
|
-
let value = '';
|
|
9
|
-
const placeholderRegex = /\{\{\s*(\w+)\s*\}\}/;
|
|
10
|
-
const formatString = format || '${{amount}}';
|
|
11
|
-
/**
|
|
12
|
-
* check default
|
|
13
|
-
* @param opt opt
|
|
14
|
-
* @param def def
|
|
15
|
-
* @returns any
|
|
16
|
-
*/ function defaultOption(opt, def) {
|
|
17
|
-
return typeof opt == 'undefined' ? def : opt;
|
|
18
|
-
}
|
|
19
|
-
/**
|
|
20
|
-
* formatWithDelimiters
|
|
21
|
-
* @param number number
|
|
22
|
-
* @param precision precision
|
|
23
|
-
* @param thousands thousands
|
|
24
|
-
* @param decimal decimal
|
|
25
|
-
* @returns any
|
|
26
|
-
*/ // eslint-disable-next-line max-params
|
|
27
|
-
function formatWithDelimiters(number, precision, thousands, decimal) {
|
|
28
|
-
precision = defaultOption(precision, 2);
|
|
29
|
-
thousands = defaultOption(thousands, ',');
|
|
30
|
-
decimal = defaultOption(decimal, '.');
|
|
31
|
-
if (isNaN(number) || number == null) {
|
|
32
|
-
return 0;
|
|
33
|
-
}
|
|
34
|
-
// shopify làm tròn bằng cách cắt đi các số ở đằng sau chứ không sử dụng toFixed để làm tròn như toán học
|
|
35
|
-
number = parseFloat(`${number}`).toFixed(Number(precision) + 1).slice(0, -1);
|
|
36
|
-
const parts = number.split('.'), dollars = parts[0]?.replace(/(\d)(?=(\d\d\d)+(?!\d))/g, '$1' + thousands), cents = parts[1] ? decimal + parts[1] : '';
|
|
37
|
-
return dollars + cents;
|
|
38
|
-
}
|
|
39
|
-
switch(formatString.match(placeholderRegex)[1]){
|
|
40
|
-
case 'amount':
|
|
41
|
-
value = formatWithDelimiters(cents, 2);
|
|
42
|
-
break;
|
|
43
|
-
case 'amount_no_decimals':
|
|
44
|
-
value = formatWithDelimiters(cents, 0);
|
|
45
|
-
break;
|
|
46
|
-
case 'amount_with_comma_separator':
|
|
47
|
-
value = formatWithDelimiters(cents, 2, '.', ',');
|
|
48
|
-
break;
|
|
49
|
-
case 'amount_no_decimals_with_comma_separator':
|
|
50
|
-
value = formatWithDelimiters(cents, 0, '.', ',');
|
|
51
|
-
break;
|
|
52
|
-
}
|
|
53
|
-
return formatString.replace(placeholderRegex, value);
|
|
54
|
-
};
|
|
55
|
-
return withCurrency ? formatMoney(`${amount}`, moneyWithCurrencyFormat || moneyFormat) : formatMoney(`${amount}`, moneyFormat);
|
|
56
|
-
};
|
|
57
|
-
|
|
58
|
-
exports.useFormatMoney = useFormatMoney;
|
|
1
|
+
"use strict";var shop=require("./shop.js");const shopifyPriceRounding=(e,o)=>parseFloat(`${e}`).toFixed(Number(o)+1).slice(0,-1),useFormatMoney=(e,o)=>{let{moneyFormat:r,moneyWithCurrencyFormat:t}=shop.useMoneyFormat(),n=function(e,o){let r="",t=/\{\{\s*(\w+)\s*\}\}/,n=o||"${{amount}}";function s(e,o){return void 0===e?o:e}function a(e,o,r,t){if(o=s(o,2),r=s(r,","),t=s(t,"."),isNaN(e)||null==e)return 0;e=shopifyPriceRounding(e,Number(o));let n=e.split("."),a=n[0]?.replace(/(\d)(?=(\d\d\d)+(?!\d))/g,"$1"+r),i=n[1]?t+n[1]:"";return a+i}switch(n.match(t)[1]){case"amount":r=a(e,2);break;case"amount_no_decimals":r=a(e,0);break;case"amount_with_comma_separator":r=a(e,2,".",",");break;case"amount_no_decimals_with_comma_separator":r=a(e,0,".",",")}return n.replace(t,r)};return n(`${e}`,o&&t||r)};exports.shopifyPriceRounding=shopifyPriceRounding,exports.useFormatMoney=useFormatMoney;
|
|
@@ -1,113 +1 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
-
|
|
5
|
-
var useSWR = require('swr');
|
|
6
|
-
var productValueLabel_generated = require('../graphql/queries/product-value-label.generated.js');
|
|
7
|
-
var variantPresets = require('../components/src/product/helpers/variant-presets.js');
|
|
8
|
-
var shop = require('./shop.js');
|
|
9
|
-
var useFetchHandle = require('./useFetchHandle.js');
|
|
10
|
-
var ShopContext = require('../contexts/ShopContext.js');
|
|
11
|
-
|
|
12
|
-
let swatchChange = false;
|
|
13
|
-
let colorChange = false;
|
|
14
|
-
const useInitialSwatchesOptions = (options)=>{
|
|
15
|
-
const fetcher = useFetchHandle.useFetchHandle();
|
|
16
|
-
const changeSwatches = ShopContext.useShopStore((s)=>s.changeSwatches);
|
|
17
|
-
const { swatches } = shop.useSwatches();
|
|
18
|
-
const { data: productOptionName } = useSWR([
|
|
19
|
-
'/query/productOptionName',
|
|
20
|
-
{}
|
|
21
|
-
], async ()=>fetchProductValueLabel(fetcher), {
|
|
22
|
-
revalidateOnMount: true
|
|
23
|
-
});
|
|
24
|
-
const swatchesTitleList = [];
|
|
25
|
-
swatches?.forEach((el)=>{
|
|
26
|
-
swatchesTitleList.push(el.optionTitle);
|
|
27
|
-
});
|
|
28
|
-
productOptionName?.productOptionName?.forEach((el)=>{
|
|
29
|
-
if (!swatchesTitleList.includes(el)) {
|
|
30
|
-
swatchChange = true;
|
|
31
|
-
swatches?.push({
|
|
32
|
-
optionTitle: el,
|
|
33
|
-
optionType: 'rectangle_list',
|
|
34
|
-
optionValues: []
|
|
35
|
-
});
|
|
36
|
-
}
|
|
37
|
-
});
|
|
38
|
-
if (!options) return [];
|
|
39
|
-
setDefaultSwatches(swatches, options);
|
|
40
|
-
if (swatches?.length && (swatchChange || colorChange)) {
|
|
41
|
-
window?.parent?.postMessage?.(JSON.stringify({
|
|
42
|
-
type: 'update-swatches',
|
|
43
|
-
swatches
|
|
44
|
-
}), '*');
|
|
45
|
-
changeSwatches(swatches);
|
|
46
|
-
}
|
|
47
|
-
};
|
|
48
|
-
const getColorDefault = (label, color)=>{
|
|
49
|
-
const colorByLabel = label ? variantPresets.colorPreset[label.toLocaleLowerCase()] : undefined;
|
|
50
|
-
const colorArray = colorByLabel ? [
|
|
51
|
-
colorByLabel
|
|
52
|
-
] : [];
|
|
53
|
-
const firstColor = color?.[0];
|
|
54
|
-
if (!firstColor && colorArray.length) colorChange = true;
|
|
55
|
-
return firstColor ? [
|
|
56
|
-
firstColor
|
|
57
|
-
] : colorArray;
|
|
58
|
-
};
|
|
59
|
-
const getProductOptionsLabelByName = (options, name)=>{
|
|
60
|
-
const labels = [];
|
|
61
|
-
const optionByName = options.find((op)=>op.name === name);
|
|
62
|
-
optionByName?.values.forEach((val)=>{
|
|
63
|
-
labels.push(val.label ?? '');
|
|
64
|
-
});
|
|
65
|
-
return labels;
|
|
66
|
-
};
|
|
67
|
-
const getSwatchesOptionsLabel = (options)=>{
|
|
68
|
-
const labels = [];
|
|
69
|
-
options.forEach((op)=>{
|
|
70
|
-
labels.push(op.label ?? '');
|
|
71
|
-
return;
|
|
72
|
-
});
|
|
73
|
-
return labels;
|
|
74
|
-
};
|
|
75
|
-
const setDefaultSwatches = (swatches, options)=>{
|
|
76
|
-
if (swatches) {
|
|
77
|
-
swatches?.map((sw)=>{
|
|
78
|
-
const productLabels = getProductOptionsLabelByName(options, sw.optionTitle);
|
|
79
|
-
const swLabels = getSwatchesOptionsLabel(sw.optionValues);
|
|
80
|
-
productLabels.forEach((label)=>{
|
|
81
|
-
if (!swLabels.includes(label)) {
|
|
82
|
-
sw.optionValues.push({
|
|
83
|
-
label,
|
|
84
|
-
colors: getColorDefault(label),
|
|
85
|
-
imageUrl: ''
|
|
86
|
-
});
|
|
87
|
-
}
|
|
88
|
-
});
|
|
89
|
-
sw.optionValues = sw.optionValues.map((op)=>{
|
|
90
|
-
if (op.imageUrl === undefined) swatchChange = true;
|
|
91
|
-
return {
|
|
92
|
-
label: op.label ?? '',
|
|
93
|
-
colors: getColorDefault(op.label, op.colors),
|
|
94
|
-
imageUrl: op.imageUrl ?? ''
|
|
95
|
-
};
|
|
96
|
-
});
|
|
97
|
-
});
|
|
98
|
-
}
|
|
99
|
-
return swatches;
|
|
100
|
-
};
|
|
101
|
-
const fetchProductValueLabel = async (fetcher)=>{
|
|
102
|
-
const initVariables = {};
|
|
103
|
-
const query = async (variables)=>{
|
|
104
|
-
const response = await fetcher([
|
|
105
|
-
productValueLabel_generated.ProductOptionNameDocument,
|
|
106
|
-
variables
|
|
107
|
-
]);
|
|
108
|
-
return response;
|
|
109
|
-
};
|
|
110
|
-
return query(initVariables);
|
|
111
|
-
};
|
|
112
|
-
|
|
113
|
-
exports.default = useInitialSwatchesOptions;
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var useSWR=require("swr"),productValueLabel_generated=require("../graphql/queries/product-value-label.generated.js"),variantPresets=require("../components/src/product/helpers/variant-presets.js"),shop=require("./shop.js"),useFetchHandle=require("./useFetchHandle.js"),ShopContext=require("../contexts/ShopContext.js");let swatchChange=!1,colorChange=!1;const useInitialSwatchesOptions=e=>{let t=useFetchHandle.useFetchHandle(),a=ShopContext.useShopStore(e=>e.changeSwatches),{swatches:o}=shop.useSwatches(),{data:s}=useSWR(["/query/productOptionName",{}],async()=>fetchProductValueLabel(t),{revalidateOnMount:!0}),r=[];if(o?.forEach(e=>{r.push(e.optionTitle)}),s?.productOptionName?.forEach(e=>{r.includes(e)||(swatchChange=!0,o?.push({optionTitle:e,optionType:"rectangle_list",optionValues:[]}))}),!e)return[];setDefaultSwatches(o,e),o?.length&&(swatchChange||colorChange)&&(window?.parent?.postMessage?.(JSON.stringify({type:"update-swatches",swatches:o}),"*"),a(o))},getColorDefault=(e,t)=>{let a=e?variantPresets.colorPreset[e.toLocaleLowerCase()]:void 0,o=a?[a]:[],s=t?.[0];return!s&&o.length&&(colorChange=!0),s?[s]:o},getProductOptionsLabelByName=(e,t)=>{let a=[],o=e.find(e=>e.name===t);return o?.values.forEach(e=>{a.push(e.label??"")}),a},getSwatchesOptionsLabel=e=>{let t=[];return e.forEach(e=>{t.push(e.label??"")}),t},setDefaultSwatches=(e,t)=>(e&&e?.map(e=>{let a=getProductOptionsLabelByName(t,e.optionTitle),o=getSwatchesOptionsLabel(e.optionValues);a.forEach(t=>{o.includes(t)||e.optionValues.push({label:t,colors:getColorDefault(t),imageUrl:""})}),e.optionValues=e.optionValues.map(e=>(void 0===e.imageUrl&&(swatchChange=!0),{label:e.label??"",colors:getColorDefault(e.label,e.colors),imageUrl:e.imageUrl??""}))}),e),fetchProductValueLabel=async e=>{let t={},a=async t=>{let a=await e([productValueLabel_generated.ProductOptionNameDocument,t]);return a};return a(t)};exports.default=useInitialSwatchesOptions;
|
|
@@ -1,10 +1 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
-
|
|
5
|
-
var react = require('react');
|
|
6
|
-
|
|
7
|
-
// const isBrowser = typeof window !== 'undefined';
|
|
8
|
-
const useIsomorphicLayoutEffect = react.useLayoutEffect;
|
|
9
|
-
|
|
10
|
-
exports.default = useIsomorphicLayoutEffect;
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var react=require("react");const useIsomorphicLayoutEffect=react.useLayoutEffect;exports.default=useIsomorphicLayoutEffect;
|
|
@@ -1,32 +1 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
-
|
|
5
|
-
var react = require('react');
|
|
6
|
-
var loadScript = require('../helpers/load-script.js');
|
|
7
|
-
|
|
8
|
-
/**
|
|
9
|
-
* The `useLoadScript` hook loads an external script tag on the client-side.
|
|
10
|
-
*/ function useLoadScript(url, options) {
|
|
11
|
-
const [status, setStatus] = react.useState('loading');
|
|
12
|
-
const stringifiedOptions = JSON.stringify(options);
|
|
13
|
-
react.useEffect(()=>{
|
|
14
|
-
async function loadScriptWrapper() {
|
|
15
|
-
try {
|
|
16
|
-
setStatus('loading');
|
|
17
|
-
await loadScript.loadScript(url, options);
|
|
18
|
-
setStatus('done');
|
|
19
|
-
} catch (error) {
|
|
20
|
-
setStatus('error');
|
|
21
|
-
}
|
|
22
|
-
}
|
|
23
|
-
loadScriptWrapper();
|
|
24
|
-
}, [
|
|
25
|
-
url,
|
|
26
|
-
stringifiedOptions,
|
|
27
|
-
options
|
|
28
|
-
]);
|
|
29
|
-
return status;
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
exports.default = useLoadScript;
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var react=require("react"),loadScript=require("../helpers/load-script.js");function useLoadScript(e,r){let[t,a]=react.useState("loading"),c=JSON.stringify(r);return react.useEffect(()=>{(async function(){try{a("loading"),await loadScript.loadScript(e,r),a("done")}catch(e){a("error")}})()},[e,c,r]),t}exports.default=useLoadScript;
|
|
@@ -1,84 +1 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
-
|
|
5
|
-
var react = require('react');
|
|
6
|
-
var shop = require('./shop.js');
|
|
7
|
-
|
|
8
|
-
const useMoney = (amount)=>{
|
|
9
|
-
const { locale } = shop.useLocale();
|
|
10
|
-
const { currency } = shop.useCurrency();
|
|
11
|
-
const options = react.useMemo(()=>({
|
|
12
|
-
style: 'currency',
|
|
13
|
-
currency: currency
|
|
14
|
-
}), [
|
|
15
|
-
currency
|
|
16
|
-
]);
|
|
17
|
-
const defaultFormatter = useLazyFormatter(locale, options);
|
|
18
|
-
const nameFormatter = useLazyFormatter(locale, {
|
|
19
|
-
...options,
|
|
20
|
-
currencyDisplay: 'name'
|
|
21
|
-
});
|
|
22
|
-
const narrowSymbolFormatter = useLazyFormatter(locale, {
|
|
23
|
-
...options,
|
|
24
|
-
currencyDisplay: 'narrowSymbol'
|
|
25
|
-
});
|
|
26
|
-
const withoutTrailingZerosFormatter = useLazyFormatter(locale, {
|
|
27
|
-
...options,
|
|
28
|
-
minimumFractionDigits: 0,
|
|
29
|
-
maximumFractionDigits: 0
|
|
30
|
-
});
|
|
31
|
-
const withoutCurrencyFormatter = useLazyFormatter(locale);
|
|
32
|
-
const withoutTrailingZerosOrCurrencyFormatter = useLazyFormatter(locale, {
|
|
33
|
-
minimumFractionDigits: 0,
|
|
34
|
-
maximumFractionDigits: 0
|
|
35
|
-
});
|
|
36
|
-
const isPartCurrency = (part)=>part.type === 'currency';
|
|
37
|
-
// By wrapping these properties in functions, we only
|
|
38
|
-
// create formatters if they are going to be used.
|
|
39
|
-
const lazyFormatters = react.useMemo(()=>({
|
|
40
|
-
currencyCode: ()=>currency,
|
|
41
|
-
localizedString: ()=>defaultFormatter().format(amount),
|
|
42
|
-
parts: ()=>defaultFormatter().formatToParts(amount),
|
|
43
|
-
withoutTrailingZeros: ()=>amount % 1 === 0 ? withoutTrailingZerosFormatter().format(amount) : defaultFormatter().format(amount),
|
|
44
|
-
withoutTrailingZerosAndCurrency: ()=>amount % 1 === 0 ? withoutTrailingZerosOrCurrencyFormatter().format(amount) : withoutCurrencyFormatter().format(amount),
|
|
45
|
-
currencyName: ()=>nameFormatter().formatToParts(amount).find(isPartCurrency)?.value ?? currency,
|
|
46
|
-
currencySymbol: ()=>defaultFormatter().formatToParts(amount).find(isPartCurrency)?.value ?? currency,
|
|
47
|
-
currencyNarrowSymbol: ()=>narrowSymbolFormatter().formatToParts(amount).find(isPartCurrency)?.value ?? '',
|
|
48
|
-
amount: ()=>defaultFormatter().formatToParts(amount).filter((part)=>[
|
|
49
|
-
'decimal',
|
|
50
|
-
'fraction',
|
|
51
|
-
'group',
|
|
52
|
-
'integer',
|
|
53
|
-
'literal'
|
|
54
|
-
].includes(part.type)).map((part)=>part.value).join('')
|
|
55
|
-
}), [
|
|
56
|
-
currency,
|
|
57
|
-
amount,
|
|
58
|
-
nameFormatter,
|
|
59
|
-
defaultFormatter,
|
|
60
|
-
narrowSymbolFormatter,
|
|
61
|
-
withoutCurrencyFormatter,
|
|
62
|
-
withoutTrailingZerosFormatter,
|
|
63
|
-
withoutTrailingZerosOrCurrencyFormatter
|
|
64
|
-
]);
|
|
65
|
-
// Call functions automatically when the properties are accessed
|
|
66
|
-
// to keep these functions as an implementation detail.
|
|
67
|
-
return react.useMemo(()=>new Proxy(lazyFormatters, {
|
|
68
|
-
// eslint-disable-next-line @typescript-eslint/no-unsafe-return, @typescript-eslint/no-unsafe-member-access, @typescript-eslint/no-unsafe-call
|
|
69
|
-
get: (target, key)=>Reflect.get(target, key)?.call(null)
|
|
70
|
-
}), [
|
|
71
|
-
lazyFormatters
|
|
72
|
-
]);
|
|
73
|
-
};
|
|
74
|
-
function useLazyFormatter(locale, options) {
|
|
75
|
-
return react.useMemo(()=>{
|
|
76
|
-
let memoized;
|
|
77
|
-
return ()=>memoized ??= new Intl.NumberFormat(locale, options);
|
|
78
|
-
}, [
|
|
79
|
-
locale,
|
|
80
|
-
options
|
|
81
|
-
]);
|
|
82
|
-
}
|
|
83
|
-
|
|
84
|
-
exports.default = useMoney;
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var react=require("react"),shop=require("./shop.js");const useMoney=r=>{let{locale:e}=shop.useLocale(),{currency:t}=shop.useCurrency(),a=react.useMemo(()=>({style:"currency",currency:t}),[t]),o=useLazyFormatter(e,a),u=useLazyFormatter(e,{...a,currencyDisplay:"name"}),n=useLazyFormatter(e,{...a,currencyDisplay:"narrowSymbol"}),i=useLazyFormatter(e,{...a,minimumFractionDigits:0,maximumFractionDigits:0}),m=useLazyFormatter(e),s=useLazyFormatter(e,{minimumFractionDigits:0,maximumFractionDigits:0}),c=r=>"currency"===r.type,l=react.useMemo(()=>({currencyCode:()=>t,localizedString:()=>o().format(r),parts:()=>o().formatToParts(r),withoutTrailingZeros:()=>r%1==0?i().format(r):o().format(r),withoutTrailingZerosAndCurrency:()=>r%1==0?s().format(r):m().format(r),currencyName:()=>u().formatToParts(r).find(c)?.value??t,currencySymbol:()=>o().formatToParts(r).find(c)?.value??t,currencyNarrowSymbol:()=>n().formatToParts(r).find(c)?.value??"",amount:()=>o().formatToParts(r).filter(r=>["decimal","fraction","group","integer","literal"].includes(r.type)).map(r=>r.value).join("")}),[t,r,u,o,n,m,i,s]);return react.useMemo(()=>new Proxy(l,{get:(r,e)=>Reflect.get(r,e)?.call(null)}),[l])};function useLazyFormatter(r,e){return react.useMemo(()=>{let t;return()=>t??=new Intl.NumberFormat(r,e)},[r,e])}exports.default=useMoney;
|
|
@@ -1,19 +1 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
var react = require('react');
|
|
4
|
-
|
|
5
|
-
const usePrevious = (value)=>{
|
|
6
|
-
// The ref object is a generic container whose current property is mutable ...
|
|
7
|
-
// ... and can hold any value, similar to an instance property on a class
|
|
8
|
-
const ref = react.useRef();
|
|
9
|
-
// Store current value in ref
|
|
10
|
-
react.useEffect(()=>{
|
|
11
|
-
ref.current = value;
|
|
12
|
-
}, [
|
|
13
|
-
value
|
|
14
|
-
]); // Only re-run if value changes
|
|
15
|
-
// Return previous value (happens before update in useEffect above)
|
|
16
|
-
return ref.current;
|
|
17
|
-
};
|
|
18
|
-
|
|
19
|
-
exports.usePrevious = usePrevious;
|
|
1
|
+
"use strict";var react=require("react");const usePrevious=e=>{let r=react.useRef();return react.useEffect(()=>{r.current=e},[e]),r.current};exports.usePrevious=usePrevious;
|