@ubnt/store.core 9.11.1 → 9.12.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.
Files changed (384) hide show
  1. package/CHANGELOG.md +55 -2
  2. package/lib/assets/ai360.jpg +0 -0
  3. package/lib/assets/g5-ptz.jpg +0 -0
  4. package/lib/assets/g5Ptz.jpg +0 -0
  5. package/lib/assets/keyFeatures/music.svg +3 -0
  6. package/lib/{components/Explore/assets/ProAV.jpg.js → assets/keyFeatures/music.svg.js} +6 -6
  7. package/lib/assets/keyFeatures/music.svg.js.map +1 -0
  8. package/lib/assets/keyFeatures/music.svg.mjs +3 -0
  9. package/lib/assets/keyFeatures/music.svg.mjs.map +1 -0
  10. package/lib/assets/minus4.svg +8 -8
  11. package/lib/assets/minus5.svg +8 -8
  12. package/lib/assets/music.svg +3 -0
  13. package/lib/assets/pause.svg +3 -3
  14. package/lib/assets/pause2.svg +3 -3
  15. package/lib/assets/plus5.svg +9 -9
  16. package/lib/assets/plus6.svg +9 -9
  17. package/lib/assets/powerAmp.jpg +0 -0
  18. package/lib/assets/powerAmp.svg +3 -0
  19. package/lib/assets/udmPro.jpg +0 -0
  20. package/lib/assets/udmPro2.jpg +0 -0
  21. package/lib/assets/udmProMax.jpg +0 -0
  22. package/lib/assets/udmProMax2.jpg +0 -0
  23. package/lib/assets/udmProSpecial.jpg +0 -0
  24. package/lib/assets/udmProSpecial2.jpg +0 -0
  25. package/lib/assets/udr.jpg +0 -0
  26. package/lib/assets/udr2.jpg +0 -0
  27. package/lib/assets/udw.jpg +0 -0
  28. package/lib/assets/udw2.jpg +0 -0
  29. package/lib/assets/umr.jpg +0 -0
  30. package/lib/assets/umr2.jpg +0 -0
  31. package/lib/assets/wideAngle.jpg +0 -0
  32. package/lib/components/Explore/Explore.js +2 -9
  33. package/lib/components/Explore/Explore.js.map +1 -1
  34. package/lib/components/Explore/Explore.mjs +2 -9
  35. package/lib/components/Explore/Explore.mjs.map +1 -1
  36. package/lib/components/Explore/ExploreData.d.ts +4 -7
  37. package/lib/components/Explore/ExploreData.js +80 -140
  38. package/lib/components/Explore/ExploreData.js.map +1 -1
  39. package/lib/components/Explore/ExploreData.mjs +72 -130
  40. package/lib/components/Explore/ExploreData.mjs.map +1 -1
  41. package/lib/components/Explore/assets/{baseStation-mobile.jpg.js → baseStation--mobile.jpg.js} +6 -6
  42. package/lib/components/Explore/assets/baseStation--mobile.jpg.js.map +1 -0
  43. package/lib/components/Explore/assets/baseStation--mobile.jpg.mjs +3 -0
  44. package/lib/components/Explore/assets/baseStation--mobile.jpg.mjs.map +1 -0
  45. package/lib/components/Explore/assets/baseStation.jpg.js +5 -5
  46. package/lib/components/Explore/assets/{g4-ptz.jpg.js → g4Ptz.jpg.js} +2 -2
  47. package/lib/components/Explore/assets/g4Ptz.jpg.js.map +1 -0
  48. package/lib/components/Explore/assets/g4Ptz.jpg.mjs +3 -0
  49. package/lib/components/Explore/assets/g4Ptz.jpg.mjs.map +1 -0
  50. package/lib/components/Explore/assets/{g5-ptz.jpg.js → g5Ptz.jpg.js} +2 -2
  51. package/lib/components/Explore/assets/g5Ptz.jpg.js.map +1 -0
  52. package/lib/components/Explore/assets/g5Ptz.jpg.mjs +3 -0
  53. package/lib/components/Explore/assets/g5Ptz.jpg.mjs.map +1 -0
  54. package/lib/components/Explore/assets/{AITheta.jpg.js → powerAmp.jpg.js} +6 -6
  55. package/lib/components/Explore/assets/powerAmp.jpg.js.map +1 -0
  56. package/lib/components/Explore/assets/powerAmp.jpg.mjs +3 -0
  57. package/lib/components/Explore/assets/powerAmp.jpg.mjs.map +1 -0
  58. package/lib/components/Explore/{LensCompare/assets/ai360.jpg.js → assets/udr.jpg.js} +6 -6
  59. package/lib/components/Explore/assets/udr.jpg.js.map +1 -0
  60. package/lib/components/Explore/assets/udr.jpg.mjs +3 -0
  61. package/lib/components/Explore/assets/udr.jpg.mjs.map +1 -0
  62. package/lib/components/Explore/assets/udw.jpg.js +27 -0
  63. package/lib/components/Explore/assets/udw.jpg.js.map +1 -0
  64. package/lib/components/Explore/assets/udw.jpg.mjs +3 -0
  65. package/lib/components/Explore/assets/udw.jpg.mjs.map +1 -0
  66. package/lib/components/Explore/assets/{UISPConsole.jpg.js → uispConsole.jpg.js} +6 -6
  67. package/lib/components/Explore/assets/uispConsole.jpg.js.map +1 -0
  68. package/lib/components/Explore/assets/uispConsole.jpg.mjs +3 -0
  69. package/lib/components/Explore/assets/uispConsole.jpg.mjs.map +1 -0
  70. package/lib/components/Explore/assets/umr.jpg.js +27 -0
  71. package/lib/components/Explore/assets/umr.jpg.js.map +1 -0
  72. package/lib/components/Explore/assets/umr.jpg.mjs +3 -0
  73. package/lib/components/Explore/assets/umr.jpg.mjs.map +1 -0
  74. package/lib/components/Explore/assets/ux.jpg.js +27 -0
  75. package/lib/components/Explore/assets/ux.jpg.js.map +1 -0
  76. package/lib/components/Explore/assets/ux.jpg.mjs +3 -0
  77. package/lib/components/Explore/assets/ux.jpg.mjs.map +1 -0
  78. package/lib/components/Explore/translations/en.json.js +8 -30
  79. package/lib/components/Explore/translations/en.json.js.map +1 -1
  80. package/lib/components/Explore/translations/en.json.mjs +9 -30
  81. package/lib/components/Explore/translations/en.json.mjs.map +1 -1
  82. package/lib/components/Header/ProHeader/ProHeader.js +19 -2
  83. package/lib/components/Header/ProHeader/ProHeader.js.map +1 -1
  84. package/lib/components/Header/ProHeader/ProHeader.mjs +19 -2
  85. package/lib/components/Header/ProHeader/ProHeader.mjs.map +1 -1
  86. package/lib/components/Header/ProHeader/ProHeader.styles.d.ts +1 -0
  87. package/lib/components/Header/ProHeader/ProHeader.styles.js +6 -0
  88. package/lib/components/Header/ProHeader/ProHeader.styles.js.map +1 -1
  89. package/lib/components/Header/ProHeader/ProHeader.styles.mjs +6 -0
  90. package/lib/components/Header/ProHeader/ProHeader.styles.mjs.map +1 -1
  91. package/lib/components/LandingPagePro/LandingPagePro.d.ts +3 -0
  92. package/lib/components/LandingPagePro/LandingPagePro.js +3 -3
  93. package/lib/components/LandingPagePro/LandingPagePro.js.map +1 -1
  94. package/lib/components/LandingPagePro/LandingPagePro.mjs +2 -2
  95. package/lib/components/LandingPagePro/LandingPagePro.mjs.map +1 -1
  96. package/lib/components/MicrositeVideoSlideshow/MicrositeVideoSlideshow.js +1 -1
  97. package/lib/components/MicrositeVideoSlideshow/MicrositeVideoSlideshow.mjs +1 -1
  98. package/lib/components/MicrositeVideoSlideshow/assets/pause.svg.js +1 -1
  99. package/lib/components/MicrositeVideoSlideshow/assets/pause.svg.mjs +2 -2
  100. package/lib/components/ModelCompareV3/assets/Consoles/bigCompare/udmPro.jpg.js +5 -5
  101. package/lib/components/ModelCompareV3/assets/Consoles/bigCompare/udmPro.jpg.mjs +2 -2
  102. package/lib/components/ModelCompareV3/assets/Consoles/bigCompare/udmProMax.jpg.js +5 -5
  103. package/lib/components/ModelCompareV3/assets/Consoles/bigCompare/udmProMax.jpg.mjs +2 -2
  104. package/lib/components/ModelCompareV3/assets/Consoles/bigCompare/udmProSpecial.jpg.js +5 -5
  105. package/lib/components/ModelCompareV3/assets/Consoles/bigCompare/udmProSpecial.jpg.mjs +2 -2
  106. package/lib/components/ModelCompareV3/assets/Consoles/bigCompare/udr.jpg.js +1 -1
  107. package/lib/components/ModelCompareV3/assets/Consoles/bigCompare/udr.jpg.mjs +2 -2
  108. package/lib/components/ModelCompareV3/assets/Consoles/bigCompare/udw.jpg.js +1 -1
  109. package/lib/components/ModelCompareV3/assets/Consoles/bigCompare/udw.jpg.mjs +2 -2
  110. package/lib/components/ModelCompareV3/assets/Consoles/udmPro.jpg.js +1 -1
  111. package/lib/components/ModelCompareV3/assets/Consoles/udmPro.jpg.mjs +2 -2
  112. package/lib/components/ModelCompareV3/assets/Consoles/udmProMax.jpg.js +1 -1
  113. package/lib/components/ModelCompareV3/assets/Consoles/udmProMax.jpg.mjs +2 -2
  114. package/lib/components/ModelCompareV3/assets/Consoles/udmProSpecial.jpg.js +1 -1
  115. package/lib/components/ModelCompareV3/assets/Consoles/udmProSpecial.jpg.mjs +2 -2
  116. package/lib/components/ModelCompareV3/assets/Interior/ai360.jpg.js +1 -1
  117. package/lib/components/ModelCompareV3/assets/Interior/ai360.jpg.mjs +2 -2
  118. package/lib/components/ModelCompareV3/assets/Interior/wideAngle.jpg.js +1 -1
  119. package/lib/components/ModelCompareV3/assets/Interior/wideAngle.jpg.mjs +2 -2
  120. package/lib/components/ModelCompareV3/assets/MobileRouters/umr.jpg.js +1 -1
  121. package/lib/components/ModelCompareV3/assets/MobileRouters/umr.jpg.mjs +2 -2
  122. package/lib/components/ModelCompareV3/assets/PTZ/g5-ptz.jpg.js +1 -1
  123. package/lib/components/ModelCompareV3/assets/PTZ/g5-ptz.jpg.mjs +2 -2
  124. package/lib/components/ModelCompareV3/data/CloudGateways.js +11 -11
  125. package/lib/components/ModelCompareV3/data/CloudGateways.mjs +8 -8
  126. package/lib/components/ModelCompareV3/data/products/g5Ptz.js +1 -1
  127. package/lib/components/ModelCompareV3/data/products/g5Ptz.mjs +1 -1
  128. package/lib/components/ModelCompareV3/data/products/theta360.js +1 -1
  129. package/lib/components/ModelCompareV3/data/products/theta360.mjs +1 -1
  130. package/lib/components/ModelCompareV3/data/products/thetaWideAngle.js +1 -1
  131. package/lib/components/ModelCompareV3/data/products/thetaWideAngle.mjs +1 -1
  132. package/lib/components/ModelCompareV3/data/products/udmPro.js +1 -1
  133. package/lib/components/ModelCompareV3/data/products/udmPro.mjs +1 -1
  134. package/lib/components/ModelCompareV3/data/products/udmProMax.js +1 -1
  135. package/lib/components/ModelCompareV3/data/products/udmProMax.mjs +1 -1
  136. package/lib/components/ModelCompareV3/data/products/udmProSpecial.js +1 -1
  137. package/lib/components/ModelCompareV3/data/products/udmProSpecial.mjs +1 -1
  138. package/lib/components/ModelCompareV3/data/products/udr.js +1 -1
  139. package/lib/components/ModelCompareV3/data/products/udr.mjs +1 -1
  140. package/lib/components/ModelCompareV3/data/products/udw.js +1 -1
  141. package/lib/components/ModelCompareV3/data/products/udw.mjs +1 -1
  142. package/lib/components/ModelCompareV3/data/products/umr.js +1 -1
  143. package/lib/components/ModelCompareV3/data/products/umr.mjs +1 -1
  144. package/lib/components/ResourceCalculatorV1/ComputeResourceCalculator/ComputeResourceCalculator.constants.js +6 -1
  145. package/lib/components/ResourceCalculatorV1/ComputeResourceCalculator/ComputeResourceCalculator.constants.js.map +1 -1
  146. package/lib/components/ResourceCalculatorV1/ComputeResourceCalculator/ComputeResourceCalculator.constants.mjs +6 -1
  147. package/lib/components/ResourceCalculatorV1/ComputeResourceCalculator/ComputeResourceCalculator.constants.mjs.map +1 -1
  148. package/lib/components/ResourceCalculatorV1/ComputeResourceCalculator/components/InputCard/InputCard.js +1 -1
  149. package/lib/components/ResourceCalculatorV1/ComputeResourceCalculator/components/InputCard/InputCard.js.map +1 -1
  150. package/lib/components/ResourceCalculatorV1/ComputeResourceCalculator/components/InputCard/InputCard.mjs +1 -1
  151. package/lib/components/ResourceCalculatorV1/ComputeResourceCalculator/components/InputCard/InputCard.mjs.map +1 -1
  152. package/lib/components/ResourceCalculatorV1/ComputeResourceCalculator/components/InputCard/InputCard.styles.js +2 -0
  153. package/lib/components/ResourceCalculatorV1/ComputeResourceCalculator/components/InputCard/InputCard.styles.js.map +1 -1
  154. package/lib/components/ResourceCalculatorV1/ComputeResourceCalculator/components/InputCard/InputCard.styles.mjs +2 -0
  155. package/lib/components/ResourceCalculatorV1/ComputeResourceCalculator/components/InputCard/InputCard.styles.mjs.map +1 -1
  156. package/lib/components/ResourceCalculatorV1/ComputeResourceCalculator/components/InputCard/InputSections/CounterSection.js +2 -2
  157. package/lib/components/ResourceCalculatorV1/ComputeResourceCalculator/components/InputCard/InputSections/CounterSection.mjs +2 -2
  158. package/lib/components/ResourceCalculatorV1/ComputeResourceCalculator/components/InputCard/assets/minus.svg.js +1 -1
  159. package/lib/components/ResourceCalculatorV1/ComputeResourceCalculator/components/InputCard/assets/minus.svg.mjs +2 -2
  160. package/lib/components/ResourceCalculatorV1/ComputeResourceCalculator/components/InputCard/assets/plus.svg.js +1 -1
  161. package/lib/components/ResourceCalculatorV1/ComputeResourceCalculator/components/InputCard/assets/plus.svg.mjs +2 -2
  162. package/lib/components/ResourceCalculatorV1/PoeCalculator/components/PoeConsumerConfigurator/PoeConsumerSelectModal/PoeConsumerSelectModal.js +2 -2
  163. package/lib/components/ResourceCalculatorV1/PoeCalculator/components/PoeConsumerConfigurator/PoeConsumerSelectModal/PoeConsumerSelectModal.mjs +2 -2
  164. package/lib/components/ResourceCalculatorV1/PoeCalculator/components/PoeConsumerConfigurator/assets/minus.svg.js +1 -1
  165. package/lib/components/ResourceCalculatorV1/PoeCalculator/components/PoeConsumerConfigurator/assets/minus.svg.mjs +2 -2
  166. package/lib/components/ResourceCalculatorV1/PoeCalculator/components/PoeConsumerConfigurator/assets/plus.svg.js +1 -1
  167. package/lib/components/ResourceCalculatorV1/PoeCalculator/components/PoeConsumerConfigurator/assets/plus.svg.mjs +2 -2
  168. package/lib/components/Tooltip/Tooltip.d.ts +2 -0
  169. package/lib/components/Tooltip/Tooltip.js +45 -0
  170. package/lib/components/Tooltip/Tooltip.js.map +1 -0
  171. package/lib/components/Tooltip/Tooltip.mjs +43 -0
  172. package/lib/components/Tooltip/Tooltip.mjs.map +1 -0
  173. package/lib/components/Tooltip/Tooltip.styles.d.ts +32 -0
  174. package/lib/components/Tooltip/Tooltip.styles.js +44 -0
  175. package/lib/components/Tooltip/Tooltip.styles.js.map +1 -0
  176. package/lib/components/Tooltip/Tooltip.styles.mjs +34 -0
  177. package/lib/components/Tooltip/Tooltip.styles.mjs.map +1 -0
  178. package/lib/components/Tooltip/index.d.ts +1 -0
  179. package/lib/components/Tooltip/index.js +6 -0
  180. package/lib/components/Tooltip/index.js.map +1 -0
  181. package/lib/components/Tooltip/index.mjs +3 -0
  182. package/lib/components/Tooltip/index.mjs.map +1 -0
  183. package/lib/components/VideoPlayerNew/VideoPlayer.js +1 -1
  184. package/lib/components/VideoPlayerNew/VideoPlayer.mjs +1 -1
  185. package/lib/components/VideoPlayerNew/assets/pause.svg.js +1 -1
  186. package/lib/components/VideoPlayerNew/assets/pause.svg.mjs +2 -2
  187. package/lib/constants/icons/menu/index.d.ts +1 -0
  188. package/lib/constants/icons/menu/index.js +9 -0
  189. package/lib/constants/icons/menu/index.js.map +1 -1
  190. package/lib/constants/icons/menu/index.mjs +2 -0
  191. package/lib/constants/icons/menu/index.mjs.map +1 -1
  192. package/lib/{components/Explore/assets/MobileR.jpg.js → constants/icons/menu/powerAmp.svg.js} +6 -6
  193. package/lib/constants/icons/menu/powerAmp.svg.js.map +1 -0
  194. package/lib/constants/icons/menu/powerAmp.svg.mjs +3 -0
  195. package/lib/constants/icons/menu/powerAmp.svg.mjs.map +1 -0
  196. package/lib/constants/icons/options/colors/black.svg.js +5 -5
  197. package/lib/constants/icons/options/colors/index.js +3 -3
  198. package/lib/constants/icons/options/styles/black.svg.js +5 -5
  199. package/lib/constants/icons/options/styles/index.js +3 -3
  200. package/lib/constants/keyFeatureIcons.d.ts +1 -0
  201. package/lib/constants/keyFeatureIcons.js +3 -0
  202. package/lib/constants/keyFeatureIcons.js.map +1 -1
  203. package/lib/constants/keyFeatureIcons.mjs +3 -0
  204. package/lib/constants/keyFeatureIcons.mjs.map +1 -1
  205. package/lib/constants/optionIcons.js +6 -6
  206. package/lib/constants/optionIcons.mjs +4 -4
  207. package/lib/constants/proStoreCategories/mapping/index.d.ts +1 -0
  208. package/lib/constants/proStoreCategories/mapping/index.js +13 -8
  209. package/lib/constants/proStoreCategories/mapping/index.js.map +1 -1
  210. package/lib/constants/proStoreCategories/mapping/index.mjs +13 -8
  211. package/lib/constants/proStoreCategories/mapping/index.mjs.map +1 -1
  212. package/lib/constants/proStoreCategories/mapping/unifi.d.ts +2 -1
  213. package/lib/constants/proStoreCategories/mapping/unifi.js +1 -0
  214. package/lib/constants/proStoreCategories/mapping/unifi.js.map +1 -1
  215. package/lib/constants/proStoreCategories/mapping/unifi.mjs +1 -0
  216. package/lib/constants/proStoreCategories/mapping/unifi.mjs.map +1 -1
  217. package/lib/constants/proStoreCategories/translations/en.json.js +3 -0
  218. package/lib/constants/proStoreCategories/translations/en.json.js.map +1 -1
  219. package/lib/constants/proStoreCategories/translations/en.json.mjs +3 -1
  220. package/lib/constants/proStoreCategories/translations/en.json.mjs.map +1 -1
  221. package/lib/constants/proStoreCategories/translations/fr.json.js +1 -1
  222. package/lib/constants/proStoreCategories/translations/fr.json.mjs +1 -1
  223. package/lib/constants/proStoreCategories/translations/zh-Hans.json.js +1 -1
  224. package/lib/constants/proStoreCategories/translations/zh-Hans.json.mjs +1 -1
  225. package/lib/constants/proStoreCategories/translations/zh-Hant-TW.json.js +1 -1
  226. package/lib/constants/proStoreCategories/translations/zh-Hant-TW.json.mjs +1 -1
  227. package/lib/constants/shopify/keyFeatureIcons.js +4 -0
  228. package/lib/constants/shopify/keyFeatureIcons.js.map +1 -1
  229. package/lib/constants/shopify/keyFeatureIcons.mjs +3 -0
  230. package/lib/constants/shopify/keyFeatureIcons.mjs.map +1 -1
  231. package/lib/contexts/MenuContext/mapping.js +20 -11
  232. package/lib/contexts/MenuContext/mapping.js.map +1 -1
  233. package/lib/contexts/MenuContext/mapping.mjs +19 -11
  234. package/lib/contexts/MenuContext/mapping.mjs.map +1 -1
  235. package/lib/utils/money/allocators/fixedAmount.d.ts +26 -0
  236. package/lib/utils/money/allocators/fixedAmount.js +55 -0
  237. package/lib/utils/money/allocators/fixedAmount.js.map +1 -0
  238. package/lib/utils/money/allocators/fixedAmount.mjs +53 -0
  239. package/lib/utils/money/allocators/fixedAmount.mjs.map +1 -0
  240. package/lib/utils/money/allocators/index.d.ts +2 -0
  241. package/lib/utils/money/allocators/index.js +8 -0
  242. package/lib/utils/money/allocators/index.js.map +1 -0
  243. package/lib/utils/money/allocators/index.mjs +4 -0
  244. package/lib/utils/money/allocators/index.mjs.map +1 -0
  245. package/lib/utils/money/allocators/productAmount.d.ts +13 -0
  246. package/lib/utils/money/allocators/productAmount.js +110 -0
  247. package/lib/utils/money/allocators/productAmount.js.map +1 -0
  248. package/lib/utils/money/allocators/productAmount.mjs +108 -0
  249. package/lib/utils/money/allocators/productAmount.mjs.map +1 -0
  250. package/lib/utils/money/constants.d.ts +56 -25
  251. package/lib/utils/money/constants.js +72 -7
  252. package/lib/utils/money/constants.js.map +1 -1
  253. package/lib/utils/money/constants.mjs +70 -7
  254. package/lib/utils/money/constants.mjs.map +1 -1
  255. package/lib/utils/money/exchangeRate.d.ts +31 -0
  256. package/lib/utils/money/exchangeRate.js +27 -0
  257. package/lib/utils/money/exchangeRate.js.map +1 -0
  258. package/lib/utils/money/exchangeRate.mjs +23 -0
  259. package/lib/utils/money/exchangeRate.mjs.map +1 -0
  260. package/lib/utils/money/format.d.ts +10 -5
  261. package/lib/utils/money/format.js +22 -14
  262. package/lib/utils/money/format.js.map +1 -1
  263. package/lib/utils/money/format.mjs +23 -16
  264. package/lib/utils/money/format.mjs.map +1 -1
  265. package/lib/utils/money/index.d.ts +4 -1
  266. package/lib/utils/money/index.js +26 -8
  267. package/lib/utils/money/index.js.map +1 -1
  268. package/lib/utils/money/index.mjs +8 -4
  269. package/lib/utils/money/index.mjs.map +1 -1
  270. package/lib/utils/money/misc.d.ts +68 -28
  271. package/lib/utils/money/misc.js +35 -64
  272. package/lib/utils/money/misc.js.map +1 -1
  273. package/lib/utils/money/misc.mjs +32 -43
  274. package/lib/utils/money/misc.mjs.map +1 -1
  275. package/lib/utils/money/misc.private.d.ts +23 -0
  276. package/lib/utils/money/misc.private.js +46 -0
  277. package/lib/utils/money/misc.private.js.map +1 -0
  278. package/lib/utils/money/misc.private.mjs +21 -0
  279. package/lib/utils/money/misc.private.mjs.map +1 -0
  280. package/lib/utils/money/shipping.d.ts +5 -0
  281. package/lib/utils/money/shipping.js +8 -0
  282. package/lib/utils/money/shipping.js.map +1 -0
  283. package/lib/utils/money/shipping.mjs +6 -0
  284. package/lib/utils/money/shipping.mjs.map +1 -0
  285. package/lib/utils/money/tax.d.ts +38 -2
  286. package/lib/utils/money/tax.js +46 -10
  287. package/lib/utils/money/tax.js.map +1 -1
  288. package/lib/utils/money/tax.mjs +42 -11
  289. package/lib/utils/money/tax.mjs.map +1 -1
  290. package/lib/utils/money/tax.private.d.ts +17 -0
  291. package/lib/utils/money/tax.private.js +65 -0
  292. package/lib/utils/money/tax.private.js.map +1 -0
  293. package/lib/utils/money/tax.private.mjs +60 -0
  294. package/lib/utils/money/tax.private.mjs.map +1 -0
  295. package/lib/utils/money/types.d.ts +78 -3
  296. package/lib/utils/number.d.ts +1 -1
  297. package/lib/utils/number.js +1 -1
  298. package/lib/utils/number.js.map +1 -1
  299. package/lib/utils/number.mjs +1 -1
  300. package/lib/utils/number.mjs.map +1 -1
  301. package/package.json +53 -53
  302. package/lib/assets/AITheta.jpg +0 -0
  303. package/lib/assets/MobileR.jpg +0 -0
  304. package/lib/assets/ProAV.jpg +0 -0
  305. package/lib/assets/ai3602.jpg +0 -0
  306. package/lib/assets/cloudgatewayultra.jpg +0 -0
  307. package/lib/assets/dreamRouter.jpg +0 -0
  308. package/lib/assets/dreamWall.jpg +0 -0
  309. package/lib/assets/g5-ptz2.jpg +0 -0
  310. package/lib/assets/wideAngle2.jpg +0 -0
  311. package/lib/components/Explore/LensCompare/LensCompare.d.ts +0 -2
  312. package/lib/components/Explore/LensCompare/LensCompare.js +0 -111
  313. package/lib/components/Explore/LensCompare/LensCompare.js.map +0 -1
  314. package/lib/components/Explore/LensCompare/LensCompare.mjs +0 -109
  315. package/lib/components/Explore/LensCompare/LensCompare.mjs.map +0 -1
  316. package/lib/components/Explore/LensCompare/LensCompare.styles.d.ts +0 -16
  317. package/lib/components/Explore/LensCompare/LensCompare.styles.js +0 -153
  318. package/lib/components/Explore/LensCompare/LensCompare.styles.js.map +0 -1
  319. package/lib/components/Explore/LensCompare/LensCompare.styles.mjs +0 -132
  320. package/lib/components/Explore/LensCompare/LensCompare.styles.mjs.map +0 -1
  321. package/lib/components/Explore/LensCompare/LensCompare.types.d.ts +0 -9
  322. package/lib/components/Explore/LensCompare/LensCompare.utils.d.ts +0 -2
  323. package/lib/components/Explore/LensCompare/LensCompare.utils.js +0 -23
  324. package/lib/components/Explore/LensCompare/LensCompare.utils.js.map +0 -1
  325. package/lib/components/Explore/LensCompare/LensCompare.utils.mjs +0 -21
  326. package/lib/components/Explore/LensCompare/LensCompare.utils.mjs.map +0 -1
  327. package/lib/components/Explore/LensCompare/LensCompareData.d.ts +0 -29
  328. package/lib/components/Explore/LensCompare/LensCompareData.js +0 -68
  329. package/lib/components/Explore/LensCompare/LensCompareData.js.map +0 -1
  330. package/lib/components/Explore/LensCompare/LensCompareData.mjs +0 -58
  331. package/lib/components/Explore/LensCompare/LensCompareData.mjs.map +0 -1
  332. package/lib/components/Explore/LensCompare/assets/ai360.jpg.js.map +0 -1
  333. package/lib/components/Explore/LensCompare/assets/ai360.jpg.mjs +0 -3
  334. package/lib/components/Explore/LensCompare/assets/ai360.jpg.mjs.map +0 -1
  335. package/lib/components/Explore/LensCompare/assets/wideAngle.jpg.js +0 -27
  336. package/lib/components/Explore/LensCompare/assets/wideAngle.jpg.js.map +0 -1
  337. package/lib/components/Explore/LensCompare/assets/wideAngle.jpg.mjs +0 -3
  338. package/lib/components/Explore/LensCompare/assets/wideAngle.jpg.mjs.map +0 -1
  339. package/lib/components/Explore/assets/AITheta.jpg.js.map +0 -1
  340. package/lib/components/Explore/assets/AITheta.jpg.mjs +0 -3
  341. package/lib/components/Explore/assets/AITheta.jpg.mjs.map +0 -1
  342. package/lib/components/Explore/assets/MobileR.jpg.js.map +0 -1
  343. package/lib/components/Explore/assets/MobileR.jpg.mjs +0 -3
  344. package/lib/components/Explore/assets/MobileR.jpg.mjs.map +0 -1
  345. package/lib/components/Explore/assets/ProAV.jpg.js.map +0 -1
  346. package/lib/components/Explore/assets/ProAV.jpg.mjs +0 -3
  347. package/lib/components/Explore/assets/ProAV.jpg.mjs.map +0 -1
  348. package/lib/components/Explore/assets/UISPConsole.jpg.js.map +0 -1
  349. package/lib/components/Explore/assets/UISPConsole.jpg.mjs +0 -3
  350. package/lib/components/Explore/assets/UISPConsole.jpg.mjs.map +0 -1
  351. package/lib/components/Explore/assets/baseStation-mobile.jpg.js.map +0 -1
  352. package/lib/components/Explore/assets/baseStation-mobile.jpg.mjs +0 -3
  353. package/lib/components/Explore/assets/baseStation-mobile.jpg.mjs.map +0 -1
  354. package/lib/components/Explore/assets/cloudgatewayultra.jpg.js +0 -27
  355. package/lib/components/Explore/assets/cloudgatewayultra.jpg.js.map +0 -1
  356. package/lib/components/Explore/assets/cloudgatewayultra.jpg.mjs +0 -3
  357. package/lib/components/Explore/assets/cloudgatewayultra.jpg.mjs.map +0 -1
  358. package/lib/components/Explore/assets/dreamRouter.jpg.js +0 -27
  359. package/lib/components/Explore/assets/dreamRouter.jpg.js.map +0 -1
  360. package/lib/components/Explore/assets/dreamRouter.jpg.mjs +0 -3
  361. package/lib/components/Explore/assets/dreamRouter.jpg.mjs.map +0 -1
  362. package/lib/components/Explore/assets/dreamWall.jpg.js +0 -27
  363. package/lib/components/Explore/assets/dreamWall.jpg.js.map +0 -1
  364. package/lib/components/Explore/assets/dreamWall.jpg.mjs +0 -3
  365. package/lib/components/Explore/assets/dreamWall.jpg.mjs.map +0 -1
  366. package/lib/components/Explore/assets/g4-ptz.jpg.js.map +0 -1
  367. package/lib/components/Explore/assets/g4-ptz.jpg.mjs +0 -3
  368. package/lib/components/Explore/assets/g4-ptz.jpg.mjs.map +0 -1
  369. package/lib/components/Explore/assets/g5-ptz.jpg.js.map +0 -1
  370. package/lib/components/Explore/assets/g5-ptz.jpg.mjs +0 -3
  371. package/lib/components/Explore/assets/g5-ptz.jpg.mjs.map +0 -1
  372. package/lib/components/Explore/assets/unifiExpress.jpg.js +0 -27
  373. package/lib/components/Explore/assets/unifiExpress.jpg.js.map +0 -1
  374. package/lib/components/Explore/assets/unifiExpress.jpg.mjs +0 -3
  375. package/lib/components/Explore/assets/unifiExpress.jpg.mjs.map +0 -1
  376. package/lib/utils/validations.d.ts +0 -15
  377. package/lib/utils/validations.js +0 -23
  378. package/lib/utils/validations.js.map +0 -1
  379. package/lib/utils/validations.mjs +0 -21
  380. package/lib/utils/validations.mjs.map +0 -1
  381. /package/lib/assets/{baseStation-mobile.jpg → baseStation--mobile.jpg} +0 -0
  382. /package/lib/assets/{g4-ptz.jpg → g4Ptz.jpg} +0 -0
  383. /package/lib/assets/{UISPConsole.jpg → uispConsole.jpg} +0 -0
  384. /package/lib/assets/{unifiExpress.jpg → ux.jpg} +0 -0
@@ -0,0 +1,65 @@
1
+ 'use strict';
2
+
3
+ var dinero_js = require('dinero.js');
4
+ var errors = require('../errors.js');
5
+ var fixedAmount = require('./allocators/fixedAmount.js');
6
+ var misc = require('./misc.js');
7
+ "use strict";
8
+ const taxRateToDineroAllocation = taxRate => {
9
+ if (taxRate <= 0 || taxRate >= 1) {
10
+ throw new RangeError("Unsupported rate, expected in range of 0>rate<1");
11
+ }
12
+ const rateScale = String(taxRate).split(".")[1]?.length;
13
+ errors.assert(rateScale !== void 0, "rateScale is undefined");
14
+ const rateInt = Math.round(taxRate * Math.pow(10, rateScale));
15
+ return [rateInt, Math.pow(10, rateScale) - rateInt];
16
+ };
17
+ const allocatePerItemTaxableAmount = itemSummary => {
18
+ if (itemSummary.quantity === 1) {
19
+ return [itemSummary];
20
+ }
21
+ const preDiscountAmount = dinero_js.add(misc.getDinero(itemSummary.taxableAmount, itemSummary.currency), misc.getDinero(itemSummary.discountAmount, itemSummary.currency));
22
+ const allocator = new fixedAmount.FixedAmountAllocator({
23
+ initialAllocateAmount: itemSummary.discountAmount,
24
+ initialTotalAmount: misc.amount(preDiscountAmount),
25
+ currency: itemSummary.currency
26
+ });
27
+ return Array.from({
28
+ length: itemSummary.quantity
29
+ }, () => {
30
+ const discountAllocatedAmount = allocator.allocate(itemSummary.itemPrice, itemSummary.currency);
31
+ const taxableAmount = dinero_js.subtract(misc.getDinero(itemSummary.itemPrice, itemSummary.currency), discountAllocatedAmount);
32
+ return {
33
+ itemPrice: itemSummary.itemPrice,
34
+ taxableAmount: misc.amount(taxableAmount),
35
+ discountAmount: misc.amount(discountAllocatedAmount),
36
+ currency: itemSummary.currency,
37
+ quantity: 1
38
+ };
39
+ });
40
+ };
41
+ const calculateWholeQtyLineItemTax = (itemSummary, taxRate) => {
42
+ if (taxRate === 0) {
43
+ return misc.getDinero(0, itemSummary.currency);
44
+ }
45
+ const [taxAmount] = dinero_js.allocate(misc.getDinero(itemSummary.taxableAmount, itemSummary.currency), taxRateToDineroAllocation(taxRate));
46
+ errors.assert(taxAmount !== void 0, "taxAmount is undefined");
47
+ return taxAmount;
48
+ };
49
+ const calculatePerQtyLineItemTax = (itemSummary, taxRate) => {
50
+ if (taxRate === 0) {
51
+ return misc.getDinero(0, itemSummary.currency);
52
+ }
53
+ const singleItemSummaries = allocatePerItemTaxableAmount(itemSummary);
54
+ let totalTaxAmount = misc.getDinero(0, itemSummary.currency);
55
+ singleItemSummaries.forEach(itemSummary2 => {
56
+ const taxAmount = calculateWholeQtyLineItemTax(itemSummary2, taxRate);
57
+ totalTaxAmount = dinero_js.add(totalTaxAmount, taxAmount);
58
+ });
59
+ return totalTaxAmount;
60
+ };
61
+ exports.allocatePerItemTaxableAmount = allocatePerItemTaxableAmount;
62
+ exports.calculatePerQtyLineItemTax = calculatePerQtyLineItemTax;
63
+ exports.calculateWholeQtyLineItemTax = calculateWholeQtyLineItemTax;
64
+ exports.taxRateToDineroAllocation = taxRateToDineroAllocation;
65
+ //# sourceMappingURL=tax.private.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"tax.private.js","sources":["../../../src/utils/money/tax.private.ts"],"sourcesContent":["// #############################################################################\n// Internal helper functions not for consumption outside of store.core!\n// Wrote as separate files so that they can be easily unit tested without exposing them\n// #############################################################################\nimport type { Dinero } from \"dinero.js\";\nimport { add, allocate, subtract } from \"dinero.js\";\n\nimport { assert } from \"../errors\";\nimport { FixedAmountAllocator } from \"./allocators/fixedAmount\";\nimport { amount, getDinero } from \"./misc\";\nimport type {\n Cents,\n LineItemSummary,\n SingleLineItemSummary,\n TaxRate,\n} from \"./types\";\n\n/**\n * Private helper to convert a floating number to a dinero friendly allocation integer pair\n * @see https://v2.dinerojs.com/docs/api/mutations/allocate\n * @example\n * taxRateToDineroAllocation(0.1) // [1, 9]\n * taxRateToDineroAllocation(0.5) // [5, 5]\n */\nexport const taxRateToDineroAllocation = (\n taxRate: TaxRate,\n): [number, number] => {\n if (taxRate <= 0 || taxRate >= 1) {\n throw new RangeError(\"Unsupported rate, expected in range of 0>rate<1\");\n }\n\n // Get the scale of the rate\n const rateScale = String(taxRate).split(\".\")[1]?.length;\n assert(rateScale !== undefined, \"rateScale is undefined\");\n\n // Convert to integers\n const rateInt = Math.round(taxRate * Math.pow(10, rateScale));\n return [rateInt, Math.pow(10, rateScale) - rateInt];\n};\n\n/**\n * Reverse engineer the taxable amount from \"whole item\" taxable amount into \"per item\" taxable amount for custom tax\n * rate calculations\n */\nexport const allocatePerItemTaxableAmount = (\n itemSummary: LineItemSummary,\n): SingleLineItemSummary[] => {\n /**\n * If the item quantity is 1, we can just return the item summary as is\n */\n if (itemSummary.quantity === 1) {\n return [itemSummary as SingleLineItemSummary];\n }\n\n // Reverse engineer price before discount\n const preDiscountAmount = add(\n getDinero(itemSummary.taxableAmount, itemSummary.currency),\n getDinero(itemSummary.discountAmount, itemSummary.currency),\n );\n\n const allocator = new FixedAmountAllocator({\n initialAllocateAmount: itemSummary.discountAmount,\n initialTotalAmount: amount(preDiscountAmount),\n currency: itemSummary.currency,\n });\n\n // Iterate over the amount of qty to reverse engineer the discount price\n return Array.from({ length: itemSummary.quantity }, () => {\n const discountAllocatedAmount = allocator.allocate(\n itemSummary.itemPrice,\n itemSummary.currency,\n );\n\n const taxableAmount = subtract(\n getDinero(itemSummary.itemPrice, itemSummary.currency),\n discountAllocatedAmount,\n );\n\n return {\n itemPrice: itemSummary.itemPrice,\n taxableAmount: amount(taxableAmount),\n discountAmount: amount(discountAllocatedAmount),\n currency: itemSummary.currency,\n quantity: 1,\n } as SingleLineItemSummary;\n });\n};\n\nexport const calculateWholeQtyLineItemTax = (\n itemSummary: LineItemSummary,\n taxRate: TaxRate,\n): Dinero<Cents> => {\n // Nothing to calculate\n if (taxRate === 0) {\n return getDinero(0, itemSummary.currency);\n }\n\n /**\n * FIXME: look into approach with multiply and different scale for control over rounding, currently we just inherit\n * what dinero gives us which cause unexpected rounding issue\n */\n const [taxAmount] = allocate(\n getDinero(itemSummary.taxableAmount, itemSummary.currency),\n taxRateToDineroAllocation(taxRate),\n );\n\n assert(taxAmount !== undefined, \"taxAmount is undefined\");\n return taxAmount;\n};\n\nexport const calculatePerQtyLineItemTax = (\n itemSummary: LineItemSummary,\n taxRate: TaxRate,\n): Dinero<Cents> => {\n // Nothing to calculate\n if (taxRate === 0) {\n return getDinero(0, itemSummary.currency);\n }\n\n // Split the item summary into per individual item qty summaries\n const singleItemSummaries = allocatePerItemTaxableAmount(itemSummary);\n\n // Calculate individual item qty tax and sum them up\n let totalTaxAmount = getDinero(0, itemSummary.currency);\n\n singleItemSummaries.forEach((itemSummary) => {\n // Probably a bit confusing at first, but calling the whole qty tax calculation function here as we can safely use\n // it as item summary is always a single item summary here\n const taxAmount = calculateWholeQtyLineItemTax(itemSummary, taxRate);\n totalTaxAmount = add(totalTaxAmount, taxAmount);\n });\n\n return totalTaxAmount;\n};\n"],"names":["taxRateToDineroAllocation","taxRate","RangeError","rateScale","String","split","length","assert","rateInt","Math","round","pow","allocatePerItemTaxableAmount","itemSummary","quantity","preDiscountAmount","add","getDinero","taxableAmount","currency","discountAmount","allocator","FixedAmountAllocator","initialAllocateAmount","initialTotalAmount","amount","Array","from","discountAllocatedAmount","allocate","itemPrice","subtract","calculateWholeQtyLineItemTax","taxAmount","calculatePerQtyLineItemTax","singleItemSummaries","totalTaxAmount","forEach"],"mappings":";;;;;;;AAwBa,MAAAA,yBAAA,G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BnB,CAAAA,YAAAA,EAAaZ,OAAO,CAAA;IAClDmC,cAAA,GAAApB,SAAA,CAAAA,GAAA,CAAIoB,gBAAgBH,SAAS,CAAA;EAAA,CAC/C,CAAA;EAEM,OAAAG,cAAA;AACT,CAAA;;;;"}
@@ -0,0 +1,60 @@
1
+ import { add, subtract, allocate } from 'dinero.js';
2
+ import { assert } from '../errors.mjs';
3
+ import { FixedAmountAllocator } from './allocators/fixedAmount.mjs';
4
+ import { getDinero, amount } from './misc.mjs';
5
+ "use strict";
6
+ const taxRateToDineroAllocation = taxRate => {
7
+ if (taxRate <= 0 || taxRate >= 1) {
8
+ throw new RangeError("Unsupported rate, expected in range of 0>rate<1");
9
+ }
10
+ const rateScale = String(taxRate).split(".")[1]?.length;
11
+ assert(rateScale !== void 0, "rateScale is undefined");
12
+ const rateInt = Math.round(taxRate * Math.pow(10, rateScale));
13
+ return [rateInt, Math.pow(10, rateScale) - rateInt];
14
+ };
15
+ const allocatePerItemTaxableAmount = itemSummary => {
16
+ if (itemSummary.quantity === 1) {
17
+ return [itemSummary];
18
+ }
19
+ const preDiscountAmount = add(getDinero(itemSummary.taxableAmount, itemSummary.currency), getDinero(itemSummary.discountAmount, itemSummary.currency));
20
+ const allocator = new FixedAmountAllocator({
21
+ initialAllocateAmount: itemSummary.discountAmount,
22
+ initialTotalAmount: amount(preDiscountAmount),
23
+ currency: itemSummary.currency
24
+ });
25
+ return Array.from({
26
+ length: itemSummary.quantity
27
+ }, () => {
28
+ const discountAllocatedAmount = allocator.allocate(itemSummary.itemPrice, itemSummary.currency);
29
+ const taxableAmount = subtract(getDinero(itemSummary.itemPrice, itemSummary.currency), discountAllocatedAmount);
30
+ return {
31
+ itemPrice: itemSummary.itemPrice,
32
+ taxableAmount: amount(taxableAmount),
33
+ discountAmount: amount(discountAllocatedAmount),
34
+ currency: itemSummary.currency,
35
+ quantity: 1
36
+ };
37
+ });
38
+ };
39
+ const calculateWholeQtyLineItemTax = (itemSummary, taxRate) => {
40
+ if (taxRate === 0) {
41
+ return getDinero(0, itemSummary.currency);
42
+ }
43
+ const [taxAmount] = allocate(getDinero(itemSummary.taxableAmount, itemSummary.currency), taxRateToDineroAllocation(taxRate));
44
+ assert(taxAmount !== void 0, "taxAmount is undefined");
45
+ return taxAmount;
46
+ };
47
+ const calculatePerQtyLineItemTax = (itemSummary, taxRate) => {
48
+ if (taxRate === 0) {
49
+ return getDinero(0, itemSummary.currency);
50
+ }
51
+ const singleItemSummaries = allocatePerItemTaxableAmount(itemSummary);
52
+ let totalTaxAmount = getDinero(0, itemSummary.currency);
53
+ singleItemSummaries.forEach(itemSummary2 => {
54
+ const taxAmount = calculateWholeQtyLineItemTax(itemSummary2, taxRate);
55
+ totalTaxAmount = add(totalTaxAmount, taxAmount);
56
+ });
57
+ return totalTaxAmount;
58
+ };
59
+ export { allocatePerItemTaxableAmount, calculatePerQtyLineItemTax, calculateWholeQtyLineItemTax, taxRateToDineroAllocation };
60
+ //# sourceMappingURL=tax.private.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"tax.private.mjs","sources":["../../../src/utils/money/tax.private.ts"],"sourcesContent":["// #############################################################################\n// Internal helper functions not for consumption outside of store.core!\n// Wrote as separate files so that they can be easily unit tested without exposing them\n// #############################################################################\nimport type { Dinero } from \"dinero.js\";\nimport { add, allocate, subtract } from \"dinero.js\";\n\nimport { assert } from \"../errors\";\nimport { FixedAmountAllocator } from \"./allocators/fixedAmount\";\nimport { amount, getDinero } from \"./misc\";\nimport type {\n Cents,\n LineItemSummary,\n SingleLineItemSummary,\n TaxRate,\n} from \"./types\";\n\n/**\n * Private helper to convert a floating number to a dinero friendly allocation integer pair\n * @see https://v2.dinerojs.com/docs/api/mutations/allocate\n * @example\n * taxRateToDineroAllocation(0.1) // [1, 9]\n * taxRateToDineroAllocation(0.5) // [5, 5]\n */\nexport const taxRateToDineroAllocation = (\n taxRate: TaxRate,\n): [number, number] => {\n if (taxRate <= 0 || taxRate >= 1) {\n throw new RangeError(\"Unsupported rate, expected in range of 0>rate<1\");\n }\n\n // Get the scale of the rate\n const rateScale = String(taxRate).split(\".\")[1]?.length;\n assert(rateScale !== undefined, \"rateScale is undefined\");\n\n // Convert to integers\n const rateInt = Math.round(taxRate * Math.pow(10, rateScale));\n return [rateInt, Math.pow(10, rateScale) - rateInt];\n};\n\n/**\n * Reverse engineer the taxable amount from \"whole item\" taxable amount into \"per item\" taxable amount for custom tax\n * rate calculations\n */\nexport const allocatePerItemTaxableAmount = (\n itemSummary: LineItemSummary,\n): SingleLineItemSummary[] => {\n /**\n * If the item quantity is 1, we can just return the item summary as is\n */\n if (itemSummary.quantity === 1) {\n return [itemSummary as SingleLineItemSummary];\n }\n\n // Reverse engineer price before discount\n const preDiscountAmount = add(\n getDinero(itemSummary.taxableAmount, itemSummary.currency),\n getDinero(itemSummary.discountAmount, itemSummary.currency),\n );\n\n const allocator = new FixedAmountAllocator({\n initialAllocateAmount: itemSummary.discountAmount,\n initialTotalAmount: amount(preDiscountAmount),\n currency: itemSummary.currency,\n });\n\n // Iterate over the amount of qty to reverse engineer the discount price\n return Array.from({ length: itemSummary.quantity }, () => {\n const discountAllocatedAmount = allocator.allocate(\n itemSummary.itemPrice,\n itemSummary.currency,\n );\n\n const taxableAmount = subtract(\n getDinero(itemSummary.itemPrice, itemSummary.currency),\n discountAllocatedAmount,\n );\n\n return {\n itemPrice: itemSummary.itemPrice,\n taxableAmount: amount(taxableAmount),\n discountAmount: amount(discountAllocatedAmount),\n currency: itemSummary.currency,\n quantity: 1,\n } as SingleLineItemSummary;\n });\n};\n\nexport const calculateWholeQtyLineItemTax = (\n itemSummary: LineItemSummary,\n taxRate: TaxRate,\n): Dinero<Cents> => {\n // Nothing to calculate\n if (taxRate === 0) {\n return getDinero(0, itemSummary.currency);\n }\n\n /**\n * FIXME: look into approach with multiply and different scale for control over rounding, currently we just inherit\n * what dinero gives us which cause unexpected rounding issue\n */\n const [taxAmount] = allocate(\n getDinero(itemSummary.taxableAmount, itemSummary.currency),\n taxRateToDineroAllocation(taxRate),\n );\n\n assert(taxAmount !== undefined, \"taxAmount is undefined\");\n return taxAmount;\n};\n\nexport const calculatePerQtyLineItemTax = (\n itemSummary: LineItemSummary,\n taxRate: TaxRate,\n): Dinero<Cents> => {\n // Nothing to calculate\n if (taxRate === 0) {\n return getDinero(0, itemSummary.currency);\n }\n\n // Split the item summary into per individual item qty summaries\n const singleItemSummaries = allocatePerItemTaxableAmount(itemSummary);\n\n // Calculate individual item qty tax and sum them up\n let totalTaxAmount = getDinero(0, itemSummary.currency);\n\n singleItemSummaries.forEach((itemSummary) => {\n // Probably a bit confusing at first, but calling the whole qty tax calculation function here as we can safely use\n // it as item summary is always a single item summary here\n const taxAmount = calculateWholeQtyLineItemTax(itemSummary, taxRate);\n totalTaxAmount = add(totalTaxAmount, taxAmount);\n });\n\n return totalTaxAmount;\n};\n"],"names":["taxRateToDineroAllocation","taxRate","RangeError","rateScale","String","split","length","assert","rateInt","Math","round","pow","allocatePerItemTaxableAmount","itemSummary","quantity","preDiscountAmount","add","getDinero","taxableAmount","currency","discountAmount","allocator","FixedAmountAllocator","initialAllocateAmount","initialTotalAmount","amount","Array","from","discountAllocatedAmount","allocate","itemPrice","subtract","calculateWholeQtyLineItemTax","taxAmount","calculatePerQtyLineItemTax","singleItemSummaries","totalTaxAmount","forEach"],"mappings":";;;;;AAwBa,MAAAA,yBAAA,GACXC,OACqB,IAAA;EACjB,IAAAA,OAAA,IAAW,CAAK,IAAAA,OAAA,IAAW,CAAG,EAAA;IAC1B,MAAA,IAAIC,WAAW,iDAAiD,CAAA;EACxE;EAGM,MAAAC,SAAA,GAAYC,OAAOH,OAAO,CAAA,CAAEI,MAAM,GAAG,CAAA,CAAE,CAAC,CAAG,EAAAC,MAAA;EAC1CC,MAAA,CAAAJ,SAAA,KAAc,QAAW,wBAAwB,CAAA;EAGlD,MAAAK,OAAA,GAAUC,KAAKC,KAAM,CAAAT,OAAA,GAAUQ,KAAKE,GAAI,CAAA,EAAA,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YAAY,CAAG,EAAA;IACV,OAAAgB,SAAA,CAAU,CAAG,EAAAJ,WAAA,CAAYM,QAAQ,CAAA;EAC1C;EAMM,MAAA,CAACc,SAAS,CAAI,GAAAJ,QAAA,CAClBZ,SAAU,CAAAJ,WAAA,CAAYK,aAAe,EAAAL,WAAA,CAAYM,QAAQ,CAAA,EACzDnB,0BAA0BC,OAAO,CAAA,CACnC;EAEOM,MAAA,CAAA0B,SAAA,KAAc,QAAW,wBAAwB,CAAA;EACjD,OAAAA,SAAA;AACT,CAAA;AAEa,MAAAC,0BAAA,GAA6BA,CACxCrB,WAAA,EACAZ,OACkB,KAAA;EAElB,IAAIA,YAAY,CAAG,EAAA;IACV,OAAAgB,SAAA,CAAU,CAAG,EAAAJ,WAAA,CAAYM,QAAQ,CAAA;EAC1C;EAGM,MAAAgB,mBAAA,GAAsBvB,6BAA6BC,WAAW,CAAA;EAGpE,IAAIuB,cAAiB,GAAAnB,SAAA,CAAU,CAAG,EAAAJ,WAAA,CAAYM,QAAQ,CAAA;EAElCgB,mBAAA,CAAAE,OAAA,CAASxB,YAAgB,IAAA;IAGrC,MAAAoB,SAAA,GAAYD,4BAA6BnB,CAAAA,YAAAA,EAAaZ,OAAO,CAAA;IAClDmC,cAAA,GAAApB,GAAA,CAAIoB,gBAAgBH,SAAS,CAAA;EAAA,CAC/C,CAAA;EAEM,OAAAG,cAAA;AACT,CAAA;"}
@@ -1,10 +1,85 @@
1
- import type { Currency as DineroCurrency } from "dinero.js";
1
+ import type { Dinero, Currency as DineroCurrency } from "dinero.js";
2
+ import type { Currency } from "../../types";
3
+ /**
4
+ * Floating point number of item tax rate
5
+ * Number in range of 0>rate<1 (non-inclusive boundaries)
6
+ * @example
7
+ * 0.09 // 9%
8
+ */
9
+ export type TaxRate = number;
10
+ /**
11
+ * Shorthand for Dinero.js instance with number as the amount
12
+ */
13
+ export type Dino = Dinero<number>;
14
+ /**
15
+ * Shorthand for Dinero.js currency instance representing either a currency or custom currency such as tax-rate or shipping
16
+ */
17
+ export type DinoCurrency = DineroCurrency<number>;
18
+ /**
19
+ * Cents representation of specific currency
20
+ * As a helper to easily understand the code, we use `Cents` as a type alias for `number` as historically we have had
21
+ * mistakes by the team where we have used as dollar instead of `Cents` and vice versa.
22
+ * @example
23
+ * 100 // in USD this is $1.00
24
+ * 100 // in YEN this is ¥100
25
+ */
26
+ export type Cents = number;
27
+ /**
28
+ * Type definition for a rounding function that can be used to round fractions
29
+ */
30
+ export type RoundingFn = (float: number) => Cents;
31
+ /**
32
+ * Convenient way to represent a money on the API level
33
+ * When working with dinero you typically will convert this to a Dinero instance
34
+ */
35
+ export interface Money {
36
+ amount: Cents;
37
+ currency: Currency;
38
+ }
2
39
  /**
3
40
  * Attempt to type out some locales `language-TERRITORY` which "we" as store care about
4
41
  * @see https://unicode-org.github.io/cldr-staging/charts/38/supplemental/territory_language_information.html
5
42
  */
6
43
  export type Locale = "ar-AE" | "ar-SA" | "bg-BG" | "bn-BD" | "bn-IN" | "cs-CZ" | "da-DK" | "de-AT" | "de-CH" | "de-DE" | "el-GR" | "en-AU" | "en-BR" | "en-CA" | "en-GB" | "en-IE" | "en-IN" | "en-JP" | "en-NZ" | "en-SG" | "en-US" | "en-ZA" | "es-AR" | "es-CL" | "es-CO" | "es-ES" | "es-MX" | "es-US" | "fi-FI" | "fr-BE" | "fr-CA" | "fr-CH" | "fr-FR" | "he-IL" | "hi-IN" | "hr-HR" | "hu-HU" | "id-ID" | "it-CH" | "it-IT" | "ja-JP" | "ko-KR" | "nl-BE" | "nl-NL" | "no-NO" | "pl-PL" | "pt-BR" | "pt-PT" | "ro-RO" | "ru-RU" | "sk-SK" | "sv-SE" | "ta-IN" | "ta-LK" | "th-TH" | "tr-TR" | "zh-CN" | "zh-HK" | "zh-TW" | string;
7
- export type CurrencyObj = {
8
- currency: DineroCurrency<number>;
44
+ export type LocalizedCurrency = {
45
+ currency: DinoCurrency;
9
46
  locale: Locale;
10
47
  };
48
+ export interface LineItemSummary {
49
+ itemPrice: Cents;
50
+ /**
51
+ * Item quantity that is always bigger than zero!
52
+ */
53
+ quantity: number;
54
+ currency: Currency;
55
+ /**
56
+ * Total discount amount (only) applied for the given item quantity.
57
+ * No taxes are included. Calculated by `total_raw_price * <discount-allocation-percentage>`
58
+ */
59
+ discountAmount: Cents;
60
+ /**
61
+ * subtotal - discountAmount
62
+ */
63
+ taxableAmount: Cents;
64
+ }
65
+ /**
66
+ * Pretty much the same as PreTaxItemSummary but with quantity always set to 1 (for clearer type hinting and reasoning
67
+ * around the topic)
68
+ */
69
+ export interface SingleLineItemSummary extends LineItemSummary {
70
+ quantity: 1;
71
+ }
72
+ export interface FullLineItemSummary extends LineItemSummary {
73
+ /**
74
+ * Total price for the given item quantity. Calculated by `(itemPrice * quantity)`
75
+ */
76
+ subtotal: Cents;
77
+ /**
78
+ * Total tax amount for the given item quantity.
79
+ */
80
+ tax: Cents;
81
+ /**
82
+ * Total price for the given item quantity. Calculated by `subtotal - discountAmount + tax`
83
+ */
84
+ total: Cents;
85
+ }
@@ -31,7 +31,7 @@ export declare function isFloat(value: unknown, entity?: string, ErrorClass?: ne
31
31
  * toFixed(1.2345, 0) // => "1"
32
32
  * toFixed(1.23, 4) // => "1.2300"
33
33
  */
34
- export declare function toFixedRate(rate: number, scale: number): string;
34
+ export declare function toFixedRate(rate: number, scale: number, asNumber?: boolean): string;
35
35
  export declare function toFixedRate(rate: number, scale: number, asNumber: true): number;
36
36
  /**
37
37
  * Util to convert a float number to a string. Using this rather than simple template string to have a consistent way of
@@ -21,7 +21,7 @@ function isInt(value, entity = "Value", ErrorClass = TypeError) {
21
21
  function isFloat(value, entity = "Value", ErrorClass = TypeError) {
22
22
  isFiniteNumber(value, entity, ErrorClass);
23
23
  }
24
- function toFixedRate(rate, scale = 0, asNumber = false) {
24
+ function toFixedRate(rate, scale, asNumber) {
25
25
  isFloat(rate, "Rate");
26
26
  const fixedRate = rate.toFixed(scale);
27
27
  return asNumber ? +fixedRate : fixedRate;
@@ -1 +1 @@
1
- {"version":3,"file":"number.js","sources":["../../src/utils/number.ts"],"sourcesContent":["/**\n * Util to easily parse that any given input is a finite number (not NaN, Infinity, -Infinity, etc.)\n * @throws If given input is not a finite number\n */\nexport function isFiniteNumber(\n value: unknown,\n entity = \"Value\",\n ErrorClass: new (message: string) => void = TypeError,\n): asserts value is number {\n if (typeof value !== \"number\" || Number.isNaN(value)) {\n // eslint-disable-next-line @typescript-eslint/no-throw-literal\n throw new ErrorClass(`${entity} is not a number: ${value}`);\n }\n\n if (!Number.isFinite(value)) {\n // eslint-disable-next-line @typescript-eslint/no-throw-literal\n throw new ErrorClass(`${entity} is not a finite number: ${value}`);\n }\n}\n\n/**\n * Custom isInt validation function that returns a more fine-grained error message otherwise for type safety alone a\n * Number.isSafeInteger would be sufficient.\n *\n * Code inspired from graphql-scalars library.\n * @see\n * https://github.com/Urigo/graphql-scalars/blob/c4fa3d27b965e39ceda6c33fc18041f112ecce49/src/scalars/utilities.ts#L20-L32\n * @throws If given input is not a valid integer\n */\nexport function isInt(\n value: unknown,\n entity = \"Value\",\n ErrorClass: new (message: string) => void = TypeError,\n): asserts value is number {\n isFiniteNumber(value, entity, ErrorClass);\n\n if (!Number.isInteger(value)) {\n // eslint-disable-next-line @typescript-eslint/no-throw-literal\n throw new ErrorClass(`${entity} is not an integer: ${value}`);\n }\n\n if (!Number.isSafeInteger(value)) {\n // eslint-disable-next-line @typescript-eslint/no-throw-literal\n throw new ErrorClass(`${entity} is not a safe integer: ${value}`);\n }\n}\n\n/**\n * Custom isFloat validation function that returns a more fine-grained error message otherwise for type safety alone a\n * Number.parseFloat would be sufficient.\n *\n * Code inspired from graphql-scalars library.\n * @see\n * https://github.com/Urigo/graphql-scalars/blob/c4fa3d27b965e39ceda6c33fc18041f112ecce49/src/scalars/utilities.ts#L34-L38\n * @throws If given input is not a valid float\n */\nexport function isFloat(\n value: unknown,\n entity = \"Value\",\n ErrorClass: new (message: string) => void = TypeError,\n): asserts value is number {\n isFiniteNumber(value, entity, ErrorClass);\n}\n\n/**\n * Returns a string representing a number in fixed-point notation.\n * Overload: Returns the rate parsed as a number\n * @example\n * toFixed(1.2345, 2) // => \"1.23\"\n * toFixed(1.2345, 0) // => \"1\"\n * toFixed(1.23, 4) // => \"1.2300\"\n */\nexport function toFixedRate(rate: number, scale: number): string;\nexport function toFixedRate(\n rate: number,\n scale: number,\n asNumber: true,\n): number;\nexport function toFixedRate(rate: number, scale = 0, asNumber = false) {\n // Verify rate\n isFloat(rate, \"Rate\");\n\n const fixedRate = rate.toFixed(scale);\n\n return asNumber ? +fixedRate : fixedRate;\n}\n\n/**\n * Util to convert a float number to a string. Using this rather than simple template string to have a consistent way of\n * doing it. Removes any redundant trailing zeros.\n * @example\n * numberToString(1.23) // => \"1.23\"\n * numberToString(10.00) // => \"10\"\n * @throws If given input is not a valid number\n */\nexport const numberToString = (num: number): string => {\n isFloat(num);\n return num.toString(10);\n};\n\n/**\n * @see https://stackoverflow.com/a/35000557\n */\nexport const findClosestNumber = <T extends number>(\n haystack: T[],\n needle: number,\n): T => {\n return haystack.reduce((prev, curr) =>\n Math.abs(curr - needle) < Math.abs(prev - needle) ? curr : prev,\n );\n};\n\n/**\n * Splits number into array by max value provided.\n * E.g. splitNumberBy(100, 30) => [30, 30, 30, 10]\n */\nexport const splitNumberBy = (value: number, by: number) => {\n const chunks = new Array(Math.floor(value / by)).fill(by);\n const remainder = value % by;\n\n if (remainder > 0) {\n chunks.push(remainder);\n }\n\n return chunks;\n};\n\n/**\n * Clamp value to a given range\n */\nexport const clamp = (val: number, min: number, max: number) => {\n const trueMin = Math.min(min, max);\n const trueMax = Math.max(min, max);\n\n return Math.min(trueMax, Math.max(trueMin, val));\n};\n\n/**\n * Interpolate a number to a new range\n *\n * @example\n * linearInterpolate(5, [0, 10], [0, 100]); // 50\n */\nexport const linearInterpolate = (\n inputY: number,\n [fromMin, fromMax]: [number, number],\n [toMin, toMax]: [number, number],\n clampResult = true,\n) => {\n const percent = (inputY - fromMin) / (fromMax - fromMin);\n const outputX = percent * (toMax - toMin) + toMin;\n\n return clampResult ? clamp(outputX, toMin, toMax) : outputX;\n};\n\n/**\n * Increase value and start over once the range is overflown\n */\nexport const incrementLoopValue = (\n value: number,\n [min, max]: [number, number],\n) => {\n if (value === max) {\n return min;\n }\n return value + 1;\n};\n"],"names":["isFiniteNumber","value","entity","ErrorClass","TypeError","Number","isNaN","isFinite","isInt","isInteger","isSafeInteger","isFloat","toFixedRate","rate","scale","asNumber","fixedRate","toFixed","numberToString","num","toString","findClosestNumber","haystack","needle","reduce","prev","curr","Math","abs","splitNumberBy","by","chunks","Array","floor","fill","remainder","push","clamp","val","min","max","trueMin","trueMax","linearInterpolate","inputY","fromMin","fromMax","toMin","toMax","clampResult","percent","outputX","incrementLoopValue"],"mappings":";;;AAIO,SAASA,cACdA,CAAAC,KAAA,EACAC,MAAS,GAAA,OAAA,EACTC,aAA4CC,SACnB,EAAA;EACzB,IAAI,OAAOH,KAAU,KAAA,QAAA,IAAYI,MAAO,CAAAC,KAAA,CAAML,KAAK,CAAG,EAAA;IAEpD,MAAM,IAAIE,UAAW,CAAA,GAAGD,MAAM,qBAAqBD,KAAO,EAAA,CAAA;EAC5D;EAEA,IAAI,CAACI,MAAA,CAAOE,QAAS,CAAAN,KAAK,CAAG,EAAA;IAE3B,MAAM,IAAIE,UAAW,CAAA,GAAGD,MAAM,4BAA4BD,KAAO,EAAA,CAAA;EACnE;AACF;AAWO,SAASO,KACdA,CAAAP,KAAA,EACAC,MAAS,GAAA,OAAA,EACTC,aAA4CC,SACnB,EAAA;EACVJ,cAAA,CAAAC,KAAA,EAAOC,QAAQC,UAAU,CAAA;EAExC,IAAI,CAACE,MAAA,CAAOI,SAAU,CAAAR,KAAK,CAAG,EAAA;IAE5B,MAAM,IAAIE,UAAW,CAAA,GAAGD,MAAM,uBAAuBD,KAAO,EAAA,CAAA;EAC9D;EAEA,IAAI,CAACI,MAAA,CAAOK,aAAc,CAAAT,KAAK,CAAG,EAAA;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A;AAKO,MAAMM,KAAQ,GAAAA,CAACC,GAAa,EAAAC,GAAA,EAAaC,GAAgB,KAAA;EAC9D,MAAMC,OAAU,GAAAd,IAAA,CAAKY,GAAI,CAAAA,GAAA,EAAKC,GAAG,CAAA;EACjC,MAAME,OAAU,GAAAf,IAAA,CAAKa,GAAI,CAAAD,GAAA,EAAKC,GAAG,CAAA;EAEjC,OAAOb,KAAKY,GAAI,CAAAG,OAAA,EAASf,KAAKa,GAAI,CAAAC,OAAA,EAASH,GAAG,CAAC,CAAA;AACjD,CAAA;AAQO,MAAMK,iBAAoB,GAAAA,CAC/BC,MACA,EAAA,CAACC,OAAS,EAAAC,OAAO,CACjB,EAAA,CAACC,KAAO,EAAAC,KAAK,CACb,EAAAC,WAAA,GAAc,IACX,KAAA;EACG,MAAAC,OAAA,GAAA,CAAWN,MAAS,GAAAC,OAAA,KAAYC,OAAU,GAAAD,OAAA,CAAA;EAC1C,MAAAM,OAAA,GAAUD,OAAW,IAAAF,KAAA,GAAQD,KAAS,CAAA,GAAAA,KAAA;EAE5C,OAAOE,WAAc,GAAAZ,KAAA,CAAMc,OAAS,EAAAJ,KAAA,EAAOC,KAAK,CAAI,GAAAG,OAAA;AACtD,CAAA;AAKO,MAAMC,qBAAqBA,CAChCnD,KAAA,EACA,CAACsC,GAAA,EAAKC,GAAG,CACN,KAAA;EACH,IAAIvC,UAAUuC,GAAK,EAAA;IACV,OAAAD,GAAA;EACT;EACA,OAAOtC,KAAQ,GAAA,CAAA;AACjB,CAAA;;;;;;;;;;"}
1
+ {"version":3,"file":"number.js","sources":["../../src/utils/number.ts"],"sourcesContent":["/**\n * Util to easily parse that any given input is a finite number (not NaN, Infinity, -Infinity, etc.)\n * @throws If given input is not a finite number\n */\nexport function isFiniteNumber(\n value: unknown,\n entity = \"Value\",\n ErrorClass: new (message: string) => void = TypeError,\n): asserts value is number {\n if (typeof value !== \"number\" || Number.isNaN(value)) {\n // eslint-disable-next-line @typescript-eslint/no-throw-literal\n throw new ErrorClass(`${entity} is not a number: ${value}`);\n }\n\n if (!Number.isFinite(value)) {\n // eslint-disable-next-line @typescript-eslint/no-throw-literal\n throw new ErrorClass(`${entity} is not a finite number: ${value}`);\n }\n}\n\n/**\n * Custom isInt validation function that returns a more fine-grained error message otherwise for type safety alone a\n * Number.isSafeInteger would be sufficient.\n *\n * Code inspired from graphql-scalars library.\n * @see\n * https://github.com/Urigo/graphql-scalars/blob/c4fa3d27b965e39ceda6c33fc18041f112ecce49/src/scalars/utilities.ts#L20-L32\n * @throws If given input is not a valid integer\n */\nexport function isInt(\n value: unknown,\n entity = \"Value\",\n ErrorClass: new (message: string) => void = TypeError,\n): asserts value is number {\n isFiniteNumber(value, entity, ErrorClass);\n\n if (!Number.isInteger(value)) {\n // eslint-disable-next-line @typescript-eslint/no-throw-literal\n throw new ErrorClass(`${entity} is not an integer: ${value}`);\n }\n\n if (!Number.isSafeInteger(value)) {\n // eslint-disable-next-line @typescript-eslint/no-throw-literal\n throw new ErrorClass(`${entity} is not a safe integer: ${value}`);\n }\n}\n\n/**\n * Custom isFloat validation function that returns a more fine-grained error message otherwise for type safety alone a\n * Number.parseFloat would be sufficient.\n *\n * Code inspired from graphql-scalars library.\n * @see\n * https://github.com/Urigo/graphql-scalars/blob/c4fa3d27b965e39ceda6c33fc18041f112ecce49/src/scalars/utilities.ts#L34-L38\n * @throws If given input is not a valid float\n */\nexport function isFloat(\n value: unknown,\n entity = \"Value\",\n ErrorClass: new (message: string) => void = TypeError,\n): asserts value is number {\n isFiniteNumber(value, entity, ErrorClass);\n}\n\n/**\n * Returns a string representing a number in fixed-point notation.\n * Overload: Returns the rate parsed as a number\n * @example\n * toFixed(1.2345, 2) // => \"1.23\"\n * toFixed(1.2345, 0) // => \"1\"\n * toFixed(1.23, 4) // => \"1.2300\"\n */\nexport function toFixedRate(\n rate: number,\n scale: number,\n asNumber?: boolean,\n): string;\nexport function toFixedRate(\n rate: number,\n scale: number,\n asNumber: true,\n): number;\nexport function toFixedRate(rate: number, scale: number, asNumber?: boolean) {\n // Verify rate\n isFloat(rate, \"Rate\");\n\n const fixedRate = rate.toFixed(scale);\n\n return asNumber ? +fixedRate : fixedRate;\n}\n\n/**\n * Util to convert a float number to a string. Using this rather than simple template string to have a consistent way of\n * doing it. Removes any redundant trailing zeros.\n * @example\n * numberToString(1.23) // => \"1.23\"\n * numberToString(10.00) // => \"10\"\n * @throws If given input is not a valid number\n */\nexport const numberToString = (num: number): string => {\n isFloat(num);\n return num.toString(10);\n};\n\n/**\n * @see https://stackoverflow.com/a/35000557\n */\nexport const findClosestNumber = <T extends number>(\n haystack: T[],\n needle: number,\n): T => {\n return haystack.reduce((prev, curr) =>\n Math.abs(curr - needle) < Math.abs(prev - needle) ? curr : prev,\n );\n};\n\n/**\n * Splits number into array by max value provided.\n * E.g. splitNumberBy(100, 30) => [30, 30, 30, 10]\n */\nexport const splitNumberBy = (value: number, by: number) => {\n const chunks = new Array(Math.floor(value / by)).fill(by);\n const remainder = value % by;\n\n if (remainder > 0) {\n chunks.push(remainder);\n }\n\n return chunks;\n};\n\n/**\n * Clamp value to a given range\n */\nexport const clamp = (val: number, min: number, max: number) => {\n const trueMin = Math.min(min, max);\n const trueMax = Math.max(min, max);\n\n return Math.min(trueMax, Math.max(trueMin, val));\n};\n\n/**\n * Interpolate a number to a new range\n *\n * @example\n * linearInterpolate(5, [0, 10], [0, 100]); // 50\n */\nexport const linearInterpolate = (\n inputY: number,\n [fromMin, fromMax]: [number, number],\n [toMin, toMax]: [number, number],\n clampResult = true,\n) => {\n const percent = (inputY - fromMin) / (fromMax - fromMin);\n const outputX = percent * (toMax - toMin) + toMin;\n\n return clampResult ? clamp(outputX, toMin, toMax) : outputX;\n};\n\n/**\n * Increase value and start over once the range is overflown\n */\nexport const incrementLoopValue = (\n value: number,\n [min, max]: [number, number],\n) => {\n if (value === max) {\n return min;\n }\n return value + 1;\n};\n"],"names":["isFiniteNumber","value","entity","ErrorClass","TypeError","Number","isNaN","isFinite","isInt","isInteger","isSafeInteger","isFloat","toFixedRate","rate","scale","asNumber","fixedRate","toFixed","numberToString","num","toString","findClosestNumber","haystack","needle","reduce","prev","curr","Math","abs","splitNumberBy","by","chunks","Array","floor","fill","remainder","push","clamp","val","min","max","trueMin","trueMax","linearInterpolate","inputY","fromMin","fromMax","toMin","toMax","clampResult","percent","outputX","incrementLoopValue"],"mappings":";;;AAIO,SAASA,cACdA,CAAAC,KAAA,EACAC,MAAS,GAAA,OAAA,EACTC,aAA4CC,SACnB,EAAA;EACzB,IAAI,OAAOH,KAAU,KAAA,QAAA,IAAYI,MAAO,CAAAC,KAAA,CAAML,KAAK,CAAG,EAAA;IAEpD,MAAM,IAAIE,UAAW,CAAA,GAAGD,MAAM,qBAAqBD,KAAO,EAAA,CAAA;EAC5D;EAEA,IAAI,CAACI,MAAA,CAAOE,QAAS,CAAAN,KAAK,CAAG,EAAA;IAE3B,MAAM,IAAIE,UAAW,CAAA,GAAGD,MAAM,4BAA4BD,KAAO,EAAA,CAAA;EACnE;AACF;AAWO,SAASO,KACdA,CAAAP,KAAA,EACAC,MAAS,GAAA,OAAA,EACTC,aAA4CC,SACnB,EAAA;EACVJ,cAAA,CAAAC,KAAA,EAAOC,QAAQC,UAAU,CAAA;EAExC,IAAI,CAACE,MAAA,CAAOI,SAAU,CAAAR,KAAK,CAAG,EAAA;IAE5B,MAAM,IAAIE,UAAW,CAAA,GAAGD,MAAM,uBAAuBD,KAAO,EAAA,CAAA;EAC9D;EAEA,IAAI,CAACI,MAAA,CAAOK,aAAc,CAAAT,KAAK,CAAG,EAAA;IAEhC,MAAM,IAAIE,UAAW,CAAA,GAAGD,MAAM,2BAA2BD,KAAO,EAAA,CAAA;EAClE;AACF;AAWO,SAASU,OACdA,CAAAV,KAAA,EACAC,MAAS,GAAA,OAAA,EACTC,aAA4CC,SACnB,EAAA;EACVJ,cAAA,CAAAC,KAAA,EAAOC,QAAQC,UAAU,CAAA;AAC1C;AAoBgB,SAAAS,WAAAA,CAAYC,IAAc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ASf,KAAKa,GAAI,CAAAC,OAAA,EAASH,GAAG,CAAC,CAAA;AACjD,CAAA;AAQO,MAAMK,iBAAoB,GAAAA,CAC/BC,MACA,EAAA,CAACC,OAAS,EAAAC,OAAO,CACjB,EAAA,CAACC,KAAO,EAAAC,KAAK,CACb,EAAAC,WAAA,GAAc,IACX,KAAA;EACG,MAAAC,OAAA,GAAA,CAAWN,MAAS,GAAAC,OAAA,KAAYC,OAAU,GAAAD,OAAA,CAAA;EAC1C,MAAAM,OAAA,GAAUD,OAAW,IAAAF,KAAA,GAAQD,KAAS,CAAA,GAAAA,KAAA;EAE5C,OAAOE,WAAc,GAAAZ,KAAA,CAAMc,OAAS,EAAAJ,KAAA,EAAOC,KAAK,CAAI,GAAAG,OAAA;AACtD,CAAA;AAKO,MAAMC,qBAAqBA,CAChCnD,KAAA,EACA,CAACsC,GAAA,EAAKC,GAAG,CACN,KAAA;EACH,IAAIvC,UAAUuC,GAAK,EAAA;IACV,OAAAD,GAAA;EACT;EACA,OAAOtC,KAAQ,GAAA,CAAA;AACjB,CAAA;;;;;;;;;;"}
@@ -20,7 +20,7 @@ function isInt(value, entity = "Value", ErrorClass = TypeError) {
20
20
  function isFloat(value, entity = "Value", ErrorClass = TypeError) {
21
21
  isFiniteNumber(value, entity, ErrorClass);
22
22
  }
23
- function toFixedRate(rate, scale = 0, asNumber = false) {
23
+ function toFixedRate(rate, scale, asNumber) {
24
24
  isFloat(rate, "Rate");
25
25
  const fixedRate = rate.toFixed(scale);
26
26
  return asNumber ? +fixedRate : fixedRate;
@@ -1 +1 @@
1
- {"version":3,"file":"number.mjs","sources":["../../src/utils/number.ts"],"sourcesContent":["/**\n * Util to easily parse that any given input is a finite number (not NaN, Infinity, -Infinity, etc.)\n * @throws If given input is not a finite number\n */\nexport function isFiniteNumber(\n value: unknown,\n entity = \"Value\",\n ErrorClass: new (message: string) => void = TypeError,\n): asserts value is number {\n if (typeof value !== \"number\" || Number.isNaN(value)) {\n // eslint-disable-next-line @typescript-eslint/no-throw-literal\n throw new ErrorClass(`${entity} is not a number: ${value}`);\n }\n\n if (!Number.isFinite(value)) {\n // eslint-disable-next-line @typescript-eslint/no-throw-literal\n throw new ErrorClass(`${entity} is not a finite number: ${value}`);\n }\n}\n\n/**\n * Custom isInt validation function that returns a more fine-grained error message otherwise for type safety alone a\n * Number.isSafeInteger would be sufficient.\n *\n * Code inspired from graphql-scalars library.\n * @see\n * https://github.com/Urigo/graphql-scalars/blob/c4fa3d27b965e39ceda6c33fc18041f112ecce49/src/scalars/utilities.ts#L20-L32\n * @throws If given input is not a valid integer\n */\nexport function isInt(\n value: unknown,\n entity = \"Value\",\n ErrorClass: new (message: string) => void = TypeError,\n): asserts value is number {\n isFiniteNumber(value, entity, ErrorClass);\n\n if (!Number.isInteger(value)) {\n // eslint-disable-next-line @typescript-eslint/no-throw-literal\n throw new ErrorClass(`${entity} is not an integer: ${value}`);\n }\n\n if (!Number.isSafeInteger(value)) {\n // eslint-disable-next-line @typescript-eslint/no-throw-literal\n throw new ErrorClass(`${entity} is not a safe integer: ${value}`);\n }\n}\n\n/**\n * Custom isFloat validation function that returns a more fine-grained error message otherwise for type safety alone a\n * Number.parseFloat would be sufficient.\n *\n * Code inspired from graphql-scalars library.\n * @see\n * https://github.com/Urigo/graphql-scalars/blob/c4fa3d27b965e39ceda6c33fc18041f112ecce49/src/scalars/utilities.ts#L34-L38\n * @throws If given input is not a valid float\n */\nexport function isFloat(\n value: unknown,\n entity = \"Value\",\n ErrorClass: new (message: string) => void = TypeError,\n): asserts value is number {\n isFiniteNumber(value, entity, ErrorClass);\n}\n\n/**\n * Returns a string representing a number in fixed-point notation.\n * Overload: Returns the rate parsed as a number\n * @example\n * toFixed(1.2345, 2) // => \"1.23\"\n * toFixed(1.2345, 0) // => \"1\"\n * toFixed(1.23, 4) // => \"1.2300\"\n */\nexport function toFixedRate(rate: number, scale: number): string;\nexport function toFixedRate(\n rate: number,\n scale: number,\n asNumber: true,\n): number;\nexport function toFixedRate(rate: number, scale = 0, asNumber = false) {\n // Verify rate\n isFloat(rate, \"Rate\");\n\n const fixedRate = rate.toFixed(scale);\n\n return asNumber ? +fixedRate : fixedRate;\n}\n\n/**\n * Util to convert a float number to a string. Using this rather than simple template string to have a consistent way of\n * doing it. Removes any redundant trailing zeros.\n * @example\n * numberToString(1.23) // => \"1.23\"\n * numberToString(10.00) // => \"10\"\n * @throws If given input is not a valid number\n */\nexport const numberToString = (num: number): string => {\n isFloat(num);\n return num.toString(10);\n};\n\n/**\n * @see https://stackoverflow.com/a/35000557\n */\nexport const findClosestNumber = <T extends number>(\n haystack: T[],\n needle: number,\n): T => {\n return haystack.reduce((prev, curr) =>\n Math.abs(curr - needle) < Math.abs(prev - needle) ? curr : prev,\n );\n};\n\n/**\n * Splits number into array by max value provided.\n * E.g. splitNumberBy(100, 30) => [30, 30, 30, 10]\n */\nexport const splitNumberBy = (value: number, by: number) => {\n const chunks = new Array(Math.floor(value / by)).fill(by);\n const remainder = value % by;\n\n if (remainder > 0) {\n chunks.push(remainder);\n }\n\n return chunks;\n};\n\n/**\n * Clamp value to a given range\n */\nexport const clamp = (val: number, min: number, max: number) => {\n const trueMin = Math.min(min, max);\n const trueMax = Math.max(min, max);\n\n return Math.min(trueMax, Math.max(trueMin, val));\n};\n\n/**\n * Interpolate a number to a new range\n *\n * @example\n * linearInterpolate(5, [0, 10], [0, 100]); // 50\n */\nexport const linearInterpolate = (\n inputY: number,\n [fromMin, fromMax]: [number, number],\n [toMin, toMax]: [number, number],\n clampResult = true,\n) => {\n const percent = (inputY - fromMin) / (fromMax - fromMin);\n const outputX = percent * (toMax - toMin) + toMin;\n\n return clampResult ? clamp(outputX, toMin, toMax) : outputX;\n};\n\n/**\n * Increase value and start over once the range is overflown\n */\nexport const incrementLoopValue = (\n value: number,\n [min, max]: [number, number],\n) => {\n if (value === max) {\n return min;\n }\n return value + 1;\n};\n"],"names":["isFiniteNumber","value","entity","ErrorClass","TypeError","Number","isNaN","isFinite","isInt","isInteger","isSafeInteger","isFloat","toFixedRate","rate","scale","asNumber","fixedRate","toFixed","numberToString","num","toString","findClosestNumber","haystack","needle","reduce","prev","curr","Math","abs","splitNumberBy","by","chunks","Array","floor","fill","remainder","push","clamp","val","min","max","trueMin","trueMax","linearInterpolate","inputY","fromMin","fromMax","toMin","toMax","clampResult","percent","outputX","incrementLoopValue"],"mappings":";;AAIO,SAASA,cACdA,CAAAC,KAAA,EACAC,MAAS,GAAA,OAAA,EACTC,aAA4CC,SACnB,EAAA;EACzB,IAAI,OAAOH,KAAU,KAAA,QAAA,IAAYI,MAAO,CAAAC,KAAA,CAAML,KAAK,CAAG,EAAA;IAEpD,MAAM,IAAIE,UAAW,CAAA,GAAGD,MAAM,qBAAqBD,KAAO,EAAA,CAAA;EAC5D;EAEA,IAAI,CAACI,MAAA,CAAOE,QAAS,CAAAN,KAAK,CAAG,EAAA;IAE3B,MAAM,IAAIE,UAAW,CAAA,GAAGD,MAAM,4BAA4BD,KAAO,EAAA,CAAA;EACnE;AACF;AAWO,SAASO,KACdA,CAAAP,KAAA,EACAC,MAAS,GAAA,OAAA,EACTC,aAA4CC,SACnB,EAAA;EACVJ,cAAA,CAAAC,KAAA,EAAOC,QAAQC,UAAU,CAAA;EAExC,IAAI,CAACE,MAAA,CAAOI,SAAU,CAAAR,KAAK,CAAG,EAAA;IAE5B,MAAM,IAAIE,UAAW,CAAA,GAAGD,MAAM,uBAAuBD,KAAO,EAAA,CAAA;EAC9D;EAEA,IAAI,CAACI,MAAA,CAAOK,aAAc,CAAAT,KAAK,CAAG,EAAA;IAEhC,MAAM,IAAIE,UAAW,CAAA,GAAGD,MAAM,2BAA2BD,KAAO,EAAA,CAAA;EAClE;AACF;AAWO,SAASU,OACdA,CAAAV,KAAA,EACAC,MAAS,GAAA,OAAA,EACTC,aAA4CC,SACnB,EAAA;EACVJ,cAAA,CAAAC,KAAA,EAAOC,QAAQC,UAAU,CAAA;AAC1C;AAgBO,SAASS,WAAYA,CAAAC,IAAA,EAAc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G,OAAA,EAASf,KAAKa,GAAI,CAAAC,OAAA,EAASH,GAAG,CAAC,CAAA;AACjD,CAAA;AAQO,MAAMK,iBAAoB,GAAAA,CAC/BC,MACA,EAAA,CAACC,OAAS,EAAAC,OAAO,CACjB,EAAA,CAACC,KAAO,EAAAC,KAAK,CACb,EAAAC,WAAA,GAAc,IACX,KAAA;EACG,MAAAC,OAAA,GAAA,CAAWN,MAAS,GAAAC,OAAA,KAAYC,OAAU,GAAAD,OAAA,CAAA;EAC1C,MAAAM,OAAA,GAAUD,OAAW,IAAAF,KAAA,GAAQD,KAAS,CAAA,GAAAA,KAAA;EAE5C,OAAOE,WAAc,GAAAZ,KAAA,CAAMc,OAAS,EAAAJ,KAAA,EAAOC,KAAK,CAAI,GAAAG,OAAA;AACtD,CAAA;AAKO,MAAMC,qBAAqBA,CAChCnD,KAAA,EACA,CAACsC,GAAA,EAAKC,GAAG,CACN,KAAA;EACH,IAAIvC,UAAUuC,GAAK,EAAA;IACV,OAAAD,GAAA;EACT;EACA,OAAOtC,KAAQ,GAAA,CAAA;AACjB,CAAA;"}
1
+ {"version":3,"file":"number.mjs","sources":["../../src/utils/number.ts"],"sourcesContent":["/**\n * Util to easily parse that any given input is a finite number (not NaN, Infinity, -Infinity, etc.)\n * @throws If given input is not a finite number\n */\nexport function isFiniteNumber(\n value: unknown,\n entity = \"Value\",\n ErrorClass: new (message: string) => void = TypeError,\n): asserts value is number {\n if (typeof value !== \"number\" || Number.isNaN(value)) {\n // eslint-disable-next-line @typescript-eslint/no-throw-literal\n throw new ErrorClass(`${entity} is not a number: ${value}`);\n }\n\n if (!Number.isFinite(value)) {\n // eslint-disable-next-line @typescript-eslint/no-throw-literal\n throw new ErrorClass(`${entity} is not a finite number: ${value}`);\n }\n}\n\n/**\n * Custom isInt validation function that returns a more fine-grained error message otherwise for type safety alone a\n * Number.isSafeInteger would be sufficient.\n *\n * Code inspired from graphql-scalars library.\n * @see\n * https://github.com/Urigo/graphql-scalars/blob/c4fa3d27b965e39ceda6c33fc18041f112ecce49/src/scalars/utilities.ts#L20-L32\n * @throws If given input is not a valid integer\n */\nexport function isInt(\n value: unknown,\n entity = \"Value\",\n ErrorClass: new (message: string) => void = TypeError,\n): asserts value is number {\n isFiniteNumber(value, entity, ErrorClass);\n\n if (!Number.isInteger(value)) {\n // eslint-disable-next-line @typescript-eslint/no-throw-literal\n throw new ErrorClass(`${entity} is not an integer: ${value}`);\n }\n\n if (!Number.isSafeInteger(value)) {\n // eslint-disable-next-line @typescript-eslint/no-throw-literal\n throw new ErrorClass(`${entity} is not a safe integer: ${value}`);\n }\n}\n\n/**\n * Custom isFloat validation function that returns a more fine-grained error message otherwise for type safety alone a\n * Number.parseFloat would be sufficient.\n *\n * Code inspired from graphql-scalars library.\n * @see\n * https://github.com/Urigo/graphql-scalars/blob/c4fa3d27b965e39ceda6c33fc18041f112ecce49/src/scalars/utilities.ts#L34-L38\n * @throws If given input is not a valid float\n */\nexport function isFloat(\n value: unknown,\n entity = \"Value\",\n ErrorClass: new (message: string) => void = TypeError,\n): asserts value is number {\n isFiniteNumber(value, entity, ErrorClass);\n}\n\n/**\n * Returns a string representing a number in fixed-point notation.\n * Overload: Returns the rate parsed as a number\n * @example\n * toFixed(1.2345, 2) // => \"1.23\"\n * toFixed(1.2345, 0) // => \"1\"\n * toFixed(1.23, 4) // => \"1.2300\"\n */\nexport function toFixedRate(\n rate: number,\n scale: number,\n asNumber?: boolean,\n): string;\nexport function toFixedRate(\n rate: number,\n scale: number,\n asNumber: true,\n): number;\nexport function toFixedRate(rate: number, scale: number, asNumber?: boolean) {\n // Verify rate\n isFloat(rate, \"Rate\");\n\n const fixedRate = rate.toFixed(scale);\n\n return asNumber ? +fixedRate : fixedRate;\n}\n\n/**\n * Util to convert a float number to a string. Using this rather than simple template string to have a consistent way of\n * doing it. Removes any redundant trailing zeros.\n * @example\n * numberToString(1.23) // => \"1.23\"\n * numberToString(10.00) // => \"10\"\n * @throws If given input is not a valid number\n */\nexport const numberToString = (num: number): string => {\n isFloat(num);\n return num.toString(10);\n};\n\n/**\n * @see https://stackoverflow.com/a/35000557\n */\nexport const findClosestNumber = <T extends number>(\n haystack: T[],\n needle: number,\n): T => {\n return haystack.reduce((prev, curr) =>\n Math.abs(curr - needle) < Math.abs(prev - needle) ? curr : prev,\n );\n};\n\n/**\n * Splits number into array by max value provided.\n * E.g. splitNumberBy(100, 30) => [30, 30, 30, 10]\n */\nexport const splitNumberBy = (value: number, by: number) => {\n const chunks = new Array(Math.floor(value / by)).fill(by);\n const remainder = value % by;\n\n if (remainder > 0) {\n chunks.push(remainder);\n }\n\n return chunks;\n};\n\n/**\n * Clamp value to a given range\n */\nexport const clamp = (val: number, min: number, max: number) => {\n const trueMin = Math.min(min, max);\n const trueMax = Math.max(min, max);\n\n return Math.min(trueMax, Math.max(trueMin, val));\n};\n\n/**\n * Interpolate a number to a new range\n *\n * @example\n * linearInterpolate(5, [0, 10], [0, 100]); // 50\n */\nexport const linearInterpolate = (\n inputY: number,\n [fromMin, fromMax]: [number, number],\n [toMin, toMax]: [number, number],\n clampResult = true,\n) => {\n const percent = (inputY - fromMin) / (fromMax - fromMin);\n const outputX = percent * (toMax - toMin) + toMin;\n\n return clampResult ? clamp(outputX, toMin, toMax) : outputX;\n};\n\n/**\n * Increase value and start over once the range is overflown\n */\nexport const incrementLoopValue = (\n value: number,\n [min, max]: [number, number],\n) => {\n if (value === max) {\n return min;\n }\n return value + 1;\n};\n"],"names":["isFiniteNumber","value","entity","ErrorClass","TypeError","Number","isNaN","isFinite","isInt","isInteger","isSafeInteger","isFloat","toFixedRate","rate","scale","asNumber","fixedRate","toFixed","numberToString","num","toString","findClosestNumber","haystack","needle","reduce","prev","curr","Math","abs","splitNumberBy","by","chunks","Array","floor","fill","remainder","push","clamp","val","min","max","trueMin","trueMax","linearInterpolate","inputY","fromMin","fromMax","toMin","toMax","clampResult","percent","outputX","incrementLoopValue"],"mappings":";;AAIO,SAASA,cACdA,CAAAC,KAAA,EACAC,MAA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,GAAAD,OAAA,CAAA;EAC1C,MAAAM,OAAA,GAAUD,OAAW,IAAAF,KAAA,GAAQD,KAAS,CAAA,GAAAA,KAAA;EAE5C,OAAOE,WAAc,GAAAZ,KAAA,CAAMc,OAAS,EAAAJ,KAAA,EAAOC,KAAK,CAAI,GAAAG,OAAA;AACtD,CAAA;AAKO,MAAMC,qBAAqBA,CAChCnD,KAAA,EACA,CAACsC,GAAA,EAAKC,GAAG,CACN,KAAA;EACH,IAAIvC,UAAUuC,GAAK,EAAA;IACV,OAAAD,GAAA;EACT;EACA,OAAOtC,KAAQ,GAAA,CAAA;AACjB,CAAA;"}
package/package.json CHANGED
@@ -1,29 +1,52 @@
1
1
  {
2
- "name": "@ubnt/store.core",
3
- "version": "9.11.1",
4
- "description": "",
5
- "sideEffects": false,
6
- "scripts": {
7
- "build": "rollup -c && tsc --emitDeclarationOnly",
8
- "build:watch": "nodemon --config ./nodemon.json",
9
- "lint:tsc": "tsc --project ./tsconfig.json",
10
- "prepublishOnly": "npm run build",
11
- "storybook": "start-storybook -p 6008 --no-open",
12
- "storybook:build": "build-storybook",
13
- "test": "echo 'Hi from @ubnt/store.core 👋'"
14
- },
15
- "keywords": [],
16
- "files": [
17
- "lib",
18
- "CHANGELOG.md"
19
- ],
20
2
  "dependencies": {
21
3
  "adm-zip": "0.5.14",
22
- "axios": "1.7.4",
4
+ "axios": "1.7.2",
23
5
  "json-stable-stringify": "1.1.1",
24
6
  "terser": "5.31.1",
25
7
  "tldts": "6.1.31"
26
8
  },
9
+ "description": "",
10
+ "devDependencies": {
11
+ "@rollup/plugin-commonjs": "26.0.1",
12
+ "@rollup/plugin-json": "6.1.0",
13
+ "@rollup/plugin-multi-entry": "6.0.1",
14
+ "@rollup/plugin-node-resolve": "15.2.3",
15
+ "@storybook/addon-actions": "6.5.16",
16
+ "@storybook/addon-essentials": "6.5.16",
17
+ "@storybook/addon-interactions": "6.5.16",
18
+ "@storybook/addon-links": "6.5.16",
19
+ "@storybook/builder-webpack5": "6.5.16",
20
+ "@storybook/manager-webpack5": "6.5.16",
21
+ "@storybook/preset-scss": "1.0.3",
22
+ "@storybook/react": "6.5.16",
23
+ "@storybook/testing-library": "0.0.13",
24
+ "@types/adm-zip": "0.5.5",
25
+ "@types/big.js": "6.2.2",
26
+ "@types/node": "20.14.10",
27
+ "@types/react": "^17.0.0 || ^18.3.3",
28
+ "@types/styled-components": "5.1.26",
29
+ "@types/url-join": "^4.0.3",
30
+ "babel-plugin-styled-components": "2.1.4",
31
+ "css-loader": "7.1.2",
32
+ "nodemon": "2.0.22",
33
+ "react-hook-form": "7.52.1",
34
+ "rollup": "4.18.1",
35
+ "rollup-plugin-copy": "3.5.0",
36
+ "rollup-plugin-delete": "2.0.0",
37
+ "rollup-plugin-esbuild": "6.1.1",
38
+ "rollup-plugin-external-assets": "4.1.1",
39
+ "rollup-plugin-peer-deps-external": "2.2.4",
40
+ "sass": "1.77.6",
41
+ "sass-loader": "14.2.1",
42
+ "style-loader": "4.0.0"
43
+ },
44
+ "files": [
45
+ "lib",
46
+ "CHANGELOG.md"
47
+ ],
48
+ "keywords": [],
49
+ "name": "@ubnt/store.core",
27
50
  "peerDependencies": {
28
51
  "@dinero.js/currencies": "2.0.0-alpha.8",
29
52
  "@faker-js/faker": "^7.6.0",
@@ -70,38 +93,15 @@
70
93
  "optional": true
71
94
  }
72
95
  },
73
- "devDependencies": {
74
- "@rollup/plugin-commonjs": "26.0.1",
75
- "@rollup/plugin-json": "6.1.0",
76
- "@rollup/plugin-multi-entry": "6.0.1",
77
- "@rollup/plugin-node-resolve": "15.2.3",
78
- "@storybook/addon-actions": "6.5.16",
79
- "@storybook/addon-essentials": "6.5.16",
80
- "@storybook/addon-interactions": "6.5.16",
81
- "@storybook/addon-links": "6.5.16",
82
- "@storybook/builder-webpack5": "6.5.16",
83
- "@storybook/manager-webpack5": "6.5.16",
84
- "@storybook/preset-scss": "1.0.3",
85
- "@storybook/react": "6.5.16",
86
- "@storybook/testing-library": "0.0.13",
87
- "@types/adm-zip": "0.5.5",
88
- "@types/big.js": "6.2.2",
89
- "@types/node": "20.14.10",
90
- "@types/react": "^17.0.0 || ^18.3.3",
91
- "@types/styled-components": "5.1.26",
92
- "@types/url-join": "^4.0.3",
93
- "babel-plugin-styled-components": "2.1.4",
94
- "css-loader": "7.1.2",
95
- "nodemon": "2.0.22",
96
- "react-hook-form": "7.52.1",
97
- "rollup": "4.18.1",
98
- "rollup-plugin-copy": "3.5.0",
99
- "rollup-plugin-delete": "2.0.0",
100
- "rollup-plugin-esbuild": "6.1.1",
101
- "rollup-plugin-external-assets": "4.1.1",
102
- "rollup-plugin-peer-deps-external": "2.2.4",
103
- "sass": "1.77.6",
104
- "sass-loader": "14.2.1",
105
- "style-loader": "4.0.0"
106
- }
96
+ "scripts": {
97
+ "build": "rollup -c && tsc --emitDeclarationOnly",
98
+ "build:watch": "nodemon --config ./nodemon.json",
99
+ "lint:tsc": "tsc --project ./tsconfig.json",
100
+ "prepublishOnly": "npm run build",
101
+ "storybook": "start-storybook -p 6008 --no-open",
102
+ "storybook:build": "build-storybook",
103
+ "test": "echo 'Hi from @ubnt/store.core 👋'"
104
+ },
105
+ "sideEffects": false,
106
+ "version": "9.12.0-alpha.0"
107
107
  }
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
Binary file
@@ -1,2 +0,0 @@
1
- import type { LensCompareProps } from "./LensCompare.types";
2
- export declare const ExploreModelCompare: ({ variants, }: LensCompareProps) => JSX.Element | null;
@@ -1,111 +0,0 @@
1
- 'use strict';
2
-
3
- var jsxRuntime = require('react/jsx-runtime');
4
- var react = require('react');
5
- var iconParsing = require('../../../helpers/shopify/iconParsing.js');
6
- require('../../ScrollWrapper/index.js');
7
- require('../../StyleableSvgImage/index.js');
8
- var LensCompare_styles = require('./LensCompare.styles.js');
9
- var LensCompare_utils = require('./LensCompare.utils.js');
10
- var LensCompareData = require('./LensCompareData.js');
11
- var ScrollWrapper = require('../../ScrollWrapper/ScrollWrapper.js');
12
- var StyleableSvgImage = require('../../StyleableSvgImage/StyleableSvgImage.js');
13
- "use strict";
14
- const ExploreModelCompare = function ExploreModelCompare2({
15
- variants
16
- }) {
17
- const seperateVariants = react.useMemo(() => {
18
- return LensCompare_utils.seperateLensCompareVariants(variants);
19
- }, [variants]);
20
- const section = react.useMemo(() => {
21
- for (const separateVariant of seperateVariants) {
22
- const foundSection = LensCompareData.LENS_COMPARE_DATA.sections.find(section2 => section2.id === separateVariant.compareSectionId);
23
- if (foundSection) {
24
- return foundSection;
25
- }
26
- }
27
- return null;
28
- }, [seperateVariants]);
29
- const allRowHeights = react.useRef(seperateVariants.reduce((map, variant) => {
30
- for (let row = 0; row < variant.compare.featureValues.length; row++) {
31
- if (!map[row]) {
32
- map[row] = [];
33
- }
34
- }
35
- return map;
36
- }, {}));
37
- const maxMinHeightCaption = react.useMemo(() => {
38
- return seperateVariants.reduce((max, variant) => {
39
- const caption = variant.variant.minHeight;
40
- if (caption && caption > max) {
41
- return caption;
42
- }
43
- return max;
44
- }, 0);
45
- }, [seperateVariants]);
46
- if (!section || seperateVariants.length < 2) {
47
- return null;
48
- }
49
- return /* @__PURE__ */jsxRuntime.jsxs(LensCompare_styles.Wrap, {
50
- children: [/* @__PURE__ */jsxRuntime.jsx(LensCompare_styles.GroupTitle, {
51
- children: section.groupTitle
52
- }), /* @__PURE__ */jsxRuntime.jsx(ScrollWrapper.ScrollWrapper, {
53
- gap: 20,
54
- circleArrowBackground: true,
55
- align: "center",
56
- direction: "horizontal",
57
- fillType: "gradient",
58
- gradientSize: 20,
59
- scrollStepType: "itemWidth",
60
- className: LensCompare_styles.scrollWrapperClassName,
61
- items: seperateVariants.map(variant => ({
62
- id: variant.compare.sku,
63
- render: () => /* @__PURE__ */jsxRuntime.jsxs(LensCompare_styles.Item, {
64
- children: [/* @__PURE__ */jsxRuntime.jsxs(LensCompare_styles.Header, {
65
- children: [/* @__PURE__ */jsxRuntime.jsx(LensCompare_styles.ImageContainer, {
66
- children: /* @__PURE__ */jsxRuntime.jsx(LensCompare_styles.VariantImage, {
67
- src: variant.compare.image.src
68
- })
69
- }), /* @__PURE__ */jsxRuntime.jsx(LensCompare_styles.ProductName, {
70
- children: variant.variant.title
71
- }), /* @__PURE__ */jsxRuntime.jsx(LensCompare_styles.Caption, {
72
- style: {
73
- minHeight: maxMinHeightCaption
74
- },
75
- children: variant.variant.caption
76
- })]
77
- }), /* @__PURE__ */jsxRuntime.jsx(LensCompare_styles.FeaturesWrap, {
78
- children: variant.compare.featureValues.map((feature, row) => {
79
- const isFeatureValue = feature && typeof feature === "object" && "icon" in feature && "value" in feature;
80
- const featureIconSvg = isFeatureValue && feature.icon ? iconParsing.getTemplateIconSvg(feature.icon) : null;
81
- const rowHeights = allRowHeights.current[row];
82
- const height = rowHeights?.length ? Math.max(...rowHeights) : 0;
83
- return /* @__PURE__ */jsxRuntime.jsx(LensCompare_styles.Feature, {
84
- ref: e => {
85
- if (!rowHeights || !e) return;
86
- rowHeights.push(e.offsetHeight);
87
- },
88
- $height: height,
89
- children: isFeatureValue && feature.value ? /* @__PURE__ */jsxRuntime.jsxs(jsxRuntime.Fragment, {
90
- children: [featureIconSvg && /* @__PURE__ */jsxRuntime.jsx(LensCompare_styles.FeatureIcon, {
91
- children: /* @__PURE__ */jsxRuntime.jsx(StyleableSvgImage.StyleableSvgImage, {
92
- src: featureIconSvg,
93
- width: 30,
94
- height: 30
95
- })
96
- }), /* @__PURE__ */jsxRuntime.jsx(LensCompare_styles.FeatureText, {
97
- dangerouslySetInnerHTML: {
98
- __html: feature.value
99
- }
100
- })]
101
- }) : /* @__PURE__ */jsxRuntime.jsx(LensCompare_styles.FeatureDash, {})
102
- }, isFeatureValue ? (feature.icon ?? "") + row : row);
103
- })
104
- })]
105
- }, variant.compare.sku)
106
- }))
107
- })]
108
- });
109
- };
110
- exports.ExploreModelCompare = ExploreModelCompare;
111
- //# sourceMappingURL=LensCompare.js.map