@ubnt/store.core 9.12.1 → 9.13.0-alpha.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 +103 -0
- package/lib/_virtual/_virtual_multi-entry.js +15 -2
- package/lib/_virtual/_virtual_multi-entry.js.map +1 -1
- package/lib/_virtual/_virtual_multi-entry.mjs +2 -0
- package/lib/_virtual/_virtual_multi-entry.mjs.map +1 -1
- package/lib/assets/ai360.jpg +0 -0
- package/lib/assets/attention.svg +5 -5
- package/lib/assets/attention2.svg +5 -5
- package/lib/assets/close.svg +1 -3
- package/lib/assets/close2.svg +3 -1
- package/lib/assets/efg.png +0 -0
- package/lib/assets/g5-ptz.jpg +0 -0
- package/lib/assets/g5Ptz.jpg +0 -0
- package/lib/assets/group.svg +6 -0
- package/lib/assets/keyFeatures/group.svg +6 -0
- package/lib/{components/Explore/assets/ProAV.jpg.js → assets/keyFeatures/group.svg.js} +6 -6
- package/lib/assets/keyFeatures/group.svg.js.map +1 -0
- package/lib/assets/keyFeatures/group.svg.mjs +3 -0
- package/lib/assets/keyFeatures/group.svg.mjs.map +1 -0
- package/lib/assets/keyFeatures/music.svg +3 -0
- package/lib/{components/Explore/LensCompare/assets/ai360.jpg.js → assets/keyFeatures/music.svg.js} +6 -6
- package/lib/assets/keyFeatures/music.svg.js.map +1 -0
- package/lib/assets/keyFeatures/music.svg.mjs +3 -0
- package/lib/assets/keyFeatures/music.svg.mjs.map +1 -0
- package/lib/assets/music.svg +3 -0
- package/lib/assets/powerAmp.jpg +0 -0
- package/lib/assets/powerAmp.svg +3 -0
- package/lib/assets/ucg-max.png +0 -0
- package/lib/assets/ucgMax.jpg +0 -0
- package/lib/assets/ucgMax2.jpg +0 -0
- package/lib/assets/ucgUltra.jpg +0 -0
- package/lib/assets/ucgUltra2.jpg +0 -0
- package/lib/assets/udmPro.jpg +0 -0
- package/lib/assets/udmPro2.jpg +0 -0
- package/lib/assets/udr.jpg +0 -0
- package/lib/assets/udr2.jpg +0 -0
- package/lib/assets/udw.jpg +0 -0
- package/lib/assets/udw2.jpg +0 -0
- package/lib/assets/umr.jpg +0 -0
- package/lib/assets/umr2.jpg +0 -0
- package/lib/assets/volume-on2.svg +3 -0
- package/lib/assets/wideAngle.jpg +0 -0
- package/lib/components/CustomImage/CustomImage.js +1 -1
- package/lib/components/CustomImage/CustomImage.mjs +1 -1
- package/lib/components/Explore/Explore.js +2 -9
- package/lib/components/Explore/Explore.js.map +1 -1
- package/lib/components/Explore/Explore.mjs +2 -9
- package/lib/components/Explore/Explore.mjs.map +1 -1
- package/lib/components/Explore/ExploreData.d.ts +4 -7
- package/lib/components/Explore/ExploreData.js +88 -138
- package/lib/components/Explore/ExploreData.js.map +1 -1
- package/lib/components/Explore/ExploreData.mjs +80 -128
- package/lib/components/Explore/ExploreData.mjs.map +1 -1
- 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/{g4-ptz.jpg.js → g4Ptz.jpg.js} +2 -2
- package/lib/components/Explore/assets/g4Ptz.jpg.js.map +1 -0
- package/lib/components/Explore/assets/g4Ptz.jpg.mjs +3 -0
- package/lib/components/Explore/assets/g4Ptz.jpg.mjs.map +1 -0
- package/lib/components/Explore/assets/{g5-ptz.jpg.js → g5Ptz.jpg.js} +2 -2
- package/lib/components/Explore/assets/g5Ptz.jpg.js.map +1 -0
- package/lib/components/Explore/assets/g5Ptz.jpg.mjs +3 -0
- package/lib/components/Explore/assets/g5Ptz.jpg.mjs.map +1 -0
- package/lib/components/Explore/assets/{AITheta.jpg.js → powerAmp.jpg.js} +6 -6
- package/lib/components/Explore/assets/powerAmp.jpg.js.map +1 -0
- package/lib/components/Explore/assets/powerAmp.jpg.mjs +3 -0
- package/lib/components/Explore/assets/powerAmp.jpg.mjs.map +1 -0
- package/lib/components/Explore/assets/udr.jpg.js +27 -0
- package/lib/components/Explore/assets/udr.jpg.js.map +1 -0
- package/lib/components/Explore/assets/udr.jpg.mjs +3 -0
- package/lib/components/Explore/assets/udr.jpg.mjs.map +1 -0
- package/lib/components/Explore/assets/udw.jpg.js +27 -0
- package/lib/components/Explore/assets/udw.jpg.js.map +1 -0
- package/lib/components/Explore/assets/udw.jpg.mjs +3 -0
- package/lib/components/Explore/assets/udw.jpg.mjs.map +1 -0
- package/lib/components/Explore/assets/umr.jpg.js +27 -0
- package/lib/components/Explore/assets/umr.jpg.js.map +1 -0
- package/lib/components/Explore/assets/umr.jpg.mjs +3 -0
- package/lib/components/Explore/assets/umr.jpg.mjs.map +1 -0
- package/lib/components/Explore/assets/ux.jpg.js +27 -0
- package/lib/components/Explore/assets/ux.jpg.js.map +1 -0
- package/lib/components/Explore/assets/ux.jpg.mjs +3 -0
- package/lib/components/Explore/assets/ux.jpg.mjs.map +1 -0
- package/lib/components/Explore/translations/ar.json.js +19 -0
- package/lib/components/Explore/translations/ar.json.js.map +1 -1
- package/lib/components/Explore/translations/ar.json.mjs +19 -0
- package/lib/components/Explore/translations/ar.json.mjs.map +1 -1
- package/lib/components/Explore/translations/de.json.js +19 -0
- package/lib/components/Explore/translations/de.json.js.map +1 -1
- package/lib/components/Explore/translations/de.json.mjs +19 -0
- package/lib/components/Explore/translations/de.json.mjs.map +1 -1
- package/lib/components/Explore/translations/el.json.js +19 -0
- package/lib/components/Explore/translations/el.json.js.map +1 -1
- package/lib/components/Explore/translations/el.json.mjs +19 -0
- package/lib/components/Explore/translations/el.json.mjs.map +1 -1
- package/lib/components/Explore/translations/en.json.js +11 -30
- package/lib/components/Explore/translations/en.json.js.map +1 -1
- package/lib/components/Explore/translations/en.json.mjs +12 -30
- package/lib/components/Explore/translations/en.json.mjs.map +1 -1
- package/lib/components/Explore/translations/es.json.js +101 -82
- package/lib/components/Explore/translations/es.json.js.map +1 -1
- package/lib/components/Explore/translations/es.json.mjs +101 -82
- package/lib/components/Explore/translations/es.json.mjs.map +1 -1
- package/lib/components/Explore/translations/fr.json.js +19 -0
- package/lib/components/Explore/translations/fr.json.js.map +1 -1
- package/lib/components/Explore/translations/fr.json.mjs +19 -0
- package/lib/components/Explore/translations/fr.json.mjs.map +1 -1
- package/lib/components/Explore/translations/it.json.js +19 -0
- package/lib/components/Explore/translations/it.json.js.map +1 -1
- package/lib/components/Explore/translations/it.json.mjs +19 -0
- package/lib/components/Explore/translations/it.json.mjs.map +1 -1
- package/lib/components/Explore/translations/ja.json.js +19 -0
- package/lib/components/Explore/translations/ja.json.js.map +1 -1
- package/lib/components/Explore/translations/ja.json.mjs +19 -0
- package/lib/components/Explore/translations/ja.json.mjs.map +1 -1
- package/lib/components/Explore/translations/pt-BR.json.js +19 -0
- package/lib/components/Explore/translations/pt-BR.json.js.map +1 -1
- package/lib/components/Explore/translations/pt-BR.json.mjs +19 -0
- package/lib/components/Explore/translations/pt-BR.json.mjs.map +1 -1
- package/lib/components/Explore/translations/zh-Hans.json.js +19 -0
- package/lib/components/Explore/translations/zh-Hans.json.js.map +1 -1
- package/lib/components/Explore/translations/zh-Hans.json.mjs +19 -0
- package/lib/components/Explore/translations/zh-Hans.json.mjs.map +1 -1
- package/lib/components/Explore/translations/zh-Hant-TW.json.js +19 -0
- package/lib/components/Explore/translations/zh-Hant-TW.json.js.map +1 -1
- package/lib/components/Explore/translations/zh-Hant-TW.json.mjs +19 -0
- package/lib/components/Explore/translations/zh-Hant-TW.json.mjs.map +1 -1
- package/lib/components/GridGallery/GridModal/GridModal.js +1 -1
- package/lib/components/GridGallery/GridModal/GridModal.mjs +1 -1
- package/lib/components/Header/CartModalV2/CartModal.js +1 -1
- package/lib/components/Header/CartModalV2/CartModal.mjs +1 -1
- package/lib/components/Header/Header.js +2 -1
- package/lib/components/Header/Header.js.map +1 -1
- package/lib/components/Header/Header.mjs +2 -1
- package/lib/components/Header/Header.mjs.map +1 -1
- package/lib/components/LandingPagePro/LandingPagePro.d.ts +3 -0
- 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/LandingPageSidebar/LandingPageSidebar.js +1 -1
- package/lib/components/LandingPageSidebar/LandingPageSidebar.mjs +1 -1
- package/lib/components/ModelCompareV3/ModelCompareV3.types.d.ts +1 -0
- package/lib/components/ModelCompareV3/assets/Consoles/bigCompare/ucgMax.jpg.js +5 -5
- package/lib/components/ModelCompareV3/assets/Consoles/bigCompare/ucgMax.jpg.mjs +2 -2
- package/lib/components/ModelCompareV3/assets/Consoles/bigCompare/ucgUltra.jpg.js +5 -5
- package/lib/components/ModelCompareV3/assets/Consoles/bigCompare/ucgUltra.jpg.mjs +2 -2
- package/lib/components/ModelCompareV3/assets/Consoles/bigCompare/udmPro.jpg.js +5 -5
- package/lib/components/ModelCompareV3/assets/Consoles/bigCompare/udmPro.jpg.mjs +2 -2
- 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/Consoles/ucgMax.jpg.js +1 -1
- package/lib/components/ModelCompareV3/assets/Consoles/ucgMax.jpg.mjs +2 -2
- package/lib/components/ModelCompareV3/assets/Consoles/ucgUltra.jpg.js +1 -1
- package/lib/components/ModelCompareV3/assets/Consoles/ucgUltra.jpg.mjs +2 -2
- package/lib/components/ModelCompareV3/assets/Consoles/udmPro.jpg.js +1 -1
- package/lib/components/ModelCompareV3/assets/Consoles/udmPro.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/assets/volume-on.svg.js +27 -0
- package/lib/components/ModelCompareV3/assets/volume-on.svg.js.map +1 -0
- package/lib/components/ModelCompareV3/assets/volume-on.svg.mjs +3 -0
- package/lib/components/ModelCompareV3/assets/volume-on.svg.mjs.map +1 -0
- package/lib/components/ModelCompareV3/data/CloudGateways.js +11 -11
- package/lib/components/ModelCompareV3/data/CloudGateways.mjs +8 -8
- package/lib/components/ModelCompareV3/data/Switching.js +3 -1
- package/lib/components/ModelCompareV3/data/Switching.js.map +1 -1
- package/lib/components/ModelCompareV3/data/Switching.mjs +3 -1
- package/lib/components/ModelCompareV3/data/Switching.mjs.map +1 -1
- package/lib/components/ModelCompareV3/data/products/aggregation.js +16 -8
- package/lib/components/ModelCompareV3/data/products/aggregation.js.map +1 -1
- package/lib/components/ModelCompareV3/data/products/aggregation.mjs +16 -8
- 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 +16 -8
- package/lib/components/ModelCompareV3/data/products/enterprise24PoE.js.map +1 -1
- package/lib/components/ModelCompareV3/data/products/enterprise24PoE.mjs +16 -8
- package/lib/components/ModelCompareV3/data/products/enterprise24PoE.mjs.map +1 -1
- package/lib/components/ModelCompareV3/data/products/enterprise48PoE.js +16 -8
- package/lib/components/ModelCompareV3/data/products/enterprise48PoE.js.map +1 -1
- package/lib/components/ModelCompareV3/data/products/enterprise48PoE.mjs +16 -8
- package/lib/components/ModelCompareV3/data/products/enterprise48PoE.mjs.map +1 -1
- package/lib/components/ModelCompareV3/data/products/enterpriseXG24.js +16 -8
- package/lib/components/ModelCompareV3/data/products/enterpriseXG24.js.map +1 -1
- package/lib/components/ModelCompareV3/data/products/enterpriseXG24.mjs +16 -8
- 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 +16 -8
- package/lib/components/ModelCompareV3/data/products/highCapacityAggregation.js.map +1 -1
- package/lib/components/ModelCompareV3/data/products/highCapacityAggregation.mjs +16 -8
- package/lib/components/ModelCompareV3/data/products/highCapacityAggregation.mjs.map +1 -1
- package/lib/components/ModelCompareV3/data/products/missionCritical.js +8 -0
- package/lib/components/ModelCompareV3/data/products/missionCritical.js.map +1 -1
- package/lib/components/ModelCompareV3/data/products/missionCritical.mjs +8 -0
- package/lib/components/ModelCompareV3/data/products/missionCritical.mjs.map +1 -1
- package/lib/components/ModelCompareV3/data/products/phoneTouch.js +5 -3
- package/lib/components/ModelCompareV3/data/products/phoneTouch.js.map +1 -1
- package/lib/components/ModelCompareV3/data/products/phoneTouch.mjs +5 -3
- package/lib/components/ModelCompareV3/data/products/phoneTouch.mjs.map +1 -1
- package/lib/components/ModelCompareV3/data/products/phoneTouchMax.js +4 -2
- package/lib/components/ModelCompareV3/data/products/phoneTouchMax.js.map +1 -1
- package/lib/components/ModelCompareV3/data/products/phoneTouchMax.mjs +4 -2
- package/lib/components/ModelCompareV3/data/products/phoneTouchMax.mjs.map +1 -1
- package/lib/components/ModelCompareV3/data/products/professional24.js +8 -0
- package/lib/components/ModelCompareV3/data/products/professional24.js.map +1 -1
- package/lib/components/ModelCompareV3/data/products/professional24.mjs +8 -0
- package/lib/components/ModelCompareV3/data/products/professional24.mjs.map +1 -1
- package/lib/components/ModelCompareV3/data/products/professional24PoE.js +8 -0
- package/lib/components/ModelCompareV3/data/products/professional24PoE.js.map +1 -1
- package/lib/components/ModelCompareV3/data/products/professional24PoE.mjs +8 -0
- package/lib/components/ModelCompareV3/data/products/professional24PoE.mjs.map +1 -1
- package/lib/components/ModelCompareV3/data/products/professional48.js +8 -0
- package/lib/components/ModelCompareV3/data/products/professional48.js.map +1 -1
- package/lib/components/ModelCompareV3/data/products/professional48.mjs +8 -0
- package/lib/components/ModelCompareV3/data/products/professional48.mjs.map +1 -1
- package/lib/components/ModelCompareV3/data/products/professional48PoE.js +8 -0
- package/lib/components/ModelCompareV3/data/products/professional48PoE.js.map +1 -1
- package/lib/components/ModelCompareV3/data/products/professional48PoE.mjs +8 -0
- package/lib/components/ModelCompareV3/data/products/professional48PoE.mjs.map +1 -1
- package/lib/components/ModelCompareV3/data/products/professionalMax16.js +7 -0
- package/lib/components/ModelCompareV3/data/products/professionalMax16.js.map +1 -1
- package/lib/components/ModelCompareV3/data/products/professionalMax16.mjs +7 -0
- package/lib/components/ModelCompareV3/data/products/professionalMax16.mjs.map +1 -1
- package/lib/components/ModelCompareV3/data/products/professionalMax16PoE.js +7 -0
- package/lib/components/ModelCompareV3/data/products/professionalMax16PoE.js.map +1 -1
- package/lib/components/ModelCompareV3/data/products/professionalMax16PoE.mjs +7 -0
- package/lib/components/ModelCompareV3/data/products/professionalMax16PoE.mjs.map +1 -1
- package/lib/components/ModelCompareV3/data/products/professionalMax24.js +7 -0
- package/lib/components/ModelCompareV3/data/products/professionalMax24.js.map +1 -1
- package/lib/components/ModelCompareV3/data/products/professionalMax24.mjs +7 -0
- package/lib/components/ModelCompareV3/data/products/professionalMax24.mjs.map +1 -1
- package/lib/components/ModelCompareV3/data/products/professionalMax24PoE.js +7 -0
- package/lib/components/ModelCompareV3/data/products/professionalMax24PoE.js.map +1 -1
- package/lib/components/ModelCompareV3/data/products/professionalMax24PoE.mjs +7 -0
- package/lib/components/ModelCompareV3/data/products/professionalMax24PoE.mjs.map +1 -1
- package/lib/components/ModelCompareV3/data/products/professionalMax48.js +7 -0
- package/lib/components/ModelCompareV3/data/products/professionalMax48.js.map +1 -1
- package/lib/components/ModelCompareV3/data/products/professionalMax48.mjs +7 -0
- package/lib/components/ModelCompareV3/data/products/professionalMax48.mjs.map +1 -1
- package/lib/components/ModelCompareV3/data/products/professionalMax48PoE.js +7 -0
- package/lib/components/ModelCompareV3/data/products/professionalMax48PoE.js.map +1 -1
- package/lib/components/ModelCompareV3/data/products/professionalMax48PoE.mjs +7 -0
- package/lib/components/ModelCompareV3/data/products/professionalMax48PoE.mjs.map +1 -1
- package/lib/components/ModelCompareV3/data/products/switchesEnterprise.js +11 -1
- package/lib/components/ModelCompareV3/data/products/switchesEnterprise.js.map +1 -1
- package/lib/components/ModelCompareV3/data/products/switchesEnterprise.mjs +11 -1
- package/lib/components/ModelCompareV3/data/products/switchesEnterprise.mjs.map +1 -1
- package/lib/components/ModelCompareV3/data/products/switchesProfessional.js +8 -0
- package/lib/components/ModelCompareV3/data/products/switchesProfessional.js.map +1 -1
- package/lib/components/ModelCompareV3/data/products/switchesProfessional.mjs +8 -0
- package/lib/components/ModelCompareV3/data/products/switchesProfessional.mjs.map +1 -1
- package/lib/components/ModelCompareV3/data/products/switchesProfessionalMax.js +8 -0
- package/lib/components/ModelCompareV3/data/products/switchesProfessionalMax.js.map +1 -1
- package/lib/components/ModelCompareV3/data/products/switchesProfessionalMax.mjs +8 -0
- package/lib/components/ModelCompareV3/data/products/switchesProfessionalMax.mjs.map +1 -1
- package/lib/components/ModelCompareV3/data/products/switchesStandard.js +8 -0
- package/lib/components/ModelCompareV3/data/products/switchesStandard.js.map +1 -1
- package/lib/components/ModelCompareV3/data/products/switchesStandard.mjs +8 -0
- 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/ucgMax.js +1 -1
- package/lib/components/ModelCompareV3/data/products/ucgMax.mjs +1 -1
- package/lib/components/ModelCompareV3/data/products/ucgUltra.js +1 -1
- package/lib/components/ModelCompareV3/data/products/ucgUltra.mjs +1 -1
- package/lib/components/ModelCompareV3/data/products/udmPro.js +1 -1
- package/lib/components/ModelCompareV3/data/products/udmPro.mjs +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 +1 -0
- package/lib/components/ModelCompareV3/data/properties/index.js +2 -0
- package/lib/components/ModelCompareV3/data/properties/index.js.map +1 -1
- package/lib/components/ModelCompareV3/data/properties/index.mjs +1 -0
- package/lib/components/ModelCompareV3/data/properties/index.mjs.map +1 -1
- package/lib/components/ModelCompareV3/data/properties/proAvSupport.d.ts +2 -0
- package/lib/components/ModelCompareV3/data/properties/proAvSupport.js +19 -0
- package/lib/components/ModelCompareV3/data/properties/proAvSupport.js.map +1 -0
- package/lib/components/ModelCompareV3/data/properties/proAvSupport.mjs +11 -0
- package/lib/components/ModelCompareV3/data/properties/proAvSupport.mjs.map +1 -0
- package/lib/components/ModelCompareV3/data/property-sets/switching.js +6 -4
- package/lib/components/ModelCompareV3/data/property-sets/switching.js.map +1 -1
- package/lib/components/ModelCompareV3/data/property-sets/switching.mjs +6 -4
- package/lib/components/ModelCompareV3/data/property-sets/switching.mjs.map +1 -1
- package/lib/components/ModelCompareV3/translations/ar.json.js +3 -0
- package/lib/components/ModelCompareV3/translations/ar.json.js.map +1 -1
- package/lib/components/ModelCompareV3/translations/ar.json.mjs +3 -0
- package/lib/components/ModelCompareV3/translations/ar.json.mjs.map +1 -1
- package/lib/components/ModelCompareV3/translations/de.json.js +3 -0
- package/lib/components/ModelCompareV3/translations/de.json.js.map +1 -1
- package/lib/components/ModelCompareV3/translations/de.json.mjs +3 -0
- package/lib/components/ModelCompareV3/translations/de.json.mjs.map +1 -1
- package/lib/components/ModelCompareV3/translations/el.json.js +3 -0
- package/lib/components/ModelCompareV3/translations/el.json.js.map +1 -1
- package/lib/components/ModelCompareV3/translations/el.json.mjs +3 -0
- package/lib/components/ModelCompareV3/translations/el.json.mjs.map +1 -1
- package/lib/components/ModelCompareV3/translations/en.json.js +3 -0
- package/lib/components/ModelCompareV3/translations/en.json.js.map +1 -1
- package/lib/components/ModelCompareV3/translations/en.json.mjs +3 -0
- package/lib/components/ModelCompareV3/translations/en.json.mjs.map +1 -1
- package/lib/components/ModelCompareV3/translations/es.json.js +3 -0
- package/lib/components/ModelCompareV3/translations/es.json.js.map +1 -1
- package/lib/components/ModelCompareV3/translations/es.json.mjs +3 -0
- package/lib/components/ModelCompareV3/translations/es.json.mjs.map +1 -1
- package/lib/components/ModelCompareV3/translations/fr.json.js +3 -0
- package/lib/components/ModelCompareV3/translations/fr.json.js.map +1 -1
- package/lib/components/ModelCompareV3/translations/fr.json.mjs +3 -0
- package/lib/components/ModelCompareV3/translations/fr.json.mjs.map +1 -1
- package/lib/components/ModelCompareV3/translations/it.json.js +3 -0
- package/lib/components/ModelCompareV3/translations/it.json.js.map +1 -1
- package/lib/components/ModelCompareV3/translations/it.json.mjs +3 -0
- package/lib/components/ModelCompareV3/translations/it.json.mjs.map +1 -1
- package/lib/components/ModelCompareV3/translations/ja.json.js +3 -0
- package/lib/components/ModelCompareV3/translations/ja.json.js.map +1 -1
- package/lib/components/ModelCompareV3/translations/ja.json.mjs +3 -0
- package/lib/components/ModelCompareV3/translations/ja.json.mjs.map +1 -1
- package/lib/components/ModelCompareV3/translations/pt-BR.json.js +3 -0
- package/lib/components/ModelCompareV3/translations/pt-BR.json.js.map +1 -1
- package/lib/components/ModelCompareV3/translations/pt-BR.json.mjs +3 -0
- package/lib/components/ModelCompareV3/translations/pt-BR.json.mjs.map +1 -1
- package/lib/components/ModelCompareV3/translations/useModelCompareTranslation.d.ts +2 -2
- package/lib/components/ModelCompareV3/translations/zh-Hans.json.js +3 -0
- package/lib/components/ModelCompareV3/translations/zh-Hans.json.js.map +1 -1
- package/lib/components/ModelCompareV3/translations/zh-Hans.json.mjs +3 -0
- package/lib/components/ModelCompareV3/translations/zh-Hans.json.mjs.map +1 -1
- package/lib/components/ModelCompareV3/translations/zh-Hant-TW.json.js +3 -0
- package/lib/components/ModelCompareV3/translations/zh-Hant-TW.json.js.map +1 -1
- package/lib/components/ModelCompareV3/translations/zh-Hant-TW.json.mjs +3 -0
- package/lib/components/ModelCompareV3/translations/zh-Hant-TW.json.mjs.map +1 -1
- package/lib/components/ResourceCalculatorV1/ComputeResourceCalculator/ComputeResourceCalculator.constants.js +311 -15
- package/lib/components/ResourceCalculatorV1/ComputeResourceCalculator/ComputeResourceCalculator.constants.js.map +1 -1
- package/lib/components/ResourceCalculatorV1/ComputeResourceCalculator/ComputeResourceCalculator.constants.mjs +309 -15
- package/lib/components/ResourceCalculatorV1/ComputeResourceCalculator/ComputeResourceCalculator.constants.mjs.map +1 -1
- package/lib/components/ResourceCalculatorV1/ComputeResourceCalculator/ComputeResourceCalculator.js +38 -22
- package/lib/components/ResourceCalculatorV1/ComputeResourceCalculator/ComputeResourceCalculator.js.map +1 -1
- package/lib/components/ResourceCalculatorV1/ComputeResourceCalculator/ComputeResourceCalculator.mjs +38 -22
- package/lib/components/ResourceCalculatorV1/ComputeResourceCalculator/ComputeResourceCalculator.mjs.map +1 -1
- package/lib/components/ResourceCalculatorV1/ComputeResourceCalculator/ComputeResourceCalculator.types.d.ts +10 -2
- package/lib/components/ResourceCalculatorV1/ComputeResourceCalculator/ComputeResourceCalculator.types.js +2 -0
- package/lib/components/ResourceCalculatorV1/ComputeResourceCalculator/ComputeResourceCalculator.types.js.map +1 -1
- package/lib/components/ResourceCalculatorV1/ComputeResourceCalculator/ComputeResourceCalculator.types.mjs +2 -0
- 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 +5 -4
- package/lib/components/ResourceCalculatorV1/ComputeResourceCalculator/components/HddSlots/HddSlots.js.map +1 -1
- package/lib/components/ResourceCalculatorV1/ComputeResourceCalculator/components/HddSlots/HddSlots.mjs +5 -4
- package/lib/components/ResourceCalculatorV1/ComputeResourceCalculator/components/HddSlots/HddSlots.mjs.map +1 -1
- package/lib/components/ResourceCalculatorV1/ComputeResourceCalculator/components/InputCard/InputCard.js +2 -2
- package/lib/components/ResourceCalculatorV1/ComputeResourceCalculator/components/InputCard/InputCard.js.map +1 -1
- package/lib/components/ResourceCalculatorV1/ComputeResourceCalculator/components/InputCard/InputCard.mjs +2 -2
- package/lib/components/ResourceCalculatorV1/ComputeResourceCalculator/components/InputCard/InputCard.mjs.map +1 -1
- package/lib/components/ResourceCalculatorV1/ComputeResourceCalculator/components/InputCard/InputCard.styles.js +2 -0
- package/lib/components/ResourceCalculatorV1/ComputeResourceCalculator/components/InputCard/InputCard.styles.js.map +1 -1
- package/lib/components/ResourceCalculatorV1/ComputeResourceCalculator/components/InputCard/InputCard.styles.mjs +2 -0
- package/lib/components/ResourceCalculatorV1/ComputeResourceCalculator/components/InputCard/InputCard.styles.mjs.map +1 -1
- package/lib/components/ResourceCalculatorV1/ComputeResourceCalculator/components/InputCard/assets/attention.svg.js +1 -1
- package/lib/components/ResourceCalculatorV1/ComputeResourceCalculator/components/InputCard/assets/attention.svg.mjs +2 -2
- package/lib/components/ResourceCalculatorV1/ComputeResourceCalculator/components/ProgressBarChart/ProgressBarChart.js +1 -1
- package/lib/components/ResourceCalculatorV1/ComputeResourceCalculator/components/ProgressBarChart/ProgressBarChart.mjs +1 -1
- package/lib/components/ResourceCalculatorV1/ComputeResourceCalculator/components/ProgressBarChart/assets/attention.svg.js +1 -1
- package/lib/components/ResourceCalculatorV1/ComputeResourceCalculator/components/ProgressBarChart/assets/attention.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/assets/consoles/efg.png.js +27 -0
- package/lib/components/ResourceCalculatorV1/assets/consoles/efg.png.js.map +1 -0
- package/lib/components/ResourceCalculatorV1/assets/consoles/efg.png.mjs +3 -0
- package/lib/components/ResourceCalculatorV1/assets/consoles/efg.png.mjs.map +1 -0
- package/lib/components/ResourceCalculatorV1/assets/consoles/ucg-max.png.js +27 -0
- package/lib/components/ResourceCalculatorV1/assets/consoles/ucg-max.png.js.map +1 -0
- package/lib/components/ResourceCalculatorV1/assets/consoles/ucg-max.png.mjs +3 -0
- package/lib/components/ResourceCalculatorV1/assets/consoles/ucg-max.png.mjs.map +1 -0
- package/lib/components/ResourceCalculatorV1/translations/en.json.js +4 -1
- package/lib/components/ResourceCalculatorV1/translations/en.json.js.map +1 -1
- package/lib/components/ResourceCalculatorV1/translations/en.json.mjs +4 -1
- package/lib/components/ResourceCalculatorV1/translations/en.json.mjs.map +1 -1
- package/lib/components/ResourceCalculatorV1/translations/useResourceCalculatorTranslation.d.ts +2 -2
- package/lib/components/Search/Input/Input.js +1 -1
- package/lib/components/Search/Input/Input.mjs +1 -1
- 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/close.svg.js +1 -1
- package/lib/constants/icons/generic/close.svg.mjs +2 -2
- package/lib/constants/icons/generic/index.js +1 -1
- package/lib/constants/icons/generic/index.mjs +1 -1
- package/lib/constants/icons/menu/index.d.ts +1 -0
- package/lib/constants/icons/menu/index.js +9 -0
- package/lib/constants/icons/menu/index.js.map +1 -1
- package/lib/constants/icons/menu/index.mjs +2 -0
- package/lib/constants/icons/menu/index.mjs.map +1 -1
- package/lib/{components/Explore/assets/MobileR.jpg.js → constants/icons/menu/powerAmp.svg.js} +6 -6
- package/lib/constants/icons/menu/powerAmp.svg.js.map +1 -0
- package/lib/constants/icons/menu/powerAmp.svg.mjs +3 -0
- package/lib/constants/icons/menu/powerAmp.svg.mjs.map +1 -0
- package/lib/constants/keyFeatureIcons.d.ts +2 -0
- package/lib/constants/keyFeatureIcons.js +6 -0
- package/lib/constants/keyFeatureIcons.js.map +1 -1
- package/lib/constants/keyFeatureIcons.mjs +6 -0
- package/lib/constants/keyFeatureIcons.mjs.map +1 -1
- package/lib/constants/proStoreCategories/mapping/index.d.ts +3 -1
- package/lib/constants/proStoreCategories/mapping/index.js +18 -8
- package/lib/constants/proStoreCategories/mapping/index.js.map +1 -1
- package/lib/constants/proStoreCategories/mapping/index.mjs +18 -8
- package/lib/constants/proStoreCategories/mapping/index.mjs.map +1 -1
- package/lib/constants/proStoreCategories/mapping/redirects.js +8 -1
- package/lib/constants/proStoreCategories/mapping/redirects.js.map +1 -1
- package/lib/constants/proStoreCategories/mapping/redirects.mjs +8 -1
- package/lib/constants/proStoreCategories/mapping/redirects.mjs.map +1 -1
- package/lib/constants/proStoreCategories/mapping/unifi.d.ts +4 -2
- package/lib/constants/proStoreCategories/mapping/unifi.js +3 -1
- package/lib/constants/proStoreCategories/mapping/unifi.js.map +1 -1
- package/lib/constants/proStoreCategories/mapping/unifi.mjs +3 -1
- package/lib/constants/proStoreCategories/mapping/unifi.mjs.map +1 -1
- package/lib/constants/proStoreCategories/translations/ar.json.js +3 -2
- package/lib/constants/proStoreCategories/translations/ar.json.js.map +1 -1
- package/lib/constants/proStoreCategories/translations/ar.json.mjs +3 -2
- package/lib/constants/proStoreCategories/translations/ar.json.mjs.map +1 -1
- package/lib/constants/proStoreCategories/translations/de.json.js +3 -2
- package/lib/constants/proStoreCategories/translations/de.json.js.map +1 -1
- package/lib/constants/proStoreCategories/translations/de.json.mjs +3 -2
- package/lib/constants/proStoreCategories/translations/de.json.mjs.map +1 -1
- package/lib/constants/proStoreCategories/translations/el.json.js +3 -2
- package/lib/constants/proStoreCategories/translations/el.json.js.map +1 -1
- package/lib/constants/proStoreCategories/translations/el.json.mjs +3 -2
- package/lib/constants/proStoreCategories/translations/el.json.mjs.map +1 -1
- package/lib/constants/proStoreCategories/translations/en.json.js +5 -1
- package/lib/constants/proStoreCategories/translations/en.json.js.map +1 -1
- package/lib/constants/proStoreCategories/translations/en.json.mjs +5 -2
- package/lib/constants/proStoreCategories/translations/en.json.mjs.map +1 -1
- package/lib/constants/proStoreCategories/translations/es.json.js +3 -2
- package/lib/constants/proStoreCategories/translations/es.json.js.map +1 -1
- package/lib/constants/proStoreCategories/translations/es.json.mjs +3 -2
- package/lib/constants/proStoreCategories/translations/es.json.mjs.map +1 -1
- package/lib/constants/proStoreCategories/translations/fr.json.js +4 -3
- package/lib/constants/proStoreCategories/translations/fr.json.js.map +1 -1
- package/lib/constants/proStoreCategories/translations/fr.json.mjs +4 -3
- package/lib/constants/proStoreCategories/translations/fr.json.mjs.map +1 -1
- package/lib/constants/proStoreCategories/translations/it.json.js +3 -2
- package/lib/constants/proStoreCategories/translations/it.json.js.map +1 -1
- package/lib/constants/proStoreCategories/translations/it.json.mjs +3 -2
- package/lib/constants/proStoreCategories/translations/it.json.mjs.map +1 -1
- package/lib/constants/proStoreCategories/translations/ja.json.js +3 -2
- package/lib/constants/proStoreCategories/translations/ja.json.js.map +1 -1
- package/lib/constants/proStoreCategories/translations/ja.json.mjs +3 -2
- package/lib/constants/proStoreCategories/translations/ja.json.mjs.map +1 -1
- package/lib/constants/proStoreCategories/translations/pt-BR.json.js +3 -2
- package/lib/constants/proStoreCategories/translations/pt-BR.json.js.map +1 -1
- package/lib/constants/proStoreCategories/translations/pt-BR.json.mjs +3 -2
- package/lib/constants/proStoreCategories/translations/pt-BR.json.mjs.map +1 -1
- package/lib/constants/proStoreCategories/translations/zh-Hans.json.js +4 -3
- package/lib/constants/proStoreCategories/translations/zh-Hans.json.js.map +1 -1
- package/lib/constants/proStoreCategories/translations/zh-Hans.json.mjs +4 -3
- package/lib/constants/proStoreCategories/translations/zh-Hans.json.mjs.map +1 -1
- package/lib/constants/proStoreCategories/translations/zh-Hant-TW.json.js +4 -3
- package/lib/constants/proStoreCategories/translations/zh-Hant-TW.json.js.map +1 -1
- package/lib/constants/proStoreCategories/translations/zh-Hant-TW.json.mjs +4 -3
- package/lib/constants/proStoreCategories/translations/zh-Hant-TW.json.mjs.map +1 -1
- package/lib/constants/shopify/keyFeatureIcons.js +8 -0
- package/lib/constants/shopify/keyFeatureIcons.js.map +1 -1
- package/lib/constants/shopify/keyFeatureIcons.mjs +6 -0
- 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 +21 -7
- package/lib/contexts/MenuContext/mapping.js.map +1 -1
- package/lib/contexts/MenuContext/mapping.mjs +20 -7
- package/lib/contexts/MenuContext/mapping.mjs.map +1 -1
- package/lib/contexts/MenuContext/presets.d.ts +11 -4
- package/lib/contexts/MenuContext/presets.js +16 -12
- 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 +5 -1
- package/lib/contexts/MenuContext/utils.js.map +1 -1
- package/lib/contexts/MenuContext/utils.mjs +5 -1
- package/lib/contexts/MenuContext/utils.mjs.map +1 -1
- package/lib/helpers/index.d.ts +1 -0
- package/lib/helpers/index.js +11 -0
- package/lib/helpers/index.js.map +1 -1
- package/lib/helpers/index.mjs +1 -0
- package/lib/helpers/index.mjs.map +1 -1
- package/lib/helpers/product.d.ts +87 -0
- package/lib/helpers/product.js +346 -0
- package/lib/helpers/product.js.map +1 -0
- package/lib/helpers/product.mjs +335 -0
- package/lib/helpers/product.mjs.map +1 -0
- package/lib/types/index.d.ts +1 -0
- package/lib/types/index.js +2 -0
- package/lib/types/index.js.map +1 -1
- package/lib/types/index.mjs +1 -0
- package/lib/types/index.mjs.map +1 -1
- package/lib/types/product.d.ts +87 -0
- package/lib/types/product.js +14 -0
- package/lib/types/product.js.map +1 -0
- package/lib/types/product.mjs +13 -0
- package/lib/types/product.mjs.map +1 -0
- package/lib/utils/array.d.ts +4 -0
- package/lib/utils/array.js +10 -0
- package/lib/utils/array.js.map +1 -1
- package/lib/utils/array.mjs +10 -1
- package/lib/utils/array.mjs.map +1 -1
- package/lib/utils/money/allocators/fixedAmount.d.ts +26 -0
- package/lib/utils/money/allocators/fixedAmount.js +55 -0
- package/lib/utils/money/allocators/fixedAmount.js.map +1 -0
- package/lib/utils/money/allocators/fixedAmount.mjs +53 -0
- package/lib/utils/money/allocators/fixedAmount.mjs.map +1 -0
- package/lib/utils/money/allocators/index.d.ts +2 -0
- package/lib/utils/money/allocators/index.js +8 -0
- package/lib/utils/money/allocators/index.js.map +1 -0
- package/lib/utils/money/allocators/index.mjs +4 -0
- package/lib/utils/money/allocators/index.mjs.map +1 -0
- package/lib/utils/money/allocators/productAmount.d.ts +13 -0
- package/lib/utils/money/allocators/productAmount.js +110 -0
- package/lib/utils/money/allocators/productAmount.js.map +1 -0
- package/lib/utils/money/allocators/productAmount.mjs +108 -0
- package/lib/utils/money/allocators/productAmount.mjs.map +1 -0
- package/lib/utils/money/constants.d.ts +56 -25
- package/lib/utils/money/constants.js +72 -7
- package/lib/utils/money/constants.js.map +1 -1
- package/lib/utils/money/constants.mjs +70 -7
- package/lib/utils/money/constants.mjs.map +1 -1
- package/lib/utils/money/exchangeRate.d.ts +31 -0
- package/lib/utils/money/exchangeRate.js +27 -0
- package/lib/utils/money/exchangeRate.js.map +1 -0
- package/lib/utils/money/exchangeRate.mjs +23 -0
- package/lib/utils/money/exchangeRate.mjs.map +1 -0
- package/lib/utils/money/format.d.ts +10 -5
- package/lib/utils/money/format.js +22 -14
- package/lib/utils/money/format.js.map +1 -1
- package/lib/utils/money/format.mjs +23 -16
- package/lib/utils/money/format.mjs.map +1 -1
- package/lib/utils/money/index.d.ts +4 -1
- package/lib/utils/money/index.js +26 -8
- package/lib/utils/money/index.js.map +1 -1
- package/lib/utils/money/index.mjs +8 -4
- package/lib/utils/money/index.mjs.map +1 -1
- package/lib/utils/money/misc.d.ts +68 -28
- package/lib/utils/money/misc.js +35 -64
- package/lib/utils/money/misc.js.map +1 -1
- package/lib/utils/money/misc.mjs +32 -43
- package/lib/utils/money/misc.mjs.map +1 -1
- package/lib/utils/money/misc.private.d.ts +23 -0
- package/lib/utils/money/misc.private.js +46 -0
- package/lib/utils/money/misc.private.js.map +1 -0
- package/lib/utils/money/misc.private.mjs +21 -0
- package/lib/utils/money/misc.private.mjs.map +1 -0
- package/lib/utils/money/shipping.d.ts +5 -0
- package/lib/utils/money/shipping.js +8 -0
- package/lib/utils/money/shipping.js.map +1 -0
- package/lib/utils/money/shipping.mjs +6 -0
- package/lib/utils/money/shipping.mjs.map +1 -0
- package/lib/utils/money/tax.d.ts +38 -2
- package/lib/utils/money/tax.js +46 -10
- package/lib/utils/money/tax.js.map +1 -1
- package/lib/utils/money/tax.mjs +42 -11
- package/lib/utils/money/tax.mjs.map +1 -1
- package/lib/utils/money/tax.private.d.ts +17 -0
- package/lib/utils/money/tax.private.js +65 -0
- package/lib/utils/money/tax.private.js.map +1 -0
- package/lib/utils/money/tax.private.mjs +60 -0
- package/lib/utils/money/tax.private.mjs.map +1 -0
- package/lib/utils/money/types.d.ts +78 -3
- package/lib/utils/nextjs/navigationPresets.d.ts +5 -3
- package/lib/utils/nextjs/navigationPresets.js +13 -7
- package/lib/utils/nextjs/navigationPresets.js.map +1 -1
- package/lib/utils/nextjs/navigationPresets.mjs +14 -8
- 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/productSort.d.ts +41 -0
- package/lib/utils/productSort.js +66 -0
- package/lib/utils/productSort.js.map +1 -0
- package/lib/utils/productSort.mjs +59 -0
- package/lib/utils/productSort.mjs.map +1 -0
- package/package.json +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/ai3602.jpg +0 -0
- 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-ptz2.jpg +0 -0
- package/lib/assets/wideAngle2.jpg +0 -0
- package/lib/components/Explore/LensCompare/LensCompare.d.ts +0 -2
- package/lib/components/Explore/LensCompare/LensCompare.js +0 -111
- package/lib/components/Explore/LensCompare/LensCompare.js.map +0 -1
- package/lib/components/Explore/LensCompare/LensCompare.mjs +0 -109
- package/lib/components/Explore/LensCompare/LensCompare.mjs.map +0 -1
- package/lib/components/Explore/LensCompare/LensCompare.styles.d.ts +0 -16
- package/lib/components/Explore/LensCompare/LensCompare.styles.js +0 -153
- package/lib/components/Explore/LensCompare/LensCompare.styles.js.map +0 -1
- package/lib/components/Explore/LensCompare/LensCompare.styles.mjs +0 -132
- package/lib/components/Explore/LensCompare/LensCompare.styles.mjs.map +0 -1
- package/lib/components/Explore/LensCompare/LensCompare.types.d.ts +0 -9
- package/lib/components/Explore/LensCompare/LensCompare.utils.d.ts +0 -2
- package/lib/components/Explore/LensCompare/LensCompare.utils.js +0 -23
- package/lib/components/Explore/LensCompare/LensCompare.utils.js.map +0 -1
- package/lib/components/Explore/LensCompare/LensCompare.utils.mjs +0 -21
- package/lib/components/Explore/LensCompare/LensCompare.utils.mjs.map +0 -1
- package/lib/components/Explore/LensCompare/LensCompareData.d.ts +0 -29
- package/lib/components/Explore/LensCompare/LensCompareData.js +0 -68
- package/lib/components/Explore/LensCompare/LensCompareData.js.map +0 -1
- package/lib/components/Explore/LensCompare/LensCompareData.mjs +0 -58
- package/lib/components/Explore/LensCompare/LensCompareData.mjs.map +0 -1
- package/lib/components/Explore/LensCompare/assets/ai360.jpg.js.map +0 -1
- package/lib/components/Explore/LensCompare/assets/ai360.jpg.mjs +0 -3
- package/lib/components/Explore/LensCompare/assets/ai360.jpg.mjs.map +0 -1
- package/lib/components/Explore/LensCompare/assets/wideAngle.jpg.js +0 -27
- package/lib/components/Explore/LensCompare/assets/wideAngle.jpg.js.map +0 -1
- package/lib/components/Explore/LensCompare/assets/wideAngle.jpg.mjs +0 -3
- package/lib/components/Explore/LensCompare/assets/wideAngle.jpg.mjs.map +0 -1
- package/lib/components/Explore/assets/AITheta.jpg.js.map +0 -1
- package/lib/components/Explore/assets/AITheta.jpg.mjs +0 -3
- package/lib/components/Explore/assets/AITheta.jpg.mjs.map +0 -1
- package/lib/components/Explore/assets/MobileR.jpg.js.map +0 -1
- package/lib/components/Explore/assets/MobileR.jpg.mjs +0 -3
- package/lib/components/Explore/assets/MobileR.jpg.mjs.map +0 -1
- package/lib/components/Explore/assets/ProAV.jpg.js.map +0 -1
- package/lib/components/Explore/assets/ProAV.jpg.mjs +0 -3
- package/lib/components/Explore/assets/ProAV.jpg.mjs.map +0 -1
- 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/cloudgatewayultra.jpg.js +0 -27
- package/lib/components/Explore/assets/cloudgatewayultra.jpg.js.map +0 -1
- package/lib/components/Explore/assets/cloudgatewayultra.jpg.mjs +0 -3
- package/lib/components/Explore/assets/cloudgatewayultra.jpg.mjs.map +0 -1
- package/lib/components/Explore/assets/dreamRouter.jpg.js +0 -27
- package/lib/components/Explore/assets/dreamRouter.jpg.js.map +0 -1
- package/lib/components/Explore/assets/dreamRouter.jpg.mjs +0 -3
- package/lib/components/Explore/assets/dreamRouter.jpg.mjs.map +0 -1
- package/lib/components/Explore/assets/dreamWall.jpg.js +0 -27
- package/lib/components/Explore/assets/dreamWall.jpg.js.map +0 -1
- package/lib/components/Explore/assets/dreamWall.jpg.mjs +0 -3
- package/lib/components/Explore/assets/dreamWall.jpg.mjs.map +0 -1
- package/lib/components/Explore/assets/g4-ptz.jpg.js.map +0 -1
- package/lib/components/Explore/assets/g4-ptz.jpg.mjs +0 -3
- package/lib/components/Explore/assets/g4-ptz.jpg.mjs.map +0 -1
- package/lib/components/Explore/assets/g5-ptz.jpg.js.map +0 -1
- package/lib/components/Explore/assets/g5-ptz.jpg.mjs +0 -3
- package/lib/components/Explore/assets/g5-ptz.jpg.mjs.map +0 -1
- package/lib/components/Explore/assets/unifiExpress.jpg.js +0 -27
- package/lib/components/Explore/assets/unifiExpress.jpg.js.map +0 -1
- package/lib/components/Explore/assets/unifiExpress.jpg.mjs +0 -3
- package/lib/components/Explore/assets/unifiExpress.jpg.mjs.map +0 -1
- package/lib/utils/validations.d.ts +0 -15
- package/lib/utils/validations.js +0 -23
- package/lib/utils/validations.js.map +0 -1
- package/lib/utils/validations.mjs +0 -21
- package/lib/utils/validations.mjs.map +0 -1
- /package/lib/assets/{baseStation-mobile.jpg → baseStation--mobile.jpg} +0 -0
- /package/lib/assets/{g4-ptz.jpg → g4Ptz.jpg} +0 -0
- /package/lib/assets/{unifiExpress.jpg → ux.jpg} +0 -0
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"format.mjs","sources":["../../../src/utils/money/format.ts"],"sourcesContent":["import {
|
|
1
|
+
{"version":3,"file":"format.mjs","sources":["../../../src/utils/money/format.ts"],"sourcesContent":["import { hasSubUnits, toFormat, toUnit } from \"dinero.js\";\n\nimport type { Currency, Nullish } from \"../../types\";\nimport { assert } from \"../errors\";\nimport {\n localizedCurrencyLookup,\n prettifyPriceLookup,\n Round,\n} from \"./constants\";\nimport { getDinero, roundDinero } from \"./misc\";\nimport type { Dino, LocalizedCurrency, Money } from \"./types\";\n\nexport const getLocalizedCurrency = (\n currencyCode: Nullish<Currency>,\n): LocalizedCurrency | undefined => {\n return currencyCode ? localizedCurrencyLookup.get(currencyCode) : undefined;\n};\n\n// #############################################################################\n// Formatter\n// #############################################################################\nconst currencyFormatterCache = new Map<string, Intl.NumberFormat>();\n/**\n * Function to get a Int.NumberFormat instance that can be reused to format currency over using\n * `Number.toLocaleString(...)` function, which makes more sense to use as we usually just display 1 or 2 currencies\n * MAX, so reusing the formatted makes a lot of sense\n * @see https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number/toLocaleString#performance\n */\nconst getCurrencyFormatter = (\n locale: string,\n currencyCode: string,\n): Intl.NumberFormat => {\n const cacheKey = `${locale}_${currencyCode}`;\n\n let formatter = currencyFormatterCache.get(cacheKey);\n if (formatter) {\n return formatter;\n }\n\n formatter = new Intl.NumberFormat(locale, {\n style: \"currency\",\n currency: currencyCode,\n /**\n * Explicitly define default behavior - just in case some runtime overrides it\n * @see https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/NumberFormat/NumberFormat#currencysign\n * @see https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/NumberFormat/NumberFormat#currencydisplay\n */\n currencySign: \"standard\",\n currencyDisplay: \"symbol\",\n });\n currencyFormatterCache.set(cacheKey, formatter);\n\n return formatter;\n};\n\nexport type FormatPriceOptions = {\n /**\n * Optionally remove trailing zeroes (only if all of them are 0)\n * @default false\n * @example\n * \"420,66 €\" => \"420,66 €\"\n * \"420,60 €\" => \"420,60 €\"\n * \"420,00 €\" => \"420 €\"\n */\n removeTrailingZeros?: boolean;\n /**\n * Optionally return currency rounded down to the nearest dollar-equivalent of a the given currency. Doesn't apply any\n * rounding just \"trims\" end decimal values\n *\n * ! Only use for display purposes where monetary precision is not required!\n *\n * @default false\n * @example\n * \"420,66 €\" => \"420 €\"\n * \"420,60 €\" => \"420 €\"\n * \"420,00 €\" => \"420 €\"\n */\n removeFractions?: boolean;\n};\n\n/**\n * Currency formatter based on dinero currency types and browser internationalizing functions\n *\n * Based on:\n * @see https://v2.dinerojs.com/docs/guides/formatting-in-a-multilingual-site#building-a-custom-internationalization-formatter\n * @protected\n * @deprecated Use `formatPrice` instead as this functions is for INTERNAL USE ONLY! (function not actual deprecated,\n * just marked so it discourages usage of it)\n */\nexport function formatPriceRaw(\n dinero: Dino,\n locale: string,\n options?: FormatPriceOptions,\n): string {\n return toFormat(dinero, ({ amount, currency }) => {\n const formatter = getCurrencyFormatter(locale, currency.code);\n const formatted = formatter.format(amount);\n\n return options?.removeFractions || options?.removeTrailingZeros\n ? /**\n * Regex to handle complex removing trailing zeros from currency\n * - Dynamically create regex based on currency as their exponent changes\n * - Also handles some currencies (e.g. EUR) having trailing currency symbol\n *\n * TODO: improve how we detect \"decimal separator\" for formatted currency, at least right now we have tests for it and doesn't seem like an issue\n */\n formatted.replace(\n // For some reason `\\.` need to be double-escaped `\\\\` when creating the regex from template string\n new RegExp(\n `(\\\\.|,)${\n // Depending options remove all trailing digits or just zeros, this way we don't need to do any rounding\n options?.removeFractions ? \"\\\\d\" : 0\n }{0,${currency.exponent}}(\\\\s\\\\D)?$`,\n ),\n // In the replaced using \"last capture group\" (if-exists) so we restore the trailing currency sign\n \"$2\",\n )\n : formatted;\n });\n}\n\n/**\n * Currency formatter based on dinero currency types and browser internationalizing functions\n *\n * In reality just a wrapper around `formatPriceRaw` that does the real formatting\n */\nexport const formatPrice = (\n money: Money,\n options?: FormatPriceOptions,\n): string => {\n const localizedCurrency = getLocalizedCurrency(money.currency);\n assert(!!localizedCurrency, `Currency ${money.currency} not supported`);\n\n return formatPriceRaw(\n getDinero(money.amount, money.currency),\n localizedCurrency.locale,\n options,\n );\n};\n\n/**\n * Prettify numbers depending on the currency using rounding down.\n * ! Should only be used to prettify storefront product prices after currency conversion but nothing else !\n */\nexport const prettifyTotal = (total: Dino): Dino => {\n // Nothing to round\n if (!hasSubUnits(total)) {\n return total;\n }\n\n const totalJson = total.toJSON();\n\n const minValueInclusiveToRoundDownFrom = prettifyPriceLookup.get(\n totalJson.currency.code,\n );\n\n // Don't round if currency unsupported or value is below min threshold\n if (\n minValueInclusiveToRoundDownFrom == null ||\n toUnit(total) < minValueInclusiveToRoundDownFrom\n ) {\n return total;\n }\n\n return roundDinero(total, Round.Prettify);\n};\n"],"names":["getLocalizedCurrency","currencyCode","localizedCurrencyLookup","get","currencyFormatterCache","Map","getCurrencyFormatter","locale","cacheKey","formatter","Intl","NumberFormat","style","currency","currencySign","currencyDisplay","set","formatPriceRaw","dinero","options","toFormat","amount","code","formatted","format","removeFractions","removeTrailingZeros","replace","RegExp","exponent","formatPrice","money","localizedCurrency","assert","getDinero","prettifyTotal","total","hasSubUnits","totalJson","toJSON","minValueInclusiveToRoundDownFrom","prettifyPriceLookup","toUnit","roundDinero","Round","Prettify"],"mappings":";;;;;AAYa,MAAAA,oBAAA,GACXC,YACkC,IAAA;EAClC,OAAOA,YAAe,GAAAC,uBAAA,CAAwBC,GAAI,CAAAF,YAAY,CAAI,GAAA,KAAA,CAAA;AACpE,CAAA;AAKA,MAAMG,sBAAA,GAAA,mBAA6BC,GAA+B,EAAA;AAOlE,MAAMC,oBAAA,GAAuBA,CAC3BC,MAAA,EACAN,YACsB,KAAA;EACtB,MAAMO,QAAW,GAAA,GAAGD,MAAM,IAAIN,YAAY,EAAA;EAEtC,IAAAQ,SAAA,GAAYL,sBAAuB,CAAAD,GAAA,CAAIK,QAAQ,CAAA;EACnD,IAAIC,SAAW,EAAA;IACN,OAAAA,SAAA;EACT;EAEYA,SAAA,GAAA,IAAIC,IAAK,CAAAC,YAAA,CAAaJ,MAAQ,EAAA;IACxCK,KAAO,EAAA,UAAA;IACPC,QAAU,EAAAZ,YAAA;IAAA;AAA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AAA;EACT;EAEM,MAAAE,SAAA,GAAYF,MAAMG,MAAO,EAAA;EAE/B,MAAMC,mCAAmCC,mBAAoB,CAAAtC,GAAA,CAC3DmC,UAAUzB,QAAS,CAAAS,IAAA,CACrB;EAGA,IACEkB,gCAAoC,IAAA,IAAA,IACpCE,MAAO,CAAAN,KAAK,IAAII,gCAChB,EAAA;IACO,OAAAJ,KAAA;EACT;EAEO,OAAAO,WAAA,CAAYP,KAAO,EAAAQ,KAAA,CAAMC,QAAQ,CAAA;AAC1C,CAAA;"}
|
|
@@ -1,5 +1,8 @@
|
|
|
1
|
+
export * as Allocators from "./allocators";
|
|
1
2
|
export * from "./constants";
|
|
3
|
+
export * from "./exchangeRate";
|
|
2
4
|
export * from "./format";
|
|
3
5
|
export * from "./misc";
|
|
4
|
-
export * from "./
|
|
6
|
+
export * from "./shipping";
|
|
5
7
|
export * from "./tax";
|
|
8
|
+
export * from "./types";
|
package/lib/utils/money/index.js
CHANGED
|
@@ -1,33 +1,51 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
+
var index = require('./allocators/index.js');
|
|
3
4
|
var constants = require('./constants.js');
|
|
5
|
+
var exchangeRate = require('./exchangeRate.js');
|
|
4
6
|
var format = require('./format.js');
|
|
5
7
|
var misc = require('./misc.js');
|
|
6
|
-
require('./
|
|
8
|
+
var shipping = require('./shipping.js');
|
|
7
9
|
var tax = require('./tax.js');
|
|
10
|
+
require('./types.js');
|
|
8
11
|
"use strict";
|
|
9
|
-
exports.
|
|
10
|
-
exports.
|
|
11
|
-
exports.
|
|
12
|
+
exports.Allocators = index;
|
|
13
|
+
exports.EXCHANGE_RATE_DINERO_CURRENCY = constants.EXCHANGE_RATE_DINERO_CURRENCY;
|
|
14
|
+
exports.Round = constants.Round;
|
|
15
|
+
exports.TAX_RATE_DINERO_CURRENCY = constants.TAX_RATE_DINERO_CURRENCY;
|
|
16
|
+
exports.localizedCurrencyLookup = constants.localizedCurrencyLookup;
|
|
12
17
|
exports.prettifyPriceLookup = constants.prettifyPriceLookup;
|
|
13
18
|
exports.smallestSubunitLookup = constants.smallestSubunitLookup;
|
|
19
|
+
exports.storesWithPerItemTaxRate = constants.storesWithPerItemTaxRate;
|
|
20
|
+
exports.invertExchangeRate = exchangeRate.invertExchangeRate;
|
|
21
|
+
exports.toFixedExchangeRate = exchangeRate.toFixedExchangeRate;
|
|
22
|
+
exports.toSnapshotExchangeRate = exchangeRate.toSnapshotExchangeRate;
|
|
14
23
|
exports.formatPrice = format.formatPrice;
|
|
15
24
|
exports.formatPriceRaw = format.formatPriceRaw;
|
|
16
|
-
exports.
|
|
25
|
+
exports.getLocalizedCurrency = format.getLocalizedCurrency;
|
|
26
|
+
exports.prettifyTotal = format.prettifyTotal;
|
|
17
27
|
exports.addMany = misc.addMany;
|
|
18
28
|
exports.amount = misc.amount;
|
|
19
|
-
exports.
|
|
29
|
+
exports.centsToCurrencyUnit = misc.centsToCurrencyUnit;
|
|
20
30
|
exports.currency = misc.currency;
|
|
31
|
+
exports.dineroToCurrencyUnit = misc.dineroToCurrencyUnit;
|
|
21
32
|
exports.getDinero = misc.getDinero;
|
|
22
33
|
exports.getDineroCurrency = misc.getDineroCurrency;
|
|
23
34
|
exports.money = misc.money;
|
|
24
35
|
exports.multiplyByFullPercent = misc.multiplyByFullPercent;
|
|
25
36
|
exports.parseCurrencyCode = misc.parseCurrencyCode;
|
|
26
37
|
exports.parseFloatToDinero = misc.parseFloatToDinero;
|
|
27
|
-
exports.
|
|
38
|
+
exports.parseFloatToDineroRaw = misc.parseFloatToDineroRaw;
|
|
39
|
+
exports.roundDinero = misc.roundDinero;
|
|
28
40
|
exports.stringAmountToDinero = misc.stringAmountToDinero;
|
|
29
41
|
exports.subtractMany = misc.subtractMany;
|
|
30
42
|
exports.toSmallestSubunit = misc.toSmallestSubunit;
|
|
31
|
-
exports.
|
|
43
|
+
exports.roundShippingPrice = shipping.roundShippingPrice;
|
|
44
|
+
exports.calculateLineItemTax = tax.calculateLineItemTax;
|
|
45
|
+
exports.calculateTotalTaxRate = tax.calculateTotalTaxRate;
|
|
46
|
+
exports.convertDecimalTaxRateToPercentage = tax.convertDecimalTaxRateToPercentage;
|
|
47
|
+
exports.decimalTaxRateToDinero = tax.decimalTaxRateToDinero;
|
|
48
|
+
exports.formatDecimalTaxRate = tax.formatDecimalTaxRate;
|
|
32
49
|
exports.removeTaxAmount = tax.removeTaxAmount;
|
|
50
|
+
exports.stringTaxRateToFloat = tax.stringTaxRateToFloat;
|
|
33
51
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
|
|
@@ -1,7 +1,11 @@
|
|
|
1
|
-
|
|
2
|
-
export {
|
|
3
|
-
export {
|
|
1
|
+
import * as index from './allocators/index.mjs';
|
|
2
|
+
export { index as Allocators };
|
|
3
|
+
export { EXCHANGE_RATE_DINERO_CURRENCY, Round, TAX_RATE_DINERO_CURRENCY, localizedCurrencyLookup, prettifyPriceLookup, smallestSubunitLookup, storesWithPerItemTaxRate } from './constants.mjs';
|
|
4
|
+
export { invertExchangeRate, toFixedExchangeRate, toSnapshotExchangeRate } from './exchangeRate.mjs';
|
|
5
|
+
export { formatPrice, formatPriceRaw, getLocalizedCurrency, prettifyTotal } from './format.mjs';
|
|
6
|
+
export { addMany, amount, centsToCurrencyUnit, currency, dineroToCurrencyUnit, getDinero, getDineroCurrency, money, multiplyByFullPercent, parseCurrencyCode, parseFloatToDinero, parseFloatToDineroRaw, roundDinero, stringAmountToDinero, subtractMany, toSmallestSubunit } from './misc.mjs';
|
|
7
|
+
export { roundShippingPrice } from './shipping.mjs';
|
|
8
|
+
export { calculateLineItemTax, calculateTotalTaxRate, convertDecimalTaxRateToPercentage, decimalTaxRateToDinero, formatDecimalTaxRate, removeTaxAmount, stringTaxRateToFloat } from './tax.mjs';
|
|
4
9
|
import './types.mjs';
|
|
5
|
-
export { allocateTaxAmount, removeTaxAmount } from './tax.mjs';
|
|
6
10
|
"use strict";
|
|
7
11
|
//# 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":";;;;;;;;;"}
|
|
@@ -1,53 +1,72 @@
|
|
|
1
|
-
import type { Dinero, Currency as DineroCurrency } from "dinero.js";
|
|
2
1
|
import { Currency } from "../../types";
|
|
3
|
-
|
|
4
|
-
amount: number;
|
|
5
|
-
currency: Currency;
|
|
6
|
-
}
|
|
7
|
-
/**
|
|
8
|
-
* Prettify numbers depending on the currency using rounding down.
|
|
9
|
-
* ! Should only be used to prettify storefront product prices after currency conversion but nothing else !
|
|
10
|
-
*/
|
|
11
|
-
export declare const prettifyTotal: (total: Dinero<number>) => Dinero<number>;
|
|
2
|
+
import type { Cents, Dino, DinoCurrency, Money, RoundingFn } from "./types";
|
|
12
3
|
/**
|
|
13
4
|
* Some currencies have subunits in their currency spec that are not used in reality. This causes Dinero to return incorrect subunit values for those currencies.
|
|
14
5
|
* This util rounds down any unused subunits to closest subunit resolution.
|
|
15
6
|
*
|
|
16
7
|
* ! Not to be confused with prettifyTotal
|
|
17
8
|
*/
|
|
18
|
-
export declare const toSmallestSubunit: (total:
|
|
9
|
+
export declare const toSmallestSubunit: (total: Dino) => Dino;
|
|
19
10
|
/**
|
|
20
11
|
* Find Dinero.js currency instance from our Currency enum.
|
|
21
12
|
* @throws Throws an error if currency is not found!
|
|
13
|
+
*
|
|
22
14
|
* @example
|
|
23
15
|
* getDineroCurrency(Currency.Usd); // => Dinero.js currency instance
|
|
24
16
|
* getDineroCurrency("invalid"); // => throws AssertionError
|
|
25
17
|
*/
|
|
26
|
-
export declare const getDineroCurrency: (currency: Currency) =>
|
|
18
|
+
export declare const getDineroCurrency: (currency: Currency) => DinoCurrency;
|
|
27
19
|
/**
|
|
28
|
-
* Convert Dinero currency to local currency type
|
|
20
|
+
* Convert Dinero currency (case-insensitive) to local currency type
|
|
21
|
+
* @throws Throws an error if currency is not found!
|
|
22
|
+
*
|
|
23
|
+
* @example
|
|
24
|
+
* parseCurrencyCode('usd') // Currency.Usd
|
|
25
|
+
* parseCurrencyCode('JPY') // Currency.Jpy
|
|
26
|
+
* parseCurrencyCode('invalid') // throws AssertionError
|
|
29
27
|
*/
|
|
30
28
|
export declare const parseCurrencyCode: (code: string) => Currency;
|
|
31
29
|
/**
|
|
32
|
-
*
|
|
30
|
+
* Utility to quickly convert cents to a to currency float amount number
|
|
31
|
+
*
|
|
32
|
+
* @example
|
|
33
|
+
* centsToCurrencyUnit(100, "USD") // 1
|
|
34
|
+
* centsToCurrencyUnit(1, "USD") // 0.01
|
|
35
|
+
* centsToCurrencyUnit(420, "USD") // 4.2
|
|
36
|
+
* centsToCurrencyUnit(420, "JPY") // 420
|
|
37
|
+
* FIXME: worth moving to a combined method of centsToCurrencyUnit & dineroToCurrencyUnit that accepts Money|Dino as input
|
|
38
|
+
*/
|
|
39
|
+
export declare const centsToCurrencyUnit: (centsAmount: Cents, currency: Currency) => number;
|
|
40
|
+
/**
|
|
41
|
+
* Utility to quickly convert dinero instance to a to currency amount number
|
|
33
42
|
*
|
|
34
|
-
*
|
|
35
|
-
*
|
|
36
|
-
*
|
|
43
|
+
* @example
|
|
44
|
+
* dineroToCurrencyUnit(getDinero(100, Currency.Usd)) // 1
|
|
45
|
+
* dineroToCurrencyUnit(getDinero(1, Currency.Usd)) // 0.01
|
|
46
|
+
* dineroToCurrencyUnit(getDinero(420, Currency.Usd)) // 4.2
|
|
37
47
|
*/
|
|
38
|
-
export declare const
|
|
48
|
+
export declare const dineroToCurrencyUnit: (dineroObj: Dino) => number;
|
|
39
49
|
/**
|
|
40
|
-
* Parse arbitrary float amount in a given currency to a dinero object
|
|
50
|
+
* Parse arbitrary float amount in a given currency to a dinero object.
|
|
51
|
+
* Wrapper around `parseFloatToDineroRaw` for easier usage.
|
|
41
52
|
*
|
|
42
53
|
* Doesn't work on string float amounts!
|
|
43
54
|
* @example
|
|
44
55
|
* parseFloatToDinero(420, Currency.Usd); // => Dinero.js instance
|
|
45
56
|
*/
|
|
46
|
-
export declare const parseFloatToDinero: (floatAmount: number, currency: Currency) => Dinero<number>;
|
|
57
|
+
export declare const parseFloatToDinero: (floatAmount: number, currency: Currency) => import("dinero.js").Dinero<number>;
|
|
58
|
+
/**
|
|
59
|
+
* Parse arbitrary float amount in a given dinero like currency object to a dinero object.
|
|
60
|
+
* ! Typically use `parseFloatToDinero` instead of this method ! But this one is useful for custom currencies (e.g. custom exchange rates)
|
|
61
|
+
*/
|
|
62
|
+
export declare const parseFloatToDineroRaw: (floatAmount: number, dineroCurrency: DinoCurrency) => import("dinero.js").Dinero<number>;
|
|
47
63
|
/**
|
|
48
64
|
* Shorthand for dinero constructor
|
|
65
|
+
*
|
|
66
|
+
* @example
|
|
67
|
+
* getDinero(100, Currency.Usd); // => Dinero.js instance (representing $1)
|
|
49
68
|
*/
|
|
50
|
-
export declare const getDinero: (amount:
|
|
69
|
+
export declare const getDinero: (amount: Cents, currency: Currency) => Dino;
|
|
51
70
|
/**
|
|
52
71
|
* Shorthand to get amount from dinero instance
|
|
53
72
|
*
|
|
@@ -58,8 +77,11 @@ export declare const getDinero: (amount: number, currency: Currency) => Dinero<n
|
|
|
58
77
|
*
|
|
59
78
|
* We should call something like: transformScale(d, currency.exponent)
|
|
60
79
|
* @see https://v2.dinerojs.com/docs/api/conversions/transform-scale
|
|
80
|
+
*
|
|
81
|
+
* @example
|
|
82
|
+
* amount(getDinero(100, Currency.Usd)); // 100
|
|
61
83
|
*/
|
|
62
|
-
export declare const amount: (dinero:
|
|
84
|
+
export declare const amount: (dinero: Dino) => Cents;
|
|
63
85
|
/**
|
|
64
86
|
* Method to multiply dinero amount by full percent.
|
|
65
87
|
* It also transforms scale back to currency exponent.
|
|
@@ -68,24 +90,42 @@ export declare const amount: (dinero: Dinero<number>) => number;
|
|
|
68
90
|
* Will convert 0.01 - 12% to 0, but thats edge case we can tolerate, because
|
|
69
91
|
* of dinero version we do not control rounding
|
|
70
92
|
*/
|
|
71
|
-
export declare const multiplyByFullPercent: (dinero:
|
|
93
|
+
export declare const multiplyByFullPercent: (dinero: Dino, percentIncrease: number) => Dino;
|
|
72
94
|
/**
|
|
73
95
|
* Shorthand to get currency from dinero instance
|
|
96
|
+
*
|
|
97
|
+
* @example
|
|
98
|
+
* currency(getDinero(100, Currency.Usd)); // Currency.Usd
|
|
74
99
|
*/
|
|
75
|
-
export declare const currency: (dinero:
|
|
100
|
+
export declare const currency: (dinero: Dino) => Currency;
|
|
76
101
|
/**
|
|
77
102
|
* Shorthand to get our GraphQL Money type from dinero instance
|
|
103
|
+
*
|
|
104
|
+
* @example
|
|
105
|
+
* money(getDinero(100, Currency.Usd)); // { amount: 100, currency: Currency.Usd }
|
|
78
106
|
*/
|
|
79
|
-
export declare const money: (dinero:
|
|
107
|
+
export declare const money: (dinero: Dino) => Money;
|
|
80
108
|
/**
|
|
81
109
|
* Helper to quickly add multiple dinero instances with same currency
|
|
110
|
+
*
|
|
111
|
+
* @example
|
|
112
|
+
* addMany([getDinero(100, Currency.Usd), getDinero(200, Currency.Usd)], Currency.Usd); // => Dinero.js instance (representing $3)
|
|
82
113
|
*/
|
|
83
|
-
export declare const addMany: (addends: Array<
|
|
114
|
+
export declare const addMany: (addends: Array<Dino>, defaultCurrency: Currency) => Dino;
|
|
84
115
|
/**
|
|
85
116
|
* Helper to quickly subtract multiple dinero instances with same currency
|
|
86
117
|
*/
|
|
87
|
-
export declare const subtractMany: (subtractions: Array<
|
|
118
|
+
export declare const subtractMany: (subtractions: Array<Dino>, defaultCurrency: Currency) => Dino;
|
|
88
119
|
/**
|
|
89
120
|
* Helper to quickly get dinero object from string
|
|
90
121
|
*/
|
|
91
|
-
export declare const stringAmountToDinero: (price: string, currency: Currency) => Dinero<number>;
|
|
122
|
+
export declare const stringAmountToDinero: (price: string, currency: Currency) => import("dinero.js").Dinero<number>;
|
|
123
|
+
/**
|
|
124
|
+
* Helper to quickly round dinero object to closest integer by a given rounding function
|
|
125
|
+
* FIXME: add tests
|
|
126
|
+
*
|
|
127
|
+
* @example
|
|
128
|
+
* roundDinero(getDinero(120, Currency.Usd), Math.floor); // => Dinero.js instance (representing $1)
|
|
129
|
+
* roundDinero(getDinero(120, Currency.Usd), Math.ceil); // => Dinero.js instance (representing $2)
|
|
130
|
+
*/
|
|
131
|
+
export declare const roundDinero: (dinero: Dino, roundingFn: RoundingFn) => Dino;
|
package/lib/utils/money/misc.js
CHANGED
|
@@ -1,56 +1,14 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var currencies = require('@dinero.js/currencies');
|
|
4
3
|
var dinero_js = require('dinero.js');
|
|
5
4
|
require('../../types/index.js');
|
|
6
5
|
var errors = require('../errors.js');
|
|
7
6
|
var number = require('../number.js');
|
|
8
7
|
var string = require('../string.js');
|
|
9
|
-
var validations = require('../validations.js');
|
|
10
8
|
var constants = require('./constants.js');
|
|
9
|
+
var misc_private = require('./misc.private.js');
|
|
11
10
|
var generated = require('../../types/generated.js');
|
|
12
|
-
function _interopNamespace(e) {
|
|
13
|
-
if (e && e.__esModule) return e;
|
|
14
|
-
var n = Object.create(null);
|
|
15
|
-
if (e) {
|
|
16
|
-
Object.keys(e).forEach(function (k) {
|
|
17
|
-
if (k !== 'default') {
|
|
18
|
-
var d = Object.getOwnPropertyDescriptor(e, k);
|
|
19
|
-
Object.defineProperty(n, k, d.get ? d : {
|
|
20
|
-
enumerable: true,
|
|
21
|
-
get: function () {
|
|
22
|
-
return e[k];
|
|
23
|
-
}
|
|
24
|
-
});
|
|
25
|
-
}
|
|
26
|
-
});
|
|
27
|
-
}
|
|
28
|
-
n["default"] = e;
|
|
29
|
-
return Object.freeze(n);
|
|
30
|
-
}
|
|
31
|
-
var currencies__namespace = /*#__PURE__*/_interopNamespace(currencies);
|
|
32
11
|
"use strict";
|
|
33
|
-
const currencyLookup = new Set(Object.keys(generated.Currency).map(el => el.toString()));
|
|
34
|
-
const currenciesMap = new Map(Object.values(currencies__namespace).map(currency2 => [currency2.code, currency2]));
|
|
35
|
-
const floatToInt = (floatAmount, base, exponent) => constants.financialRound(floatAmount * Math.pow(base, exponent));
|
|
36
|
-
const prettifyTotal = total => {
|
|
37
|
-
if (!dinero_js.hasSubUnits(total)) {
|
|
38
|
-
return total;
|
|
39
|
-
}
|
|
40
|
-
const totalJson = total.toJSON();
|
|
41
|
-
const minValueInclusiveToRoundDownFrom = constants.prettifyPriceLookup.get(totalJson.currency.code);
|
|
42
|
-
if (minValueInclusiveToRoundDownFrom == null || dinero_js.toUnit(total) < minValueInclusiveToRoundDownFrom) {
|
|
43
|
-
return total;
|
|
44
|
-
}
|
|
45
|
-
const roundedUnitPrice = dinero_js.toUnit(total, {
|
|
46
|
-
digits: 0,
|
|
47
|
-
round: dinero_js.down
|
|
48
|
-
});
|
|
49
|
-
return dinero_js.dinero({
|
|
50
|
-
amount: roundedUnitPrice * Math.pow(totalJson.currency.base, totalJson.currency.exponent),
|
|
51
|
-
currency: totalJson.currency
|
|
52
|
-
});
|
|
53
|
-
};
|
|
54
12
|
const toSmallestSubunit = total => {
|
|
55
13
|
if (!dinero_js.hasSubUnits(total)) {
|
|
56
14
|
return total;
|
|
@@ -60,49 +18,47 @@ const toSmallestSubunit = total => {
|
|
|
60
18
|
if (roundToDigits == null || roundingMode == null) {
|
|
61
19
|
return total;
|
|
62
20
|
}
|
|
63
|
-
|
|
64
|
-
digits: roundToDigits,
|
|
65
|
-
round: roundingMode
|
|
66
|
-
});
|
|
67
|
-
return dinero_js.dinero({
|
|
68
|
-
amount: roundedUnitPrice * Math.pow(totalJson.currency.base, totalJson.currency.exponent),
|
|
69
|
-
currency: totalJson.currency
|
|
70
|
-
});
|
|
21
|
+
return roundDinero(total, roundingMode);
|
|
71
22
|
};
|
|
72
23
|
const getDineroCurrency = currency2 => {
|
|
73
|
-
const dineroCurrency =
|
|
24
|
+
const dineroCurrency = misc_private.dineroCurrenciesLookup.get(currency2);
|
|
74
25
|
errors.assert(!!dineroCurrency, `Unsupported currency: "${currency2}"`);
|
|
75
26
|
return dineroCurrency;
|
|
76
27
|
};
|
|
77
28
|
const parseCurrencyCode = code => {
|
|
78
29
|
const normalizedCode = string.capitalize(code.toLowerCase());
|
|
79
|
-
errors.assert(currencyLookup.has(normalizedCode), `Invalid currency code: ${normalizedCode}`);
|
|
30
|
+
errors.assert(misc_private.currencyLookup.has(normalizedCode), `Invalid currency code: ${normalizedCode}`);
|
|
80
31
|
return generated.Currency[normalizedCode];
|
|
81
32
|
};
|
|
82
|
-
const
|
|
33
|
+
const centsToCurrencyUnit = (centsAmount, currency2) => {
|
|
83
34
|
const dineroCurrency = getDineroCurrency(currency2);
|
|
84
|
-
const
|
|
85
|
-
amount:
|
|
35
|
+
const dineroObj = dinero_js.dinero({
|
|
36
|
+
amount: centsAmount,
|
|
86
37
|
currency: dineroCurrency
|
|
87
38
|
});
|
|
88
|
-
|
|
89
|
-
|
|
39
|
+
return dineroToCurrencyUnit(dineroObj);
|
|
40
|
+
};
|
|
41
|
+
const dineroToCurrencyUnit = dineroObj => {
|
|
42
|
+
return dinero_js.toUnit(dineroObj);
|
|
90
43
|
};
|
|
91
44
|
const parseFloatToDinero = (floatAmount, currency2) => {
|
|
92
|
-
number.isFloat(floatAmount, "Amount");
|
|
93
45
|
const dineroCurrency = getDineroCurrency(currency2);
|
|
46
|
+
return parseFloatToDineroRaw(floatAmount, dineroCurrency);
|
|
47
|
+
};
|
|
48
|
+
const parseFloatToDineroRaw = (floatAmount, dineroCurrency) => {
|
|
49
|
+
number.isFloat(floatAmount, "Amount");
|
|
94
50
|
const scaleOfGivenAmount = String(floatAmount).split(".")[1]?.length ?? dineroCurrency.exponent;
|
|
95
51
|
if (scaleOfGivenAmount == null || scaleOfGivenAmount > dineroCurrency.exponent) {
|
|
96
52
|
throw new Error(`scaleOfGivenAmount is unsupported ${scaleOfGivenAmount}`);
|
|
97
53
|
}
|
|
98
|
-
const rateInt = floatToInt(floatAmount, dineroCurrency.base, dineroCurrency.exponent);
|
|
54
|
+
const rateInt = misc_private.floatToInt(floatAmount, dineroCurrency.base, dineroCurrency.exponent);
|
|
99
55
|
return dinero_js.dinero({
|
|
100
56
|
amount: rateInt,
|
|
101
57
|
currency: dineroCurrency
|
|
102
58
|
});
|
|
103
59
|
};
|
|
104
60
|
const getDinero = (amount2, currency2) => {
|
|
105
|
-
|
|
61
|
+
number.isInt(amount2, "Amount");
|
|
106
62
|
return dinero_js.dinero({
|
|
107
63
|
amount: amount2,
|
|
108
64
|
currency: getDineroCurrency(currency2)
|
|
@@ -134,18 +90,33 @@ const money = dinero2 => {
|
|
|
134
90
|
};
|
|
135
91
|
const addMany = (addends, defaultCurrency) => [...addends, getDinero(0, defaultCurrency)].reduce(dinero_js.add);
|
|
136
92
|
const subtractMany = (subtractions, defaultCurrency) => [...subtractions, getDinero(0, defaultCurrency)].reduce(dinero_js.subtract);
|
|
137
|
-
const stringAmountToDinero = (price, currency2) =>
|
|
93
|
+
const stringAmountToDinero = (price, currency2) =>
|
|
94
|
+
// FIXME: parseFloat seems dangerous O_O
|
|
95
|
+
parseFloatToDinero(parseFloat(price), currency2);
|
|
96
|
+
const roundDinero = (dinero2, roundingFn) => {
|
|
97
|
+
const roundedUnitPrice = dinero_js.toUnit(dinero2, {
|
|
98
|
+
digits: 0,
|
|
99
|
+
round: roundingFn
|
|
100
|
+
});
|
|
101
|
+
const snapshot = dinero_js.toSnapshot(dinero2);
|
|
102
|
+
return dinero2.create({
|
|
103
|
+
amount: roundedUnitPrice * snapshot.currency.base ** snapshot.currency.exponent,
|
|
104
|
+
currency: snapshot.currency
|
|
105
|
+
});
|
|
106
|
+
};
|
|
138
107
|
exports.addMany = addMany;
|
|
139
108
|
exports.amount = amount;
|
|
140
|
-
exports.
|
|
109
|
+
exports.centsToCurrencyUnit = centsToCurrencyUnit;
|
|
141
110
|
exports.currency = currency;
|
|
111
|
+
exports.dineroToCurrencyUnit = dineroToCurrencyUnit;
|
|
142
112
|
exports.getDinero = getDinero;
|
|
143
113
|
exports.getDineroCurrency = getDineroCurrency;
|
|
144
114
|
exports.money = money;
|
|
145
115
|
exports.multiplyByFullPercent = multiplyByFullPercent;
|
|
146
116
|
exports.parseCurrencyCode = parseCurrencyCode;
|
|
147
117
|
exports.parseFloatToDinero = parseFloatToDinero;
|
|
148
|
-
exports.
|
|
118
|
+
exports.parseFloatToDineroRaw = parseFloatToDineroRaw;
|
|
119
|
+
exports.roundDinero = roundDinero;
|
|
149
120
|
exports.stringAmountToDinero = stringAmountToDinero;
|
|
150
121
|
exports.subtractMany = subtractMany;
|
|
151
122
|
exports.toSmallestSubunit = toSmallestSubunit;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"misc.js","sources":["../../../src/utils/money/misc.ts"],"sourcesContent":["import * as currencies from \"@dinero.js/currencies\";\nimport type { Dinero, Currency as DineroCurrency } from \"dinero.js\";\nimport {\n add,\n dinero,\n down,\n hasSubUnits,\n multiply,\n subtract,\n toSnapshot,\n toUnit,\n transformScale,\n} from \"dinero.js\";\n\nimport { Currency } from \"../../types\";\nimport { assert } from \"../errors\";\nimport { isFloat } from \"../number\";\nimport { capitalize } from \"../string\";\nimport { isInt } from \"../validations\";\nimport {\n financialRound,\n prettifyPriceLookup,\n smallestSubunitLookup,\n} from \"./constants\";\n\nexport interface Money {\n amount: number;\n currency: Currency;\n}\n\n// #############################################################################\n// Private helpers\n// #############################################################################\nconst currencyLookup = new Set(\n Object.keys(Currency).map((el) => el.toString()),\n);\n\n/**\n * Creating a map of currencies for way faster lookup then doing a array.find()\n * @see https://stackoverflow.com/a/65604244/1378261\n */\nconst currenciesMap = new Map(\n Object.values(currencies).map((currency) => [currency.code, currency]),\n);\n\n/**\n * Private util to convert a float value into a int. Also applies financial rounding to the value if needed.\n * Inspired by https://v2.dinerojs.com/docs/faq/how-can-i-create-dinero-objects-from-floats\n * @private Just for using within this file, please consider using other methods to solve your issue\n * @example\n * floatToInt(69.10, 10, 2); // 6910\n * floatToInt(42, 10, 2); // 4200\n * floatToInt(0.22, 10, 6); // 220000\n */\nconst floatToInt = (\n floatAmount: number,\n base: number,\n exponent: number,\n): number => financialRound(floatAmount * Math.pow(base, exponent));\n\n// #############################################################################\n// Public functions\n// #############################################################################\n\n/**\n * Prettify numbers depending on the currency using rounding down.\n * ! Should only be used to prettify storefront product prices after currency conversion but nothing else !\n */\nexport const prettifyTotal = (total: Dinero<number>): Dinero<number> => {\n // Nothing to round\n if (!hasSubUnits(total)) {\n return total;\n }\n\n const totalJson = total.toJSON();\n\n const minValueInclusiveToRoundDownFrom = prettifyPriceLookup.get(\n totalJson.currency.code,\n );\n\n // Don't round if currency unsupported or value is below min threshold\n if (\n minValueInclusiveToRoundDownFrom == null ||\n toUnit(total) < minValueInclusiveToRoundDownFrom\n ) {\n return total;\n }\n\n const roundedUnitPrice = toUnit(total, { digits: 0, round: down });\n // Multiplying by 100 to get the cents\n return dinero({\n amount:\n roundedUnitPrice *\n Math.pow(totalJson.currency.base, totalJson.currency.exponent),\n currency: totalJson.currency,\n });\n};\n\n/**\n * Some currencies have subunits in their currency spec that are not used in reality. This causes Dinero to return incorrect subunit values for those currencies.\n * This util rounds down any unused subunits to closest subunit resolution.\n *\n * ! Not to be confused with prettifyTotal\n */\nexport const toSmallestSubunit = (total: Dinero<number>): Dinero<number> => {\n // Nothing to round\n if (!hasSubUnits(total)) {\n return total;\n }\n\n const totalJson = total.toJSON();\n\n const [roundToDigits, roundingMode] =\n smallestSubunitLookup.get(totalJson.currency.code) ?? [];\n\n if (roundToDigits == null || roundingMode == null) {\n return total;\n }\n\n const roundedUnitPrice = toUnit(total, {\n digits: roundToDigits,\n round: roundingMode,\n });\n return dinero({\n amount:\n roundedUnitPrice *\n Math.pow(totalJson.currency.base, totalJson.currency.exponent),\n currency: totalJson.currency,\n });\n};\n\n/**\n * Find Dinero.js currency instance from our Currency enum.\n * @throws Throws an error if currency is not found!\n * @example\n * getDineroCurrency(Currency.Usd); // => Dinero.js currency instance\n * getDineroCurrency(\"invalid\"); // => throws AssertionError\n */\nexport const getDineroCurrency = (\n currency: Currency,\n): DineroCurrency<number> => {\n const dineroCurrency = currenciesMap.get(currency);\n assert(!!dineroCurrency, `Unsupported currency: \"${currency}\"`);\n return dineroCurrency;\n};\n\n/**\n * Convert Dinero currency to local currency type\n */\nexport const parseCurrencyCode = (code: string): Currency => {\n const normalizedCode = capitalize(code.toLowerCase());\n assert(\n currencyLookup.has(normalizedCode),\n `Invalid currency code: ${normalizedCode}`,\n );\n return Currency[normalizedCode as keyof typeof Currency];\n};\n\n/**\n * Get major units amount for cents amount and currency\n *\n * Can look into the approach of dinero core toUnits if we need a more robust approach\n * https://github.com/dinerojs/dinero.js/blob/main/packages/core/src/api/toUnits.ts\n * Though, based on experimentation, it's a basic division in the end regardless\n */\nexport const centsToMajorUnits = (\n amount: number,\n currency: Currency,\n): number => {\n const dineroCurrency = getDineroCurrency(currency);\n const price = dinero({ amount, currency: dineroCurrency });\n const divider = Math.pow(10, dineroCurrency.exponent);\n\n return toSnapshot(price).amount / divider;\n};\n\n/**\n * Parse arbitrary float amount in a given currency to a dinero object\n *\n * Doesn't work on string float amounts!\n * @example\n * parseFloatToDinero(420, Currency.Usd); // => Dinero.js instance\n */\nexport const parseFloatToDinero = (floatAmount: number, currency: Currency) => {\n isFloat(floatAmount, \"Amount\");\n\n const dineroCurrency = getDineroCurrency(currency);\n\n /**\n * Try to determine given input scale after comma, if not found, use currency default as that would indicate that\n * given input was an integer instead of a float\n *\n * FIXME: Won't work correctly if some currencies use dot/comma separation for decimal digits:\n * At least MacOS shows 4 different kind of formats to numbers.\n * 1. \"1234567,89\"\n * 2. \"1,234,567,89\"\n * 3. \"1.234.567,89\"\n * 4. \"1 234 567,89\"\n * Have to research if there are any more standards we should try to parse support\n */\n const scaleOfGivenAmount =\n String(floatAmount).split(\".\")[1]?.length ?? dineroCurrency.exponent;\n\n if (\n scaleOfGivenAmount == null ||\n scaleOfGivenAmount > dineroCurrency.exponent\n ) {\n throw new Error(`scaleOfGivenAmount is unsupported ${scaleOfGivenAmount}`);\n }\n const rateInt = floatToInt(\n floatAmount,\n dineroCurrency.base,\n dineroCurrency.exponent,\n );\n return dinero({\n amount: rateInt,\n currency: dineroCurrency,\n });\n};\n\n/**\n * Shorthand for dinero constructor\n */\nexport const getDinero = (\n amount: number,\n currency: Currency,\n): Dinero<number> => {\n isInt(amount, \"Amount\");\n return dinero({ amount, currency: getDineroCurrency(currency) });\n};\n\n/**\n * Shorthand to get amount from dinero instance\n *\n * FIXME: There is potential issue because we are not trimming scale:\n * multiply(getDinero(100, Currency.Usd), { amount: 100 + percentIncrease, scale: 2 })\n * will result in amount:10600, scale:4 (2*2), because dinero is rounding to safest scale.\n * @see https://v2.dinerojs.com/docs/core-concepts/scale#trimming-scale\n *\n * We should call something like: transformScale(d, currency.exponent)\n * @see https://v2.dinerojs.com/docs/api/conversions/transform-scale\n */\nexport const amount = (dinero: Dinero<number>): number => {\n return toSnapshot(dinero).amount;\n};\n\n/**\n * Method to multiply dinero amount by full percent.\n * It also transforms scale back to currency exponent.\n * Where in case 20.34*1.06=21,5604, it will round to 21.56\n *\n * Will convert 0.01 - 12% to 0, but thats edge case we can tolerate, because\n * of dinero version we do not control rounding\n */\nexport const multiplyByFullPercent = (\n dinero: Dinero<number>,\n percentIncrease: number,\n): Dinero<number> => {\n assert(\n percentIncrease >= -100 && percentIncrease <= 100,\n \"Range should be in [-100, 100]\",\n );\n // (106 / 10^2 = 1.06)\n const multiplyResult = multiply(dinero, {\n amount: 100 + percentIncrease,\n scale: 2,\n });\n return transformScale(\n multiplyResult,\n multiplyResult.toJSON().currency.exponent,\n );\n};\n\n/**\n * Shorthand to get currency from dinero instance\n */\nexport const currency = (dinero: Dinero<number>): Currency => {\n return parseCurrencyCode(toSnapshot(dinero).currency.code);\n};\n\n/**\n * Shorthand to get our GraphQL Money type from dinero instance\n */\nexport const money = (dinero: Dinero<number>): Money => {\n const { amount, currency } = toSnapshot(dinero);\n\n return {\n amount,\n currency: parseCurrencyCode(currency.code),\n };\n};\n\n/**\n * Helper to quickly add multiple dinero instances with same currency\n */\nexport const addMany = (\n addends: Array<Dinero<number>>,\n defaultCurrency: Currency,\n) => [...addends, getDinero(0, defaultCurrency)].reduce(add);\n\n/**\n * Helper to quickly subtract multiple dinero instances with same currency\n */\nexport const subtractMany = (\n subtractions: Array<Dinero<number>>,\n defaultCurrency: Currency,\n) => [...subtractions, getDinero(0, defaultCurrency)].reduce(subtract);\n\n/**\n * Helper to quickly get dinero object from string\n */\nexport const stringAmountToDinero = (price: string, currency: Currency) =>\n parseFloatToDinero(parseFloat(price), currency);\n"],"names":["currencyLookup","Set","Object","keys","Currency","map","el","toString","currenciesMap","Map","values","currencies","currency","code","floatToInt","floatAmount","base","exponent","financialRound","Math","pow","prettifyTotal","total","hasSubUnits","totalJson","toJSON","minValueInclusiveToRoundDownFrom","prettifyPriceLookup","get","toUnit","roundedUnitPrice","digits","round","down","dinero","amount","toSmallestSubunit","roundToDigits","roundingMode","smallestSubunitLookup","getDineroCurrency","dineroCurrency","assert","parseCurrencyCode","normalizedCode","capitalize","toLowerCase","has","centsToMajorUnits","price","divider","toSnapshot","parseFloatToDinero","isFloat","scaleOfGivenAmount","String","split","length","Error","rateInt","getDinero","isInt","multiplyByFullPercent","percentIncrease","multiplyResult","multiply","scale","transformScale","money","addMany","addends","defaultCurrency","reduce","add","subtractMany","subtractions","subtract","stringAmountToDinero","parseFloat"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAiCA,MAAMA,iBAAiB,IAAIC,GAAA,CACzBC,MAAA,CAAOC,KAAKC,SAAAA,CAAAA,QAA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AA,CAAEC,OAAOI,SAAAA,CAAAA,QAAQ,CAAA;AAKxD,MAAAC,oBAAA,GAAuBA,CAAC5B,KAAerC,EAAAA,SAAAA,KAClDwC,mBAAmB0B,UAAW,CAAA7B,KAAK,GAAGrC,SAAQ,CAAA;;;;;;;;;;;;;;"}
|
|
1
|
+
{"version":3,"file":"misc.js","sources":["../../../src/utils/money/misc.ts"],"sourcesContent":["import {\n add,\n dinero,\n hasSubUnits,\n multiply,\n subtract,\n toSnapshot,\n toUnit,\n transformScale,\n} from \"dinero.js\";\n\nimport { Currency } from \"../../types\";\nimport { assert } from \"../errors\";\nimport { isFloat, isInt } from \"../number\";\nimport { capitalize } from \"../string\";\nimport { smallestSubunitLookup } from \"./constants\";\nimport {\n currencyLookup,\n dineroCurrenciesLookup,\n floatToInt,\n} from \"./misc.private\";\nimport type { Cents, Dino, DinoCurrency, Money, RoundingFn } from \"./types\";\n\n/**\n * Some currencies have subunits in their currency spec that are not used in reality. This causes Dinero to return incorrect subunit values for those currencies.\n * This util rounds down any unused subunits to closest subunit resolution.\n *\n * ! Not to be confused with prettifyTotal\n */\nexport const toSmallestSubunit = (total: Dino): Dino => {\n // Nothing to round\n if (!hasSubUnits(total)) {\n return total;\n }\n\n const totalJson = total.toJSON();\n\n const [roundToDigits, roundingMode] =\n smallestSubunitLookup.get(totalJson.currency.code) ?? [];\n\n if (roundToDigits == null || roundingMode == null) {\n return total;\n }\n\n return roundDinero(total, roundingMode);\n};\n\n/**\n * Find Dinero.js currency instance from our Currency enum.\n * @throws Throws an error if currency is not found!\n *\n * @example\n * getDineroCurrency(Currency.Usd); // => Dinero.js currency instance\n * getDineroCurrency(\"invalid\"); // => throws AssertionError\n */\nexport const getDineroCurrency = (currency: Currency): DinoCurrency => {\n const dineroCurrency = dineroCurrenciesLookup.get(currency);\n assert(!!dineroCurrency, `Unsupported currency: \"${currency}\"`);\n return dineroCurrency;\n};\n\n/**\n * Convert Dinero currency (case-insensitive) to local currency type\n * @throws Throws an error if currency is not found!\n *\n * @example\n * parseCurrencyCode('usd') // Currency.Usd\n * parseCurrencyCode('JPY') // Currency.Jpy\n * parseCurrencyCode('invalid') // throws AssertionError\n */\nexport const parseCurrencyCode = (code: string): Currency => {\n const normalizedCode = capitalize(code.toLowerCase());\n assert(\n currencyLookup.has(normalizedCode),\n `Invalid currency code: ${normalizedCode}`,\n );\n return Currency[normalizedCode as keyof typeof Currency];\n};\n\n/**\n * Utility to quickly convert cents to a to currency float amount number\n *\n * @example\n * centsToCurrencyUnit(100, \"USD\") // 1\n * centsToCurrencyUnit(1, \"USD\") // 0.01\n * centsToCurrencyUnit(420, \"USD\") // 4.2\n * centsToCurrencyUnit(420, \"JPY\") // 420\n * FIXME: worth moving to a combined method of centsToCurrencyUnit & dineroToCurrencyUnit that accepts Money|Dino as input\n */\nexport const centsToCurrencyUnit = (\n centsAmount: Cents,\n currency: Currency,\n): number => {\n const dineroCurrency = getDineroCurrency(currency);\n const dineroObj = dinero({ amount: centsAmount, currency: dineroCurrency });\n return dineroToCurrencyUnit(dineroObj);\n};\n\n/**\n * Utility to quickly convert dinero instance to a to currency amount number\n *\n * @example\n * dineroToCurrencyUnit(getDinero(100, Currency.Usd)) // 1\n * dineroToCurrencyUnit(getDinero(1, Currency.Usd)) // 0.01\n * dineroToCurrencyUnit(getDinero(420, Currency.Usd)) // 4.2\n */\nexport const dineroToCurrencyUnit = (dineroObj: Dino): number => {\n return toUnit(dineroObj);\n};\n\n/**\n * Parse arbitrary float amount in a given currency to a dinero object.\n * Wrapper around `parseFloatToDineroRaw` for easier usage.\n *\n * Doesn't work on string float amounts!\n * @example\n * parseFloatToDinero(420, Currency.Usd); // => Dinero.js instance\n */\nexport const parseFloatToDinero = (floatAmount: number, currency: Currency) => {\n const dineroCurrency = getDineroCurrency(currency);\n return parseFloatToDineroRaw(floatAmount, dineroCurrency);\n};\n\n/**\n * Parse arbitrary float amount in a given dinero like currency object to a dinero object.\n * ! Typically use `parseFloatToDinero` instead of this method ! But this one is useful for custom currencies (e.g. custom exchange rates)\n */\nexport const parseFloatToDineroRaw = (\n floatAmount: number,\n dineroCurrency: DinoCurrency,\n) => {\n isFloat(floatAmount, \"Amount\");\n\n /**\n * Try to determine given input scale after comma, if not found, use currency default as that would indicate that\n * given input was an integer instead of a float\n *\n * FIXME: Won't work correctly if some currencies use dot/comma separation for decimal digits:\n * At least MacOS shows 4 different kind of formats to numbers.\n * 1. \"1234567,89\"\n * 2. \"1,234,567,89\"\n * 3. \"1.234.567,89\"\n * 4. \"1 234 567,89\"\n * Have to research if there are any more standards we should try to parse support\n */\n const scaleOfGivenAmount =\n String(floatAmount).split(\".\")[1]?.length ?? dineroCurrency.exponent;\n\n if (\n scaleOfGivenAmount == null ||\n scaleOfGivenAmount > dineroCurrency.exponent\n ) {\n throw new Error(`scaleOfGivenAmount is unsupported ${scaleOfGivenAmount}`);\n }\n const rateInt = floatToInt(\n floatAmount,\n dineroCurrency.base,\n dineroCurrency.exponent,\n );\n return dinero({\n amount: rateInt,\n currency: dineroCurrency,\n });\n};\n\n/**\n * Shorthand for dinero constructor\n *\n * @example\n * getDinero(100, Currency.Usd); // => Dinero.js instance (representing $1)\n */\nexport const getDinero = (amount: Cents, currency: Currency): Dino => {\n // TODO: verify if this is even needed, as dinero might already handle this\n isInt(amount, \"Amount\");\n return dinero({ amount, currency: getDineroCurrency(currency) });\n};\n\n/**\n * Shorthand to get amount from dinero instance\n *\n * FIXME: There is potential issue because we are not trimming scale:\n * multiply(getDinero(100, Currency.Usd), { amount: 100 + percentIncrease, scale: 2 })\n * will result in amount:10600, scale:4 (2*2), because dinero is rounding to safest scale.\n * @see https://v2.dinerojs.com/docs/core-concepts/scale#trimming-scale\n *\n * We should call something like: transformScale(d, currency.exponent)\n * @see https://v2.dinerojs.com/docs/api/conversions/transform-scale\n *\n * @example\n * amount(getDinero(100, Currency.Usd)); // 100\n */\nexport const amount = (dinero: Dino): Cents => {\n return toSnapshot(dinero).amount;\n};\n\n/**\n * Method to multiply dinero amount by full percent.\n * It also transforms scale back to currency exponent.\n * Where in case 20.34*1.06=21,5604, it will round to 21.56\n *\n * Will convert 0.01 - 12% to 0, but thats edge case we can tolerate, because\n * of dinero version we do not control rounding\n */\nexport const multiplyByFullPercent = (\n dinero: Dino,\n percentIncrease: number,\n): Dino => {\n assert(\n percentIncrease >= -100 && percentIncrease <= 100,\n \"Range should be in [-100, 100]\",\n );\n // (106 / 10^2 = 1.06)\n const multiplyResult = multiply(dinero, {\n amount: 100 + percentIncrease,\n scale: 2,\n });\n return transformScale(\n multiplyResult,\n multiplyResult.toJSON().currency.exponent,\n );\n};\n\n/**\n * Shorthand to get currency from dinero instance\n *\n * @example\n * currency(getDinero(100, Currency.Usd)); // Currency.Usd\n */\nexport const currency = (dinero: Dino): Currency => {\n return parseCurrencyCode(toSnapshot(dinero).currency.code);\n};\n\n/**\n * Shorthand to get our GraphQL Money type from dinero instance\n *\n * @example\n * money(getDinero(100, Currency.Usd)); // { amount: 100, currency: Currency.Usd }\n */\nexport const money = (dinero: Dino): Money => {\n const { amount, currency } = toSnapshot(dinero);\n\n return {\n amount,\n currency: parseCurrencyCode(currency.code),\n };\n};\n\n/**\n * Helper to quickly add multiple dinero instances with same currency\n *\n * @example\n * addMany([getDinero(100, Currency.Usd), getDinero(200, Currency.Usd)], Currency.Usd); // => Dinero.js instance (representing $3)\n */\nexport const addMany = (addends: Array<Dino>, defaultCurrency: Currency) =>\n [...addends, getDinero(0, defaultCurrency)].reduce(add);\n\n/**\n * Helper to quickly subtract multiple dinero instances with same currency\n */\nexport const subtractMany = (\n subtractions: Array<Dino>,\n defaultCurrency: Currency,\n) => [...subtractions, getDinero(0, defaultCurrency)].reduce(subtract);\n\n/**\n * Helper to quickly get dinero object from string\n */\nexport const stringAmountToDinero = (price: string, currency: Currency) =>\n // FIXME: parseFloat seems dangerous O_O\n parseFloatToDinero(parseFloat(price), currency);\n\n/**\n * Helper to quickly round dinero object to closest integer by a given rounding function\n * FIXME: add tests\n *\n * @example\n * roundDinero(getDinero(120, Currency.Usd), Math.floor); // => Dinero.js instance (representing $1)\n * roundDinero(getDinero(120, Currency.Usd), Math.ceil); // => Dinero.js instance (representing $2)\n */\nexport const roundDinero = (dinero: Dino, roundingFn: RoundingFn): Dino => {\n const roundedUnitPrice = toUnit(dinero, { digits: 0, round: roundingFn });\n\n const snapshot = toSnapshot(dinero);\n\n return dinero.create({\n amount:\n roundedUnitPrice * snapshot.currency.base ** snapshot.currency.exponent,\n currency: snapshot.currency,\n });\n};\n"],"names":["toSmallestSubunit","total","hasSubUnits","totalJson","toJSON","roundToDigits","roundingMode","smallestSubunitLookup","get","currency","code","roundDinero","getDineroCurrency","dineroCurrency","dineroCurrenciesLookup","assert","parseCurrencyCode","normalizedCode","capitalize","toLowerCase","currencyLookup","has","Currency","centsToCurrencyUnit","centsAmount","dineroObj","dinero","amount","dineroToCurrencyUnit","toUnit","parseFloatToDinero","floatAmount","parseFloatToDineroRaw","isFloat","scaleOfGivenAmount","String","split","length","exponent","Error","rateInt","floatToInt","base","getDinero","isInt","toSnapshot","multiplyByFullPercent","percentIncrease","multiplyResult","multiply","scale","transformScale","money","addMany","addends","defaultCurrency","reduce","add","subtractMany","subtractions","subtract","stringAmountToDinero","price","parseFloat","roundingFn","roundedUnitPrice","digits","round","snapshot","create"],"mappings":";;;;;;;;;;;AA6Ba,MAAAA,iBAAA,GAAqBC,KAAsB,IAAA;EAElD,IAAA,CAACC,SAAAA,CAAAA,WAAY,CAAAD,KAAK,CAAG,EAAA;IAChB,OAAAA,KAAA;EACT;EAEM,MAAAE,SAAA,GAAYF,MAAMG,MAAO,EAAA;EAEzB,MAAA,CAACC,aAAe,EAAAC,YAAY,CAChC,GAAAC,SAAA,CAAAA,qBAAA,CAAsBC,IAAIL,SAAU,CAAAM,QAAA,CAASC,IAAI,CAAA,IAAK,EAAC;EAErD,IAAAL,aAAA,IAAiB,IAAQ,IAAAC,YAAA,IAAgB,IAAM,EAAA;IAC1C,OAAAL,KAAA;EACT;EA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