@ubnt/store.core 9.12.0-alpha.8 → 9.12.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 +3 -89
- package/lib/_virtual/_virtual_multi-entry.js +2 -15
- package/lib/_virtual/_virtual_multi-entry.js.map +1 -1
- package/lib/_virtual/_virtual_multi-entry.mjs +0 -2
- package/lib/_virtual/_virtual_multi-entry.mjs.map +1 -1
- package/lib/assets/AITheta.jpg +0 -0
- package/lib/assets/MobileR.jpg +0 -0
- package/lib/assets/ProAV.jpg +0 -0
- package/lib/assets/ai360.jpg +0 -0
- package/lib/assets/ai3602.jpg +0 -0
- package/lib/assets/close2.svg +3 -2
- package/lib/assets/close3.svg +2 -3
- package/lib/assets/cloudgatewayultra.jpg +0 -0
- package/lib/assets/dreamRouter.jpg +0 -0
- package/lib/assets/dreamWall.jpg +0 -0
- package/lib/assets/g5-ptz.jpg +0 -0
- package/lib/assets/g5-ptz2.jpg +0 -0
- package/lib/assets/minus4.svg +8 -8
- package/lib/assets/minus5.svg +8 -8
- package/lib/assets/plus2.svg +4 -1
- package/lib/assets/plus3.svg +1 -4
- package/lib/assets/plus5.svg +9 -9
- package/lib/assets/plus6.svg +9 -9
- package/lib/assets/udr.jpg +0 -0
- package/lib/assets/udw.jpg +0 -0
- package/lib/assets/umr.jpg +0 -0
- package/lib/assets/wideAngle.jpg +0 -0
- package/lib/assets/wideAngle2.jpg +0 -0
- package/lib/components/Explore/Explore.js +9 -2
- package/lib/components/Explore/Explore.js.map +1 -1
- package/lib/components/Explore/Explore.mjs +9 -2
- package/lib/components/Explore/Explore.mjs.map +1 -1
- package/lib/components/Explore/ExploreData.d.ts +7 -4
- package/lib/components/Explore/ExploreData.js +139 -82
- package/lib/components/Explore/ExploreData.js.map +1 -1
- package/lib/components/Explore/ExploreData.mjs +129 -74
- package/lib/components/Explore/ExploreData.mjs.map +1 -1
- package/lib/components/Explore/LensCompare/LensCompare.d.ts +2 -0
- package/lib/components/Explore/LensCompare/LensCompare.js +111 -0
- package/lib/components/Explore/LensCompare/LensCompare.js.map +1 -0
- package/lib/components/Explore/LensCompare/LensCompare.mjs +109 -0
- package/lib/components/Explore/LensCompare/LensCompare.mjs.map +1 -0
- package/lib/components/Explore/LensCompare/LensCompare.styles.d.ts +16 -0
- package/lib/components/Explore/LensCompare/LensCompare.styles.js +153 -0
- package/lib/components/Explore/LensCompare/LensCompare.styles.js.map +1 -0
- package/lib/components/Explore/LensCompare/LensCompare.styles.mjs +132 -0
- package/lib/components/Explore/LensCompare/LensCompare.styles.mjs.map +1 -0
- package/lib/components/Explore/LensCompare/LensCompare.types.d.ts +9 -0
- package/lib/components/Explore/LensCompare/LensCompare.utils.d.ts +2 -0
- package/lib/components/Explore/LensCompare/LensCompare.utils.js +23 -0
- package/lib/components/Explore/LensCompare/LensCompare.utils.js.map +1 -0
- package/lib/components/Explore/LensCompare/LensCompare.utils.mjs +21 -0
- package/lib/components/Explore/LensCompare/LensCompare.utils.mjs.map +1 -0
- package/lib/components/Explore/LensCompare/LensCompareData.d.ts +29 -0
- package/lib/components/Explore/LensCompare/LensCompareData.js +68 -0
- package/lib/components/Explore/LensCompare/LensCompareData.js.map +1 -0
- package/lib/components/Explore/LensCompare/LensCompareData.mjs +58 -0
- package/lib/components/Explore/LensCompare/LensCompareData.mjs.map +1 -0
- package/lib/components/Explore/{assets/udr.jpg.js → LensCompare/assets/ai360.jpg.js} +6 -6
- package/lib/components/Explore/LensCompare/assets/ai360.jpg.js.map +1 -0
- package/lib/components/Explore/LensCompare/assets/ai360.jpg.mjs +3 -0
- package/lib/components/Explore/LensCompare/assets/ai360.jpg.mjs.map +1 -0
- package/lib/components/Explore/LensCompare/assets/wideAngle.jpg.js +27 -0
- package/lib/components/Explore/LensCompare/assets/wideAngle.jpg.js.map +1 -0
- package/lib/components/Explore/LensCompare/assets/wideAngle.jpg.mjs +3 -0
- package/lib/components/Explore/LensCompare/assets/wideAngle.jpg.mjs.map +1 -0
- package/lib/components/Explore/assets/AITheta.jpg.js +27 -0
- package/lib/components/Explore/assets/AITheta.jpg.js.map +1 -0
- package/lib/components/Explore/assets/AITheta.jpg.mjs +3 -0
- package/lib/components/Explore/assets/AITheta.jpg.mjs.map +1 -0
- package/lib/components/Explore/assets/MobileR.jpg.js +27 -0
- package/lib/components/Explore/assets/MobileR.jpg.js.map +1 -0
- package/lib/components/Explore/assets/MobileR.jpg.mjs +3 -0
- package/lib/components/Explore/assets/MobileR.jpg.mjs.map +1 -0
- package/lib/{assets/keyFeatures/music.svg.js → components/Explore/assets/ProAV.jpg.js} +6 -6
- package/lib/components/Explore/assets/ProAV.jpg.js.map +1 -0
- package/lib/components/Explore/assets/ProAV.jpg.mjs +3 -0
- package/lib/components/Explore/assets/ProAV.jpg.mjs.map +1 -0
- package/lib/components/Explore/assets/UISPConsole.jpg.js +5 -5
- package/lib/components/Explore/assets/{baseStation--mobile.jpg.js → baseStation-mobile.jpg.js} +6 -6
- package/lib/components/Explore/assets/baseStation-mobile.jpg.js.map +1 -0
- package/lib/components/Explore/assets/baseStation-mobile.jpg.mjs +3 -0
- package/lib/components/Explore/assets/baseStation-mobile.jpg.mjs.map +1 -0
- package/lib/components/Explore/assets/baseStation.jpg.js +5 -5
- package/lib/components/Explore/assets/cloudgatewayultra.jpg.js +27 -0
- package/lib/components/Explore/assets/cloudgatewayultra.jpg.js.map +1 -0
- package/lib/components/Explore/assets/cloudgatewayultra.jpg.mjs +3 -0
- package/lib/components/Explore/assets/cloudgatewayultra.jpg.mjs.map +1 -0
- package/lib/components/Explore/assets/dreamRouter.jpg.js +27 -0
- package/lib/components/Explore/assets/dreamRouter.jpg.js.map +1 -0
- package/lib/components/Explore/assets/dreamRouter.jpg.mjs +3 -0
- package/lib/components/Explore/assets/dreamRouter.jpg.mjs.map +1 -0
- package/lib/components/Explore/assets/{powerAmp.jpg.js → dreamWall.jpg.js} +6 -6
- package/lib/components/Explore/assets/dreamWall.jpg.js.map +1 -0
- package/lib/components/Explore/assets/dreamWall.jpg.mjs +3 -0
- package/lib/components/Explore/assets/dreamWall.jpg.mjs.map +1 -0
- package/lib/components/Explore/assets/{g4Ptz.jpg.js → g4-ptz.jpg.js} +2 -2
- package/lib/components/Explore/assets/g4-ptz.jpg.js.map +1 -0
- package/lib/components/Explore/assets/g4-ptz.jpg.mjs +3 -0
- package/lib/components/Explore/assets/g4-ptz.jpg.mjs.map +1 -0
- package/lib/components/Explore/assets/{g5Ptz.jpg.js → g5-ptz.jpg.js} +2 -2
- package/lib/components/Explore/assets/g5-ptz.jpg.js.map +1 -0
- package/lib/components/Explore/assets/g5-ptz.jpg.mjs +3 -0
- package/lib/components/Explore/assets/g5-ptz.jpg.mjs.map +1 -0
- package/lib/components/Explore/assets/unifiExpress.jpg.js +27 -0
- package/lib/components/Explore/assets/unifiExpress.jpg.js.map +1 -0
- package/lib/components/Explore/assets/unifiExpress.jpg.mjs +3 -0
- package/lib/components/Explore/assets/unifiExpress.jpg.mjs.map +1 -0
- package/lib/components/Explore/translations/en.json.js +30 -9
- package/lib/components/Explore/translations/en.json.js.map +1 -1
- package/lib/components/Explore/translations/en.json.mjs +30 -10
- package/lib/components/Explore/translations/en.json.mjs.map +1 -1
- package/lib/components/FeaturesSection_deprecated/AllFeaturesButton/AllFeaturesButton.js +1 -1
- package/lib/components/FeaturesSection_deprecated/AllFeaturesButton/AllFeaturesButton.mjs +1 -1
- package/lib/components/FeaturesSection_deprecated/FeaturesSection.js +1 -1
- package/lib/components/FeaturesSection_deprecated/FeaturesSection.mjs +1 -1
- package/lib/components/FeaturesSection_deprecated/assets/close.svg.js +1 -1
- package/lib/components/FeaturesSection_deprecated/assets/close.svg.mjs +2 -2
- package/lib/components/FeaturesSection_deprecated/assets/plus.svg.js +1 -1
- package/lib/components/FeaturesSection_deprecated/assets/plus.svg.mjs +2 -2
- package/lib/components/Header/CartModalV2/Item/Item.js +3 -3
- package/lib/components/Header/CartModalV2/Item/Item.mjs +2 -2
- package/lib/components/Header/Header.js +0 -1
- package/lib/components/Header/Header.js.map +1 -1
- package/lib/components/Header/Header.mjs +0 -1
- package/lib/components/Header/Header.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/ModelCompareV3/ModelCompareV3.types.d.ts +0 -1
- package/lib/components/ModelCompareV3/assets/Consoles/bigCompare/udr.jpg.js +1 -1
- package/lib/components/ModelCompareV3/assets/Consoles/bigCompare/udr.jpg.mjs +2 -2
- package/lib/components/ModelCompareV3/assets/Consoles/bigCompare/udw.jpg.js +1 -1
- package/lib/components/ModelCompareV3/assets/Consoles/bigCompare/udw.jpg.mjs +2 -2
- package/lib/components/ModelCompareV3/assets/Interior/ai360.jpg.js +1 -1
- package/lib/components/ModelCompareV3/assets/Interior/ai360.jpg.mjs +2 -2
- package/lib/components/ModelCompareV3/assets/Interior/wideAngle.jpg.js +1 -1
- package/lib/components/ModelCompareV3/assets/Interior/wideAngle.jpg.mjs +2 -2
- package/lib/components/ModelCompareV3/assets/MobileRouters/umr.jpg.js +1 -1
- package/lib/components/ModelCompareV3/assets/MobileRouters/umr.jpg.mjs +2 -2
- package/lib/components/ModelCompareV3/assets/PTZ/g5-ptz.jpg.js +1 -1
- package/lib/components/ModelCompareV3/assets/PTZ/g5-ptz.jpg.mjs +2 -2
- package/lib/components/ModelCompareV3/data/CloudGateways.js +2 -2
- package/lib/components/ModelCompareV3/data/CloudGateways.mjs +2 -2
- package/lib/components/ModelCompareV3/data/Switching.js +1 -3
- package/lib/components/ModelCompareV3/data/Switching.js.map +1 -1
- package/lib/components/ModelCompareV3/data/Switching.mjs +1 -3
- package/lib/components/ModelCompareV3/data/Switching.mjs.map +1 -1
- package/lib/components/ModelCompareV3/data/products/aggregation.js +8 -16
- package/lib/components/ModelCompareV3/data/products/aggregation.js.map +1 -1
- package/lib/components/ModelCompareV3/data/products/aggregation.mjs +8 -16
- package/lib/components/ModelCompareV3/data/products/aggregation.mjs.map +1 -1
- package/lib/components/ModelCompareV3/data/products/connectDisplay.js +1 -1
- package/lib/components/ModelCompareV3/data/products/connectDisplay.js.map +1 -1
- package/lib/components/ModelCompareV3/data/products/connectDisplay.mjs +1 -1
- package/lib/components/ModelCompareV3/data/products/connectDisplay.mjs.map +1 -1
- package/lib/components/ModelCompareV3/data/products/enterprise24PoE.js +8 -16
- package/lib/components/ModelCompareV3/data/products/enterprise24PoE.js.map +1 -1
- package/lib/components/ModelCompareV3/data/products/enterprise24PoE.mjs +8 -16
- package/lib/components/ModelCompareV3/data/products/enterprise24PoE.mjs.map +1 -1
- package/lib/components/ModelCompareV3/data/products/enterprise48PoE.js +8 -16
- package/lib/components/ModelCompareV3/data/products/enterprise48PoE.js.map +1 -1
- package/lib/components/ModelCompareV3/data/products/enterprise48PoE.mjs +8 -16
- package/lib/components/ModelCompareV3/data/products/enterprise48PoE.mjs.map +1 -1
- package/lib/components/ModelCompareV3/data/products/enterpriseXG24.js +8 -16
- package/lib/components/ModelCompareV3/data/products/enterpriseXG24.js.map +1 -1
- package/lib/components/ModelCompareV3/data/products/enterpriseXG24.mjs +8 -16
- package/lib/components/ModelCompareV3/data/products/enterpriseXG24.mjs.map +1 -1
- package/lib/components/ModelCompareV3/data/products/g5Ptz.js +1 -1
- package/lib/components/ModelCompareV3/data/products/g5Ptz.mjs +1 -1
- package/lib/components/ModelCompareV3/data/products/highCapacityAggregation.js +8 -16
- package/lib/components/ModelCompareV3/data/products/highCapacityAggregation.js.map +1 -1
- package/lib/components/ModelCompareV3/data/products/highCapacityAggregation.mjs +8 -16
- package/lib/components/ModelCompareV3/data/products/highCapacityAggregation.mjs.map +1 -1
- package/lib/components/ModelCompareV3/data/products/missionCritical.js +0 -8
- package/lib/components/ModelCompareV3/data/products/missionCritical.js.map +1 -1
- package/lib/components/ModelCompareV3/data/products/missionCritical.mjs +0 -8
- package/lib/components/ModelCompareV3/data/products/missionCritical.mjs.map +1 -1
- package/lib/components/ModelCompareV3/data/products/phoneTouch.js +3 -5
- package/lib/components/ModelCompareV3/data/products/phoneTouch.js.map +1 -1
- package/lib/components/ModelCompareV3/data/products/phoneTouch.mjs +3 -5
- package/lib/components/ModelCompareV3/data/products/phoneTouch.mjs.map +1 -1
- package/lib/components/ModelCompareV3/data/products/phoneTouchMax.js +2 -4
- package/lib/components/ModelCompareV3/data/products/phoneTouchMax.js.map +1 -1
- package/lib/components/ModelCompareV3/data/products/phoneTouchMax.mjs +2 -4
- package/lib/components/ModelCompareV3/data/products/phoneTouchMax.mjs.map +1 -1
- package/lib/components/ModelCompareV3/data/products/professional24.js +0 -8
- package/lib/components/ModelCompareV3/data/products/professional24.js.map +1 -1
- package/lib/components/ModelCompareV3/data/products/professional24.mjs +0 -8
- package/lib/components/ModelCompareV3/data/products/professional24.mjs.map +1 -1
- package/lib/components/ModelCompareV3/data/products/professional24PoE.js +0 -8
- package/lib/components/ModelCompareV3/data/products/professional24PoE.js.map +1 -1
- package/lib/components/ModelCompareV3/data/products/professional24PoE.mjs +0 -8
- package/lib/components/ModelCompareV3/data/products/professional24PoE.mjs.map +1 -1
- package/lib/components/ModelCompareV3/data/products/professional48.js +0 -8
- package/lib/components/ModelCompareV3/data/products/professional48.js.map +1 -1
- package/lib/components/ModelCompareV3/data/products/professional48.mjs +0 -8
- package/lib/components/ModelCompareV3/data/products/professional48.mjs.map +1 -1
- package/lib/components/ModelCompareV3/data/products/professional48PoE.js +0 -8
- package/lib/components/ModelCompareV3/data/products/professional48PoE.js.map +1 -1
- package/lib/components/ModelCompareV3/data/products/professional48PoE.mjs +0 -8
- package/lib/components/ModelCompareV3/data/products/professional48PoE.mjs.map +1 -1
- package/lib/components/ModelCompareV3/data/products/professionalMax16.js +0 -7
- package/lib/components/ModelCompareV3/data/products/professionalMax16.js.map +1 -1
- package/lib/components/ModelCompareV3/data/products/professionalMax16.mjs +0 -7
- package/lib/components/ModelCompareV3/data/products/professionalMax16.mjs.map +1 -1
- package/lib/components/ModelCompareV3/data/products/professionalMax16PoE.js +0 -7
- package/lib/components/ModelCompareV3/data/products/professionalMax16PoE.js.map +1 -1
- package/lib/components/ModelCompareV3/data/products/professionalMax16PoE.mjs +0 -7
- package/lib/components/ModelCompareV3/data/products/professionalMax16PoE.mjs.map +1 -1
- package/lib/components/ModelCompareV3/data/products/professionalMax24.js +0 -7
- package/lib/components/ModelCompareV3/data/products/professionalMax24.js.map +1 -1
- package/lib/components/ModelCompareV3/data/products/professionalMax24.mjs +0 -7
- package/lib/components/ModelCompareV3/data/products/professionalMax24.mjs.map +1 -1
- package/lib/components/ModelCompareV3/data/products/professionalMax24PoE.js +0 -7
- package/lib/components/ModelCompareV3/data/products/professionalMax24PoE.js.map +1 -1
- package/lib/components/ModelCompareV3/data/products/professionalMax24PoE.mjs +0 -7
- package/lib/components/ModelCompareV3/data/products/professionalMax24PoE.mjs.map +1 -1
- package/lib/components/ModelCompareV3/data/products/professionalMax48.js +0 -7
- package/lib/components/ModelCompareV3/data/products/professionalMax48.js.map +1 -1
- package/lib/components/ModelCompareV3/data/products/professionalMax48.mjs +0 -7
- package/lib/components/ModelCompareV3/data/products/professionalMax48.mjs.map +1 -1
- package/lib/components/ModelCompareV3/data/products/professionalMax48PoE.js +0 -7
- package/lib/components/ModelCompareV3/data/products/professionalMax48PoE.js.map +1 -1
- package/lib/components/ModelCompareV3/data/products/professionalMax48PoE.mjs +0 -7
- package/lib/components/ModelCompareV3/data/products/professionalMax48PoE.mjs.map +1 -1
- package/lib/components/ModelCompareV3/data/products/switchesEnterprise.js +1 -11
- package/lib/components/ModelCompareV3/data/products/switchesEnterprise.js.map +1 -1
- package/lib/components/ModelCompareV3/data/products/switchesEnterprise.mjs +1 -11
- package/lib/components/ModelCompareV3/data/products/switchesEnterprise.mjs.map +1 -1
- package/lib/components/ModelCompareV3/data/products/switchesProfessional.js +0 -8
- package/lib/components/ModelCompareV3/data/products/switchesProfessional.js.map +1 -1
- package/lib/components/ModelCompareV3/data/products/switchesProfessional.mjs +0 -8
- package/lib/components/ModelCompareV3/data/products/switchesProfessional.mjs.map +1 -1
- package/lib/components/ModelCompareV3/data/products/switchesProfessionalMax.js +0 -8
- package/lib/components/ModelCompareV3/data/products/switchesProfessionalMax.js.map +1 -1
- package/lib/components/ModelCompareV3/data/products/switchesProfessionalMax.mjs +0 -8
- package/lib/components/ModelCompareV3/data/products/switchesProfessionalMax.mjs.map +1 -1
- package/lib/components/ModelCompareV3/data/products/switchesStandard.js +0 -8
- package/lib/components/ModelCompareV3/data/products/switchesStandard.js.map +1 -1
- package/lib/components/ModelCompareV3/data/products/switchesStandard.mjs +0 -8
- package/lib/components/ModelCompareV3/data/products/switchesStandard.mjs.map +1 -1
- package/lib/components/ModelCompareV3/data/products/theta360.js +1 -1
- package/lib/components/ModelCompareV3/data/products/theta360.mjs +1 -1
- package/lib/components/ModelCompareV3/data/products/thetaWideAngle.js +1 -1
- package/lib/components/ModelCompareV3/data/products/thetaWideAngle.mjs +1 -1
- package/lib/components/ModelCompareV3/data/products/ucCast.js +1 -1
- package/lib/components/ModelCompareV3/data/products/ucCast.js.map +1 -1
- package/lib/components/ModelCompareV3/data/products/ucCast.mjs +1 -1
- package/lib/components/ModelCompareV3/data/products/ucCast.mjs.map +1 -1
- package/lib/components/ModelCompareV3/data/products/ucCastPro.js +1 -1
- package/lib/components/ModelCompareV3/data/products/ucCastPro.js.map +1 -1
- package/lib/components/ModelCompareV3/data/products/ucCastPro.mjs +1 -1
- package/lib/components/ModelCompareV3/data/products/ucCastPro.mjs.map +1 -1
- package/lib/components/ModelCompareV3/data/products/udr.js +1 -1
- package/lib/components/ModelCompareV3/data/products/udr.mjs +1 -1
- package/lib/components/ModelCompareV3/data/products/udw.js +1 -1
- package/lib/components/ModelCompareV3/data/products/udw.mjs +1 -1
- package/lib/components/ModelCompareV3/data/products/umr.js +1 -1
- package/lib/components/ModelCompareV3/data/products/umr.mjs +1 -1
- package/lib/components/ModelCompareV3/data/properties/index.d.ts +0 -1
- package/lib/components/ModelCompareV3/data/properties/index.js +0 -2
- package/lib/components/ModelCompareV3/data/properties/index.js.map +1 -1
- package/lib/components/ModelCompareV3/data/properties/index.mjs +0 -1
- package/lib/components/ModelCompareV3/data/properties/index.mjs.map +1 -1
- package/lib/components/ModelCompareV3/data/property-sets/switching.js +4 -6
- package/lib/components/ModelCompareV3/data/property-sets/switching.js.map +1 -1
- package/lib/components/ModelCompareV3/data/property-sets/switching.mjs +4 -6
- package/lib/components/ModelCompareV3/data/property-sets/switching.mjs.map +1 -1
- package/lib/components/ModelCompareV3/translations/en.json.js +0 -3
- package/lib/components/ModelCompareV3/translations/en.json.js.map +1 -1
- package/lib/components/ModelCompareV3/translations/en.json.mjs +0 -3
- package/lib/components/ModelCompareV3/translations/en.json.mjs.map +1 -1
- package/lib/components/ModelCompareV3/translations/useModelCompareTranslation.d.ts +2 -2
- package/lib/components/ResourceCalculatorV1/ComputeResourceCalculator/ComputeResourceCalculator.constants.js +15 -311
- package/lib/components/ResourceCalculatorV1/ComputeResourceCalculator/ComputeResourceCalculator.constants.js.map +1 -1
- package/lib/components/ResourceCalculatorV1/ComputeResourceCalculator/ComputeResourceCalculator.constants.mjs +15 -309
- package/lib/components/ResourceCalculatorV1/ComputeResourceCalculator/ComputeResourceCalculator.constants.mjs.map +1 -1
- package/lib/components/ResourceCalculatorV1/ComputeResourceCalculator/ComputeResourceCalculator.js +22 -38
- package/lib/components/ResourceCalculatorV1/ComputeResourceCalculator/ComputeResourceCalculator.js.map +1 -1
- package/lib/components/ResourceCalculatorV1/ComputeResourceCalculator/ComputeResourceCalculator.mjs +22 -38
- package/lib/components/ResourceCalculatorV1/ComputeResourceCalculator/ComputeResourceCalculator.mjs.map +1 -1
- package/lib/components/ResourceCalculatorV1/ComputeResourceCalculator/ComputeResourceCalculator.types.d.ts +2 -10
- 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/HddSlots/HddSlots.d.ts +1 -1
- package/lib/components/ResourceCalculatorV1/ComputeResourceCalculator/components/HddSlots/HddSlots.js +4 -5
- package/lib/components/ResourceCalculatorV1/ComputeResourceCalculator/components/HddSlots/HddSlots.js.map +1 -1
- package/lib/components/ResourceCalculatorV1/ComputeResourceCalculator/components/HddSlots/HddSlots.mjs +4 -5
- package/lib/components/ResourceCalculatorV1/ComputeResourceCalculator/components/HddSlots/HddSlots.mjs.map +1 -1
- 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/components/InputCard/InputSections/CounterSection.js +2 -2
- package/lib/components/ResourceCalculatorV1/ComputeResourceCalculator/components/InputCard/InputSections/CounterSection.mjs +2 -2
- package/lib/components/ResourceCalculatorV1/ComputeResourceCalculator/components/InputCard/assets/minus.svg.js +1 -1
- package/lib/components/ResourceCalculatorV1/ComputeResourceCalculator/components/InputCard/assets/minus.svg.mjs +2 -2
- package/lib/components/ResourceCalculatorV1/ComputeResourceCalculator/components/InputCard/assets/plus.svg.js +1 -1
- package/lib/components/ResourceCalculatorV1/ComputeResourceCalculator/components/InputCard/assets/plus.svg.mjs +2 -2
- 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.mjs +2 -2
- package/lib/components/ResourceCalculatorV1/PoeCalculator/components/PoeConsumerConfigurator/assets/minus.svg.js +1 -1
- package/lib/components/ResourceCalculatorV1/PoeCalculator/components/PoeConsumerConfigurator/assets/minus.svg.mjs +2 -2
- package/lib/components/ResourceCalculatorV1/PoeCalculator/components/PoeConsumerConfigurator/assets/plus.svg.js +1 -1
- package/lib/components/ResourceCalculatorV1/PoeCalculator/components/PoeConsumerConfigurator/assets/plus.svg.mjs +2 -2
- package/lib/components/ResourceCalculatorV1/translations/en.json.js +1 -4
- package/lib/components/ResourceCalculatorV1/translations/en.json.js.map +1 -1
- package/lib/components/ResourceCalculatorV1/translations/en.json.mjs +1 -4
- package/lib/components/ResourceCalculatorV1/translations/en.json.mjs.map +1 -1
- package/lib/components/ResourceCalculatorV1/translations/useResourceCalculatorTranslation.d.ts +2 -2
- package/lib/components/VideoPlayerNew/VideoPlayer.js +1 -1
- package/lib/components/VideoPlayerNew/VideoPlayer.mjs +1 -1
- package/lib/components/VideoPlayerNew/assets/close.svg.js +1 -1
- package/lib/components/VideoPlayerNew/assets/close.svg.mjs +2 -2
- package/lib/constants/icons/generic/index.js +3 -3
- package/lib/constants/icons/generic/index.mjs +1 -1
- package/lib/constants/icons/generic/plus.svg.js +5 -5
- package/lib/constants/icons/generic/plus.svg.mjs +2 -2
- package/lib/constants/icons/menu/index.d.ts +0 -1
- package/lib/constants/icons/menu/index.js +0 -9
- package/lib/constants/icons/menu/index.js.map +1 -1
- package/lib/constants/icons/menu/index.mjs +0 -2
- package/lib/constants/icons/menu/index.mjs.map +1 -1
- package/lib/constants/icons/options/colors/black.svg.js +5 -5
- package/lib/constants/icons/options/colors/index.js +3 -3
- package/lib/constants/icons/options/styles/black.svg.js +5 -5
- package/lib/constants/icons/options/styles/index.js +3 -3
- package/lib/constants/keyFeatureIcons.d.ts +0 -1
- package/lib/constants/keyFeatureIcons.js +0 -3
- package/lib/constants/keyFeatureIcons.js.map +1 -1
- package/lib/constants/keyFeatureIcons.mjs +0 -3
- package/lib/constants/keyFeatureIcons.mjs.map +1 -1
- package/lib/constants/optionIcons.js +6 -6
- package/lib/constants/optionIcons.mjs +4 -4
- package/lib/constants/proStoreCategories/mapping/index.d.ts +1 -3
- package/lib/constants/proStoreCategories/mapping/index.js +8 -18
- package/lib/constants/proStoreCategories/mapping/index.js.map +1 -1
- package/lib/constants/proStoreCategories/mapping/index.mjs +8 -18
- package/lib/constants/proStoreCategories/mapping/index.mjs.map +1 -1
- package/lib/constants/proStoreCategories/mapping/redirects.js +1 -8
- package/lib/constants/proStoreCategories/mapping/redirects.js.map +1 -1
- package/lib/constants/proStoreCategories/mapping/redirects.mjs +1 -8
- package/lib/constants/proStoreCategories/mapping/redirects.mjs.map +1 -1
- package/lib/constants/proStoreCategories/mapping/unifi.d.ts +2 -4
- package/lib/constants/proStoreCategories/mapping/unifi.js +1 -3
- package/lib/constants/proStoreCategories/mapping/unifi.js.map +1 -1
- package/lib/constants/proStoreCategories/mapping/unifi.mjs +1 -3
- package/lib/constants/proStoreCategories/mapping/unifi.mjs.map +1 -1
- package/lib/constants/proStoreCategories/translations/ar.json.js +2 -3
- package/lib/constants/proStoreCategories/translations/ar.json.js.map +1 -1
- package/lib/constants/proStoreCategories/translations/ar.json.mjs +2 -3
- package/lib/constants/proStoreCategories/translations/ar.json.mjs.map +1 -1
- package/lib/constants/proStoreCategories/translations/de.json.js +2 -3
- package/lib/constants/proStoreCategories/translations/de.json.js.map +1 -1
- package/lib/constants/proStoreCategories/translations/de.json.mjs +2 -3
- package/lib/constants/proStoreCategories/translations/de.json.mjs.map +1 -1
- package/lib/constants/proStoreCategories/translations/el.json.js +2 -3
- package/lib/constants/proStoreCategories/translations/el.json.js.map +1 -1
- package/lib/constants/proStoreCategories/translations/el.json.mjs +2 -3
- package/lib/constants/proStoreCategories/translations/el.json.mjs.map +1 -1
- package/lib/constants/proStoreCategories/translations/en.json.js +1 -5
- package/lib/constants/proStoreCategories/translations/en.json.js.map +1 -1
- package/lib/constants/proStoreCategories/translations/en.json.mjs +2 -5
- package/lib/constants/proStoreCategories/translations/en.json.mjs.map +1 -1
- package/lib/constants/proStoreCategories/translations/es.json.js +2 -3
- package/lib/constants/proStoreCategories/translations/es.json.js.map +1 -1
- package/lib/constants/proStoreCategories/translations/es.json.mjs +2 -3
- package/lib/constants/proStoreCategories/translations/es.json.mjs.map +1 -1
- package/lib/constants/proStoreCategories/translations/fr.json.js +3 -4
- package/lib/constants/proStoreCategories/translations/fr.json.js.map +1 -1
- package/lib/constants/proStoreCategories/translations/fr.json.mjs +3 -4
- package/lib/constants/proStoreCategories/translations/fr.json.mjs.map +1 -1
- package/lib/constants/proStoreCategories/translations/it.json.js +2 -3
- package/lib/constants/proStoreCategories/translations/it.json.js.map +1 -1
- package/lib/constants/proStoreCategories/translations/it.json.mjs +2 -3
- package/lib/constants/proStoreCategories/translations/it.json.mjs.map +1 -1
- package/lib/constants/proStoreCategories/translations/ja.json.js +2 -3
- package/lib/constants/proStoreCategories/translations/ja.json.js.map +1 -1
- package/lib/constants/proStoreCategories/translations/ja.json.mjs +2 -3
- package/lib/constants/proStoreCategories/translations/ja.json.mjs.map +1 -1
- package/lib/constants/proStoreCategories/translations/pt-BR.json.js +2 -3
- package/lib/constants/proStoreCategories/translations/pt-BR.json.js.map +1 -1
- package/lib/constants/proStoreCategories/translations/pt-BR.json.mjs +2 -3
- package/lib/constants/proStoreCategories/translations/pt-BR.json.mjs.map +1 -1
- package/lib/constants/proStoreCategories/translations/zh-Hans.json.js +3 -4
- package/lib/constants/proStoreCategories/translations/zh-Hans.json.js.map +1 -1
- package/lib/constants/proStoreCategories/translations/zh-Hans.json.mjs +3 -4
- package/lib/constants/proStoreCategories/translations/zh-Hans.json.mjs.map +1 -1
- package/lib/constants/proStoreCategories/translations/zh-Hant-TW.json.js +3 -4
- package/lib/constants/proStoreCategories/translations/zh-Hant-TW.json.js.map +1 -1
- package/lib/constants/proStoreCategories/translations/zh-Hant-TW.json.mjs +3 -4
- package/lib/constants/proStoreCategories/translations/zh-Hant-TW.json.mjs.map +1 -1
- package/lib/constants/shopify/keyFeatureIcons.js +0 -4
- package/lib/constants/shopify/keyFeatureIcons.js.map +1 -1
- package/lib/constants/shopify/keyFeatureIcons.mjs +0 -3
- package/lib/constants/shopify/keyFeatureIcons.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/mapping.d.ts +3 -3
- package/lib/contexts/MenuContext/mapping.js +7 -21
- package/lib/contexts/MenuContext/mapping.js.map +1 -1
- package/lib/contexts/MenuContext/mapping.mjs +7 -20
- package/lib/contexts/MenuContext/mapping.mjs.map +1 -1
- package/lib/contexts/MenuContext/presets.d.ts +4 -11
- package/lib/contexts/MenuContext/presets.js +12 -16
- package/lib/contexts/MenuContext/presets.js.map +1 -1
- package/lib/contexts/MenuContext/presets.mjs +13 -13
- package/lib/contexts/MenuContext/presets.mjs.map +1 -1
- package/lib/contexts/MenuContext/types.d.ts +1 -1
- package/lib/contexts/MenuContext/types.js.map +1 -1
- package/lib/contexts/MenuContext/types.mjs.map +1 -1
- package/lib/contexts/MenuContext/utils.js +1 -5
- package/lib/contexts/MenuContext/utils.js.map +1 -1
- package/lib/contexts/MenuContext/utils.mjs +1 -5
- 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/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/nextjs/navigationPresets.d.ts +5 -7
- package/lib/utils/nextjs/navigationPresets.js +7 -13
- package/lib/utils/nextjs/navigationPresets.js.map +1 -1
- package/lib/utils/nextjs/navigationPresets.mjs +8 -14
- package/lib/utils/nextjs/navigationPresets.mjs.map +1 -1
- 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.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/package.json +54 -55
- package/lib/assets/efg.png +0 -0
- package/lib/assets/g5Ptz.jpg +0 -0
- package/lib/assets/keyFeatures/music.svg +0 -3
- package/lib/assets/keyFeatures/music.svg.js.map +0 -1
- package/lib/assets/keyFeatures/music.svg.mjs +0 -3
- package/lib/assets/keyFeatures/music.svg.mjs.map +0 -1
- package/lib/assets/music.svg +0 -3
- package/lib/assets/powerAmp.jpg +0 -0
- package/lib/assets/powerAmp.svg +0 -3
- package/lib/assets/ucg-max.png +0 -0
- package/lib/assets/udr2.jpg +0 -0
- package/lib/assets/udw2.jpg +0 -0
- package/lib/assets/umr2.jpg +0 -0
- package/lib/assets/volume-on2.svg +0 -3
- package/lib/components/Explore/assets/baseStation--mobile.jpg.js.map +0 -1
- package/lib/components/Explore/assets/baseStation--mobile.jpg.mjs +0 -3
- package/lib/components/Explore/assets/baseStation--mobile.jpg.mjs.map +0 -1
- package/lib/components/Explore/assets/g4Ptz.jpg.js.map +0 -1
- package/lib/components/Explore/assets/g4Ptz.jpg.mjs +0 -3
- package/lib/components/Explore/assets/g4Ptz.jpg.mjs.map +0 -1
- package/lib/components/Explore/assets/g5Ptz.jpg.js.map +0 -1
- package/lib/components/Explore/assets/g5Ptz.jpg.mjs +0 -3
- package/lib/components/Explore/assets/g5Ptz.jpg.mjs.map +0 -1
- package/lib/components/Explore/assets/powerAmp.jpg.js.map +0 -1
- package/lib/components/Explore/assets/powerAmp.jpg.mjs +0 -3
- package/lib/components/Explore/assets/powerAmp.jpg.mjs.map +0 -1
- package/lib/components/Explore/assets/udr.jpg.js.map +0 -1
- package/lib/components/Explore/assets/udr.jpg.mjs +0 -3
- package/lib/components/Explore/assets/udr.jpg.mjs.map +0 -1
- package/lib/components/Explore/assets/udw.jpg.js +0 -27
- package/lib/components/Explore/assets/udw.jpg.js.map +0 -1
- package/lib/components/Explore/assets/udw.jpg.mjs +0 -3
- package/lib/components/Explore/assets/udw.jpg.mjs.map +0 -1
- package/lib/components/Explore/assets/umr.jpg.js +0 -27
- package/lib/components/Explore/assets/umr.jpg.js.map +0 -1
- package/lib/components/Explore/assets/umr.jpg.mjs +0 -3
- package/lib/components/Explore/assets/umr.jpg.mjs.map +0 -1
- package/lib/components/Explore/assets/ux.jpg.js +0 -27
- package/lib/components/Explore/assets/ux.jpg.js.map +0 -1
- package/lib/components/Explore/assets/ux.jpg.mjs +0 -3
- package/lib/components/Explore/assets/ux.jpg.mjs.map +0 -1
- package/lib/components/ModelCompareV3/assets/volume-on.svg.js +0 -27
- package/lib/components/ModelCompareV3/assets/volume-on.svg.js.map +0 -1
- package/lib/components/ModelCompareV3/assets/volume-on.svg.mjs +0 -3
- package/lib/components/ModelCompareV3/assets/volume-on.svg.mjs.map +0 -1
- package/lib/components/ModelCompareV3/data/properties/proAvSupport.d.ts +0 -2
- package/lib/components/ModelCompareV3/data/properties/proAvSupport.js +0 -19
- package/lib/components/ModelCompareV3/data/properties/proAvSupport.js.map +0 -1
- package/lib/components/ModelCompareV3/data/properties/proAvSupport.mjs +0 -11
- package/lib/components/ModelCompareV3/data/properties/proAvSupport.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 +0 -27
- 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/constants/icons/menu/powerAmp.svg.js +0 -27
- package/lib/constants/icons/menu/powerAmp.svg.js.map +0 -1
- package/lib/constants/icons/menu/powerAmp.svg.mjs +0 -3
- package/lib/constants/icons/menu/powerAmp.svg.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/assets/{baseStation--mobile.jpg → baseStation-mobile.jpg} +0 -0
- /package/lib/assets/{g4Ptz.jpg → g4-ptz.jpg} +0 -0
- /package/lib/assets/{ux.jpg → unifiExpress.jpg} +0 -0
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils.mjs","sources":["../../../src/contexts/MenuContext/utils.ts"],"sourcesContent":["import type { GlobalStoreId, StoreId } from \"../../types\";\nimport {\n assert,\n assertUnreachable,\n checkUnreachable,\n} from \"../../utils/errors\";\nimport { partsToPathname, pathnameToParts, slugify } from \"../../utils/url\";\nimport type {\n NavigationInvisibleItem,\n NavigationPath,\n NavigationSubItem,\n NavigationSubSubItem,\n SiteUrl,\n} from \"./mapping\";\nimport { GENERIC_SITE_IDS, Language, SiteId } from \"./mapping\";\nimport type { BasicSiteConfig } from \"./types\";\nimport {\n type GlobalSiteConfig,\n type ParsedNavigationItem,\n type ParsedNavigationSubItem,\n type ParsedNavigationSubSubItem,\n SiteConfigType,\n} from \"./types\";\n\nexport const parseSiteUrl = ({\n siteUrl: [siteId, pathname, searchParams, fragment],\n storeId,\n addSiteConfigReferenceSearchParams,\n language,\n targetSiteConfig,\n context,\n}: {\n siteUrl: SiteUrl;\n storeId: GlobalStoreId;\n addSiteConfigReferenceSearchParams: boolean;\n language: `${Language}`;\n targetSiteConfig: BasicSiteConfig;\n /** Current context where this function is called */\n context?: SiteId;\n}): string => {\n const { baseUrl, languages } = targetSiteConfig;\n\n const targetSiteSupportedLanguage =\n // OK to cast as we are verifying `languages` is type of Language[]\n languages && languages.includes(language as Language)\n ? language\n : targetSiteConfig.defaultLanguage;\n\n /**\n * Dynamic based url based on which side it is\n */\n const url = new URL(baseUrl);\n\n const pathnameParts = pathnameToParts(pathname);\n\n /**\n * Flag to include storeId and language in the URL\n *\n * If context is generic, we don't need to include storeId and language and we want\n * to allow the target site to handle the language and storeId\n */\n const includeStoreIdAndLanguage = !(\n context && GENERIC_SITE_IDS.includes(context)\n );\n\n switch (siteId) {\n case SiteId.Store: {\n url.pathname = `${url.pathname.replace(/\\/$/, \"\")}${partsToPathname(\n targetSiteSupportedLanguage\n ? [targetSiteSupportedLanguage, ...pathnameParts] // New platform stores (FUN-FACT: base urls already include store id)\n : pathnameParts, // Shopify stores\n )}`;\n break;\n }\n case SiteId.Ui: {\n url.pathname = `${url.pathname.replace(/\\/$/, \"\")}${partsToPathname(\n targetSiteSupportedLanguage && // Do not add storeId and language if language is not supported\n includeStoreIdAndLanguage // Do not add storeId and language if context is generic\n ? [slugify(storeId), targetSiteSupportedLanguage, ...pathnameParts] // URL to specific region + language combo\n : pathnameParts, // To \"root\" page\n )}`;\n break;\n }\n case SiteId.Uisp: {\n url.pathname = `${url.pathname.replace(/\\/$/, \"\")}${partsToPathname(\n includeStoreIdAndLanguage // Do not add storeId and language if context is generic\n ? [slugify(storeId), ...pathnameParts] // URL to specific region\n : pathnameParts, // To \"root\" page\n )}`;\n break;\n }\n case SiteId.Amplifi:\n case SiteId.TechSpecs:\n case SiteId.ExpertsUi:\n case SiteId.ExpertsUisp: {\n url.pathname = `${url.pathname.replace(/\\/$/, \"\")}${pathname}`;\n break;\n }\n // eslint-disable-next-line sonarjs/no-duplicated-branches\n case SiteId.Uwc: {\n url.pathname = `${url.pathname.replace(/\\/$/, \"\")}${partsToPathname(\n targetSiteSupportedLanguage\n ? [targetSiteSupportedLanguage, ...pathnameParts]\n : pathnameParts,\n )}`;\n break;\n }\n default: {\n checkUnreachable(siteId);\n url.pathname = `${url.pathname.replace(/\\/$/, \"\")}${pathname}`;\n break;\n }\n }\n\n if (searchParams) {\n for (const [key, value] of Object.entries(searchParams)) {\n /**\n * Although we don't allow \"empty\" values, in runtime we had an issue if passing it, which failed this function,\n * seemed to be to dramatic so add actual runtime check if value is not null|undefined\n */\n if (value != null) {\n url.searchParams.set(key, value.toString());\n }\n }\n }\n\n /**\n * Add query parameters to force target site to use the correct store and language\n */\n if (addSiteConfigReferenceSearchParams) {\n // Add `s` for store query param\n if (storeId) {\n url.searchParams.set(\"s\", storeId);\n }\n\n // Add `l` for language query param\n if (targetSiteSupportedLanguage) {\n url.searchParams.set(\"l\", targetSiteSupportedLanguage);\n }\n }\n\n /**\n * Add fragment (a.k.a. hash #) if defined\n */\n if (fragment !== undefined) {\n url.hash = slugify(fragment.toString());\n }\n\n return url.toString();\n};\n\nexport const getPathname = (\n itemWithPath: Omit<NavigationPath, \"url\">,\n storeId: GlobalStoreId,\n) => {\n const storePath = itemWithPath.storePath?.[storeId];\n\n if (storePath === null) {\n return null;\n }\n\n return storePath ?? itemWithPath.path;\n};\n\nexport const getSubItemPath = (\n subItem: NavigationSubItem | NavigationSubSubItem,\n storeId: GlobalStoreId,\n isSubitemPathnameActive: (pathname: string) => boolean,\n): string | null => {\n // Multiple paths case\n if (subItem.path == null) {\n // Normalize paths\n const paths = (subItem.items ?? [])\n .map((item) => getSubItemPath(item, storeId, isSubitemPathnameActive))\n .filter((el): el is string => !!el);\n\n // Get the first active item\n const activePath = paths.find(isSubitemPathnameActive);\n\n // Return active path or the first item\n return activePath ?? paths[0] ?? null;\n }\n\n // Single path case\n return getPathname(subItem, storeId);\n};\n\nexport const getSubItemUrl = (\n subItem: NavigationSubItem | NavigationSubSubItem,\n isSubitemUrlActive: (siteUrl: SiteUrl) => boolean,\n): SiteUrl | null => {\n if (subItem.path === null && !subItem.url) {\n const urls = (subItem.items ?? [])\n .map((item) => getSubItemUrl(item, isSubitemUrlActive))\n .filter((el): el is SiteUrl => !!el);\n\n const activeUrl = urls.find(isSubitemUrlActive);\n\n return activeUrl ?? urls[0] ?? null;\n }\n\n return subItem.url ?? null;\n};\n\n/**\n * Util to check if given pathname (needle) is a subset of another path (haystack)\n */\nexport const isPartOfUrlPathname = (\n haystackPathname: string,\n needlePathname: string,\n): boolean => {\n /**\n * Ensure all paths end with a slash\n * This ensures \"some-path\" doesn't match \"some-path-extra\"\n * Since \"some-path/\" is not included in \"some-path-extra/\"\n */\n const normalisedHaystackPathname = ensureTrailingSlash(haystackPathname);\n const normalisedNeedlePathname = ensureTrailingSlash(needlePathname);\n return normalisedHaystackPathname.includes(normalisedNeedlePathname);\n};\n\n/**\n * Util that ensures given pathname ends with trailing slash\n * @example\n * ensureTrailingSlash('/a'); // '/a/'\n * ensureTrailingSlash('/a/'); // '/a/'\n */\nexport const ensureTrailingSlash = (pathname: string) =>\n pathname.replace(/\\/$/, \"\") + \"/\";\n\n/**\n * Util to easily find first possible link from nested \"subitem\"\n * @param items\n * @returns\n */\nexport const findFirstPossibleDeepNestedItemUrl = <\n Item extends\n | ParsedNavigationSubItem\n | ParsedNavigationItem\n | ParsedNavigationSubSubItem,\n>(\n items: Item[],\n): string | undefined => {\n return items.find((item) => item.possible)?.url;\n};\n\n/**\n * Filter out invisible products\n */\nexport const filterOutUnrenderableItems = <T extends NavigationInvisibleItem>(\n items: T[],\n) => {\n return items.filter((item) => !item.invisible);\n};\n\n// #############################################################################\n// Language\n// #############################################################################\n\nexport enum LanguageDirectionType {\n ltr = \"ltr\",\n rtl = \"rtl\",\n}\n\n/**\n * Get language direction from language\n */\nexport const getLanguageDirection = (language: Language) => {\n return language === Language.Ar\n ? LanguageDirectionType.rtl\n : LanguageDirectionType.ltr;\n};\n\n// #############################################################################\n// Global Site config\n// #############################################################################\nexport const getGlobalSiteConfig = (\n globalSiteConfig: GlobalSiteConfig,\n siteId: SiteId,\n storeId: GlobalStoreId | StoreId,\n): BasicSiteConfig => {\n const siteConfig = globalSiteConfig[siteId];\n\n assert(!!siteConfig, \"Missing SiteId in globalSiteConfig\");\n\n switch (siteConfig.type) {\n case SiteConfigType.Regional:\n return siteConfig.regions[storeId] ?? siteConfig.defaultRegion;\n case SiteConfigType.Basic:\n return siteConfig;\n default:\n assertUnreachable(siteConfig);\n }\n};\n"],"names":["parseSiteUrl","siteUrl","siteId","pathname","searchParams","fragment","storeId","addSiteConfigReferenceSearchParams","language","targetSiteConfig","context","baseUrl","languages","targetSiteSupportedLanguage","includes","defaultLanguage","url","URL","pathnameParts","pathnameToParts","includeStoreIdAndLanguage","GENERIC_SITE_IDS","SiteId","Store","replace","partsToPathname","Ui","slugify","Uisp","Amplifi","TechSpecs","ExpertsUi","ExpertsUisp","Uwc","checkUnreachable","key","value","Object","entries","set","toString","hash","getPathname","itemWithPath","storePath","path","getSubItemPath","subItem","isSubitemPathnameActive","paths","items","map","item","filter","el","activePath","find","getSubItemUrl","isSubitemUrlActive","urls","activeUrl","isPartOfUrlPathname","haystackPathname","needlePathname","normalisedHaystackPathname","ensureTrailingSlash","normalisedNeedlePathname","findFirstPossibleDeepNestedItemUrl","possible","filterOutUnrenderableItems","invisible","LanguageDirectionType","getLanguageDirection","Language","Ar","getGlobalSiteConfig","globalSiteConfig","siteConfig","assert","type","SiteConfigType","Regional","regions","defaultRegion","Basic","assertUnreachable"],"mappings":";;;;;;AAwBO,MAAMA,eAAeA,CAAC;EAC3BC,OAAS,EAAA,CAACC,MAAQ,EAAAC,QAAA,EAAUC,cAAcC,QAAQ,CAAA;EAClDC,OAAA;EACAC,kCAAA;EACAC,QAAA;EACAC,gBAAA;EACAC;AACF,CAQc,KAAA;EACN,MAAA;IAAEC,OAAS;IAAAC;EAAc,CAAA,GAAAH,gBAAA;EAEzB,MAAAI,2BAAA;EAAA;EAEJD,aAAaA,SAAU,CAAAE,QAAA,CAASN,QAAoB,CAAA,GAChDA,WACAC,gBAAiB,CAAAM,eAAA;EAKjB,MAAAC,GAAA,GAAM,IAAIC,GAAA,CAAIN,OAAO,CAAA;EAErB,MAAAO,aAAA,GAAgBC,gBAAgBhB,QAAQ,CAAA;EAQ9C,MAAMiB,yBAA4B,GAAA,EAChCV,OAAW,IAAAW,gBAAA,CAAiBP,SAASJ,OAAO,CAAA,CAAA;EAG9C,QAAQR,MAAQ;IACd,KAAKoB,OAAOC,KAAO;MAAA;QACbP,GAAA,CAAAb,QAAA,MAAca,GAAI,CAAAb,QAAA,CAASqB,QAAQ,KAAO,EAAA,EAAE,CAAI,GAAAC,eAAA,CAClDZ,2BACI,GAAA,CAACA,2BAA6B,EAAA,GAAGK,aAAa,CAC9C,GAAAA;QAAA;QACL,CAAA,EAAA;QACD;MACF;IACA,KAAKI,OAAOI,EAAI;MAAA;QACVV,GAAA,CAAAb,QAAA,MAAca,GAAI,CAAAb,QAAA,CAASqB,QAAQ,KAAO,EAAA,EAAE,CAAI,GAAAC,eAAA,CAClDZ,2BAAA;QAA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AAM,CAAA,GAAA,KAAA;EAFIA,OAAAA,sBAAAA;AAAA,CAAA,EAAAA,qBAAA,IAAA,CAAA,CAAA,CAAA;AAQC,MAAAC,oBAAA,GAAwBhE,QAAuB,IAAA;EACnD,OAAAA,QAAA,KAAaiE,QAAS,CAAAC,EAAA,GACzB,KACA,CAAA,YAAA,KAAA,CAAA;AACN,CAAA;AAKO,MAAMC,mBAAsB,GAAAA,CACjCC,gBACA,EAAA1E,MAAA,EACAI,OACoB,KAAA;EACd,MAAAuE,UAAA,GAAaD,iBAAiB1E,MAAM,CAAA;EAEnC4E,MAAA,CAAA,CAAC,CAACD,UAAA,EAAY,oCAAoC,CAAA;EAEzD,QAAQA,WAAWE,IAAM;IACvB,KAAKC,cAAe,CAAAC,QAAA;MAClB,OAAOJ,UAAW,CAAAK,OAAA,CAAQ5E,OAAO,CAAA,IAAKuE,UAAW,CAAAM,aAAA;IACnD,KAAKH,cAAe,CAAAI,KAAA;MACX,OAAAP,UAAA;IACT;MACEQ,iBAAA,CAAkBR,UAAU,CAAA;EAChC;AACF,CAAA;"}
|
|
1
|
+
{"version":3,"file":"utils.mjs","sources":["../../../src/contexts/MenuContext/utils.ts"],"sourcesContent":["import type { GlobalStoreId, StoreId } from \"../../types\";\nimport {\n assert,\n assertUnreachable,\n checkUnreachable,\n} from \"../../utils/errors\";\nimport { partsToPathname, pathnameToParts, slugify } from \"../../utils/url\";\nimport type {\n NavigationInvisibleItem,\n NavigationPath,\n NavigationSubItem,\n NavigationSubSubItem,\n SiteUrl,\n} from \"./mapping\";\nimport { GENERIC_SITE_IDS, Language, SiteId } from \"./mapping\";\nimport type { BasicSiteConfig } from \"./types\";\nimport {\n type GlobalSiteConfig,\n type ParsedNavigationItem,\n type ParsedNavigationSubItem,\n type ParsedNavigationSubSubItem,\n SiteConfigType,\n} from \"./types\";\n\nexport const parseSiteUrl = ({\n siteUrl: [siteId, pathname, searchParams, fragment],\n storeId,\n addSiteConfigReferenceSearchParams,\n language,\n targetSiteConfig,\n context,\n}: {\n siteUrl: SiteUrl;\n storeId: GlobalStoreId;\n addSiteConfigReferenceSearchParams: boolean;\n language: `${Language}`;\n targetSiteConfig: BasicSiteConfig;\n /** Current context where this function is called */\n context?: SiteId;\n}): string => {\n const { baseUrl, languages } = targetSiteConfig;\n\n const targetSiteSupportedLanguage =\n // OK to cast as we are verifying `languages` is type of Language[]\n languages && languages.includes(language as Language)\n ? language\n : targetSiteConfig.defaultLanguage;\n\n /**\n * Dynamic based url based on which side it is\n */\n const url = new URL(baseUrl);\n\n const pathnameParts = pathnameToParts(pathname);\n\n /**\n * Flag to include storeId and language in the URL\n *\n * If context is generic, we don't need to include storeId and language and we want\n * to allow the target site to handle the language and storeId\n */\n const includeStoreIdAndLanguage = !(\n context && GENERIC_SITE_IDS.includes(context)\n );\n\n switch (siteId) {\n case SiteId.Store: {\n url.pathname = `${url.pathname.replace(/\\/$/, \"\")}${partsToPathname(\n targetSiteSupportedLanguage\n ? [targetSiteSupportedLanguage, ...pathnameParts] // New platform stores (FUN-FACT: base urls already include store id)\n : pathnameParts, // Shopify stores\n )}`;\n break;\n }\n case SiteId.Ui: {\n url.pathname = `${url.pathname.replace(/\\/$/, \"\")}${partsToPathname(\n targetSiteSupportedLanguage && // Do not add storeId and language if language is not supported\n includeStoreIdAndLanguage // Do not add storeId and language if context is generic\n ? [slugify(storeId), targetSiteSupportedLanguage, ...pathnameParts] // URL to specific region + language combo\n : pathnameParts, // To \"root\" page\n )}`;\n break;\n }\n case SiteId.Uisp: {\n url.pathname = `${url.pathname.replace(/\\/$/, \"\")}${partsToPathname(\n includeStoreIdAndLanguage // Do not add storeId and language if context is generic\n ? [slugify(storeId), ...pathnameParts] // URL to specific region\n : pathnameParts, // To \"root\" page\n )}`;\n break;\n }\n case SiteId.Amplifi:\n case SiteId.TechSpecs:\n case SiteId.ExpertsUi:\n case SiteId.ExpertsUisp:\n case SiteId.Experts: {\n url.pathname = `${url.pathname.replace(/\\/$/, \"\")}${pathname}`;\n break;\n }\n default: {\n checkUnreachable(siteId);\n url.pathname = `${url.pathname.replace(/\\/$/, \"\")}${pathname}`;\n break;\n }\n }\n\n if (searchParams) {\n for (const [key, value] of Object.entries(searchParams)) {\n /**\n * Although we don't allow \"empty\" values, in runtime we had an issue if passing it, which failed this function,\n * seemed to be to dramatic so add actual runtime check if value is not null|undefined\n */\n if (value != null) {\n url.searchParams.set(key, value.toString());\n }\n }\n }\n\n /**\n * Add query parameters to force target site to use the correct store and language\n */\n if (addSiteConfigReferenceSearchParams) {\n // Add `s` for store query param\n if (storeId) {\n url.searchParams.set(\"s\", storeId);\n }\n\n // Add `l` for language query param\n if (targetSiteSupportedLanguage) {\n url.searchParams.set(\"l\", targetSiteSupportedLanguage);\n }\n }\n\n /**\n * Add fragment (a.k.a. hash #) if defined\n */\n if (fragment !== undefined) {\n url.hash = slugify(fragment.toString());\n }\n\n return url.toString();\n};\n\nexport const getPathname = (\n itemWithPath: Omit<NavigationPath, \"url\">,\n storeId: GlobalStoreId,\n) => {\n const storePath = itemWithPath.storePath?.[storeId];\n\n if (storePath === null) {\n return null;\n }\n\n return storePath ?? itemWithPath.path;\n};\n\nexport const getSubItemPath = (\n subItem: NavigationSubItem | NavigationSubSubItem,\n storeId: GlobalStoreId,\n isSubitemPathnameActive: (pathname: string) => boolean,\n): string | null => {\n // Multiple paths case\n if (subItem.path == null) {\n // Normalize paths\n const paths = (subItem.items ?? [])\n .map((item) => getSubItemPath(item, storeId, isSubitemPathnameActive))\n .filter((el): el is string => !!el);\n\n // Get the first active item\n const activePath = paths.find(isSubitemPathnameActive);\n\n // Return active path or the first item\n return activePath ?? paths[0] ?? null;\n }\n\n // Single path case\n return getPathname(subItem, storeId);\n};\n\nexport const getSubItemUrl = (\n subItem: NavigationSubItem | NavigationSubSubItem,\n isSubitemUrlActive: (siteUrl: SiteUrl) => boolean,\n): SiteUrl | null => {\n if (subItem.path === null && !subItem.url) {\n const urls = (subItem.items ?? [])\n .map((item) => getSubItemUrl(item, isSubitemUrlActive))\n .filter((el): el is SiteUrl => !!el);\n\n const activeUrl = urls.find(isSubitemUrlActive);\n\n return activeUrl ?? urls[0] ?? null;\n }\n\n return subItem.url ?? null;\n};\n\n/**\n * Util to check if given pathname (needle) is a subset of another path (haystack)\n */\nexport const isPartOfUrlPathname = (\n haystackPathname: string,\n needlePathname: string,\n): boolean => {\n /**\n * Ensure all paths end with a slash\n * This ensures \"some-path\" doesn't match \"some-path-extra\"\n * Since \"some-path/\" is not included in \"some-path-extra/\"\n */\n const normalisedHaystackPathname = ensureTrailingSlash(haystackPathname);\n const normalisedNeedlePathname = ensureTrailingSlash(needlePathname);\n return normalisedHaystackPathname.includes(normalisedNeedlePathname);\n};\n\n/**\n * Util that ensures given pathname ends with trailing slash\n * @example\n * ensureTrailingSlash('/a'); // '/a/'\n * ensureTrailingSlash('/a/'); // '/a/'\n */\nexport const ensureTrailingSlash = (pathname: string) =>\n pathname.replace(/\\/$/, \"\") + \"/\";\n\n/**\n * Util to easily find first possible link from nested \"subitem\"\n * @param items\n * @returns\n */\nexport const findFirstPossibleDeepNestedItemUrl = <\n Item extends\n | ParsedNavigationSubItem\n | ParsedNavigationItem\n | ParsedNavigationSubSubItem,\n>(\n items: Item[],\n): string | undefined => {\n return items.find((item) => item.possible)?.url;\n};\n\n/**\n * Filter out invisible products\n */\nexport const filterOutUnrenderableItems = <T extends NavigationInvisibleItem>(\n items: T[],\n) => {\n return items.filter((item) => !item.invisible);\n};\n\n// #############################################################################\n// Language\n// #############################################################################\n\nexport enum LanguageDirectionType {\n ltr = \"ltr\",\n rtl = \"rtl\",\n}\n\n/**\n * Get language direction from language\n */\nexport const getLanguageDirection = (language: Language) => {\n return language === Language.Ar\n ? LanguageDirectionType.rtl\n : LanguageDirectionType.ltr;\n};\n\n// #############################################################################\n// Global Site config\n// #############################################################################\nexport const getGlobalSiteConfig = (\n globalSiteConfig: GlobalSiteConfig,\n siteId: SiteId,\n storeId: GlobalStoreId | StoreId,\n): BasicSiteConfig => {\n const siteConfig = globalSiteConfig[siteId];\n\n assert(!!siteConfig, \"Missing SiteId in globalSiteConfig\");\n\n switch (siteConfig.type) {\n case SiteConfigType.Regional:\n return siteConfig.regions[storeId] ?? siteConfig.defaultRegion;\n case SiteConfigType.Basic:\n return siteConfig;\n default:\n assertUnreachable(siteConfig);\n }\n};\n"],"names":["parseSiteUrl","siteUrl","siteId","pathname","searchParams","fragment","storeId","addSiteConfigReferenceSearchParams","language","targetSiteConfig","context","baseUrl","languages","targetSiteSupportedLanguage","includes","defaultLanguage","url","URL","pathnameParts","pathnameToParts","includeStoreIdAndLanguage","GENERIC_SITE_IDS","SiteId","Store","replace","partsToPathname","Ui","slugify","Uisp","Amplifi","TechSpecs","ExpertsUi","ExpertsUisp","Experts","checkUnreachable","key","value","Object","entries","set","toString","hash","getPathname","itemWithPath","storePath","path","getSubItemPath","subItem","isSubitemPathnameActive","paths","items","map","item","filter","el","activePath","find","getSubItemUrl","isSubitemUrlActive","urls","activeUrl","isPartOfUrlPathname","haystackPathname","needlePathname","normalisedHaystackPathname","ensureTrailingSlash","normalisedNeedlePathname","findFirstPossibleDeepNestedItemUrl","possible","filterOutUnrenderableItems","invisible","LanguageDirectionType","getLanguageDirection","Language","Ar","getGlobalSiteConfig","globalSiteConfig","siteConfig","assert","type","SiteConfigType","Regional","regions","defaultRegion","Basic","assertUnreachable"],"mappings":";;;;;;AAwBO,MAAMA,eAAeA,CAAC;EAC3BC,OAAS,EAAA,CAACC,MAAQ,EAAAC,QAAA,EAAUC,cAAcC,QAAQ,CAAA;EAClDC,OAAA;EACAC,kCAAA;EACAC,QAAA;EACAC,gBAAA;EACAC;AACF,CAQc,KAAA;EACN,MAAA;IAAEC,OAAS;IAAAC;EAAc,CAAA,GAAAH,gBAAA;EAEzB,MAAAI,2BAAA;EAAA;EAEJD,aAAaA,SAAU,CAAAE,QAAA,CAASN,QAAoB,CAAA,GAChDA,WACAC,gBAAiB,CAAAM,eAAA;EAKjB,MAAAC,GAAA,GAA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AE,CAAI,GAAA,GAAA;AAOnB,MAAA2C,kCAAA,GAMXjB,KACuB,IAAA;EACvB,OAAOA,MAAMM,IAAK,CAACJ,IAAS,IAAAA,IAAA,CAAKgB,QAAQ,CAAG,EAAApD,GAAA;AAC9C,CAAA;AAKa,MAAAqD,0BAAA,GACXnB,KACG,IAAA;EACH,OAAOA,MAAMG,MAAO,CAACD,IAAS,IAAA,CAACA,KAAKkB,SAAS,CAAA;AAC/C,CAAA;AAMY,IAAAC,qBAAA,GAAA,gBAAAA,sBAAL,IAAA;EACLA,uBAAA,KAAM,CAAA,GAAA,KAAA;EACNA,uBAAA,KAAM,CAAA,GAAA,KAAA;EAFIA,OAAAA,sBAAAA;AAAA,CAAA,EAAAA,qBAAA,IAAA,CAAA,CAAA,CAAA;AAQC,MAAAC,oBAAA,GAAwBhE,QAAuB,IAAA;EACnD,OAAAA,QAAA,KAAaiE,QAAS,CAAAC,EAAA,GACzB,KACA,CAAA,YAAA,KAAA,CAAA;AACN,CAAA;AAKO,MAAMC,mBAAsB,GAAAA,CACjCC,gBACA,EAAA1E,MAAA,EACAI,OACoB,KAAA;EACd,MAAAuE,UAAA,GAAaD,iBAAiB1E,MAAM,CAAA;EAEnC4E,MAAA,CAAA,CAAC,CAACD,UAAA,EAAY,oCAAoC,CAAA;EAEzD,QAAQA,WAAWE,IAAM;IACvB,KAAKC,cAAe,CAAAC,QAAA;MAClB,OAAOJ,UAAW,CAAAK,OAAA,CAAQ5E,OAAO,CAAA,IAAKuE,UAAW,CAAAM,aAAA;IACnD,KAAKH,cAAe,CAAAI,KAAA;MACX,OAAAP,UAAA;IACT;MACEQ,iBAAA,CAAkBR,UAAU,CAAA;EAChC;AACF,CAAA;"}
|
package/lib/helpers/index.d.ts
CHANGED
package/lib/helpers/index.js
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
3
|
var proStoreCategories = require('./proStoreCategories.js');
|
|
4
|
-
var product = require('./product.js');
|
|
5
4
|
"use strict";
|
|
6
5
|
exports.getCategoriesBySubcategory = proStoreCategories.getCategoriesBySubcategory;
|
|
7
6
|
exports.getLocalizedCategories = proStoreCategories.getLocalizedCategories;
|
|
@@ -11,14 +10,4 @@ exports.getSubCategoryIdByCollectionSlug = proStoreCategories.getSubCategoryIdBy
|
|
|
11
10
|
exports.isValidSubCategory = proStoreCategories.isValidSubCategory;
|
|
12
11
|
exports.parseCategories = proStoreCategories.parseCategories;
|
|
13
12
|
exports.useTranslatedCategories = proStoreCategories.useTranslatedCategories;
|
|
14
|
-
exports.COLLECTION_SECTION_OTHER_ID = product.COLLECTION_SECTION_OTHER_ID;
|
|
15
|
-
exports.HDDProductSlugs = product.HDDProductSlugs;
|
|
16
|
-
exports.MagicCollectionTags = product.MagicCollectionTags;
|
|
17
|
-
exports.ProductOptions = product.ProductOptions;
|
|
18
|
-
exports.createSectionHierarchy = product.createSectionHierarchy;
|
|
19
|
-
exports.getProStoreCategory = product.getProStoreCategory;
|
|
20
|
-
exports.getProductGroups = product.getProductGroups;
|
|
21
|
-
exports.getStoreProducts = product.getStoreProducts;
|
|
22
|
-
exports.isNonNullish = product.isNonNullish;
|
|
23
|
-
exports.removeExcludedProducts = product.removeExcludedProducts;
|
|
24
13
|
//# sourceMappingURL=index.js.map
|
package/lib/helpers/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/helpers/index.mjs
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
1
|
export { getCategoriesBySubcategory, getLocalizedCategories, getProductLineByCategory, getProductLineBySubcategory, getSubCategoryIdByCollectionSlug, isValidSubCategory, parseCategories, useTranslatedCategories } from './proStoreCategories.mjs';
|
|
2
|
-
export { COLLECTION_SECTION_OTHER_ID, HDDProductSlugs, MagicCollectionTags, ProductOptions, createSectionHierarchy, getProStoreCategory, getProductGroups, getStoreProducts, isNonNullish, removeExcludedProducts } from './product.mjs';
|
|
3
2
|
"use strict";
|
|
4
3
|
//# sourceMappingURL=index.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.mjs","sources":[],"sourcesContent":[],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.mjs","sources":[],"sourcesContent":[],"names":[],"mappings":";"}
|
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,mB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AAA;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,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,GAGvC,CAAA;AAAA;AAAA;AAAA;AAIA,CAACS,UAAI,CAAAA,GAAA,CAAAP,IAAA,EAAM,CAAC,CAAA,EAAGQ,SAAM,CAAAA,MAAA,CAAC,CAAA,CACvB,CAAA;AAMY,MAAAC,wBAAA,GAAA,mBAA+BX,GAAI,CAAA,CAC9C,CAACG,UAAI,CAAAA,GAAA,CAAAD,IAAA,EAAM,GAAK,CAAA,EAChB,CAACE,UAAI,CAAAA,GAAA,CAAAF,IAAA,EAAM,GAAK,CAAA,EAChB,CAACI,UAAI,CAAAA,GAAA,CAAAJ,IAAA,EAAM,GAAK,CAAA,CACjB,CAAA;AAmBM,MAAMU,cA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GAAK;EAAAS,MAAA,EAAQ;CAAS,CAAA,EACjD,CAACH,SAAAA,CAAAA,SAASsC,GAAK,EAAA;EAAEpC,UAAUqC,UAAAA,CAAAA,GAAK;EAAApC,MAAA,EAAQ;CAAS,CAAA,CAClD,CAAA;;;;;"}
|
|
@@ -1,35 +1,8 @@
|
|
|
1
1
|
import { USD, CAD, EUR, GBP, AED, ZAR, TWD, BGN, CHF, CZK, DKK, HRK, HUF, NOK, PLN, RON, SEK, INR, SGD, BRL, JPY, MXN } from '@dinero.js/currencies';
|
|
2
|
-
import {
|
|
2
|
+
import { halfUp, halfEven } from 'dinero.js';
|
|
3
3
|
import '../../types/index.mjs';
|
|
4
|
-
import { Currency
|
|
4
|
+
import { Currency } from '../../types/generated.mjs';
|
|
5
5
|
"use strict";
|
|
6
|
-
const Round = {
|
|
7
|
-
/**
|
|
8
|
-
* ⚠️ Instead of using Math.round, we HAVE to use this method to round the financial numbers everywhere where we CAN'T
|
|
9
|
-
* deal with dinero.js (Dinero.js should be the priority). But often for converting from API requests we have to
|
|
10
|
-
* normalise the values so we use this method.
|
|
11
|
-
*
|
|
12
|
-
* It just a re-export of the dinero.js halfEven (a.k.a bankers rounding) method which is the default rounding method.
|
|
13
|
-
* @see https://github.com/dinerojs/dinero.js/blob/main/packages/core/src/round/halfEven.ts
|
|
14
|
-
* @see
|
|
15
|
-
*
|
|
16
|
-
* Compared to Math.round (arithmetic rounding) it differentiates that it changes the `.5` round up or down behaviour based on if the rounded
|
|
17
|
-
* number would be an even number. So 1.5 would round to 2 while 2.5 would round to 2.
|
|
18
|
-
* See the youtube link below for a brief exclamation on why it's important to use this method over regular rounding (half-up):
|
|
19
|
-
* https://youtu.be/yuRdYlZvs1E
|
|
20
|
-
*
|
|
21
|
-
* If you really want to get knee-deep in the rounding subject, you can read the following:
|
|
22
|
-
* https://en.wikipedia.org/wiki/Rounding#Round_half_toward_zero
|
|
23
|
-
*/
|
|
24
|
-
Financial: halfEven,
|
|
25
|
-
// TODO: maybe we should have separate rounding functions depending on the input value?
|
|
26
|
-
// Reading from wiki "Round half toward zero" is better if the value is already "normalized to cents"
|
|
27
|
-
// But the "Round half to even" seems better for when working with float like values
|
|
28
|
-
// financialRound = Math.round;
|
|
29
|
-
Shipping: down,
|
|
30
|
-
Prettify: down,
|
|
31
|
-
Subunit: halfUp
|
|
32
|
-
};
|
|
33
6
|
const prettifyPriceLookup = /* @__PURE__ */new Map([[USD.code, 20], [CAD.code, 20], [EUR.code, 20], [GBP.code, 20], [AED.code, 50],
|
|
34
7
|
// Approximately every price above ~1.1 usd will be rounded in ZAR
|
|
35
8
|
[ZAR.code, 20]]);
|
|
@@ -37,8 +10,10 @@ const smallestSubunitLookup = /* @__PURE__ */new Map([
|
|
|
37
10
|
/**
|
|
38
11
|
* TWD does not use subunits at all in day to day transactions.
|
|
39
12
|
*/
|
|
40
|
-
[TWD.code, [0,
|
|
41
|
-
const
|
|
13
|
+
[TWD.code, [0, halfUp]]]);
|
|
14
|
+
const maximumPriceFilterLookup = /* @__PURE__ */new Map([[CAD.code, 7e4], [EUR.code, 7e4], [AED.code, 7e4]]);
|
|
15
|
+
const financialRound = halfEven;
|
|
16
|
+
const currencyObjLookup = /* @__PURE__ */new Map([[Currency.Aed, {
|
|
42
17
|
currency: AED,
|
|
43
18
|
locale: "ar-AE"
|
|
44
19
|
}], [Currency.Bgn, {
|
|
@@ -109,43 +84,5 @@ const localizedCurrencyLookup = /* @__PURE__ */new Map([[Currency.Aed, {
|
|
|
109
84
|
currency: MXN,
|
|
110
85
|
locale: "es-MX"
|
|
111
86
|
}]]);
|
|
112
|
-
|
|
113
|
-
// #############################################################################
|
|
114
|
-
// Stores with custom tax rates
|
|
115
|
-
// #############################################################################
|
|
116
|
-
StoreId.Br, StoreId.Tw
|
|
117
|
-
// #############################################################################
|
|
118
|
-
// Stores with Avalara, but will have custom company codes to treat
|
|
119
|
-
// FIXME: as PR is rushed we where able to test stores avalara custom codes that enable logic that calculates tax
|
|
120
|
-
// "per quantity", so for now disabling this logic and only applying to store with custom tax rates
|
|
121
|
-
// #############################################################################
|
|
122
|
-
// StoreId.Jp,
|
|
123
|
-
// StoreId.Sg,
|
|
124
|
-
]);
|
|
125
|
-
const TAX_RATE_DINERO_CURRENCY = {
|
|
126
|
-
base: 10,
|
|
127
|
-
/**
|
|
128
|
-
* We expect the tax rate to be in the range of 0..1
|
|
129
|
-
* 0 --> 0%
|
|
130
|
-
* 1 --> 100%
|
|
131
|
-
* 0.21 --> 21%
|
|
132
|
-
* 0.2169 --> 21.69%
|
|
133
|
-
* 0.12345678 --> 12.345678%
|
|
134
|
-
* !!! Don't change as this value is tied to store.backend DB schema !!!
|
|
135
|
-
*/
|
|
136
|
-
exponent: 8,
|
|
137
|
-
code: ""
|
|
138
|
-
// Not important
|
|
139
|
-
};
|
|
140
|
-
const EXCHANGE_RATE_DINERO_CURRENCY = {
|
|
141
|
-
base: 10,
|
|
142
|
-
/**
|
|
143
|
-
* We support having certain decimal places for exchange rates
|
|
144
|
-
* !!! Don't change as this value is tied to store.backend DB schema !!!
|
|
145
|
-
*/
|
|
146
|
-
exponent: 6,
|
|
147
|
-
code: ""
|
|
148
|
-
// Not important
|
|
149
|
-
};
|
|
150
|
-
export { EXCHANGE_RATE_DINERO_CURRENCY, Round, TAX_RATE_DINERO_CURRENCY, localizedCurrencyLookup, prettifyPriceLookup, smallestSubunitLookup, storesWithPerItemTaxRate };
|
|
87
|
+
export { currencyObjLookup, financialRound, maximumPriceFilterLookup, prettifyPriceLookup, smallestSubunitLookup };
|
|
151
88
|
//# sourceMappingURL=constants.mjs.map
|