@ubnt/store.core 9.17.0-alpha.4 → 9.17.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +2 -154
- package/lib/_virtual/_virtual_multi-entry.js +12 -27
- package/lib/_virtual/_virtual_multi-entry.js.map +1 -1
- package/lib/_virtual/_virtual_multi-entry.mjs +10 -14
- package/lib/_virtual/_virtual_multi-entry.mjs.map +1 -1
- package/lib/apis/smartcat.js +1 -4
- package/lib/apis/smartcat.js.map +1 -1
- package/lib/apis/smartcat.mjs +1 -4
- package/lib/apis/smartcat.mjs.map +1 -1
- package/lib/{components/ResourceCalculatorV1/assets/consoles/ucg-max.png.js → assets/icons/menu/icon-globe.svg.js} +6 -6
- package/lib/assets/icons/menu/icon-globe.svg.js.map +1 -0
- package/lib/assets/icons/menu/icon-globe.svg.mjs +3 -0
- package/lib/assets/icons/menu/icon-globe.svg.mjs.map +1 -0
- package/lib/components/CategoryTabs/CategoryTabs.styles.d.ts +1 -1
- package/lib/components/CategoryTabs/CategoryTabs.types.d.ts +1 -1
- package/lib/components/CloserLookSection/CloserLookSection.js.map +1 -1
- package/lib/components/CloserLookSection/CloserLookSection.mjs.map +1 -1
- package/lib/components/Compare/Compare.styles.d.ts +5 -5
- package/lib/components/Container/Container.d.ts +1 -1
- package/lib/components/Container/Container.js +3 -4
- package/lib/components/Container/Container.js.map +1 -1
- package/lib/components/Container/Container.mjs +4 -5
- package/lib/components/Container/Container.mjs.map +1 -1
- package/lib/components/CustomImage/CustomImage.js.map +1 -1
- package/lib/components/CustomImage/CustomImage.mjs.map +1 -1
- package/lib/components/FeaturesSection_deprecated/FeaturesSection.js.map +1 -1
- package/lib/components/FeaturesSection_deprecated/FeaturesSection.mjs.map +1 -1
- package/lib/components/Footer/hooks/useFooterContent.d.ts +3 -1
- package/lib/components/Footer/hooks/useFooterContent.js +8 -1
- package/lib/components/Footer/hooks/useFooterContent.js.map +1 -1
- package/lib/components/Footer/hooks/useFooterContent.mjs +8 -1
- package/lib/components/Footer/hooks/useFooterContent.mjs.map +1 -1
- package/lib/components/Footer/translations/ar.json.js +1 -1
- package/lib/components/Footer/translations/ar.json.mjs +1 -1
- package/lib/components/Footer/translations/de.json.js +1 -1
- package/lib/components/Footer/translations/de.json.mjs +1 -1
- package/lib/components/Footer/translations/el.json.js +1 -1
- package/lib/components/Footer/translations/el.json.mjs +1 -1
- package/lib/components/Footer/translations/en.json.js +1 -0
- package/lib/components/Footer/translations/en.json.js.map +1 -1
- package/lib/components/Footer/translations/en.json.mjs +1 -0
- package/lib/components/Footer/translations/en.json.mjs.map +1 -1
- package/lib/components/Footer/translations/es.json.js +1 -1
- package/lib/components/Footer/translations/es.json.mjs +1 -1
- package/lib/components/Footer/translations/fr.json.js +4 -4
- package/lib/components/Footer/translations/fr.json.mjs +4 -4
- package/lib/components/Footer/translations/it.json.js +1 -1
- package/lib/components/Footer/translations/it.json.mjs +1 -1
- package/lib/components/Footer/translations/ja.json.js +2 -2
- package/lib/components/Footer/translations/ja.json.mjs +2 -2
- package/lib/components/Footer/translations/pt-BR.json.js +1 -1
- package/lib/components/Footer/translations/pt-BR.json.mjs +1 -1
- package/lib/components/Footer/translations/zh-Hans.json.js +4 -4
- package/lib/components/Footer/translations/zh-Hans.json.mjs +4 -4
- package/lib/components/Footer/translations/zh-Hant-TW.json.js +1 -1
- package/lib/components/Footer/translations/zh-Hant-TW.json.mjs +1 -1
- package/lib/components/GridGallery/GridGallery.js.map +1 -1
- package/lib/components/GridGallery/GridGallery.mjs.map +1 -1
- package/lib/components/Header/AccountMenu/AccountMenu.js +12 -20
- package/lib/components/Header/AccountMenu/AccountMenu.js.map +1 -1
- package/lib/components/Header/AccountMenu/AccountMenu.mjs +14 -22
- package/lib/components/Header/AccountMenu/AccountMenu.mjs.map +1 -1
- package/lib/components/Header/AccountMenu/megaphone.http.service.js +1 -4
- package/lib/components/Header/AccountMenu/megaphone.http.service.js.map +1 -1
- package/lib/components/Header/AccountMenu/megaphone.http.service.mjs +1 -4
- package/lib/components/Header/AccountMenu/megaphone.http.service.mjs.map +1 -1
- package/lib/components/Header/CartModalV2/CartModal.js.map +1 -1
- package/lib/components/Header/CartModalV2/CartModal.mjs.map +1 -1
- package/lib/components/Header/Header.js.map +1 -1
- package/lib/components/Header/Header.mjs.map +1 -1
- package/lib/components/Header/Header.styles.d.ts +2 -2
- package/lib/components/Header/Header.types.d.ts +4 -8
- package/lib/components/Header/Header.types.js +1 -2
- package/lib/components/Header/Header.types.js.map +1 -1
- package/lib/components/Header/Header.types.mjs +1 -2
- package/lib/components/Header/Header.types.mjs.map +1 -1
- package/lib/components/Header/LanguageFrame/LanguageFrame.js.map +1 -1
- package/lib/components/Header/LanguageFrame/LanguageFrame.mjs.map +1 -1
- package/lib/components/Header/LanguageFrame/Mobile/Mobile.js.map +1 -1
- package/lib/components/Header/LanguageFrame/Mobile/Mobile.mjs.map +1 -1
- package/lib/components/Header/MenuItem/MenuItem.styles.d.ts +1 -1
- package/lib/components/Header/MenuItem/MenuItem.styles.js +1 -1
- package/lib/components/Header/MenuItem/MenuItem.styles.js.map +1 -1
- package/lib/components/Header/MenuItem/MenuItem.styles.mjs +1 -1
- package/lib/components/Header/MenuItem/MenuItem.styles.mjs.map +1 -1
- package/lib/components/Header/Navigation/MicrositeMenu/MicrositeMenu.styles.d.ts +1 -1
- package/lib/components/Header/Navigation/MobileMenu/MobileMenu.styles.d.ts +1 -1
- package/lib/components/Header/Navigation/ProMobileMenu/ProMobileMenu.d.ts +1 -1
- package/lib/components/Header/Navigation/ProMobileMenu/ProMobileMenu.js +63 -85
- package/lib/components/Header/Navigation/ProMobileMenu/ProMobileMenu.js.map +1 -1
- package/lib/components/Header/Navigation/ProMobileMenu/ProMobileMenu.mjs +64 -86
- package/lib/components/Header/Navigation/ProMobileMenu/ProMobileMenu.mjs.map +1 -1
- package/lib/components/Header/Navigation/ProMobileMenu/ProMobileMenu.styles.d.ts +0 -6
- package/lib/components/Header/Navigation/ProMobileMenu/ProMobileMenu.styles.js +1 -11
- package/lib/components/Header/Navigation/ProMobileMenu/ProMobileMenu.styles.js.map +1 -1
- package/lib/components/Header/Navigation/ProMobileMenu/ProMobileMenu.styles.mjs +2 -10
- package/lib/components/Header/Navigation/ProMobileMenu/ProMobileMenu.styles.mjs.map +1 -1
- package/lib/components/Header/Navigation/ProMobileMenu/ProMobileMenu.types.d.ts +1 -5
- package/lib/components/Header/Overlay/Overlay.js.map +1 -1
- package/lib/components/Header/Overlay/Overlay.mjs.map +1 -1
- package/lib/components/Header/ProHeader/ProHeader.d.ts +4 -2
- package/lib/components/Header/ProHeader/ProHeader.js +36 -145
- package/lib/components/Header/ProHeader/ProHeader.js.map +1 -1
- package/lib/components/Header/ProHeader/ProHeader.mjs +39 -146
- package/lib/components/Header/ProHeader/ProHeader.mjs.map +1 -1
- package/lib/components/Header/ProHeader/ProHeader.styles.d.ts +1 -4
- package/lib/components/Header/ProHeader/ProHeader.styles.js +18 -20
- package/lib/components/Header/ProHeader/ProHeader.styles.js.map +1 -1
- package/lib/components/Header/ProHeader/ProHeader.styles.mjs +19 -18
- package/lib/components/Header/ProHeader/ProHeader.styles.mjs.map +1 -1
- package/lib/components/Header/translations/en.json.js +1 -4
- package/lib/components/Header/translations/en.json.js.map +1 -1
- package/lib/components/Header/translations/en.json.mjs +2 -4
- package/lib/components/Header/translations/en.json.mjs.map +1 -1
- package/lib/components/Hero/Hero.styles.d.ts +2 -2
- package/lib/components/HeroFadeGallery/HeroFadeGallery.styles.d.ts +1 -1
- package/lib/components/HowToUseSection/HowToUseSection.styles.d.ts +2 -2
- package/lib/components/ImageSequence/ImageSequence.js.map +1 -1
- package/lib/components/ImageSequence/ImageSequence.mjs.map +1 -1
- package/lib/components/LandingPage/Cards/Card/Card.js.map +1 -1
- package/lib/components/LandingPage/Cards/Card/Card.mjs.map +1 -1
- package/lib/components/LandingPage/Cards/Cards.js.map +1 -1
- package/lib/components/LandingPage/Cards/Cards.mjs.map +1 -1
- package/lib/components/LandingPagePro/LandingPagePro.d.ts +0 -3
- package/lib/components/LandingPagePro/LandingPagePro.js +3 -3
- package/lib/components/LandingPagePro/LandingPagePro.js.map +1 -1
- package/lib/components/LandingPagePro/LandingPagePro.mjs +2 -2
- package/lib/components/LandingPagePro/LandingPagePro.mjs.map +1 -1
- package/lib/components/LandingPagePro/LandingPagePro.styles.d.ts +1 -1
- package/lib/components/LayoutRenderer/LayoutRenderer.styles.d.ts +1 -1
- package/lib/components/LayoutRendererV1/LayoutRenderer.styles.d.ts +3 -3
- package/lib/components/LayoutRendererV2/LayoutRenderer.styles.d.ts +3 -3
- package/lib/components/MicrositeIntroductionBlock/MicrositeIntroductionBlock.js.map +1 -1
- package/lib/components/MicrositeIntroductionBlock/MicrositeIntroductionBlock.mjs.map +1 -1
- package/lib/components/MicrositeMediaGrid/MicrositeMediaGrid.js.map +1 -1
- package/lib/components/MicrositeMediaGrid/MicrositeMediaGrid.mjs.map +1 -1
- package/lib/components/MicrositeProductGrid/MicrositeProductGrid.js.map +1 -1
- package/lib/components/MicrositeProductGrid/MicrositeProductGrid.mjs.map +1 -1
- package/lib/components/MicrositeSectionWrap/MicrositeSectionWrap.styles.d.ts +1 -1
- package/lib/components/Microsites/MicrositeProductPage.js +39 -0
- package/lib/components/Microsites/MicrositeProductPage.js.map +1 -1
- package/lib/components/Microsites/MicrositeProductPage.mjs +39 -0
- package/lib/components/Microsites/MicrositeProductPage.mjs.map +1 -1
- package/lib/components/ModelCompareV3/StickyGrid/StickyGridHeader.js.map +1 -1
- package/lib/components/ModelCompareV3/StickyGrid/StickyGridHeader.mjs.map +1 -1
- package/lib/components/ProductCompare/ProductCompare.js.map +1 -1
- package/lib/components/ProductCompare/ProductCompare.mjs.map +1 -1
- package/lib/components/ProductSectionNavigation/ProductSectionNavigation.styles.d.ts +1 -1
- package/lib/components/ProductSectionNavigationV2/ProductSectionNavigation.styles.d.ts +1 -1
- package/lib/components/ProductTechSpecs/ProductTechSpecs.styles.d.ts +1 -1
- package/lib/components/QuantityControls/QuantityControls.js.map +1 -1
- package/lib/components/QuantityControls/QuantityControls.mjs.map +1 -1
- package/lib/components/RelatedProducts/RelatedProducts.js.map +1 -1
- package/lib/components/RelatedProducts/RelatedProducts.mjs.map +1 -1
- package/lib/components/ResourceCalculatorV1/ComputeResourceCalculator/ComputeResourceCalculator.constants.js +17 -313
- package/lib/components/ResourceCalculatorV1/ComputeResourceCalculator/ComputeResourceCalculator.constants.js.map +1 -1
- package/lib/components/ResourceCalculatorV1/ComputeResourceCalculator/ComputeResourceCalculator.constants.mjs +17 -311
- package/lib/components/ResourceCalculatorV1/ComputeResourceCalculator/ComputeResourceCalculator.constants.mjs.map +1 -1
- package/lib/components/ResourceCalculatorV1/ComputeResourceCalculator/ComputeResourceCalculator.types.d.ts +2 -3
- package/lib/components/ResourceCalculatorV1/ComputeResourceCalculator/ComputeResourceCalculator.types.js +0 -2
- package/lib/components/ResourceCalculatorV1/ComputeResourceCalculator/ComputeResourceCalculator.types.js.map +1 -1
- package/lib/components/ResourceCalculatorV1/ComputeResourceCalculator/ComputeResourceCalculator.types.mjs +0 -2
- package/lib/components/ResourceCalculatorV1/ComputeResourceCalculator/ComputeResourceCalculator.types.mjs.map +1 -1
- package/lib/components/ResourceCalculatorV1/ComputeResourceCalculator/components/DeviceSelect/DeviceSelect.js +34 -120
- package/lib/components/ResourceCalculatorV1/ComputeResourceCalculator/components/DeviceSelect/DeviceSelect.js.map +1 -1
- package/lib/components/ResourceCalculatorV1/ComputeResourceCalculator/components/DeviceSelect/DeviceSelect.mjs +34 -120
- package/lib/components/ResourceCalculatorV1/ComputeResourceCalculator/components/DeviceSelect/DeviceSelect.mjs.map +1 -1
- package/lib/components/ResourceCalculatorV1/ComputeResourceCalculator/components/DeviceSelect/DeviceSelect.styles.d.ts +2 -16
- package/lib/components/ResourceCalculatorV1/ComputeResourceCalculator/components/DeviceSelect/DeviceSelect.styles.js +12 -54
- package/lib/components/ResourceCalculatorV1/ComputeResourceCalculator/components/DeviceSelect/DeviceSelect.styles.js.map +1 -1
- package/lib/components/ResourceCalculatorV1/ComputeResourceCalculator/components/DeviceSelect/DeviceSelect.styles.mjs +11 -50
- package/lib/components/ResourceCalculatorV1/ComputeResourceCalculator/components/DeviceSelect/DeviceSelect.styles.mjs.map +1 -1
- package/lib/components/ResourceCalculatorV1/ComputeResourceCalculator/components/DeviceSelect/assets/ArrowLeftPrimary.svg.js +5 -5
- package/lib/components/ResourceCalculatorV1/ComputeResourceCalculator/components/DeviceSelect/assets/ArrowRightPrimary.svg.js +5 -5
- package/lib/components/ResourceCalculatorV1/ComputeResourceCalculator/components/InputCard/InputCard.js +1 -1
- package/lib/components/ResourceCalculatorV1/ComputeResourceCalculator/components/InputCard/InputCard.js.map +1 -1
- package/lib/components/ResourceCalculatorV1/ComputeResourceCalculator/components/InputCard/InputCard.mjs +1 -1
- package/lib/components/ResourceCalculatorV1/ComputeResourceCalculator/components/InputCard/InputCard.mjs.map +1 -1
- package/lib/components/ResourceCalculatorV1/ComputeResourceCalculator/components/InputCard/InputCard.styles.js +0 -2
- package/lib/components/ResourceCalculatorV1/ComputeResourceCalculator/components/InputCard/InputCard.styles.js.map +1 -1
- package/lib/components/ResourceCalculatorV1/ComputeResourceCalculator/components/InputCard/InputCard.styles.mjs +0 -2
- package/lib/components/ResourceCalculatorV1/ComputeResourceCalculator/components/InputCard/InputCard.styles.mjs.map +1 -1
- package/lib/components/ResourceCalculatorV1/ComputeResourceCalculator/useComputeResourceCalculator.js +1 -1
- package/lib/components/ResourceCalculatorV1/ComputeResourceCalculator/useComputeResourceCalculator.js.map +1 -1
- package/lib/components/ResourceCalculatorV1/ComputeResourceCalculator/useComputeResourceCalculator.mjs +1 -1
- package/lib/components/ResourceCalculatorV1/ComputeResourceCalculator/useComputeResourceCalculator.mjs.map +1 -1
- package/lib/components/ResourceCalculatorV1/PoeCalculator/components/PoeConsumerConfigurator/PoeConsumerSelectModal/PoeConsumerSelectModal.js +2 -2
- package/lib/components/ResourceCalculatorV1/PoeCalculator/components/PoeConsumerConfigurator/PoeConsumerSelectModal/PoeConsumerSelectModal.js.map +1 -1
- package/lib/components/ResourceCalculatorV1/PoeCalculator/components/PoeConsumerConfigurator/PoeConsumerSelectModal/PoeConsumerSelectModal.mjs +2 -2
- package/lib/components/ResourceCalculatorV1/PoeCalculator/components/PoeConsumerConfigurator/PoeConsumerSelectModal/PoeConsumerSelectModal.mjs.map +1 -1
- package/lib/components/ResourceCalculatorV1/ResourceCalculator.js +2 -1
- package/lib/components/ResourceCalculatorV1/ResourceCalculator.js.map +1 -1
- package/lib/components/ResourceCalculatorV1/ResourceCalculator.mjs +2 -1
- package/lib/components/ResourceCalculatorV1/ResourceCalculator.mjs.map +1 -1
- package/lib/components/{HorizontalOptionSelect → ResourceCalculatorV1/components/HorizontalOptionSelect}/HorizontalOptionSelect.d.ts +1 -1
- package/lib/components/{HorizontalOptionSelect → ResourceCalculatorV1/components/HorizontalOptionSelect}/HorizontalOptionSelect.js +1 -3
- package/lib/components/ResourceCalculatorV1/components/HorizontalOptionSelect/HorizontalOptionSelect.js.map +1 -0
- package/lib/components/{HorizontalOptionSelect → ResourceCalculatorV1/components/HorizontalOptionSelect}/HorizontalOptionSelect.mjs +1 -3
- package/lib/components/ResourceCalculatorV1/components/HorizontalOptionSelect/HorizontalOptionSelect.mjs.map +1 -0
- package/lib/components/{HorizontalOptionSelect → ResourceCalculatorV1/components/HorizontalOptionSelect}/HorizontalOptionSelect.styles.d.ts +0 -1
- package/lib/components/{HorizontalOptionSelect → ResourceCalculatorV1/components/HorizontalOptionSelect}/HorizontalOptionSelect.styles.js +7 -10
- package/lib/components/ResourceCalculatorV1/components/HorizontalOptionSelect/HorizontalOptionSelect.styles.js.map +1 -0
- package/lib/components/{HorizontalOptionSelect → ResourceCalculatorV1/components/HorizontalOptionSelect}/HorizontalOptionSelect.styles.mjs +7 -10
- package/lib/components/ResourceCalculatorV1/components/HorizontalOptionSelect/HorizontalOptionSelect.styles.mjs.map +1 -0
- package/lib/components/{HorizontalOptionSelect → ResourceCalculatorV1/components/HorizontalOptionSelect}/HorizontalOptionSelect.types.d.ts +0 -1
- package/lib/components/ResourceCalculatorV1/components/index.d.ts +1 -0
- package/lib/components/ResourceCalculatorV1/components/index.js +5 -0
- package/lib/components/{Header/Navigation/ProMenu → ResourceCalculatorV1/components}/index.js.map +1 -1
- package/lib/components/ResourceCalculatorV1/components/index.mjs +3 -0
- package/lib/components/ResourceCalculatorV1/translations/en.json.js +4 -6
- package/lib/components/ResourceCalculatorV1/translations/en.json.js.map +1 -1
- package/lib/components/ResourceCalculatorV1/translations/en.json.mjs +4 -6
- package/lib/components/ResourceCalculatorV1/translations/en.json.mjs.map +1 -1
- package/lib/components/ResourceCalculatorV1/translations/useResourceCalculatorTranslation.d.ts +2 -2
- package/lib/components/ReverseLoopingVideo/ReverseLoopingVideo.js.map +1 -1
- package/lib/components/ReverseLoopingVideo/ReverseLoopingVideo.mjs.map +1 -1
- package/lib/components/ScrollWrapper/ScrollWrapper.js.map +1 -1
- package/lib/components/ScrollWrapper/ScrollWrapper.mjs.map +1 -1
- package/lib/components/StorageSliders/Slider/Slider.js.map +1 -1
- package/lib/components/StorageSliders/Slider/Slider.mjs.map +1 -1
- package/lib/components/StorageSliders/StorageSliders.context.js.map +1 -1
- package/lib/components/StorageSliders/StorageSliders.context.mjs.map +1 -1
- package/lib/components/VariantSelector/Variant/Compatibility/Compatibility.js.map +1 -1
- package/lib/components/VariantSelector/Variant/Compatibility/Compatibility.mjs.map +1 -1
- package/lib/components/VariantSelector/Variant/Variant.js.map +1 -1
- package/lib/components/VariantSelector/Variant/Variant.mjs.map +1 -1
- package/lib/components/index.d.ts +0 -1
- package/lib/components/index.js +0 -2
- package/lib/components/index.js.map +1 -1
- package/lib/components/index.mjs +0 -2
- package/lib/components/index.mjs.map +1 -1
- package/lib/constants/proStoreCategories/mapping/index.d.ts +0 -1
- package/lib/constants/proStoreCategories/mapping/index.js +10 -15
- package/lib/constants/proStoreCategories/mapping/index.js.map +1 -1
- package/lib/constants/proStoreCategories/mapping/index.mjs +10 -15
- package/lib/constants/proStoreCategories/mapping/index.mjs.map +1 -1
- package/lib/constants/proStoreCategories/mapping/unifi.d.ts +1 -2
- package/lib/constants/proStoreCategories/mapping/unifi.js +0 -1
- package/lib/constants/proStoreCategories/mapping/unifi.js.map +1 -1
- package/lib/constants/proStoreCategories/mapping/unifi.mjs +0 -1
- package/lib/constants/proStoreCategories/mapping/unifi.mjs.map +1 -1
- package/lib/constants/proStoreCategories/translations/en.json.js +0 -3
- package/lib/constants/proStoreCategories/translations/en.json.js.map +1 -1
- package/lib/constants/proStoreCategories/translations/en.json.mjs +1 -3
- package/lib/constants/proStoreCategories/translations/en.json.mjs.map +1 -1
- package/lib/constants/proStoreCategories/translations/fr.json.js +1 -1
- package/lib/constants/proStoreCategories/translations/fr.json.mjs +1 -1
- package/lib/constants/proStoreCategories/translations/zh-Hans.json.js +1 -1
- package/lib/constants/proStoreCategories/translations/zh-Hans.json.mjs +1 -1
- package/lib/constants/proStoreCategories/translations/zh-Hant-TW.json.js +1 -1
- package/lib/constants/proStoreCategories/translations/zh-Hant-TW.json.mjs +1 -1
- package/lib/constants/url.d.ts +2 -1
- package/lib/constants/url.js +1 -0
- package/lib/constants/url.js.map +1 -1
- package/lib/constants/url.mjs +1 -0
- package/lib/constants/url.mjs.map +1 -1
- package/lib/contexts/MenuContext/context.js +1 -1
- package/lib/contexts/MenuContext/context.js.map +1 -1
- package/lib/contexts/MenuContext/context.mjs +1 -1
- package/lib/contexts/MenuContext/context.mjs.map +1 -1
- package/lib/contexts/MenuContext/utils.js +1 -0
- package/lib/contexts/MenuContext/utils.js.map +1 -1
- package/lib/contexts/MenuContext/utils.mjs +1 -0
- package/lib/contexts/MenuContext/utils.mjs.map +1 -1
- package/lib/helpers/index.d.ts +0 -1
- package/lib/helpers/index.js +0 -11
- package/lib/helpers/index.js.map +1 -1
- package/lib/helpers/index.mjs +0 -1
- package/lib/helpers/index.mjs.map +1 -1
- package/lib/helpers/ux.d.ts +1 -9
- package/lib/helpers/ux.js +0 -15
- package/lib/helpers/ux.js.map +1 -1
- package/lib/helpers/ux.mjs +1 -15
- package/lib/helpers/ux.mjs.map +1 -1
- package/lib/hooks/useHasTouch.js.map +1 -1
- package/lib/hooks/useHasTouch.mjs.map +1 -1
- package/lib/hooks/useHorizontalScroll.js.map +1 -1
- package/lib/hooks/useHorizontalScroll.mjs.map +1 -1
- package/lib/types/index.d.ts +0 -1
- package/lib/types/index.js +0 -2
- package/lib/types/index.js.map +1 -1
- package/lib/types/index.mjs +0 -1
- package/lib/types/index.mjs.map +1 -1
- package/lib/utils/array.d.ts +0 -4
- package/lib/utils/array.js +0 -10
- package/lib/utils/array.js.map +1 -1
- package/lib/utils/array.mjs +1 -10
- package/lib/utils/array.mjs.map +1 -1
- package/lib/utils/money/constants.d.ts +25 -56
- package/lib/utils/money/constants.js +7 -72
- package/lib/utils/money/constants.js.map +1 -1
- package/lib/utils/money/constants.mjs +7 -70
- package/lib/utils/money/constants.mjs.map +1 -1
- package/lib/utils/money/format.d.ts +5 -10
- package/lib/utils/money/format.js +14 -22
- package/lib/utils/money/format.js.map +1 -1
- package/lib/utils/money/format.mjs +16 -23
- package/lib/utils/money/format.mjs.map +1 -1
- package/lib/utils/money/index.d.ts +1 -4
- package/lib/utils/money/index.js +8 -26
- package/lib/utils/money/index.js.map +1 -1
- package/lib/utils/money/index.mjs +4 -8
- package/lib/utils/money/index.mjs.map +1 -1
- package/lib/utils/money/misc.d.ts +28 -68
- package/lib/utils/money/misc.js +64 -35
- package/lib/utils/money/misc.js.map +1 -1
- package/lib/utils/money/misc.mjs +43 -32
- package/lib/utils/money/misc.mjs.map +1 -1
- package/lib/utils/money/tax.d.ts +2 -38
- package/lib/utils/money/tax.js +10 -46
- package/lib/utils/money/tax.js.map +1 -1
- package/lib/utils/money/tax.mjs +11 -42
- package/lib/utils/money/tax.mjs.map +1 -1
- package/lib/utils/money/types.d.ts +3 -78
- package/lib/utils/number.d.ts +1 -1
- package/lib/utils/number.js +1 -1
- package/lib/utils/number.js.map +1 -1
- package/lib/utils/number.mjs +1 -1
- package/lib/utils/number.mjs.map +1 -1
- package/lib/utils/validations/postalCodeSuperRefinement.js +3 -0
- package/lib/utils/validations/postalCodeSuperRefinement.js.map +1 -1
- package/lib/utils/validations/postalCodeSuperRefinement.mjs +3 -0
- package/lib/utils/validations/postalCodeSuperRefinement.mjs.map +1 -1
- package/lib/utils/validations/stateRegistrationNumberSuperRefinement.js +2 -0
- package/lib/utils/validations/stateRegistrationNumberSuperRefinement.js.map +1 -1
- package/lib/utils/validations/stateRegistrationNumberSuperRefinement.mjs +2 -0
- package/lib/utils/validations/stateRegistrationNumberSuperRefinement.mjs.map +1 -1
- package/lib/utils/validations/taxIdSuperRefinement.js +2 -0
- package/lib/utils/validations/taxIdSuperRefinement.js.map +1 -1
- package/lib/utils/validations/taxIdSuperRefinement.mjs +2 -0
- package/lib/utils/validations/taxIdSuperRefinement.mjs.map +1 -1
- package/lib/utils/validations.d.ts +15 -0
- package/lib/utils/validations.js +23 -0
- package/lib/utils/validations.js.map +1 -0
- package/lib/utils/validations.mjs +21 -0
- package/lib/utils/validations.mjs.map +1 -0
- package/lib/utils/variant.js.map +1 -1
- package/lib/utils/variant.mjs.map +1 -1
- package/lib/utils/wattage.js.map +1 -1
- package/lib/utils/wattage.mjs.map +1 -1
- package/package.json +1 -1
- package/lib/assets/efg.png +0 -0
- package/lib/assets/icon-location-pin.svg +0 -5
- package/lib/assets/icons/menu/icon-location-pin.svg.js +0 -27
- package/lib/assets/icons/menu/icon-location-pin.svg.js.map +0 -1
- package/lib/assets/icons/menu/icon-location-pin.svg.mjs +0 -3
- package/lib/assets/icons/menu/icon-location-pin.svg.mjs.map +0 -1
- package/lib/assets/ucg-max.png +0 -0
- package/lib/components/Header/Navigation/ProMenu/ProMenu.d.ts +0 -2
- package/lib/components/Header/Navigation/ProMenu/ProMenu.js +0 -109
- package/lib/components/Header/Navigation/ProMenu/ProMenu.js.map +0 -1
- package/lib/components/Header/Navigation/ProMenu/ProMenu.mjs +0 -87
- package/lib/components/Header/Navigation/ProMenu/ProMenu.mjs.map +0 -1
- package/lib/components/Header/Navigation/ProMenu/ProMenu.styles.d.ts +0 -24
- package/lib/components/Header/Navigation/ProMenu/ProMenu.styles.js +0 -154
- package/lib/components/Header/Navigation/ProMenu/ProMenu.styles.js.map +0 -1
- package/lib/components/Header/Navigation/ProMenu/ProMenu.styles.mjs +0 -138
- package/lib/components/Header/Navigation/ProMenu/ProMenu.styles.mjs.map +0 -1
- package/lib/components/Header/Navigation/ProMenu/ProMenu.types.d.ts +0 -13
- package/lib/components/Header/Navigation/ProMenu/index.d.ts +0 -1
- package/lib/components/Header/Navigation/ProMenu/index.js +0 -6
- package/lib/components/Header/Navigation/ProMenu/index.mjs +0 -3
- package/lib/components/HorizontalOptionSelect/HorizontalOptionSelect.js.map +0 -1
- package/lib/components/HorizontalOptionSelect/HorizontalOptionSelect.mjs.map +0 -1
- package/lib/components/HorizontalOptionSelect/HorizontalOptionSelect.styles.js.map +0 -1
- package/lib/components/HorizontalOptionSelect/HorizontalOptionSelect.styles.mjs.map +0 -1
- package/lib/components/ResourceCalculatorV1/assets/consoles/efg.png.js +0 -27
- package/lib/components/ResourceCalculatorV1/assets/consoles/efg.png.js.map +0 -1
- package/lib/components/ResourceCalculatorV1/assets/consoles/efg.png.mjs +0 -3
- package/lib/components/ResourceCalculatorV1/assets/consoles/efg.png.mjs.map +0 -1
- package/lib/components/ResourceCalculatorV1/assets/consoles/ucg-max.png.js.map +0 -1
- package/lib/components/ResourceCalculatorV1/assets/consoles/ucg-max.png.mjs +0 -3
- package/lib/components/ResourceCalculatorV1/assets/consoles/ucg-max.png.mjs.map +0 -1
- package/lib/helpers/product.d.ts +0 -87
- package/lib/helpers/product.js +0 -346
- package/lib/helpers/product.js.map +0 -1
- package/lib/helpers/product.mjs +0 -335
- package/lib/helpers/product.mjs.map +0 -1
- package/lib/types/product.d.ts +0 -87
- package/lib/types/product.js +0 -14
- package/lib/types/product.js.map +0 -1
- package/lib/types/product.mjs +0 -13
- package/lib/types/product.mjs.map +0 -1
- package/lib/utils/money/allocators/fixedAmount.d.ts +0 -26
- package/lib/utils/money/allocators/fixedAmount.js +0 -55
- package/lib/utils/money/allocators/fixedAmount.js.map +0 -1
- package/lib/utils/money/allocators/fixedAmount.mjs +0 -53
- package/lib/utils/money/allocators/fixedAmount.mjs.map +0 -1
- package/lib/utils/money/allocators/index.d.ts +0 -2
- package/lib/utils/money/allocators/index.js +0 -8
- package/lib/utils/money/allocators/index.js.map +0 -1
- package/lib/utils/money/allocators/index.mjs +0 -4
- package/lib/utils/money/allocators/index.mjs.map +0 -1
- package/lib/utils/money/allocators/productAmount.d.ts +0 -13
- package/lib/utils/money/allocators/productAmount.js +0 -110
- package/lib/utils/money/allocators/productAmount.js.map +0 -1
- package/lib/utils/money/allocators/productAmount.mjs +0 -108
- package/lib/utils/money/allocators/productAmount.mjs.map +0 -1
- package/lib/utils/money/exchangeRate.d.ts +0 -31
- package/lib/utils/money/exchangeRate.js +0 -27
- package/lib/utils/money/exchangeRate.js.map +0 -1
- package/lib/utils/money/exchangeRate.mjs +0 -23
- package/lib/utils/money/exchangeRate.mjs.map +0 -1
- package/lib/utils/money/misc.private.d.ts +0 -23
- package/lib/utils/money/misc.private.js +0 -46
- package/lib/utils/money/misc.private.js.map +0 -1
- package/lib/utils/money/misc.private.mjs +0 -21
- package/lib/utils/money/misc.private.mjs.map +0 -1
- package/lib/utils/money/shipping.d.ts +0 -5
- package/lib/utils/money/shipping.js +0 -8
- package/lib/utils/money/shipping.js.map +0 -1
- package/lib/utils/money/shipping.mjs +0 -6
- package/lib/utils/money/shipping.mjs.map +0 -1
- package/lib/utils/money/tax.private.d.ts +0 -17
- package/lib/utils/money/tax.private.js +0 -65
- package/lib/utils/money/tax.private.js.map +0 -1
- package/lib/utils/money/tax.private.mjs +0 -60
- package/lib/utils/money/tax.private.mjs.map +0 -1
- package/lib/utils/productSort.d.ts +0 -41
- package/lib/utils/productSort.js +0 -66
- package/lib/utils/productSort.js.map +0 -1
- package/lib/utils/productSort.mjs +0 -59
- package/lib/utils/productSort.mjs.map +0 -1
- /package/lib/components/{HorizontalOptionSelect → ResourceCalculatorV1/components/HorizontalOptionSelect}/index.d.ts +0 -0
- /package/lib/components/{HorizontalOptionSelect → ResourceCalculatorV1/components/HorizontalOptionSelect}/index.js +0 -0
- /package/lib/components/{HorizontalOptionSelect → ResourceCalculatorV1/components/HorizontalOptionSelect}/index.js.map +0 -0
- /package/lib/components/{HorizontalOptionSelect → ResourceCalculatorV1/components/HorizontalOptionSelect}/index.mjs +0 -0
- /package/lib/components/{HorizontalOptionSelect → ResourceCalculatorV1/components/HorizontalOptionSelect}/index.mjs.map +0 -0
- /package/lib/components/{Header/Navigation/ProMenu → ResourceCalculatorV1/components}/index.mjs.map +0 -0
package/lib/helpers/ux.d.ts
CHANGED
|
@@ -23,16 +23,8 @@ export declare const scrollIntoView: (element: Element | null, duration?: number
|
|
|
23
23
|
* whenValueIsY: css`background: blue;`,
|
|
24
24
|
* })
|
|
25
25
|
*/
|
|
26
|
-
export declare function styledSwitch
|
|
26
|
+
export declare function styledSwitch(value: string, cases: Record<string, FlattenSimpleInterpolation | string>): string | FlattenSimpleInterpolation | undefined;
|
|
27
27
|
/**
|
|
28
28
|
* Get true page offset Y summing own and all parent offsets
|
|
29
29
|
*/
|
|
30
30
|
export declare const getTrueOffsetY: (el: HTMLElement) => number;
|
|
31
|
-
/**
|
|
32
|
-
* Get true element width and height, including all margins and paddings.
|
|
33
|
-
* Uses computed styles, and supports only margins that use px.
|
|
34
|
-
*/
|
|
35
|
-
export declare const getTrueSize: (el: HTMLElement) => {
|
|
36
|
-
width: number;
|
|
37
|
-
height: number;
|
|
38
|
-
};
|
package/lib/helpers/ux.js
CHANGED
|
@@ -44,22 +44,7 @@ const getTrueOffsetY = el => {
|
|
|
44
44
|
}
|
|
45
45
|
return offset;
|
|
46
46
|
};
|
|
47
|
-
const getTrueSize = el => {
|
|
48
|
-
if (typeof window === "undefined") {
|
|
49
|
-
return {
|
|
50
|
-
width: 0,
|
|
51
|
-
height: 0
|
|
52
|
-
};
|
|
53
|
-
}
|
|
54
|
-
const style = window.getComputedStyle(el);
|
|
55
|
-
const px = value => /^[0-9]+px$/.test(value) ? parseFloat(value) : 0;
|
|
56
|
-
return {
|
|
57
|
-
width: el.offsetWidth + px(style.marginLeft) + px(style.marginRight),
|
|
58
|
-
height: el.offsetHeight + px(style.marginTop) + px(style.marginBottom)
|
|
59
|
-
};
|
|
60
|
-
};
|
|
61
47
|
exports.getTrueOffsetY = getTrueOffsetY;
|
|
62
|
-
exports.getTrueSize = getTrueSize;
|
|
63
48
|
exports.scrollIntoView = scrollIntoView;
|
|
64
49
|
exports.scrollToY = scrollToY;
|
|
65
50
|
exports.styledSwitch = styledSwitch;
|
package/lib/helpers/ux.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ux.js","sources":["../../src/helpers/ux.ts"],"sourcesContent":["import type { FlattenSimpleInterpolation } from \"styled-components\";\n\nconst SCROLL_INTO_VIEW_DEFAULT_DURATION = 600;\n\n/**\n * Same as `window.scrollTo` but allows custom duration\n *\n * ! The scroll action won't be replaced if called multiple times\n * ? Instead `useScrollToY` hook will do that if needed\n */\nexport const scrollToY = (targetY: number, duration: number) => {\n let start: number;\n let previousTimeStamp: number;\n const initY = window.scrollY;\n const limit =\n document.documentElement.scrollHeight -\n document.documentElement.clientHeight;\n\n function step(timestamp: number) {\n start === undefined && (start = timestamp);\n const elapsed = timestamp - start;\n const progress = (timestamp - start) / duration;\n\n if (previousTimeStamp !== timestamp) {\n window.scroll({\n top: ((targetY > limit ? limit : targetY) - initY) * progress + initY,\n });\n }\n\n if (elapsed < duration) {\n previousTimeStamp = timestamp;\n window.requestAnimationFrame(step);\n } else {\n window.scroll({\n top: targetY,\n });\n }\n }\n\n window.requestAnimationFrame(step);\n};\n\n/**\n * Scrolls to the element on the page\n *\n * ! This will scroll the entire page, do not use for inline scrolling\n *\n * @todo use Element.scrollIntoView() or Element.scrollIntoViewIfNeeded() when it's fully supported\n */\nexport const scrollIntoView = (\n element: Element | null,\n duration = SCROLL_INTO_VIEW_DEFAULT_DURATION,\n) => {\n if (typeof window === \"undefined\") return;\n if (!element) return;\n\n // Get scroll y target position\n const elementWindowY = element.getBoundingClientRect().top + window.scrollY;\n // Scroll to the element minus one third of the window height (so that it's at an optimal eye level)\n const y = elementWindowY - window.innerHeight * (1 / 3);\n\n // Animate\n scrollToY(y, duration);\n};\n\n/**\n * For use in styled components to reduce switch noise\n *\n * @deprecated Let's replace this with native switches - if ain't broke...\n * @example styledSwitch(variableWithMultipleCases, {\n * whenValueIsX: css`background: red;`,\n * whenValueIsY: css`background: blue;`,\n * })\n */\nexport function styledSwitch
|
|
1
|
+
{"version":3,"file":"ux.js","sources":["../../src/helpers/ux.ts"],"sourcesContent":["import type { FlattenSimpleInterpolation } from \"styled-components\";\n\nconst SCROLL_INTO_VIEW_DEFAULT_DURATION = 600;\n\n/**\n * Same as `window.scrollTo` but allows custom duration\n *\n * ! The scroll action won't be replaced if called multiple times\n * ? Instead `useScrollToY` hook will do that if needed\n */\nexport const scrollToY = (targetY: number, duration: number) => {\n let start: number;\n let previousTimeStamp: number;\n const initY = window.scrollY;\n const limit =\n document.documentElement.scrollHeight -\n document.documentElement.clientHeight;\n\n function step(timestamp: number) {\n start === undefined && (start = timestamp);\n const elapsed = timestamp - start;\n const progress = (timestamp - start) / duration;\n\n if (previousTimeStamp !== timestamp) {\n window.scroll({\n top: ((targetY > limit ? limit : targetY) - initY) * progress + initY,\n });\n }\n\n if (elapsed < duration) {\n previousTimeStamp = timestamp;\n window.requestAnimationFrame(step);\n } else {\n window.scroll({\n top: targetY,\n });\n }\n }\n\n window.requestAnimationFrame(step);\n};\n\n/**\n * Scrolls to the element on the page\n *\n * ! This will scroll the entire page, do not use for inline scrolling\n *\n * @todo use Element.scrollIntoView() or Element.scrollIntoViewIfNeeded() when it's fully supported\n */\nexport const scrollIntoView = (\n element: Element | null,\n duration = SCROLL_INTO_VIEW_DEFAULT_DURATION,\n) => {\n if (typeof window === \"undefined\") return;\n if (!element) return;\n\n // Get scroll y target position\n const elementWindowY = element.getBoundingClientRect().top + window.scrollY;\n // Scroll to the element minus one third of the window height (so that it's at an optimal eye level)\n const y = elementWindowY - window.innerHeight * (1 / 3);\n\n // Animate\n scrollToY(y, duration);\n};\n\n/**\n * For use in styled components to reduce switch noise\n *\n * @deprecated Let's replace this with native switches - if ain't broke...\n * @example styledSwitch(variableWithMultipleCases, {\n * whenValueIsX: css`background: red;`,\n * whenValueIsY: css`background: blue;`,\n * })\n */\nexport function styledSwitch(\n value: string,\n cases: Record<string, FlattenSimpleInterpolation | string>,\n) {\n return cases[value];\n}\n\n/**\n * Get true page offset Y summing own and all parent offsets\n */\nexport const getTrueOffsetY = (el: HTMLElement) => {\n let offset = el.offsetTop;\n\n if (el.parentElement) {\n offset += getTrueOffsetY(el.parentElement);\n }\n\n return offset;\n};\n"],"names":["SCROLL_INTO_VIEW_DEFAULT_DURATION","scrollToY","targetY","duration","start","previousTimeStamp","initY","window","scrollY","limit","document","documentElement","scrollHeight","clientHeight","step","timestamp","elapsed","progress","scroll","top","requestAnimationFrame","scrollIntoView","element","elementWindowY","getBoundingClientRect","y","innerHeight","styledSwitch","value","cases","getTrueOffsetY","el","offset","offsetTop","parentElement"],"mappings":";;;AAEA,MAAMA,iCAAoC,GAAA,GAAA;AAQ7B,MAAAC,SAAA,GAAYA,CAACC,OAAA,EAAiBC,QAAqB,KAAA;EAC1D,IAAAC,KAAA;EACA,IAAAC,iBAAA;EACJ,MAAMC,QAAQC,MAAO,CAAAC,OAAA;EACrB,MAAMC,KACJ,GAAAC,QAAA,CAASC,eAAgB,CAAAC,YAAA,GACzBF,SAASC,eAAgB,CAAAE,YAAA;EAE3B,SAASC,KAAKC,SA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EAC3C;EAEO,OAAAF,MAAA;AACT,CAAA;;;;"}
|
package/lib/helpers/ux.mjs
CHANGED
|
@@ -43,19 +43,5 @@ const getTrueOffsetY = el => {
|
|
|
43
43
|
}
|
|
44
44
|
return offset;
|
|
45
45
|
};
|
|
46
|
-
|
|
47
|
-
if (typeof window === "undefined") {
|
|
48
|
-
return {
|
|
49
|
-
width: 0,
|
|
50
|
-
height: 0
|
|
51
|
-
};
|
|
52
|
-
}
|
|
53
|
-
const style = window.getComputedStyle(el);
|
|
54
|
-
const px = value => /^[0-9]+px$/.test(value) ? parseFloat(value) : 0;
|
|
55
|
-
return {
|
|
56
|
-
width: el.offsetWidth + px(style.marginLeft) + px(style.marginRight),
|
|
57
|
-
height: el.offsetHeight + px(style.marginTop) + px(style.marginBottom)
|
|
58
|
-
};
|
|
59
|
-
};
|
|
60
|
-
export { getTrueOffsetY, getTrueSize, scrollIntoView, scrollToY, styledSwitch };
|
|
46
|
+
export { getTrueOffsetY, scrollIntoView, scrollToY, styledSwitch };
|
|
61
47
|
//# sourceMappingURL=ux.mjs.map
|
package/lib/helpers/ux.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ux.mjs","sources":["../../src/helpers/ux.ts"],"sourcesContent":["import type { FlattenSimpleInterpolation } from \"styled-components\";\n\nconst SCROLL_INTO_VIEW_DEFAULT_DURATION = 600;\n\n/**\n * Same as `window.scrollTo` but allows custom duration\n *\n * ! The scroll action won't be replaced if called multiple times\n * ? Instead `useScrollToY` hook will do that if needed\n */\nexport const scrollToY = (targetY: number, duration: number) => {\n let start: number;\n let previousTimeStamp: number;\n const initY = window.scrollY;\n const limit =\n document.documentElement.scrollHeight -\n document.documentElement.clientHeight;\n\n function step(timestamp: number) {\n start === undefined && (start = timestamp);\n const elapsed = timestamp - start;\n const progress = (timestamp - start) / duration;\n\n if (previousTimeStamp !== timestamp) {\n window.scroll({\n top: ((targetY > limit ? limit : targetY) - initY) * progress + initY,\n });\n }\n\n if (elapsed < duration) {\n previousTimeStamp = timestamp;\n window.requestAnimationFrame(step);\n } else {\n window.scroll({\n top: targetY,\n });\n }\n }\n\n window.requestAnimationFrame(step);\n};\n\n/**\n * Scrolls to the element on the page\n *\n * ! This will scroll the entire page, do not use for inline scrolling\n *\n * @todo use Element.scrollIntoView() or Element.scrollIntoViewIfNeeded() when it's fully supported\n */\nexport const scrollIntoView = (\n element: Element | null,\n duration = SCROLL_INTO_VIEW_DEFAULT_DURATION,\n) => {\n if (typeof window === \"undefined\") return;\n if (!element) return;\n\n // Get scroll y target position\n const elementWindowY = element.getBoundingClientRect().top + window.scrollY;\n // Scroll to the element minus one third of the window height (so that it's at an optimal eye level)\n const y = elementWindowY - window.innerHeight * (1 / 3);\n\n // Animate\n scrollToY(y, duration);\n};\n\n/**\n * For use in styled components to reduce switch noise\n *\n * @deprecated Let's replace this with native switches - if ain't broke...\n * @example styledSwitch(variableWithMultipleCases, {\n * whenValueIsX: css`background: red;`,\n * whenValueIsY: css`background: blue;`,\n * })\n */\nexport function styledSwitch
|
|
1
|
+
{"version":3,"file":"ux.mjs","sources":["../../src/helpers/ux.ts"],"sourcesContent":["import type { FlattenSimpleInterpolation } from \"styled-components\";\n\nconst SCROLL_INTO_VIEW_DEFAULT_DURATION = 600;\n\n/**\n * Same as `window.scrollTo` but allows custom duration\n *\n * ! The scroll action won't be replaced if called multiple times\n * ? Instead `useScrollToY` hook will do that if needed\n */\nexport const scrollToY = (targetY: number, duration: number) => {\n let start: number;\n let previousTimeStamp: number;\n const initY = window.scrollY;\n const limit =\n document.documentElement.scrollHeight -\n document.documentElement.clientHeight;\n\n function step(timestamp: number) {\n start === undefined && (start = timestamp);\n const elapsed = timestamp - start;\n const progress = (timestamp - start) / duration;\n\n if (previousTimeStamp !== timestamp) {\n window.scroll({\n top: ((targetY > limit ? limit : targetY) - initY) * progress + initY,\n });\n }\n\n if (elapsed < duration) {\n previousTimeStamp = timestamp;\n window.requestAnimationFrame(step);\n } else {\n window.scroll({\n top: targetY,\n });\n }\n }\n\n window.requestAnimationFrame(step);\n};\n\n/**\n * Scrolls to the element on the page\n *\n * ! This will scroll the entire page, do not use for inline scrolling\n *\n * @todo use Element.scrollIntoView() or Element.scrollIntoViewIfNeeded() when it's fully supported\n */\nexport const scrollIntoView = (\n element: Element | null,\n duration = SCROLL_INTO_VIEW_DEFAULT_DURATION,\n) => {\n if (typeof window === \"undefined\") return;\n if (!element) return;\n\n // Get scroll y target position\n const elementWindowY = element.getBoundingClientRect().top + window.scrollY;\n // Scroll to the element minus one third of the window height (so that it's at an optimal eye level)\n const y = elementWindowY - window.innerHeight * (1 / 3);\n\n // Animate\n scrollToY(y, duration);\n};\n\n/**\n * For use in styled components to reduce switch noise\n *\n * @deprecated Let's replace this with native switches - if ain't broke...\n * @example styledSwitch(variableWithMultipleCases, {\n * whenValueIsX: css`background: red;`,\n * whenValueIsY: css`background: blue;`,\n * })\n */\nexport function styledSwitch(\n value: string,\n cases: Record<string, FlattenSimpleInterpolation | string>,\n) {\n return cases[value];\n}\n\n/**\n * Get true page offset Y summing own and all parent offsets\n */\nexport const getTrueOffsetY = (el: HTMLElement) => {\n let offset = el.offsetTop;\n\n if (el.parentElement) {\n offset += getTrueOffsetY(el.parentElement);\n }\n\n return offset;\n};\n"],"names":["SCROLL_INTO_VIEW_DEFAULT_DURATION","scrollToY","targetY","duration","start","previousTimeStamp","initY","window","scrollY","limit","document","documentElement","scrollHeight","clientHeight","step","timestamp","elapsed","progress","scroll","top","requestAnimationFrame","scrollIntoView","element","elementWindowY","getBoundingClientRect","y","innerHeight","styledSwitch","value","cases","getTrueOffsetY","el","offset","offsetTop","parentElement"],"mappings":";;AAEA,MAAMA,iCAAoC,GAAA,GAAA;AAQ7B,MAAAC,SAAA,GAAYA,CAACC,OAAA,EAAiBC,QAAqB,KAAA;EAC1D,IAAAC,KAAA;EACA,IAAAC,iBAAA;EACJ,MAAMC,QAAQC,MAAO,CAAAC,OAAA;EACrB,MAAMC,KACJ,GA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E,SAAA;EAEhB,IAAIF,GAAGG,aAAe,EAAA;IACVF,MAAA,IAAAF,cAAA,CAAeC,GAAGG,aAAa,CAAA;EAC3C;EAEO,OAAAF,MAAA;AACT,CAAA;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useHasTouch.js","sources":["../../src/hooks/useHasTouch.tsx"],"sourcesContent":["import { useEffect, useState } from \"react\";\n\ntype UseHasTouch = () => boolean;\n\n/**\n * Utility to detect whether the device has touch based interface\n *\n * @see https://stackoverflow.com/a/30303898\n */\nexport const useHasTouch: UseHasTouch = () => {\n // #############################################################################\n // Touch detection\n // #############################################################################\n const [hasTouch, setHasTouch] = useState(\n (typeof document !== \"undefined\" &&\n \"ontouchstart\" in document.documentElement) ||\n (typeof window !== \"undefined\" && window.navigator.maxTouchPoints > 0),\n );\n\n useEffect(() => {\n // lastTouchTime is used for ignoring emulated mousemove events\n let lastTouchTime = 0;\n\n function disableTouch() {\n if (Date.now() - lastTouchTime < 500) return;\n setHasTouch(false);\n }\n\n function enableTouch() {\n setHasTouch(true);\n }\n\n function updateLastTouchTime() {\n lastTouchTime = Date.now();\n }\n\n document.addEventListener(\"touchstart\", updateLastTouchTime, true);\n document.addEventListener(\"touchstart\", enableTouch, true);\n document.addEventListener(\"mousemove\", disableTouch, true);\n\n return () => {\n document.removeEventListener(\"touchstart\", updateLastTouchTime);\n document.removeEventListener(\"touchstart\", enableTouch);\n document.removeEventListener(\"mousemove\", disableTouch);\n };\n }, []);\n\n // #############################################################################\n // Result\n // #############################################################################\n return hasTouch;\n};\n"],"names":["useHasTouch","hasTouch","setHasTouch","useState","document","documentElement","window","navigator","maxTouchPoints","useEffect","lastTouchTime","disableTouch","Date","now","enableTouch","updateLastTouchTime","addEventListener","removeEventListener"],"mappings":";;;;AASO,MAAMA,cAA2BA,CAAA,KAAM;EAItC,MAAA,CAACC,QAAU,EAAAC,WAAW,CAAI,GAAAC,KAAA,CAAAA,QAAA,CAC7B,OAAOC,QAAa,KAAA,WAAA,IACnB,cAAkB,IAAAA,QAAA,CAASC,eAC1B,IAAA,OAAOC,MAAW,KAAA,WAAA,IAAeA,MAAO,CAAAC,SAAA,CAAUC,cAAiB,GAAA,CAAA,CACxE;EAEAC,KAAAA,CAAAA,SAAA,CAAU,MAAM;IAEd,IAAIC,aAAgB,GAAA,CAAA;IAEpB,SAASC,YAAeA,CAAA,EAAA;
|
|
1
|
+
{"version":3,"file":"useHasTouch.js","sources":["../../src/hooks/useHasTouch.tsx"],"sourcesContent":["import { useEffect, useState } from \"react\";\n\ntype UseHasTouch = () => boolean;\n\n/**\n * Utility to detect whether the device has touch based interface\n *\n * @see https://stackoverflow.com/a/30303898\n */\nexport const useHasTouch: UseHasTouch = () => {\n // #############################################################################\n // Touch detection\n // #############################################################################\n const [hasTouch, setHasTouch] = useState(\n (typeof document !== \"undefined\" &&\n \"ontouchstart\" in document.documentElement) ||\n (typeof window !== \"undefined\" && window.navigator.maxTouchPoints > 0),\n );\n\n useEffect(() => {\n // lastTouchTime is used for ignoring emulated mousemove events\n let lastTouchTime = 0;\n\n function disableTouch() {\n if (Date.now() - lastTouchTime < 500) return;\n setHasTouch(false);\n }\n\n function enableTouch() {\n setHasTouch(true);\n }\n\n function updateLastTouchTime() {\n lastTouchTime = Date.now();\n }\n\n document.addEventListener(\"touchstart\", updateLastTouchTime, true);\n document.addEventListener(\"touchstart\", enableTouch, true);\n document.addEventListener(\"mousemove\", disableTouch, true);\n\n return () => {\n document.removeEventListener(\"touchstart\", updateLastTouchTime);\n document.removeEventListener(\"touchstart\", enableTouch);\n document.removeEventListener(\"mousemove\", disableTouch);\n };\n }, []);\n\n // #############################################################################\n // Result\n // #############################################################################\n return hasTouch;\n};\n"],"names":["useHasTouch","hasTouch","setHasTouch","useState","document","documentElement","window","navigator","maxTouchPoints","useEffect","lastTouchTime","disableTouch","Date","now","enableTouch","updateLastTouchTime","addEventListener","removeEventListener"],"mappings":";;;;AASO,MAAMA,cAA2BA,CAAA,KAAM;EAItC,MAAA,CAACC,QAAU,EAAAC,WAAW,CAAI,GAAAC,KAAA,CAAAA,QAAA,CAC7B,OAAOC,QAAa,KAAA,WAAA,IACnB,cAAkB,IAAAA,QAAA,CAASC,eAC1B,IAAA,OAAOC,MAAW,KAAA,WAAA,IAAeA,MAAO,CAAAC,SAAA,CAAUC,cAAiB,GAAA,CAAA,CACxE;EAEAC,KAAAA,CAAAA,SAAA,CAAU,MAAM;IAEd,IAAIC,aAAgB,GAAA,CAAA;IAEpB,SAASC,YAAeA,CAAA,EAAA;MACtB,IAAIC,IAAK,CAAAC,GAAA,CAAA,CAAQ,GAAAH,aAAA,GAAgB,GAAK,EAAA;MACtCR,WAAA,CAAY,KAAK,CAAA;IACnB;IAEA,SAASY,WAAcA,CAAA,EAAA;MACrBZ,WAAA,CAAY,IAAI,CAAA;IAClB;IAEA,SAASa,mBAAsBA,CAAA,EAAA;MAC7BL,aAAA,GAAgBE,KAAKC,GAAI,EAAA;IAC3B;IAEST,QAAA,CAAAY,gBAAA,CAAiB,YAAc,EAAAD,mBAAA,EAAqB,IAAI,CAAA;IACxDX,QAAA,CAAAY,gBAAA,CAAiB,YAAc,EAAAF,WAAA,EAAa,IAAI,CAAA;IAChDV,QAAA,CAAAY,gBAAA,CAAiB,WAAa,EAAAL,YAAA,EAAc,IAAI,CAAA;IAEzD,OAAO,MAAM;MACFP,QAAA,CAAAa,mBAAA,CAAoB,cAAcF,mBAAmB,CAAA;MACrDX,QAAA,CAAAa,mBAAA,CAAoB,cAAcH,WAAW,CAAA;MAC7CV,QAAA,CAAAa,mBAAA,CAAoB,aAAaN,YAAY,CAAA;IAAA,CACxD;EACF,CAAA,EAAG,EAAE,CAAA;EAKE,OAAAV,QAAA;AACT,CAAA;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useHasTouch.mjs","sources":["../../src/hooks/useHasTouch.tsx"],"sourcesContent":["import { useEffect, useState } from \"react\";\n\ntype UseHasTouch = () => boolean;\n\n/**\n * Utility to detect whether the device has touch based interface\n *\n * @see https://stackoverflow.com/a/30303898\n */\nexport const useHasTouch: UseHasTouch = () => {\n // #############################################################################\n // Touch detection\n // #############################################################################\n const [hasTouch, setHasTouch] = useState(\n (typeof document !== \"undefined\" &&\n \"ontouchstart\" in document.documentElement) ||\n (typeof window !== \"undefined\" && window.navigator.maxTouchPoints > 0),\n );\n\n useEffect(() => {\n // lastTouchTime is used for ignoring emulated mousemove events\n let lastTouchTime = 0;\n\n function disableTouch() {\n if (Date.now() - lastTouchTime < 500) return;\n setHasTouch(false);\n }\n\n function enableTouch() {\n setHasTouch(true);\n }\n\n function updateLastTouchTime() {\n lastTouchTime = Date.now();\n }\n\n document.addEventListener(\"touchstart\", updateLastTouchTime, true);\n document.addEventListener(\"touchstart\", enableTouch, true);\n document.addEventListener(\"mousemove\", disableTouch, true);\n\n return () => {\n document.removeEventListener(\"touchstart\", updateLastTouchTime);\n document.removeEventListener(\"touchstart\", enableTouch);\n document.removeEventListener(\"mousemove\", disableTouch);\n };\n }, []);\n\n // #############################################################################\n // Result\n // #############################################################################\n return hasTouch;\n};\n"],"names":["useHasTouch","hasTouch","setHasTouch","useState","document","documentElement","window","navigator","maxTouchPoints","useEffect","lastTouchTime","disableTouch","Date","now","enableTouch","updateLastTouchTime","addEventListener","removeEventListener"],"mappings":";;AASO,MAAMA,cAA2BA,CAAA,KAAM;EAItC,MAAA,CAACC,QAAU,EAAAC,WAAW,CAAI,GAAAC,QAAA,CAC7B,OAAOC,QAAa,KAAA,WAAA,IACnB,cAAkB,IAAAA,QAAA,CAASC,eAC1B,IAAA,OAAOC,MAAW,KAAA,WAAA,IAAeA,MAAO,CAAAC,SAAA,CAAUC,cAAiB,GAAA,CAAA,CACxE;EAEAC,SAAA,CAAU,MAAM;IAEd,IAAIC,aAAgB,GAAA,CAAA;IAEpB,SAASC,YAAeA,CAAA,EAAA;
|
|
1
|
+
{"version":3,"file":"useHasTouch.mjs","sources":["../../src/hooks/useHasTouch.tsx"],"sourcesContent":["import { useEffect, useState } from \"react\";\n\ntype UseHasTouch = () => boolean;\n\n/**\n * Utility to detect whether the device has touch based interface\n *\n * @see https://stackoverflow.com/a/30303898\n */\nexport const useHasTouch: UseHasTouch = () => {\n // #############################################################################\n // Touch detection\n // #############################################################################\n const [hasTouch, setHasTouch] = useState(\n (typeof document !== \"undefined\" &&\n \"ontouchstart\" in document.documentElement) ||\n (typeof window !== \"undefined\" && window.navigator.maxTouchPoints > 0),\n );\n\n useEffect(() => {\n // lastTouchTime is used for ignoring emulated mousemove events\n let lastTouchTime = 0;\n\n function disableTouch() {\n if (Date.now() - lastTouchTime < 500) return;\n setHasTouch(false);\n }\n\n function enableTouch() {\n setHasTouch(true);\n }\n\n function updateLastTouchTime() {\n lastTouchTime = Date.now();\n }\n\n document.addEventListener(\"touchstart\", updateLastTouchTime, true);\n document.addEventListener(\"touchstart\", enableTouch, true);\n document.addEventListener(\"mousemove\", disableTouch, true);\n\n return () => {\n document.removeEventListener(\"touchstart\", updateLastTouchTime);\n document.removeEventListener(\"touchstart\", enableTouch);\n document.removeEventListener(\"mousemove\", disableTouch);\n };\n }, []);\n\n // #############################################################################\n // Result\n // #############################################################################\n return hasTouch;\n};\n"],"names":["useHasTouch","hasTouch","setHasTouch","useState","document","documentElement","window","navigator","maxTouchPoints","useEffect","lastTouchTime","disableTouch","Date","now","enableTouch","updateLastTouchTime","addEventListener","removeEventListener"],"mappings":";;AASO,MAAMA,cAA2BA,CAAA,KAAM;EAItC,MAAA,CAACC,QAAU,EAAAC,WAAW,CAAI,GAAAC,QAAA,CAC7B,OAAOC,QAAa,KAAA,WAAA,IACnB,cAAkB,IAAAA,QAAA,CAASC,eAC1B,IAAA,OAAOC,MAAW,KAAA,WAAA,IAAeA,MAAO,CAAAC,SAAA,CAAUC,cAAiB,GAAA,CAAA,CACxE;EAEAC,SAAA,CAAU,MAAM;IAEd,IAAIC,aAAgB,GAAA,CAAA;IAEpB,SAASC,YAAeA,CAAA,EAAA;MACtB,IAAIC,IAAK,CAAAC,GAAA,CAAA,CAAQ,GAAAH,aAAA,GAAgB,GAAK,EAAA;MACtCR,WAAA,CAAY,KAAK,CAAA;IACnB;IAEA,SAASY,WAAcA,CAAA,EAAA;MACrBZ,WAAA,CAAY,IAAI,CAAA;IAClB;IAEA,SAASa,mBAAsBA,CAAA,EAAA;MAC7BL,aAAA,GAAgBE,KAAKC,GAAI,EAAA;IAC3B;IAEST,QAAA,CAAAY,gBAAA,CAAiB,YAAc,EAAAD,mBAAA,EAAqB,IAAI,CAAA;IACxDX,QAAA,CAAAY,gBAAA,CAAiB,YAAc,EAAAF,WAAA,EAAa,IAAI,CAAA;IAChDV,QAAA,CAAAY,gBAAA,CAAiB,WAAa,EAAAL,YAAA,EAAc,IAAI,CAAA;IAEzD,OAAO,MAAM;MACFP,QAAA,CAAAa,mBAAA,CAAoB,cAAcF,mBAAmB,CAAA;MACrDX,QAAA,CAAAa,mBAAA,CAAoB,cAAcH,WAAW,CAAA;MAC7CV,QAAA,CAAAa,mBAAA,CAAoB,aAAaN,YAAY,CAAA;IAAA,CACxD;EACF,CAAA,EAAG,EAAE,CAAA;EAKE,OAAAV,QAAA;AACT,CAAA;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useHorizontalScroll.js","sources":["../../src/hooks/useHorizontalScroll.tsx"],"sourcesContent":["import { useEffect } from \"react\";\n\n/**\n * Enables horizontal wheel scroll on a div element\n */\nexport function useHorizontalScroll(\n ref: React.MutableRefObject<HTMLDivElement | null>,\n enabled = true,\n) {\n useEffect(() => {\n if (!enabled) return;\n\n if (!ref?.current) return;\n\n const element = ref.current;\n\n const onWheel = (e: WheelEvent) => {\n if (e.deltaY == 0) return;\n\n if (element.scrollWidth > element.offsetWidth) {\n e.preventDefault();\n element.scrollBy(e.deltaY, 0);\n }\n };\n\n element.addEventListener(\"wheel\", onWheel);\n\n return () => element.removeEventListener(\"wheel\", onWheel);\n }, [enabled, ref]);\n}\n"],"names":["useHorizontalScroll","ref","enabled","useEffect","current","element","onWheel","e","deltaY","scrollWidth","offsetWidth","preventDefault","scrollBy","addEventListener","removeEventListener"],"mappings":";;;;AAKgB,SAAAA,mBAAAA,CACdC,GACA,EAAAC,OAAA,GAAU,IACV,EAAA;EACAC,KAAAA,CAAAA,SAAA,CAAU,MAAM;IACd,IAAI,CAACD,
|
|
1
|
+
{"version":3,"file":"useHorizontalScroll.js","sources":["../../src/hooks/useHorizontalScroll.tsx"],"sourcesContent":["import { useEffect } from \"react\";\n\n/**\n * Enables horizontal wheel scroll on a div element\n */\nexport function useHorizontalScroll(\n ref: React.MutableRefObject<HTMLDivElement | null>,\n enabled = true,\n) {\n useEffect(() => {\n if (!enabled) return;\n\n if (!ref?.current) return;\n\n const element = ref.current;\n\n const onWheel = (e: WheelEvent) => {\n if (e.deltaY == 0) return;\n\n if (element.scrollWidth > element.offsetWidth) {\n e.preventDefault();\n element.scrollBy(e.deltaY, 0);\n }\n };\n\n element.addEventListener(\"wheel\", onWheel);\n\n return () => element.removeEventListener(\"wheel\", onWheel);\n }, [enabled, ref]);\n}\n"],"names":["useHorizontalScroll","ref","enabled","useEffect","current","element","onWheel","e","deltaY","scrollWidth","offsetWidth","preventDefault","scrollBy","addEventListener","removeEventListener"],"mappings":";;;;AAKgB,SAAAA,mBAAAA,CACdC,GACA,EAAAC,OAAA,GAAU,IACV,EAAA;EACAC,KAAAA,CAAAA,SAAA,CAAU,MAAM;IACd,IAAI,CAACD,OAAS,EAAA;IAEV,IAAA,CAACD,KAAKG,OAAS,EAAA;IAEnB,MAAMC,UAAUJ,GAAI,CAAAG,OAAA;IAEd,MAAAE,OAAA,GAAWC,CAAkB,IAAA;MAC7B,IAAAA,CAAA,CAAEC,UAAU,CAAG,EAAA;MAEf,IAAAH,OAAA,CAAQI,WAAc,GAAAJ,OAAA,CAAQK,WAAa,EAAA;QAC7CH,CAAA,CAAEI,cAAe,CAAA,CAAA;QACTN,OAAA,CAAAO,QAAA,CAASL,CAAE,CAAAC,MAAA,EAAQ,CAAC,CAAA;MAC9B;IAAA,CACF;IAEQH,OAAA,CAAAQ,gBAAA,CAAiB,SAASP,OAAO,CAAA;IAEzC,OAAO,MAAMD,OAAA,CAAQS,mBAAoB,CAAA,OAAA,EAASR,OAAO,CAAA;EAAA,CACxD,EAAA,CAACJ,OAAS,EAAAD,GAAG,CAAC,CAAA;AACnB;"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useHorizontalScroll.mjs","sources":["../../src/hooks/useHorizontalScroll.tsx"],"sourcesContent":["import { useEffect } from \"react\";\n\n/**\n * Enables horizontal wheel scroll on a div element\n */\nexport function useHorizontalScroll(\n ref: React.MutableRefObject<HTMLDivElement | null>,\n enabled = true,\n) {\n useEffect(() => {\n if (!enabled) return;\n\n if (!ref?.current) return;\n\n const element = ref.current;\n\n const onWheel = (e: WheelEvent) => {\n if (e.deltaY == 0) return;\n\n if (element.scrollWidth > element.offsetWidth) {\n e.preventDefault();\n element.scrollBy(e.deltaY, 0);\n }\n };\n\n element.addEventListener(\"wheel\", onWheel);\n\n return () => element.removeEventListener(\"wheel\", onWheel);\n }, [enabled, ref]);\n}\n"],"names":["useHorizontalScroll","ref","enabled","useEffect","current","element","onWheel","e","deltaY","scrollWidth","offsetWidth","preventDefault","scrollBy","addEventListener","removeEventListener"],"mappings":";;AAKgB,SAAAA,mBAAAA,CACdC,GACA,EAAAC,OAAA,GAAU,IACV,EAAA;EACAC,SAAA,CAAU,MAAM;IACd,IAAI,CAACD,
|
|
1
|
+
{"version":3,"file":"useHorizontalScroll.mjs","sources":["../../src/hooks/useHorizontalScroll.tsx"],"sourcesContent":["import { useEffect } from \"react\";\n\n/**\n * Enables horizontal wheel scroll on a div element\n */\nexport function useHorizontalScroll(\n ref: React.MutableRefObject<HTMLDivElement | null>,\n enabled = true,\n) {\n useEffect(() => {\n if (!enabled) return;\n\n if (!ref?.current) return;\n\n const element = ref.current;\n\n const onWheel = (e: WheelEvent) => {\n if (e.deltaY == 0) return;\n\n if (element.scrollWidth > element.offsetWidth) {\n e.preventDefault();\n element.scrollBy(e.deltaY, 0);\n }\n };\n\n element.addEventListener(\"wheel\", onWheel);\n\n return () => element.removeEventListener(\"wheel\", onWheel);\n }, [enabled, ref]);\n}\n"],"names":["useHorizontalScroll","ref","enabled","useEffect","current","element","onWheel","e","deltaY","scrollWidth","offsetWidth","preventDefault","scrollBy","addEventListener","removeEventListener"],"mappings":";;AAKgB,SAAAA,mBAAAA,CACdC,GACA,EAAAC,OAAA,GAAU,IACV,EAAA;EACAC,SAAA,CAAU,MAAM;IACd,IAAI,CAACD,OAAS,EAAA;IAEV,IAAA,CAACD,KAAKG,OAAS,EAAA;IAEnB,MAAMC,UAAUJ,GAAI,CAAAG,OAAA;IAEd,MAAAE,OAAA,GAAWC,CAAkB,IAAA;MAC7B,IAAAA,CAAA,CAAEC,UAAU,CAAG,EAAA;MAEf,IAAAH,OAAA,CAAQI,WAAc,GAAAJ,OAAA,CAAQK,WAAa,EAAA;QAC7CH,CAAA,CAAEI,cAAe,CAAA,CAAA;QACTN,OAAA,CAAAO,QAAA,CAASL,CAAE,CAAAC,MAAA,EAAQ,CAAC,CAAA;MAC9B;IAAA,CACF;IAEQH,OAAA,CAAAQ,gBAAA,CAAiB,SAASP,OAAO,CAAA;IAEzC,OAAO,MAAMD,OAAA,CAAQS,mBAAoB,CAAA,OAAA,EAASR,OAAO,CAAA;EAAA,CACxD,EAAA,CAACJ,OAAS,EAAAD,GAAG,CAAC,CAAA;AACnB;"}
|
package/lib/types/index.d.ts
CHANGED
package/lib/types/index.js
CHANGED
|
@@ -5,7 +5,6 @@ var constants = require('./constants.js');
|
|
|
5
5
|
var generated = require('./generated.js');
|
|
6
6
|
require('./object.js');
|
|
7
7
|
require('./utils.js');
|
|
8
|
-
var product = require('./product.js');
|
|
9
8
|
"use strict";
|
|
10
9
|
exports.AddressUsageType = constants.AddressUsageType;
|
|
11
10
|
exports.Language = constants.Language;
|
|
@@ -19,5 +18,4 @@ exports.Unit = generated.Unit;
|
|
|
19
18
|
exports.UnitSystem = generated.UnitSystem;
|
|
20
19
|
exports.UserAssignedCountryCode = generated.UserAssignedCountryCode;
|
|
21
20
|
exports.ValidateTaxStatus = generated.ValidateTaxStatus;
|
|
22
|
-
exports.DisplayProductStatus = product.DisplayProductStatus;
|
|
23
21
|
//# sourceMappingURL=index.js.map
|
package/lib/types/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;"}
|
package/lib/types/index.mjs
CHANGED
|
@@ -3,6 +3,5 @@ export { AddressUsageType, Language } from './constants.mjs';
|
|
|
3
3
|
export { AddressType, CountryCode, Currency, GlobalStoreId, ProductLine, StoreId, Unit, UnitSystem, UserAssignedCountryCode, ValidateTaxStatus } from './generated.mjs';
|
|
4
4
|
import './object.mjs';
|
|
5
5
|
import './utils.mjs';
|
|
6
|
-
export { DisplayProductStatus } from './product.mjs';
|
|
7
6
|
"use strict";
|
|
8
7
|
//# sourceMappingURL=index.mjs.map
|
package/lib/types/index.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.mjs","sources":[],"sourcesContent":[],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.mjs","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;"}
|
package/lib/utils/array.d.ts
CHANGED
|
@@ -28,7 +28,3 @@ export declare const arraySafeIndexFind: <T>(array: T[], index: number) => T | u
|
|
|
28
28
|
* Normalise sort result to be in range of -1 to 1 so that we can easily combine multiple sorts
|
|
29
29
|
*/
|
|
30
30
|
export declare const normalizeSortResult: (sortResult: number) => number;
|
|
31
|
-
/**
|
|
32
|
-
* Combine multiple sort functions into one
|
|
33
|
-
*/
|
|
34
|
-
export declare const combineSorts: <T>(sorts: ((a: T, b: T) => number)[]) => ((a: T, b: T) => number);
|
package/lib/utils/array.js
CHANGED
|
@@ -24,19 +24,9 @@ const arraySafeIndexFind = (array, index) => {
|
|
|
24
24
|
return array[safeIndex];
|
|
25
25
|
};
|
|
26
26
|
const normalizeSortResult = sortResult => number.clamp(sortResult, -1, 1);
|
|
27
|
-
const combineSorts = sorts => (a, b) => {
|
|
28
|
-
for (const sort of sorts) {
|
|
29
|
-
const result = sort(a, b);
|
|
30
|
-
if (result !== 0) {
|
|
31
|
-
return result;
|
|
32
|
-
}
|
|
33
|
-
}
|
|
34
|
-
return 0;
|
|
35
|
-
};
|
|
36
27
|
exports.areEqualArrays = areEqualArrays;
|
|
37
28
|
exports.arraySafeIndex = arraySafeIndex;
|
|
38
29
|
exports.arraySafeIndexFind = arraySafeIndexFind;
|
|
39
|
-
exports.combineSorts = combineSorts;
|
|
40
30
|
exports.dedupe = dedupe;
|
|
41
31
|
exports.ensureArray = ensureArray;
|
|
42
32
|
exports.normalizeSortResult = normalizeSortResult;
|
package/lib/utils/array.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"array.js","sources":["../../src/utils/array.ts"],"sourcesContent":["import { clamp } from \"./number\";\n\n/**\n * Make sure the element is an array\n * If it's not, make it an array of one element\n */\nexport function ensureArray<T>(value: T | T[]): T[] {\n return Array.isArray(value) ? value : [value];\n}\n\n/**\n * Utility to quickly remove duplicates from an array.\n *\n * Similar to lodash's `uniq`, but doesn't require lodash as dependency.\n */\nexport const dedupe = <T>(arr: T[]) => [...new Set(arr)];\n\n/**\n * Utility function check if given arrays contain same elements (regardless the order)\n *\n * @example\n * areArraysEqual([1, 2, 3], [3, 2, 1]) // true\n * areArraysEqual([1, 2, 3], [3, 2, 1, 4]) // false\n */\nexport const areEqualArrays = (a: string[], b: string[]): boolean => {\n if (a.length !== b.length) {\n return false;\n }\n if (!a.every((el) => b.includes(el))) {\n return false;\n }\n return !b.every((el) => a.includes(el)) ? false : true;\n};\n\n/**\n * Function to get array index by positive and negative wrap-around offsets\n *\n * @see https://dirask.com/posts/JavaScript-positive-and-negative-around-index-wrapping-overlapping-to-address-items-in-array-pVyrnD\n */\nexport const arraySafeIndex = <T>(array: T[], index: number): number => {\n const indexSize = array.length;\n\n return ((index % indexSize) + indexSize) % indexSize;\n};\n\nexport const arraySafeIndexFind = <T>(\n array: T[],\n index: number,\n): T | undefined => {\n const safeIndex = arraySafeIndex(array, index);\n\n return array[safeIndex];\n};\n\n/**\n * Normalise sort result to be in range of -1 to 1 so that we can easily combine multiple sorts\n */\nexport const normalizeSortResult = (sortResult: number): number =>\n clamp(sortResult, -1, 1);\n
|
|
1
|
+
{"version":3,"file":"array.js","sources":["../../src/utils/array.ts"],"sourcesContent":["import { clamp } from \"./number\";\n\n/**\n * Make sure the element is an array\n * If it's not, make it an array of one element\n */\nexport function ensureArray<T>(value: T | T[]): T[] {\n return Array.isArray(value) ? value : [value];\n}\n\n/**\n * Utility to quickly remove duplicates from an array.\n *\n * Similar to lodash's `uniq`, but doesn't require lodash as dependency.\n */\nexport const dedupe = <T>(arr: T[]) => [...new Set(arr)];\n\n/**\n * Utility function check if given arrays contain same elements (regardless the order)\n *\n * @example\n * areArraysEqual([1, 2, 3], [3, 2, 1]) // true\n * areArraysEqual([1, 2, 3], [3, 2, 1, 4]) // false\n */\nexport const areEqualArrays = (a: string[], b: string[]): boolean => {\n if (a.length !== b.length) {\n return false;\n }\n if (!a.every((el) => b.includes(el))) {\n return false;\n }\n return !b.every((el) => a.includes(el)) ? false : true;\n};\n\n/**\n * Function to get array index by positive and negative wrap-around offsets\n *\n * @see https://dirask.com/posts/JavaScript-positive-and-negative-around-index-wrapping-overlapping-to-address-items-in-array-pVyrnD\n */\nexport const arraySafeIndex = <T>(array: T[], index: number): number => {\n const indexSize = array.length;\n\n return ((index % indexSize) + indexSize) % indexSize;\n};\n\nexport const arraySafeIndexFind = <T>(\n array: T[],\n index: number,\n): T | undefined => {\n const safeIndex = arraySafeIndex(array, index);\n\n return array[safeIndex];\n};\n\n/**\n * Normalise sort result to be in range of -1 to 1 so that we can easily combine multiple sorts\n */\nexport const normalizeSortResult = (sortResult: number): number =>\n clamp(sortResult, -1, 1);\n"],"names":["ensureArray","value","Array","isArray","dedupe","arr","Set","areEqualArrays","a","b","length","every","el","includes","arraySafeIndex","array","index","indexSize","arraySafeIndexFind","safeIndex","normalizeSortResult","sortResult","clamp"],"mappings":";;;;AAMO,SAASA,YAAeC,KAAqB,EAAA;EAClD,OAAOC,MAAMC,OAAQ,CAAAF,KAAK,CAAI,GAAAA,KAAA,GAAQ,CAACA,KAAK,CAAA;AAC9C;AAOa,MAAAG,MAAA,GAAaC,GAAa,IAAA,CAAC,GAAG,IAAIC,GAAA,CAAID,GAAG,CAAC,CAAA;AAS1C,MAAAE,cAAA,GAAiBA,CAACC,CAAA,EAAaC,CAAyB,KAAA;EAC/D,IAAAD,CAAA,CAAEE,MAAW,KAAAD,CAAA,CAAEC,MAAQ,EAAA;IAClB,OAAA,KAAA;EACT;EACI,IAAA,CAACF,EAAEG,KAAM,CAACC,MAAOH,CAAE,CAAAI,QAAA,CAASD,EAAE,CAAC,CAAG,EAAA;IAC7B,OAAA,KAAA;EACT;EACO,OAAA,CAACH,CAAE,CAAAE,KAAA,CAAOC,EAAA,IAAOJ,EAAEK,QAAS,CAAAD,EAAE,CAAC,CAAA,GAAI,KAAQ,GAAA,IAAA;AACpD,CAAA;AAOa,MAAAE,cAAA,GAAiBA,CAAIC,KAAA,EAAYC,KAA0B,KAAA;EACtE,MAAMC,YAAYF,KAAM,CAAAL,MAAA;EAEf,OAAA,CAAAM,KAAA,GAAQC,YAAaA,SAAa,IAAAA,SAAA;AAC7C,CAAA;AAEa,MAAAC,kBAAA,GAAqBA,CAChCH,KAAA,EACAC,KACkB,KAAA;EACZ,MAAAG,SAAA,GAAYL,cAAe,CAAAC,KAAA,EAAOC,KAAK,CAAA;EAE7C,OAAOD,MAAMI,SAAS,CAAA;AACxB,CAAA;AAKO,MAAMC,sBAAuBC,UAAA,IAClCC,MAAAA,CAAAA,KAAM,CAAAD,UAAA,EAAY,IAAI,CAAC,CAAA;;;;;;"}
|
package/lib/utils/array.mjs
CHANGED
|
@@ -22,14 +22,5 @@ const arraySafeIndexFind = (array, index) => {
|
|
|
22
22
|
return array[safeIndex];
|
|
23
23
|
};
|
|
24
24
|
const normalizeSortResult = sortResult => clamp(sortResult, -1, 1);
|
|
25
|
-
|
|
26
|
-
for (const sort of sorts) {
|
|
27
|
-
const result = sort(a, b);
|
|
28
|
-
if (result !== 0) {
|
|
29
|
-
return result;
|
|
30
|
-
}
|
|
31
|
-
}
|
|
32
|
-
return 0;
|
|
33
|
-
};
|
|
34
|
-
export { areEqualArrays, arraySafeIndex, arraySafeIndexFind, combineSorts, dedupe, ensureArray, normalizeSortResult };
|
|
25
|
+
export { areEqualArrays, arraySafeIndex, arraySafeIndexFind, dedupe, ensureArray, normalizeSortResult };
|
|
35
26
|
//# sourceMappingURL=array.mjs.map
|
package/lib/utils/array.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"array.mjs","sources":["../../src/utils/array.ts"],"sourcesContent":["import { clamp } from \"./number\";\n\n/**\n * Make sure the element is an array\n * If it's not, make it an array of one element\n */\nexport function ensureArray<T>(value: T | T[]): T[] {\n return Array.isArray(value) ? value : [value];\n}\n\n/**\n * Utility to quickly remove duplicates from an array.\n *\n * Similar to lodash's `uniq`, but doesn't require lodash as dependency.\n */\nexport const dedupe = <T>(arr: T[]) => [...new Set(arr)];\n\n/**\n * Utility function check if given arrays contain same elements (regardless the order)\n *\n * @example\n * areArraysEqual([1, 2, 3], [3, 2, 1]) // true\n * areArraysEqual([1, 2, 3], [3, 2, 1, 4]) // false\n */\nexport const areEqualArrays = (a: string[], b: string[]): boolean => {\n if (a.length !== b.length) {\n return false;\n }\n if (!a.every((el) => b.includes(el))) {\n return false;\n }\n return !b.every((el) => a.includes(el)) ? false : true;\n};\n\n/**\n * Function to get array index by positive and negative wrap-around offsets\n *\n * @see https://dirask.com/posts/JavaScript-positive-and-negative-around-index-wrapping-overlapping-to-address-items-in-array-pVyrnD\n */\nexport const arraySafeIndex = <T>(array: T[], index: number): number => {\n const indexSize = array.length;\n\n return ((index % indexSize) + indexSize) % indexSize;\n};\n\nexport const arraySafeIndexFind = <T>(\n array: T[],\n index: number,\n): T | undefined => {\n const safeIndex = arraySafeIndex(array, index);\n\n return array[safeIndex];\n};\n\n/**\n * Normalise sort result to be in range of -1 to 1 so that we can easily combine multiple sorts\n */\nexport const normalizeSortResult = (sortResult: number): number =>\n clamp(sortResult, -1, 1);\n
|
|
1
|
+
{"version":3,"file":"array.mjs","sources":["../../src/utils/array.ts"],"sourcesContent":["import { clamp } from \"./number\";\n\n/**\n * Make sure the element is an array\n * If it's not, make it an array of one element\n */\nexport function ensureArray<T>(value: T | T[]): T[] {\n return Array.isArray(value) ? value : [value];\n}\n\n/**\n * Utility to quickly remove duplicates from an array.\n *\n * Similar to lodash's `uniq`, but doesn't require lodash as dependency.\n */\nexport const dedupe = <T>(arr: T[]) => [...new Set(arr)];\n\n/**\n * Utility function check if given arrays contain same elements (regardless the order)\n *\n * @example\n * areArraysEqual([1, 2, 3], [3, 2, 1]) // true\n * areArraysEqual([1, 2, 3], [3, 2, 1, 4]) // false\n */\nexport const areEqualArrays = (a: string[], b: string[]): boolean => {\n if (a.length !== b.length) {\n return false;\n }\n if (!a.every((el) => b.includes(el))) {\n return false;\n }\n return !b.every((el) => a.includes(el)) ? false : true;\n};\n\n/**\n * Function to get array index by positive and negative wrap-around offsets\n *\n * @see https://dirask.com/posts/JavaScript-positive-and-negative-around-index-wrapping-overlapping-to-address-items-in-array-pVyrnD\n */\nexport const arraySafeIndex = <T>(array: T[], index: number): number => {\n const indexSize = array.length;\n\n return ((index % indexSize) + indexSize) % indexSize;\n};\n\nexport const arraySafeIndexFind = <T>(\n array: T[],\n index: number,\n): T | undefined => {\n const safeIndex = arraySafeIndex(array, index);\n\n return array[safeIndex];\n};\n\n/**\n * Normalise sort result to be in range of -1 to 1 so that we can easily combine multiple sorts\n */\nexport const normalizeSortResult = (sortResult: number): number =>\n clamp(sortResult, -1, 1);\n"],"names":["ensureArray","value","Array","isArray","dedupe","arr","Set","areEqualArrays","a","b","length","every","el","includes","arraySafeIndex","array","index","indexSize","arraySafeIndexFind","safeIndex","normalizeSortResult","sortResult","clamp"],"mappings":";;AAMO,SAASA,YAAeC,KAAqB,EAAA;EAClD,OAAOC,MAAMC,OAAQ,CAAAF,KAAK,CAAI,GAAAA,KAAA,GAAQ,CAACA,KAAK,CAAA;AAC9C;AAOa,MAAAG,MAAA,GAAaC,GAAa,IAAA,CAAC,GAAG,IAAIC,GAAA,CAAID,GAAG,CAAC,CAAA;AAS1C,MAAAE,cAAA,GAAiBA,CAACC,CAAA,EAAaC,CAAyB,KAAA;EAC/D,IAAAD,CAAA,CAAEE,MAAW,KAAAD,CAAA,CAAEC,MAAQ,EAAA;IAClB,OAAA,KAAA;EACT;EACI,IAAA,CAACF,EAAEG,KAAM,CAACC,MAAOH,CAAE,CAAAI,QAAA,CAASD,EAAE,CAAC,CAAG,EAAA;IAC7B,OAAA,KAAA;EACT;EACO,OAAA,CAACH,CAAE,CAAAE,KAAA,CAAOC,EAAA,IAAOJ,EAAEK,QAAS,CAAAD,EAAE,CAAC,CAAA,GAAI,KAAQ,GAAA,IAAA;AACpD,CAAA;AAOa,MAAAE,cAAA,GAAiBA,CAAIC,KAAA,EAAYC,KAA0B,KAAA;EACtE,MAAMC,YAAYF,KAAM,CAAAL,MAAA;EAEf,OAAA,CAAAM,KAAA,GAAQC,YAAaA,SAAa,IAAAA,SAAA;AAC7C,CAAA;AAEa,MAAAC,kBAAA,GAAqBA,CAChCH,KAAA,EACAC,KACkB,KAAA;EACZ,MAAAG,SAAA,GAAYL,cAAe,CAAAC,KAAA,EAAOC,KAAK,CAAA;EAE7C,OAAOD,MAAMI,SAAS,CAAA;AACxB,CAAA;AAKO,MAAMC,sBAAuBC,UAAA,IAClCC,KAAM,CAAAD,UAAA,EAAY,IAAI,CAAC,CAAA;"}
|
|
@@ -1,68 +1,37 @@
|
|
|
1
|
-
import { Currency
|
|
2
|
-
import type {
|
|
3
|
-
export declare const Round: {
|
|
4
|
-
/**
|
|
5
|
-
* ⚠️ Instead of using Math.round, we HAVE to use this method to round the financial numbers everywhere where we CAN'T
|
|
6
|
-
* deal with dinero.js (Dinero.js should be the priority). But often for converting from API requests we have to
|
|
7
|
-
* normalise the values so we use this method.
|
|
8
|
-
*
|
|
9
|
-
* It just a re-export of the dinero.js halfEven (a.k.a bankers rounding) method which is the default rounding method.
|
|
10
|
-
* @see https://github.com/dinerojs/dinero.js/blob/main/packages/core/src/round/halfEven.ts
|
|
11
|
-
* @see
|
|
12
|
-
*
|
|
13
|
-
* Compared to Math.round (arithmetic rounding) it differentiates that it changes the `.5` round up or down behaviour based on if the rounded
|
|
14
|
-
* number would be an even number. So 1.5 would round to 2 while 2.5 would round to 2.
|
|
15
|
-
* See the youtube link below for a brief exclamation on why it's important to use this method over regular rounding (half-up):
|
|
16
|
-
* https://youtu.be/yuRdYlZvs1E
|
|
17
|
-
*
|
|
18
|
-
* If you really want to get knee-deep in the rounding subject, you can read the following:
|
|
19
|
-
* https://en.wikipedia.org/wiki/Rounding#Round_half_toward_zero
|
|
20
|
-
*/
|
|
21
|
-
Financial: import("@dinero.js/core").RoundingMode;
|
|
22
|
-
Shipping: import("@dinero.js/core").RoundingMode;
|
|
23
|
-
Prettify: import("@dinero.js/core").RoundingMode;
|
|
24
|
-
Subunit: import("@dinero.js/core").RoundingMode;
|
|
25
|
-
};
|
|
1
|
+
import { Currency } from "../../types";
|
|
2
|
+
import type { CurrencyObj } from "./types";
|
|
26
3
|
/**
|
|
27
4
|
* Mapping of how prices should be rounded down to "whole numbers" after certain threshold
|
|
28
5
|
*/
|
|
29
6
|
export declare const prettifyPriceLookup: Map<string, number>;
|
|
30
7
|
/**
|
|
31
|
-
* Map of
|
|
8
|
+
* Map of currencycode to subunit digit count.
|
|
32
9
|
*/
|
|
33
|
-
export declare const smallestSubunitLookup: Map<string, [number,
|
|
10
|
+
export declare const smallestSubunitLookup: Map<string, [number, (value: number) => number]>;
|
|
34
11
|
/**
|
|
35
|
-
*
|
|
12
|
+
* Mapping of maximum price filter
|
|
13
|
+
* TODO: Add all possible currencies
|
|
36
14
|
*/
|
|
37
|
-
export declare const
|
|
15
|
+
export declare const maximumPriceFilterLookup: Map<string, number>;
|
|
38
16
|
/**
|
|
39
|
-
*
|
|
40
|
-
*
|
|
17
|
+
* ⚠️ Instead of using Math.round, we HAVE to use this method to round the financial numbers everywhere where we CAN'T
|
|
18
|
+
* deal with dinero.js (Dinero.js should be the priority). But often for converting from API requests we have to
|
|
19
|
+
* normalise the values so we use this method.
|
|
20
|
+
*
|
|
21
|
+
* It just a re-export of the dinero.js halfEven (a.k.a bankers rounding) method which is the default rounding method.
|
|
22
|
+
* @see https://github.com/dinerojs/dinero.js/blob/main/packages/core/src/round/halfEven.ts
|
|
23
|
+
* @see
|
|
24
|
+
*
|
|
25
|
+
* Compared to Math.round (arithmetic rounding) it differentiates that it changes the `.5` round up or down behaviour based on if the rounded
|
|
26
|
+
* number would be an even number. So 1.5 would round to 2 while 2.5 would round to 2.
|
|
27
|
+
* See the youtube link below for a brief exclamation on why it's important to use this method over regular rounding (half-up):
|
|
28
|
+
* https://youtu.be/yuRdYlZvs1E
|
|
29
|
+
*
|
|
30
|
+
* If you really want to get knee-deep in the rounding subject, you can read the following:
|
|
31
|
+
* https://en.wikipedia.org/wiki/Rounding#Round_half_toward_zero
|
|
41
32
|
*/
|
|
42
|
-
export declare const
|
|
33
|
+
export declare const financialRound: import("@dinero.js/core").RoundingMode;
|
|
43
34
|
/**
|
|
44
|
-
*
|
|
35
|
+
* Precompiled list for faster currency and locale lookups
|
|
45
36
|
*/
|
|
46
|
-
export declare const
|
|
47
|
-
base: number;
|
|
48
|
-
/**
|
|
49
|
-
* We expect the tax rate to be in the range of 0..1
|
|
50
|
-
* 0 --> 0%
|
|
51
|
-
* 1 --> 100%
|
|
52
|
-
* 0.21 --> 21%
|
|
53
|
-
* 0.2169 --> 21.69%
|
|
54
|
-
* 0.12345678 --> 12.345678%
|
|
55
|
-
* !!! Don't change as this value is tied to store.backend DB schema !!!
|
|
56
|
-
*/
|
|
57
|
-
exponent: number;
|
|
58
|
-
code: string;
|
|
59
|
-
};
|
|
60
|
-
export declare const EXCHANGE_RATE_DINERO_CURRENCY: {
|
|
61
|
-
base: number;
|
|
62
|
-
/**
|
|
63
|
-
* We support having certain decimal places for exchange rates
|
|
64
|
-
* !!! Don't change as this value is tied to store.backend DB schema !!!
|
|
65
|
-
*/
|
|
66
|
-
exponent: number;
|
|
67
|
-
code: string;
|
|
68
|
-
};
|
|
37
|
+
export declare const currencyObjLookup: Map<Currency, CurrencyObj>;
|
|
@@ -5,33 +5,6 @@ var dinero_js = require('dinero.js');
|
|
|
5
5
|
require('../../types/index.js');
|
|
6
6
|
var generated = require('../../types/generated.js');
|
|
7
7
|
"use strict";
|
|
8
|
-
const Round = {
|
|
9
|
-
/**
|
|
10
|
-
* ⚠️ Instead of using Math.round, we HAVE to use this method to round the financial numbers everywhere where we CAN'T
|
|
11
|
-
* deal with dinero.js (Dinero.js should be the priority). But often for converting from API requests we have to
|
|
12
|
-
* normalise the values so we use this method.
|
|
13
|
-
*
|
|
14
|
-
* It just a re-export of the dinero.js halfEven (a.k.a bankers rounding) method which is the default rounding method.
|
|
15
|
-
* @see https://github.com/dinerojs/dinero.js/blob/main/packages/core/src/round/halfEven.ts
|
|
16
|
-
* @see
|
|
17
|
-
*
|
|
18
|
-
* Compared to Math.round (arithmetic rounding) it differentiates that it changes the `.5` round up or down behaviour based on if the rounded
|
|
19
|
-
* number would be an even number. So 1.5 would round to 2 while 2.5 would round to 2.
|
|
20
|
-
* See the youtube link below for a brief exclamation on why it's important to use this method over regular rounding (half-up):
|
|
21
|
-
* https://youtu.be/yuRdYlZvs1E
|
|
22
|
-
*
|
|
23
|
-
* If you really want to get knee-deep in the rounding subject, you can read the following:
|
|
24
|
-
* https://en.wikipedia.org/wiki/Rounding#Round_half_toward_zero
|
|
25
|
-
*/
|
|
26
|
-
Financial: dinero_js.halfEven,
|
|
27
|
-
// TODO: maybe we should have separate rounding functions depending on the input value?
|
|
28
|
-
// Reading from wiki "Round half toward zero" is better if the value is already "normalized to cents"
|
|
29
|
-
// But the "Round half to even" seems better for when working with float like values
|
|
30
|
-
// financialRound = Math.round;
|
|
31
|
-
Shipping: dinero_js.down,
|
|
32
|
-
Prettify: dinero_js.down,
|
|
33
|
-
Subunit: dinero_js.halfUp
|
|
34
|
-
};
|
|
35
8
|
const prettifyPriceLookup = /* @__PURE__ */new Map([[currencies.USD.code, 20], [currencies.CAD.code, 20], [currencies.EUR.code, 20], [currencies.GBP.code, 20], [currencies.AED.code, 50],
|
|
36
9
|
// Approximately every price above ~1.1 usd will be rounded in ZAR
|
|
37
10
|
[currencies.ZAR.code, 20]]);
|
|
@@ -39,8 +12,10 @@ const smallestSubunitLookup = /* @__PURE__ */new Map([
|
|
|
39
12
|
/**
|
|
40
13
|
* TWD does not use subunits at all in day to day transactions.
|
|
41
14
|
*/
|
|
42
|
-
[currencies.TWD.code, [0,
|
|
43
|
-
const
|
|
15
|
+
[currencies.TWD.code, [0, dinero_js.halfUp]]]);
|
|
16
|
+
const maximumPriceFilterLookup = /* @__PURE__ */new Map([[currencies.CAD.code, 7e4], [currencies.EUR.code, 7e4], [currencies.AED.code, 7e4]]);
|
|
17
|
+
const financialRound = dinero_js.halfEven;
|
|
18
|
+
const currencyObjLookup = /* @__PURE__ */new Map([[generated.Currency.Aed, {
|
|
44
19
|
currency: currencies.AED,
|
|
45
20
|
locale: "ar-AE"
|
|
46
21
|
}], [generated.Currency.Bgn, {
|
|
@@ -111,49 +86,9 @@ const localizedCurrencyLookup = /* @__PURE__ */new Map([[generated.Currency.Aed,
|
|
|
111
86
|
currency: currencies.MXN,
|
|
112
87
|
locale: "es-MX"
|
|
113
88
|
}]]);
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
// #############################################################################
|
|
118
|
-
generated.StoreId.Br, generated.StoreId.Tw
|
|
119
|
-
// #############################################################################
|
|
120
|
-
// Stores with Avalara, but will have custom company codes to treat
|
|
121
|
-
// FIXME: as PR is rushed we where able to test stores avalara custom codes that enable logic that calculates tax
|
|
122
|
-
// "per quantity", so for now disabling this logic and only applying to store with custom tax rates
|
|
123
|
-
// #############################################################################
|
|
124
|
-
// StoreId.Jp,
|
|
125
|
-
// StoreId.Sg,
|
|
126
|
-
]);
|
|
127
|
-
const TAX_RATE_DINERO_CURRENCY = {
|
|
128
|
-
base: 10,
|
|
129
|
-
/**
|
|
130
|
-
* We expect the tax rate to be in the range of 0..1
|
|
131
|
-
* 0 --> 0%
|
|
132
|
-
* 1 --> 100%
|
|
133
|
-
* 0.21 --> 21%
|
|
134
|
-
* 0.2169 --> 21.69%
|
|
135
|
-
* 0.12345678 --> 12.345678%
|
|
136
|
-
* !!! Don't change as this value is tied to store.backend DB schema !!!
|
|
137
|
-
*/
|
|
138
|
-
exponent: 8,
|
|
139
|
-
code: ""
|
|
140
|
-
// Not important
|
|
141
|
-
};
|
|
142
|
-
const EXCHANGE_RATE_DINERO_CURRENCY = {
|
|
143
|
-
base: 10,
|
|
144
|
-
/**
|
|
145
|
-
* We support having certain decimal places for exchange rates
|
|
146
|
-
* !!! Don't change as this value is tied to store.backend DB schema !!!
|
|
147
|
-
*/
|
|
148
|
-
exponent: 6,
|
|
149
|
-
code: ""
|
|
150
|
-
// Not important
|
|
151
|
-
};
|
|
152
|
-
exports.EXCHANGE_RATE_DINERO_CURRENCY = EXCHANGE_RATE_DINERO_CURRENCY;
|
|
153
|
-
exports.Round = Round;
|
|
154
|
-
exports.TAX_RATE_DINERO_CURRENCY = TAX_RATE_DINERO_CURRENCY;
|
|
155
|
-
exports.localizedCurrencyLookup = localizedCurrencyLookup;
|
|
89
|
+
exports.currencyObjLookup = currencyObjLookup;
|
|
90
|
+
exports.financialRound = financialRound;
|
|
91
|
+
exports.maximumPriceFilterLookup = maximumPriceFilterLookup;
|
|
156
92
|
exports.prettifyPriceLookup = prettifyPriceLookup;
|
|
157
93
|
exports.smallestSubunitLookup = smallestSubunitLookup;
|
|
158
|
-
exports.storesWithPerItemTaxRate = storesWithPerItemTaxRate;
|
|
159
94
|
//# sourceMappingURL=constants.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"constants.js","sources":["../../../src/utils/money/constants.ts"],"sourcesContent":["import {\n AED,\n BGN,\n BRL,\n CAD,\n CHF,\n CZK,\n DKK,\n EUR,\n GBP,\n HRK,\n HUF,\n INR,\n JPY,\n MXN,\n NOK,\n PLN,\n RON,\n SEK,\n SGD,\n TWD,\n USD,\n ZAR,\n} from \"@dinero.js/currencies\";\nimport { down, halfEven, halfUp } from \"dinero.js\";\n\nimport { Currency, StoreId } from \"../../types\";\nimport type {\n Cents,\n DinoCurrency,\n LocalizedCurrency,\n RoundingFn,\n} from \"./types\";\n\n// #############################################################################\n// Constants\n// #############################################################################\n\nexport const Round = {\n /**\n * ⚠️ Instead of using Math.round, we HAVE to use this method to round the financial numbers everywhere where we CAN'T\n * deal with dinero.js (Dinero.js should be the priority). But often for converting from API requests we have to\n * normalise the values so we use this method.\n *\n * It just a re-export of the dinero.js halfEven (a.k.a bankers rounding) method which is the default rounding method.\n * @see https://github.com/dinerojs/dinero.js/blob/main/packages/core/src/round/halfEven.ts\n * @see\n *\n * Compared to Math.round (arithmetic rounding) it differentiates that it changes the `.5` round up or down behaviour based on if the rounded\n * number would be an even number. So 1.5 would round to 2 while 2.5 would round to 2.\n * See the youtube link below for a brief exclamation on why it's important to use this method over regular rounding (half-up):\n * https://youtu.be/yuRdYlZvs1E\n *\n * If you really want to get knee-deep in the rounding subject, you can read the following:\n * https://en.wikipedia.org/wiki/Rounding#Round_half_toward_zero\n */\n Financial: halfEven,\n // TODO: maybe we should have separate rounding functions depending on the input value?\n // Reading from wiki \"Round half toward zero\" is better if the value is already \"normalized to cents\"\n // But the \"Round half to even\" seems better for when working with float like values\n // financialRound = Math.round;\n Shipping: down,\n Prettify: down,\n Subunit: halfUp,\n} satisfies Record<string, RoundingFn>;\n\n/**\n * Mapping of how prices should be rounded down to \"whole numbers\" after certain threshold\n */\nexport const prettifyPriceLookup = new Map([\n [USD.code, 20],\n [CAD.code, 20],\n [EUR.code, 20],\n [GBP.code, 20],\n [AED.code, 50],\n // Approximately every price above ~1.1 usd will be rounded in ZAR\n [ZAR.code, 20],\n]);\n\n/**\n * Map of dinero code to subunit digit count.\n */\nexport const smallestSubunitLookup = new Map<string, [Cents, RoundingFn]>([\n /**\n * TWD does not use subunits at all in day to day transactions.\n */\n [TWD.code, [0, Round.Subunit]],\n]);\n\n/**\n * Precompiled list for faster currency and locale lookups\n */\nexport const localizedCurrencyLookup = new Map<Currency, LocalizedCurrency>([\n [Currency.Aed, { currency: AED, locale: \"ar-AE\" }],\n [Currency.Bgn, { currency: BGN, locale: \"bg-BG\" }],\n [Currency.Cad, { currency: CAD, locale: \"en-CA\" }],\n [Currency.Chf, { currency: CHF, locale: \"it-CH\" }],\n [Currency.Czk, { currency: CZK, locale: \"cs-CZ\" }],\n [Currency.Dkk, { currency: DKK, locale: \"da-DK\" }],\n [Currency.Eur, { currency: EUR, locale: \"de-DE\" }],\n [Currency.Gbp, { currency: GBP, locale: \"en-GB\" }],\n [Currency.Hrk, { currency: HRK, locale: \"hr-HR\" }],\n [Currency.Huf, { currency: HUF, locale: \"hu-HU\" }],\n [Currency.Nok, { currency: NOK, locale: \"no-NO\" }],\n [Currency.Pln, { currency: PLN, locale: \"pl-PL\" }],\n [Currency.Ron, { currency: RON, locale: \"ro-RO\" }],\n [Currency.Sek, { currency: SEK, locale: \"sv-SE\" }],\n [Currency.Usd, { currency: USD, locale: \"en-US\" }],\n [Currency.Zar, { currency: ZAR, locale: \"en-ZA\" }],\n [Currency.Inr, { currency: INR, locale: \"en-IN\" }],\n [Currency.Sgd, { currency: SGD, locale: \"en-SG\" }],\n [Currency.Brl, { currency: BRL, locale: \"pt-BR\" }],\n // NOTE: en-JP Doesn't exist\n [Currency.Jpy, { currency: JPY, locale: \"en-JP\" }],\n // NOTE: en-TW Doesn't exist\n [Currency.Twd, { currency: TWD, locale: \"en-TW\" }],\n [Currency.Mxn, { currency: MXN, locale: \"es-MX\" }],\n]);\n\n// #############################################################################\n// Tax Rate\n// #############################################################################\n/**\n * List of stores that require calculating per single item qty and then combining them to get the total tax amount for a\n * single line. Rest of the stores inherit default behavior that tax calculated on whole line item\n */\nexport const storesWithPerItemTaxRate = new Set([\n // #############################################################################\n // Stores with custom tax rates\n // #############################################################################\n StoreId.Br,\n StoreId.Tw,\n // #############################################################################\n // Stores with Avalara, but will have custom company codes to treat\n // FIXME: as PR is rushed we where able to test stores avalara custom codes that enable logic that calculates tax\n // \"per quantity\", so for now disabling this logic and only applying to store with custom tax rates\n // #############################################################################\n // StoreId.Jp,\n // StoreId.Sg,\n]);\n\n/**\n * Dinero currency option block for working with tax rates within dinero\n */\nexport const TAX_RATE_DINERO_CURRENCY = {\n base: 10,\n /**\n * We expect the tax rate to be in the range of 0..1\n * 0 --> 0%\n * 1 --> 100%\n * 0.21 --> 21%\n * 0.2169 --> 21.69%\n * 0.12345678 --> 12.345678%\n * !!! Don't change as this value is tied to store.backend DB schema !!!\n */\n exponent: 8,\n code: \"\", // Not important\n} satisfies DinoCurrency;\n\n// #############################################################################\n// Exchange Rate\n// #############################################################################\n\nexport const EXCHANGE_RATE_DINERO_CURRENCY = {\n base: 10,\n /**\n * We support having certain decimal places for exchange rates\n * !!! Don't change as this value is tied to store.backend DB schema !!!\n */\n exponent: 6,\n code: \"\", // Not important\n} satisfies DinoCurrency;\n"],"names":["Round","Financial","halfEven","Shipping","down","Prettify","Subunit","halfUp","prettifyPriceLookup","Map","USD","code","CAD","EUR","GBP","AED","ZAR","smallestSubunitLookup","TWD","localizedCurrencyLookup","Currency","Aed","currency","locale","Bgn","BGN","Cad","Chf","CHF","Czk","CZK","Dkk","DKK","Eur","Gbp","Hrk","HRK","Huf","HUF","Nok","NOK","Pln","PLN","Ron","RON","Sek","SEK","Usd","Zar","Inr","INR","Sgd","SGD","Brl","BRL","Jpy","JPY","Twd","Mxn","MXN","storesWithPerItemTaxRate","Set","StoreId","Br","Tw","TAX_RATE_DINERO_CURRENCY","base","exponent","EXCHANGE_RATE_DINERO_CURRENCY"],"mappings":";;;;;;;AAsCO,MAAMA,KAAQ,GAAA;EAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;EAkBnBC,SAAW,EAAAC,SAAA,CAAAA,QAAA;EAAA;EAAA;EAAA;EAAA;EAKXC,QAAU,EAAAC,SAAA,CAAAA,IAAA;EACVC,QAAU,EAAAD,SAAA,CAAAA,IAAA;EACVE,OAAS,EAAAC,SAAA,CAAAA;AACX,CAAA;AAKa,MAAAC,mBAAA,GAAA,mBAA0BC,GAAI,CAAA,CACzC,CAACC,UAAI,CAAAA,GAAA,CAAAC,IAAA,EAAM,EAAE,CAAA,EACb,CAACC,UAAI,CAAAA,GAAA,CAAAD,IAAA,EAAM,EAAE,CAAA,EACb,CAACE,UAAI,CAAAA,GAAA,CAAAF,IAAA,EAAM,EAAE,CAAA,EACb,CAACG,UAAI,CAAAA,GAAA,CAAAH,IAAA,EAAM,EAAE,CAAA,EACb,CAACI,UAAI,CAAAA,GAAA,CAAAJ,IAAA,EAAM,EAAE,CAAA;AAAA;AAEb,CAACK,UAAI,CAAAA,GAAA,CAAAL,IAAA,EAAM,EAAE,CAAA,CACd,CAAA;AAKY,MAAAM,qBAAA,GAAA,mBAA4BR,GAAiC,CAAA;AAAA;AAAA;AAAA;AAIxE,CAACS,UAAAA,CAAAA,GAAI,CAAAP,IAAA,EAAM,CAAC,CAAG,EAAAX,KAAA,CAAMM,OAAO,CA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AAK,MAAA,EAAQ;CAAS,CAAA,EACjD,CAACH,SAAAA,CAAAA,SAASsC,GAAK,EAAA;EAAEpC,UAAUqC,UAAAA,CAAAA,GAAK;EAAApC,MAAA,EAAQ;CAAS,CAAA,CAClD,CAAA;AASY,MAAAqC,wBAAA,GAAA,mBAA+BC,GAAI,CAAA;AAAA;AAAA;AAAA;AAI9CC,SAAAA,CAAAA,OAAQ,CAAAC,EAAA,EACRD,SAAAA,CAAAA,OAAQ,CAAAE;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,CAQT,CAAA;AAKM,MAAMC,wBAA2B,GAAA;EACtCC,IAAM,EAAA,EAAA;EAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;EAUNC,QAAU,EAAA,CAAA;EACVxD,IAAM,EAAA;EAAA;AACR,CAAA;AAMO,MAAMyD,6BAAgC,GAAA;EAC3CF,IAAM,EAAA,EAAA;EAAA;AAAA;AAAA;AAAA;EAKNC,QAAU,EAAA,CAAA;EACVxD,IAAM,EAAA;EAAA;AACR,CAAA;;;;;;;"}
|
|
1
|
+
{"version":3,"file":"constants.js","sources":["../../../src/utils/money/constants.ts"],"sourcesContent":["import {\n AED,\n BGN,\n BRL,\n CAD,\n CHF,\n CZK,\n DKK,\n EUR,\n GBP,\n HRK,\n HUF,\n INR,\n JPY,\n MXN,\n NOK,\n PLN,\n RON,\n SEK,\n SGD,\n TWD,\n USD,\n ZAR,\n} from \"@dinero.js/currencies\";\nimport { halfEven, halfUp } from \"dinero.js\";\n\nimport { Currency } from \"../../types\";\nimport type { CurrencyObj } from \"./types\";\n\n// #############################################################################\n// Constants\n// #############################################################################\n\n/**\n * Mapping of how prices should be rounded down to \"whole numbers\" after certain threshold\n */\nexport const prettifyPriceLookup = new Map([\n [USD.code, 20],\n [CAD.code, 20],\n [EUR.code, 20],\n [GBP.code, 20],\n [AED.code, 50],\n // Approximately every price above ~1.1 usd will be rounded in ZAR\n [ZAR.code, 20],\n]);\n\n/**\n * Map of currencycode to subunit digit count.\n */\nexport const smallestSubunitLookup = new Map<\n string,\n [number, (value: number) => number]\n>([\n /**\n * TWD does not use subunits at all in day to day transactions.\n */\n [TWD.code, [0, halfUp]],\n]);\n\n/**\n * Mapping of maximum price filter\n * TODO: Add all possible currencies\n */\nexport const maximumPriceFilterLookup = new Map([\n [CAD.code, 70000],\n [EUR.code, 70000],\n [AED.code, 70000],\n]);\n\n/**\n * ⚠️ Instead of using Math.round, we HAVE to use this method to round the financial numbers everywhere where we CAN'T\n * deal with dinero.js (Dinero.js should be the priority). But often for converting from API requests we have to\n * normalise the values so we use this method.\n *\n * It just a re-export of the dinero.js halfEven (a.k.a bankers rounding) method which is the default rounding method.\n * @see https://github.com/dinerojs/dinero.js/blob/main/packages/core/src/round/halfEven.ts\n * @see\n *\n * Compared to Math.round (arithmetic rounding) it differentiates that it changes the `.5` round up or down behaviour based on if the rounded\n * number would be an even number. So 1.5 would round to 2 while 2.5 would round to 2.\n * See the youtube link below for a brief exclamation on why it's important to use this method over regular rounding (half-up):\n * https://youtu.be/yuRdYlZvs1E\n *\n * If you really want to get knee-deep in the rounding subject, you can read the following:\n * https://en.wikipedia.org/wiki/Rounding#Round_half_toward_zero\n */\nexport const financialRound = halfEven;\n// TODO: maybe we should have separate rounding functions depending on the input value?\n// Reading from wiki \"Round half toward zero\" is better if the value is already \"normalized to cents\"\n// But the \"Round half to even\" seems better for when working with float like values\n// export const financialRound = Math.round;\n\n/**\n * Precompiled list for faster currency and locale lookups\n */\nexport const currencyObjLookup = new Map<Currency, CurrencyObj>([\n [Currency.Aed, { currency: AED, locale: \"ar-AE\" }],\n [Currency.Bgn, { currency: BGN, locale: \"bg-BG\" }],\n [Currency.Cad, { currency: CAD, locale: \"en-CA\" }],\n [Currency.Chf, { currency: CHF, locale: \"it-CH\" }],\n [Currency.Czk, { currency: CZK, locale: \"cs-CZ\" }],\n [Currency.Dkk, { currency: DKK, locale: \"da-DK\" }],\n [Currency.Eur, { currency: EUR, locale: \"de-DE\" }],\n [Currency.Gbp, { currency: GBP, locale: \"en-GB\" }],\n [Currency.Hrk, { currency: HRK, locale: \"hr-HR\" }],\n [Currency.Huf, { currency: HUF, locale: \"hu-HU\" }],\n [Currency.Nok, { currency: NOK, locale: \"no-NO\" }],\n [Currency.Pln, { currency: PLN, locale: \"pl-PL\" }],\n [Currency.Ron, { currency: RON, locale: \"ro-RO\" }],\n [Currency.Sek, { currency: SEK, locale: \"sv-SE\" }],\n [Currency.Usd, { currency: USD, locale: \"en-US\" }],\n [Currency.Zar, { currency: ZAR, locale: \"en-ZA\" }],\n [Currency.Inr, { currency: INR, locale: \"en-IN\" }],\n [Currency.Sgd, { currency: SGD, locale: \"en-SG\" }],\n [Currency.Brl, { currency: BRL, locale: \"pt-BR\" }],\n // NOTE: en-JP Doesn't exist\n [Currency.Jpy, { currency: JPY, locale: \"en-JP\" }],\n // NOTE: en-TW Doesn't exist\n [Currency.Twd, { currency: TWD, locale: \"en-TW\" }],\n [Currency.Mxn, { currency: MXN, locale: \"es-MX\" }],\n]);\n"],"names":["prettifyPriceLookup","Map","USD","code","CAD","EUR","GBP","AED","ZAR","smallestSubunitLookup","TWD","halfUp","maximumPriceFilterLookup","financialRound","halfEven","currencyObjLookup","Currency","Aed","currency","locale","Bgn","BGN","Cad","Chf","CHF","Czk","CZK","Dkk","DKK","Eur","Gbp","Hrk","HRK","Huf","HUF","Nok","NOK","Pln","PLN","Ron","RON","Sek","SEK","Usd","Zar","Inr","INR","Sgd","SGD","Brl","BRL","Jpy","JPY","Twd","Mxn","MXN"],"mappings":";;;;;;;AAoCa,MAAAA,mBAAA,GAAA,mBAA0BC,GAAI,CAAA,CACzC,CAACC,UAAI,CAAAA,GAAA,CAAAC,IAAA,EAAM,EAAE,CAAA,EACb,CAACC,UAAI,CAAAA,GAAA,CAAAD,IAAA,EAAM,EAAE,CAAA,EACb,CAACE,UAAI,CAAAA,GAAA,CAAAF,IAAA,EAAM,EAAE,CAAA,EAC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