@ubnt/store.core 9.18.0-alpha.8 → 9.18.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 (455) hide show
  1. package/CHANGELOG.md +1 -193
  2. package/lib/_virtual/_virtual_multi-entry.js +12 -27
  3. package/lib/_virtual/_virtual_multi-entry.js.map +1 -1
  4. package/lib/_virtual/_virtual_multi-entry.mjs +10 -14
  5. package/lib/_virtual/_virtual_multi-entry.mjs.map +1 -1
  6. package/lib/assets/attention.svg +5 -5
  7. package/lib/assets/attention2.svg +5 -5
  8. package/lib/{components/ResourceCalculatorV1/assets/consoles/ucg-max.png.js → assets/icons/menu/icon-globe.svg.js} +6 -6
  9. package/lib/assets/icons/menu/icon-globe.svg.js.map +1 -0
  10. package/lib/assets/icons/menu/icon-globe.svg.mjs +3 -0
  11. package/lib/assets/icons/menu/icon-globe.svg.mjs.map +1 -0
  12. package/lib/assets/pause.svg +3 -3
  13. package/lib/assets/pause2.svg +3 -3
  14. package/lib/assets/udmProMax.jpg +0 -0
  15. package/lib/assets/udmProMax2.jpg +0 -0
  16. package/lib/assets/udmProSpecial.jpg +0 -0
  17. package/lib/assets/udmProSpecial2.jpg +0 -0
  18. package/lib/components/CategoryTabs/CategoryTabs.styles.d.ts +1 -1
  19. package/lib/components/Compare/Compare.styles.d.ts +5 -5
  20. package/lib/components/Container/Container.d.ts +1 -1
  21. package/lib/components/Container/Container.js +3 -4
  22. package/lib/components/Container/Container.js.map +1 -1
  23. package/lib/components/Container/Container.mjs +4 -5
  24. package/lib/components/Container/Container.mjs.map +1 -1
  25. package/lib/components/Header/AccountMenu/AccountMenu.js +1 -11
  26. package/lib/components/Header/AccountMenu/AccountMenu.js.map +1 -1
  27. package/lib/components/Header/AccountMenu/AccountMenu.mjs +3 -13
  28. package/lib/components/Header/AccountMenu/AccountMenu.mjs.map +1 -1
  29. package/lib/components/Header/Header.styles.d.ts +2 -2
  30. package/lib/components/Header/Header.types.d.ts +4 -12
  31. package/lib/components/Header/Header.types.js +1 -2
  32. package/lib/components/Header/Header.types.js.map +1 -1
  33. package/lib/components/Header/Header.types.mjs +1 -2
  34. package/lib/components/Header/Header.types.mjs.map +1 -1
  35. package/lib/components/Header/MenuItem/MenuItem.styles.d.ts +1 -1
  36. package/lib/components/Header/MenuItem/MenuItem.styles.js +3 -3
  37. package/lib/components/Header/MenuItem/MenuItem.styles.js.map +1 -1
  38. package/lib/components/Header/MenuItem/MenuItem.styles.mjs +3 -3
  39. package/lib/components/Header/MenuItem/MenuItem.styles.mjs.map +1 -1
  40. package/lib/components/Header/MenuItem/MenuItem.types.d.ts +0 -1
  41. package/lib/components/Header/Navigation/MicrositeMenu/MicrositeMenu.styles.d.ts +1 -1
  42. package/lib/components/Header/Navigation/MobileMenu/MobileMenu.styles.d.ts +1 -1
  43. package/lib/components/Header/Navigation/ProMobileMenu/ProMobileMenu.d.ts +1 -1
  44. package/lib/components/Header/Navigation/ProMobileMenu/ProMobileMenu.js +95 -92
  45. package/lib/components/Header/Navigation/ProMobileMenu/ProMobileMenu.js.map +1 -1
  46. package/lib/components/Header/Navigation/ProMobileMenu/ProMobileMenu.mjs +95 -92
  47. package/lib/components/Header/Navigation/ProMobileMenu/ProMobileMenu.mjs.map +1 -1
  48. package/lib/components/Header/Navigation/ProMobileMenu/ProMobileMenu.styles.d.ts +0 -9
  49. package/lib/components/Header/Navigation/ProMobileMenu/ProMobileMenu.styles.js +1 -15
  50. package/lib/components/Header/Navigation/ProMobileMenu/ProMobileMenu.styles.js.map +1 -1
  51. package/lib/components/Header/Navigation/ProMobileMenu/ProMobileMenu.styles.mjs +2 -13
  52. package/lib/components/Header/Navigation/ProMobileMenu/ProMobileMenu.styles.mjs.map +1 -1
  53. package/lib/components/Header/Navigation/ProMobileMenu/ProMobileMenu.types.d.ts +4 -10
  54. package/lib/components/Header/ProHeader/ProHeader.d.ts +4 -3
  55. package/lib/components/Header/ProHeader/ProHeader.js +119 -245
  56. package/lib/components/Header/ProHeader/ProHeader.js.map +1 -1
  57. package/lib/components/Header/ProHeader/ProHeader.mjs +123 -247
  58. package/lib/components/Header/ProHeader/ProHeader.mjs.map +1 -1
  59. package/lib/components/Header/ProHeader/ProHeader.styles.d.ts +1 -7
  60. package/lib/components/Header/ProHeader/ProHeader.styles.js +17 -25
  61. package/lib/components/Header/ProHeader/ProHeader.styles.js.map +1 -1
  62. package/lib/components/Header/ProHeader/ProHeader.styles.mjs +18 -23
  63. package/lib/components/Header/ProHeader/ProHeader.styles.mjs.map +1 -1
  64. package/lib/components/Header/translations/ar.json.js +1 -4
  65. package/lib/components/Header/translations/ar.json.js.map +1 -1
  66. package/lib/components/Header/translations/ar.json.mjs +2 -4
  67. package/lib/components/Header/translations/ar.json.mjs.map +1 -1
  68. package/lib/components/Header/translations/de.json.js +1 -4
  69. package/lib/components/Header/translations/de.json.js.map +1 -1
  70. package/lib/components/Header/translations/de.json.mjs +2 -4
  71. package/lib/components/Header/translations/de.json.mjs.map +1 -1
  72. package/lib/components/Header/translations/el.json.js +1 -4
  73. package/lib/components/Header/translations/el.json.js.map +1 -1
  74. package/lib/components/Header/translations/el.json.mjs +2 -4
  75. package/lib/components/Header/translations/el.json.mjs.map +1 -1
  76. package/lib/components/Header/translations/en.json.js +1 -4
  77. package/lib/components/Header/translations/en.json.js.map +1 -1
  78. package/lib/components/Header/translations/en.json.mjs +2 -4
  79. package/lib/components/Header/translations/en.json.mjs.map +1 -1
  80. package/lib/components/Header/translations/es.json.js +1 -4
  81. package/lib/components/Header/translations/es.json.js.map +1 -1
  82. package/lib/components/Header/translations/es.json.mjs +2 -4
  83. package/lib/components/Header/translations/es.json.mjs.map +1 -1
  84. package/lib/components/Header/translations/fr.json.js +1 -4
  85. package/lib/components/Header/translations/fr.json.js.map +1 -1
  86. package/lib/components/Header/translations/fr.json.mjs +2 -4
  87. package/lib/components/Header/translations/fr.json.mjs.map +1 -1
  88. package/lib/components/Header/translations/it.json.js +1 -4
  89. package/lib/components/Header/translations/it.json.js.map +1 -1
  90. package/lib/components/Header/translations/it.json.mjs +2 -4
  91. package/lib/components/Header/translations/it.json.mjs.map +1 -1
  92. package/lib/components/Header/translations/ja.json.js +1 -4
  93. package/lib/components/Header/translations/ja.json.js.map +1 -1
  94. package/lib/components/Header/translations/ja.json.mjs +2 -4
  95. package/lib/components/Header/translations/ja.json.mjs.map +1 -1
  96. package/lib/components/Header/translations/pt-BR.json.js +1 -4
  97. package/lib/components/Header/translations/pt-BR.json.js.map +1 -1
  98. package/lib/components/Header/translations/pt-BR.json.mjs +2 -4
  99. package/lib/components/Header/translations/pt-BR.json.mjs.map +1 -1
  100. package/lib/components/Header/translations/zh-Hans.json.js +1 -4
  101. package/lib/components/Header/translations/zh-Hans.json.js.map +1 -1
  102. package/lib/components/Header/translations/zh-Hans.json.mjs +2 -4
  103. package/lib/components/Header/translations/zh-Hans.json.mjs.map +1 -1
  104. package/lib/components/Header/translations/zh-Hant-TW.json.js +1 -4
  105. package/lib/components/Header/translations/zh-Hant-TW.json.js.map +1 -1
  106. package/lib/components/Header/translations/zh-Hant-TW.json.mjs +2 -4
  107. package/lib/components/Header/translations/zh-Hant-TW.json.mjs.map +1 -1
  108. package/lib/components/Hero/Hero.styles.d.ts +2 -2
  109. package/lib/components/HeroFadeGallery/HeroFadeGallery.styles.d.ts +1 -1
  110. package/lib/components/HowToUseSection/HowToUseSection.styles.d.ts +2 -2
  111. package/lib/components/LandingPagePro/LandingPagePro.d.ts +0 -3
  112. package/lib/components/LandingPagePro/LandingPagePro.js +3 -3
  113. package/lib/components/LandingPagePro/LandingPagePro.js.map +1 -1
  114. package/lib/components/LandingPagePro/LandingPagePro.mjs +2 -2
  115. package/lib/components/LandingPagePro/LandingPagePro.mjs.map +1 -1
  116. package/lib/components/LandingPagePro/LandingPagePro.styles.d.ts +1 -1
  117. package/lib/components/LayoutRenderer/LayoutRenderer.styles.d.ts +1 -1
  118. package/lib/components/LayoutRendererV1/LayoutRenderer.styles.d.ts +3 -3
  119. package/lib/components/LayoutRendererV2/LayoutRenderer.styles.d.ts +3 -3
  120. package/lib/components/MicrositeSectionWrap/MicrositeSectionWrap.styles.d.ts +1 -1
  121. package/lib/components/MicrositeVideoSlideshow/MicrositeVideoSlideshow.js +1 -1
  122. package/lib/components/MicrositeVideoSlideshow/MicrositeVideoSlideshow.mjs +1 -1
  123. package/lib/components/MicrositeVideoSlideshow/assets/pause.svg.js +1 -1
  124. package/lib/components/MicrositeVideoSlideshow/assets/pause.svg.mjs +2 -2
  125. package/lib/components/ModelCompareV3/ModelCompareV3.types.d.ts +0 -1
  126. package/lib/components/ModelCompareV3/assets/Consoles/bigCompare/udmProMax.jpg.js +5 -5
  127. package/lib/components/ModelCompareV3/assets/Consoles/bigCompare/udmProMax.jpg.mjs +2 -2
  128. package/lib/components/ModelCompareV3/assets/Consoles/bigCompare/udmProSpecial.jpg.js +5 -5
  129. package/lib/components/ModelCompareV3/assets/Consoles/bigCompare/udmProSpecial.jpg.mjs +2 -2
  130. package/lib/components/ModelCompareV3/assets/Consoles/udmProMax.jpg.js +1 -1
  131. package/lib/components/ModelCompareV3/assets/Consoles/udmProMax.jpg.mjs +2 -2
  132. package/lib/components/ModelCompareV3/assets/Consoles/udmProSpecial.jpg.js +1 -1
  133. package/lib/components/ModelCompareV3/assets/Consoles/udmProSpecial.jpg.mjs +2 -2
  134. package/lib/components/ModelCompareV3/data/CloudGateways.js +6 -6
  135. package/lib/components/ModelCompareV3/data/CloudGateways.mjs +4 -4
  136. package/lib/components/ModelCompareV3/data/VideoRecorders.js +2 -3
  137. package/lib/components/ModelCompareV3/data/VideoRecorders.js.map +1 -1
  138. package/lib/components/ModelCompareV3/data/VideoRecorders.mjs +2 -3
  139. package/lib/components/ModelCompareV3/data/VideoRecorders.mjs.map +1 -1
  140. package/lib/components/ModelCompareV3/data/products/udmProMax.js +1 -1
  141. package/lib/components/ModelCompareV3/data/products/udmProMax.mjs +1 -1
  142. package/lib/components/ModelCompareV3/data/products/udmProSpecial.js +1 -1
  143. package/lib/components/ModelCompareV3/data/products/udmProSpecial.mjs +1 -1
  144. package/lib/components/ModelCompareV3/translations/ar.json.js +106 -742
  145. package/lib/components/ModelCompareV3/translations/ar.json.js.map +1 -1
  146. package/lib/components/ModelCompareV3/translations/ar.json.mjs +106 -742
  147. package/lib/components/ModelCompareV3/translations/ar.json.mjs.map +1 -1
  148. package/lib/components/ModelCompareV3/translations/de.json.js +105 -741
  149. package/lib/components/ModelCompareV3/translations/de.json.js.map +1 -1
  150. package/lib/components/ModelCompareV3/translations/de.json.mjs +105 -741
  151. package/lib/components/ModelCompareV3/translations/de.json.mjs.map +1 -1
  152. package/lib/components/ModelCompareV3/translations/el.json.js +105 -741
  153. package/lib/components/ModelCompareV3/translations/el.json.js.map +1 -1
  154. package/lib/components/ModelCompareV3/translations/el.json.mjs +105 -741
  155. package/lib/components/ModelCompareV3/translations/el.json.mjs.map +1 -1
  156. package/lib/components/ModelCompareV3/translations/en.json.js +0 -6
  157. package/lib/components/ModelCompareV3/translations/en.json.js.map +1 -1
  158. package/lib/components/ModelCompareV3/translations/en.json.mjs +0 -6
  159. package/lib/components/ModelCompareV3/translations/en.json.mjs.map +1 -1
  160. package/lib/components/ModelCompareV3/translations/es.json.js +105 -741
  161. package/lib/components/ModelCompareV3/translations/es.json.js.map +1 -1
  162. package/lib/components/ModelCompareV3/translations/es.json.mjs +105 -741
  163. package/lib/components/ModelCompareV3/translations/es.json.mjs.map +1 -1
  164. package/lib/components/ModelCompareV3/translations/fr.json.js +105 -741
  165. package/lib/components/ModelCompareV3/translations/fr.json.js.map +1 -1
  166. package/lib/components/ModelCompareV3/translations/fr.json.mjs +105 -741
  167. package/lib/components/ModelCompareV3/translations/fr.json.mjs.map +1 -1
  168. package/lib/components/ModelCompareV3/translations/it.json.js +105 -741
  169. package/lib/components/ModelCompareV3/translations/it.json.js.map +1 -1
  170. package/lib/components/ModelCompareV3/translations/it.json.mjs +105 -741
  171. package/lib/components/ModelCompareV3/translations/it.json.mjs.map +1 -1
  172. package/lib/components/ModelCompareV3/translations/ja.json.js +105 -741
  173. package/lib/components/ModelCompareV3/translations/ja.json.js.map +1 -1
  174. package/lib/components/ModelCompareV3/translations/ja.json.mjs +105 -741
  175. package/lib/components/ModelCompareV3/translations/ja.json.mjs.map +1 -1
  176. package/lib/components/ModelCompareV3/translations/pt-BR.json.js +105 -741
  177. package/lib/components/ModelCompareV3/translations/pt-BR.json.js.map +1 -1
  178. package/lib/components/ModelCompareV3/translations/pt-BR.json.mjs +105 -741
  179. package/lib/components/ModelCompareV3/translations/pt-BR.json.mjs.map +1 -1
  180. package/lib/components/ModelCompareV3/translations/useModelCompareTranslation.d.ts +2 -2
  181. package/lib/components/ModelCompareV3/translations/zh-Hans.json.js +105 -741
  182. package/lib/components/ModelCompareV3/translations/zh-Hans.json.js.map +1 -1
  183. package/lib/components/ModelCompareV3/translations/zh-Hans.json.mjs +105 -741
  184. package/lib/components/ModelCompareV3/translations/zh-Hans.json.mjs.map +1 -1
  185. package/lib/components/ModelCompareV3/translations/zh-Hant-TW.json.js +105 -741
  186. package/lib/components/ModelCompareV3/translations/zh-Hant-TW.json.js.map +1 -1
  187. package/lib/components/ModelCompareV3/translations/zh-Hant-TW.json.mjs +105 -741
  188. package/lib/components/ModelCompareV3/translations/zh-Hant-TW.json.mjs.map +1 -1
  189. package/lib/components/ProductSectionNavigation/ProductSectionNavigation.styles.d.ts +1 -1
  190. package/lib/components/ProductSectionNavigationV2/ProductSectionNavigation.styles.d.ts +1 -1
  191. package/lib/components/ProductTechSpecs/ProductTechSpecs.styles.d.ts +1 -1
  192. package/lib/components/ResourceCalculatorV1/ComputeResourceCalculator/ComputeResourceCalculator.constants.js +17 -313
  193. package/lib/components/ResourceCalculatorV1/ComputeResourceCalculator/ComputeResourceCalculator.constants.js.map +1 -1
  194. package/lib/components/ResourceCalculatorV1/ComputeResourceCalculator/ComputeResourceCalculator.constants.mjs +17 -311
  195. package/lib/components/ResourceCalculatorV1/ComputeResourceCalculator/ComputeResourceCalculator.constants.mjs.map +1 -1
  196. package/lib/components/ResourceCalculatorV1/ComputeResourceCalculator/ComputeResourceCalculator.types.d.ts +2 -3
  197. package/lib/components/ResourceCalculatorV1/ComputeResourceCalculator/ComputeResourceCalculator.types.js +0 -2
  198. package/lib/components/ResourceCalculatorV1/ComputeResourceCalculator/ComputeResourceCalculator.types.js.map +1 -1
  199. package/lib/components/ResourceCalculatorV1/ComputeResourceCalculator/ComputeResourceCalculator.types.mjs +0 -2
  200. package/lib/components/ResourceCalculatorV1/ComputeResourceCalculator/ComputeResourceCalculator.types.mjs.map +1 -1
  201. package/lib/components/ResourceCalculatorV1/ComputeResourceCalculator/components/DeviceSelect/DeviceSelect.js +34 -120
  202. package/lib/components/ResourceCalculatorV1/ComputeResourceCalculator/components/DeviceSelect/DeviceSelect.js.map +1 -1
  203. package/lib/components/ResourceCalculatorV1/ComputeResourceCalculator/components/DeviceSelect/DeviceSelect.mjs +34 -120
  204. package/lib/components/ResourceCalculatorV1/ComputeResourceCalculator/components/DeviceSelect/DeviceSelect.mjs.map +1 -1
  205. package/lib/components/ResourceCalculatorV1/ComputeResourceCalculator/components/DeviceSelect/DeviceSelect.styles.d.ts +2 -16
  206. package/lib/components/ResourceCalculatorV1/ComputeResourceCalculator/components/DeviceSelect/DeviceSelect.styles.js +12 -54
  207. package/lib/components/ResourceCalculatorV1/ComputeResourceCalculator/components/DeviceSelect/DeviceSelect.styles.js.map +1 -1
  208. package/lib/components/ResourceCalculatorV1/ComputeResourceCalculator/components/DeviceSelect/DeviceSelect.styles.mjs +11 -50
  209. package/lib/components/ResourceCalculatorV1/ComputeResourceCalculator/components/DeviceSelect/DeviceSelect.styles.mjs.map +1 -1
  210. package/lib/components/ResourceCalculatorV1/ComputeResourceCalculator/components/DeviceSelect/assets/ArrowLeftPrimary.svg.js +5 -5
  211. package/lib/components/ResourceCalculatorV1/ComputeResourceCalculator/components/DeviceSelect/assets/ArrowRightPrimary.svg.js +5 -5
  212. package/lib/components/ResourceCalculatorV1/ComputeResourceCalculator/components/InputCard/InputCard.js +2 -2
  213. package/lib/components/ResourceCalculatorV1/ComputeResourceCalculator/components/InputCard/InputCard.js.map +1 -1
  214. package/lib/components/ResourceCalculatorV1/ComputeResourceCalculator/components/InputCard/InputCard.mjs +2 -2
  215. package/lib/components/ResourceCalculatorV1/ComputeResourceCalculator/components/InputCard/InputCard.mjs.map +1 -1
  216. package/lib/components/ResourceCalculatorV1/ComputeResourceCalculator/components/InputCard/InputCard.styles.js +0 -2
  217. package/lib/components/ResourceCalculatorV1/ComputeResourceCalculator/components/InputCard/InputCard.styles.js.map +1 -1
  218. package/lib/components/ResourceCalculatorV1/ComputeResourceCalculator/components/InputCard/InputCard.styles.mjs +0 -2
  219. package/lib/components/ResourceCalculatorV1/ComputeResourceCalculator/components/InputCard/InputCard.styles.mjs.map +1 -1
  220. package/lib/components/ResourceCalculatorV1/ComputeResourceCalculator/components/InputCard/assets/attention.svg.js +1 -1
  221. package/lib/components/ResourceCalculatorV1/ComputeResourceCalculator/components/InputCard/assets/attention.svg.mjs +2 -2
  222. package/lib/components/ResourceCalculatorV1/ComputeResourceCalculator/components/ProgressBarChart/ProgressBarChart.js +1 -1
  223. package/lib/components/ResourceCalculatorV1/ComputeResourceCalculator/components/ProgressBarChart/ProgressBarChart.mjs +1 -1
  224. package/lib/components/ResourceCalculatorV1/ComputeResourceCalculator/components/ProgressBarChart/assets/attention.svg.js +1 -1
  225. package/lib/components/ResourceCalculatorV1/ComputeResourceCalculator/components/ProgressBarChart/assets/attention.svg.mjs +2 -2
  226. package/lib/components/ResourceCalculatorV1/ComputeResourceCalculator/useComputeResourceCalculator.js +1 -1
  227. package/lib/components/ResourceCalculatorV1/ComputeResourceCalculator/useComputeResourceCalculator.js.map +1 -1
  228. package/lib/components/ResourceCalculatorV1/ComputeResourceCalculator/useComputeResourceCalculator.mjs +1 -1
  229. package/lib/components/ResourceCalculatorV1/ComputeResourceCalculator/useComputeResourceCalculator.mjs.map +1 -1
  230. package/lib/components/ResourceCalculatorV1/PoeCalculator/components/PoeConsumerConfigurator/PoeConsumerSelectModal/PoeConsumerSelectModal.js +2 -2
  231. package/lib/components/ResourceCalculatorV1/PoeCalculator/components/PoeConsumerConfigurator/PoeConsumerSelectModal/PoeConsumerSelectModal.js.map +1 -1
  232. package/lib/components/ResourceCalculatorV1/PoeCalculator/components/PoeConsumerConfigurator/PoeConsumerSelectModal/PoeConsumerSelectModal.mjs +2 -2
  233. package/lib/components/ResourceCalculatorV1/PoeCalculator/components/PoeConsumerConfigurator/PoeConsumerSelectModal/PoeConsumerSelectModal.mjs.map +1 -1
  234. package/lib/components/ResourceCalculatorV1/ResourceCalculator.js +2 -1
  235. package/lib/components/ResourceCalculatorV1/ResourceCalculator.js.map +1 -1
  236. package/lib/components/ResourceCalculatorV1/ResourceCalculator.mjs +2 -1
  237. package/lib/components/ResourceCalculatorV1/ResourceCalculator.mjs.map +1 -1
  238. package/lib/components/{HorizontalOptionSelect → ResourceCalculatorV1/components/HorizontalOptionSelect}/HorizontalOptionSelect.d.ts +1 -1
  239. package/lib/components/{HorizontalOptionSelect → ResourceCalculatorV1/components/HorizontalOptionSelect}/HorizontalOptionSelect.js +1 -3
  240. package/lib/components/ResourceCalculatorV1/components/HorizontalOptionSelect/HorizontalOptionSelect.js.map +1 -0
  241. package/lib/components/{HorizontalOptionSelect → ResourceCalculatorV1/components/HorizontalOptionSelect}/HorizontalOptionSelect.mjs +1 -3
  242. package/lib/components/ResourceCalculatorV1/components/HorizontalOptionSelect/HorizontalOptionSelect.mjs.map +1 -0
  243. package/lib/components/{HorizontalOptionSelect → ResourceCalculatorV1/components/HorizontalOptionSelect}/HorizontalOptionSelect.styles.d.ts +0 -1
  244. package/lib/components/{HorizontalOptionSelect → ResourceCalculatorV1/components/HorizontalOptionSelect}/HorizontalOptionSelect.styles.js +7 -10
  245. package/lib/components/ResourceCalculatorV1/components/HorizontalOptionSelect/HorizontalOptionSelect.styles.js.map +1 -0
  246. package/lib/components/{HorizontalOptionSelect → ResourceCalculatorV1/components/HorizontalOptionSelect}/HorizontalOptionSelect.styles.mjs +7 -10
  247. package/lib/components/ResourceCalculatorV1/components/HorizontalOptionSelect/HorizontalOptionSelect.styles.mjs.map +1 -0
  248. package/lib/components/{HorizontalOptionSelect → ResourceCalculatorV1/components/HorizontalOptionSelect}/HorizontalOptionSelect.types.d.ts +0 -1
  249. package/lib/components/ResourceCalculatorV1/components/index.d.ts +1 -0
  250. package/lib/components/ResourceCalculatorV1/components/index.js +5 -0
  251. package/lib/components/{Header/Navigation/ProMenu → ResourceCalculatorV1/components}/index.js.map +1 -1
  252. package/lib/components/ResourceCalculatorV1/components/index.mjs +3 -0
  253. package/lib/components/ResourceCalculatorV1/translations/en.json.js +4 -6
  254. package/lib/components/ResourceCalculatorV1/translations/en.json.js.map +1 -1
  255. package/lib/components/ResourceCalculatorV1/translations/en.json.mjs +4 -6
  256. package/lib/components/ResourceCalculatorV1/translations/en.json.mjs.map +1 -1
  257. package/lib/components/ResourceCalculatorV1/translations/useResourceCalculatorTranslation.d.ts +2 -2
  258. package/lib/components/VideoPlayerNew/VideoPlayer.js +1 -1
  259. package/lib/components/VideoPlayerNew/VideoPlayer.mjs +1 -1
  260. package/lib/components/VideoPlayerNew/assets/pause.svg.js +1 -1
  261. package/lib/components/VideoPlayerNew/assets/pause.svg.mjs +2 -2
  262. package/lib/components/index.d.ts +0 -1
  263. package/lib/components/index.js +0 -2
  264. package/lib/components/index.js.map +1 -1
  265. package/lib/components/index.mjs +0 -2
  266. package/lib/components/index.mjs.map +1 -1
  267. package/lib/constants/icons/options/colors/black.svg.js +5 -5
  268. package/lib/constants/icons/options/colors/index.js +3 -3
  269. package/lib/constants/icons/options/styles/black.svg.js +5 -5
  270. package/lib/constants/icons/options/styles/index.js +3 -3
  271. package/lib/constants/optionIcons.js +6 -6
  272. package/lib/constants/optionIcons.mjs +4 -4
  273. package/lib/constants/proStoreCategories/mapping/index.d.ts +0 -1
  274. package/lib/constants/proStoreCategories/mapping/index.js +10 -15
  275. package/lib/constants/proStoreCategories/mapping/index.js.map +1 -1
  276. package/lib/constants/proStoreCategories/mapping/index.mjs +10 -15
  277. package/lib/constants/proStoreCategories/mapping/index.mjs.map +1 -1
  278. package/lib/constants/proStoreCategories/mapping/unifi.d.ts +1 -2
  279. package/lib/constants/proStoreCategories/mapping/unifi.js +0 -1
  280. package/lib/constants/proStoreCategories/mapping/unifi.js.map +1 -1
  281. package/lib/constants/proStoreCategories/mapping/unifi.mjs +0 -1
  282. package/lib/constants/proStoreCategories/mapping/unifi.mjs.map +1 -1
  283. package/lib/constants/proStoreCategories/translations/en.json.js +0 -3
  284. package/lib/constants/proStoreCategories/translations/en.json.js.map +1 -1
  285. package/lib/constants/proStoreCategories/translations/en.json.mjs +1 -3
  286. package/lib/constants/proStoreCategories/translations/en.json.mjs.map +1 -1
  287. package/lib/constants/proStoreCategories/translations/fr.json.js +1 -1
  288. package/lib/constants/proStoreCategories/translations/fr.json.mjs +1 -1
  289. package/lib/constants/proStoreCategories/translations/zh-Hans.json.js +1 -1
  290. package/lib/constants/proStoreCategories/translations/zh-Hans.json.mjs +1 -1
  291. package/lib/constants/proStoreCategories/translations/zh-Hant-TW.json.js +1 -1
  292. package/lib/constants/proStoreCategories/translations/zh-Hant-TW.json.mjs +1 -1
  293. package/lib/constants/theme.js +0 -4
  294. package/lib/constants/theme.js.map +1 -1
  295. package/lib/constants/theme.mjs +0 -4
  296. package/lib/constants/theme.mjs.map +1 -1
  297. package/lib/contexts/MenuContext/context.js +1 -1
  298. package/lib/contexts/MenuContext/context.js.map +1 -1
  299. package/lib/contexts/MenuContext/context.mjs +1 -1
  300. package/lib/contexts/MenuContext/context.mjs.map +1 -1
  301. package/lib/helpers/index.d.ts +0 -1
  302. package/lib/helpers/index.js +0 -11
  303. package/lib/helpers/index.js.map +1 -1
  304. package/lib/helpers/index.mjs +0 -1
  305. package/lib/helpers/index.mjs.map +1 -1
  306. package/lib/helpers/ux.d.ts +1 -9
  307. package/lib/helpers/ux.js +0 -15
  308. package/lib/helpers/ux.js.map +1 -1
  309. package/lib/helpers/ux.mjs +1 -15
  310. package/lib/helpers/ux.mjs.map +1 -1
  311. package/lib/types/index.d.ts +0 -1
  312. package/lib/types/index.js +0 -2
  313. package/lib/types/index.js.map +1 -1
  314. package/lib/types/index.mjs +0 -1
  315. package/lib/types/index.mjs.map +1 -1
  316. package/lib/utils/array.d.ts +0 -4
  317. package/lib/utils/array.js +0 -10
  318. package/lib/utils/array.js.map +1 -1
  319. package/lib/utils/array.mjs +1 -10
  320. package/lib/utils/array.mjs.map +1 -1
  321. package/lib/utils/money/constants.d.ts +25 -56
  322. package/lib/utils/money/constants.js +7 -72
  323. package/lib/utils/money/constants.js.map +1 -1
  324. package/lib/utils/money/constants.mjs +7 -70
  325. package/lib/utils/money/constants.mjs.map +1 -1
  326. package/lib/utils/money/format.d.ts +5 -10
  327. package/lib/utils/money/format.js +14 -22
  328. package/lib/utils/money/format.js.map +1 -1
  329. package/lib/utils/money/format.mjs +16 -23
  330. package/lib/utils/money/format.mjs.map +1 -1
  331. package/lib/utils/money/index.d.ts +1 -4
  332. package/lib/utils/money/index.js +8 -26
  333. package/lib/utils/money/index.js.map +1 -1
  334. package/lib/utils/money/index.mjs +4 -8
  335. package/lib/utils/money/index.mjs.map +1 -1
  336. package/lib/utils/money/misc.d.ts +28 -68
  337. package/lib/utils/money/misc.js +64 -35
  338. package/lib/utils/money/misc.js.map +1 -1
  339. package/lib/utils/money/misc.mjs +43 -32
  340. package/lib/utils/money/misc.mjs.map +1 -1
  341. package/lib/utils/money/tax.d.ts +2 -38
  342. package/lib/utils/money/tax.js +10 -46
  343. package/lib/utils/money/tax.js.map +1 -1
  344. package/lib/utils/money/tax.mjs +11 -42
  345. package/lib/utils/money/tax.mjs.map +1 -1
  346. package/lib/utils/money/types.d.ts +3 -78
  347. package/lib/utils/number.d.ts +1 -1
  348. package/lib/utils/number.js +1 -1
  349. package/lib/utils/number.js.map +1 -1
  350. package/lib/utils/number.mjs +1 -1
  351. package/lib/utils/number.mjs.map +1 -1
  352. package/lib/utils/validations.d.ts +15 -0
  353. package/lib/utils/validations.js +23 -0
  354. package/lib/utils/validations.js.map +1 -0
  355. package/lib/utils/validations.mjs +21 -0
  356. package/lib/utils/validations.mjs.map +1 -0
  357. package/package.json +1 -1
  358. package/lib/assets/efg.png +0 -0
  359. package/lib/assets/envr.png +0 -0
  360. package/lib/assets/icon-location-pin.svg +0 -5
  361. package/lib/assets/icons/menu/icon-location-pin.svg.js +0 -27
  362. package/lib/assets/icons/menu/icon-location-pin.svg.js.map +0 -1
  363. package/lib/assets/icons/menu/icon-location-pin.svg.mjs +0 -3
  364. package/lib/assets/icons/menu/icon-location-pin.svg.mjs.map +0 -1
  365. package/lib/assets/ucg-max.png +0 -0
  366. package/lib/components/Header/Navigation/ProMenu/ProMenu.d.ts +0 -2
  367. package/lib/components/Header/Navigation/ProMenu/ProMenu.js +0 -103
  368. package/lib/components/Header/Navigation/ProMenu/ProMenu.js.map +0 -1
  369. package/lib/components/Header/Navigation/ProMenu/ProMenu.mjs +0 -81
  370. package/lib/components/Header/Navigation/ProMenu/ProMenu.mjs.map +0 -1
  371. package/lib/components/Header/Navigation/ProMenu/ProMenu.styles.d.ts +0 -23
  372. package/lib/components/Header/Navigation/ProMenu/ProMenu.styles.js +0 -121
  373. package/lib/components/Header/Navigation/ProMenu/ProMenu.styles.js.map +0 -1
  374. package/lib/components/Header/Navigation/ProMenu/ProMenu.styles.mjs +0 -106
  375. package/lib/components/Header/Navigation/ProMenu/ProMenu.styles.mjs.map +0 -1
  376. package/lib/components/Header/Navigation/ProMenu/ProMenu.types.d.ts +0 -12
  377. package/lib/components/Header/Navigation/ProMenu/index.d.ts +0 -1
  378. package/lib/components/Header/Navigation/ProMenu/index.js +0 -6
  379. package/lib/components/Header/Navigation/ProMenu/index.mjs +0 -3
  380. package/lib/components/HorizontalOptionSelect/HorizontalOptionSelect.js.map +0 -1
  381. package/lib/components/HorizontalOptionSelect/HorizontalOptionSelect.mjs.map +0 -1
  382. package/lib/components/HorizontalOptionSelect/HorizontalOptionSelect.styles.js.map +0 -1
  383. package/lib/components/HorizontalOptionSelect/HorizontalOptionSelect.styles.mjs.map +0 -1
  384. package/lib/components/ModelCompareV3/assets/envr.png.js +0 -27
  385. package/lib/components/ModelCompareV3/assets/envr.png.js.map +0 -1
  386. package/lib/components/ModelCompareV3/assets/envr.png.mjs +0 -3
  387. package/lib/components/ModelCompareV3/assets/envr.png.mjs.map +0 -1
  388. package/lib/components/ModelCompareV3/data/products/envr.d.ts +0 -2
  389. package/lib/components/ModelCompareV3/data/products/envr.js +0 -97
  390. package/lib/components/ModelCompareV3/data/products/envr.js.map +0 -1
  391. package/lib/components/ModelCompareV3/data/products/envr.mjs +0 -89
  392. package/lib/components/ModelCompareV3/data/products/envr.mjs.map +0 -1
  393. package/lib/components/ResourceCalculatorV1/assets/consoles/efg.png.js +0 -27
  394. package/lib/components/ResourceCalculatorV1/assets/consoles/efg.png.js.map +0 -1
  395. package/lib/components/ResourceCalculatorV1/assets/consoles/efg.png.mjs +0 -3
  396. package/lib/components/ResourceCalculatorV1/assets/consoles/efg.png.mjs.map +0 -1
  397. package/lib/components/ResourceCalculatorV1/assets/consoles/ucg-max.png.js.map +0 -1
  398. package/lib/components/ResourceCalculatorV1/assets/consoles/ucg-max.png.mjs +0 -3
  399. package/lib/components/ResourceCalculatorV1/assets/consoles/ucg-max.png.mjs.map +0 -1
  400. package/lib/helpers/product.d.ts +0 -87
  401. package/lib/helpers/product.js +0 -346
  402. package/lib/helpers/product.js.map +0 -1
  403. package/lib/helpers/product.mjs +0 -335
  404. package/lib/helpers/product.mjs.map +0 -1
  405. package/lib/types/product.d.ts +0 -87
  406. package/lib/types/product.js +0 -14
  407. package/lib/types/product.js.map +0 -1
  408. package/lib/types/product.mjs +0 -13
  409. package/lib/types/product.mjs.map +0 -1
  410. package/lib/utils/money/allocators/fixedAmount.d.ts +0 -26
  411. package/lib/utils/money/allocators/fixedAmount.js +0 -52
  412. package/lib/utils/money/allocators/fixedAmount.js.map +0 -1
  413. package/lib/utils/money/allocators/fixedAmount.mjs +0 -50
  414. package/lib/utils/money/allocators/fixedAmount.mjs.map +0 -1
  415. package/lib/utils/money/allocators/index.d.ts +0 -2
  416. package/lib/utils/money/allocators/index.js +0 -8
  417. package/lib/utils/money/allocators/index.js.map +0 -1
  418. package/lib/utils/money/allocators/index.mjs +0 -4
  419. package/lib/utils/money/allocators/index.mjs.map +0 -1
  420. package/lib/utils/money/allocators/productAmount.d.ts +0 -13
  421. package/lib/utils/money/allocators/productAmount.js +0 -98
  422. package/lib/utils/money/allocators/productAmount.js.map +0 -1
  423. package/lib/utils/money/allocators/productAmount.mjs +0 -96
  424. package/lib/utils/money/allocators/productAmount.mjs.map +0 -1
  425. package/lib/utils/money/exchangeRate.d.ts +0 -31
  426. package/lib/utils/money/exchangeRate.js +0 -27
  427. package/lib/utils/money/exchangeRate.js.map +0 -1
  428. package/lib/utils/money/exchangeRate.mjs +0 -23
  429. package/lib/utils/money/exchangeRate.mjs.map +0 -1
  430. package/lib/utils/money/misc.private.d.ts +0 -23
  431. package/lib/utils/money/misc.private.js +0 -46
  432. package/lib/utils/money/misc.private.js.map +0 -1
  433. package/lib/utils/money/misc.private.mjs +0 -21
  434. package/lib/utils/money/misc.private.mjs.map +0 -1
  435. package/lib/utils/money/shipping.d.ts +0 -5
  436. package/lib/utils/money/shipping.js +0 -8
  437. package/lib/utils/money/shipping.js.map +0 -1
  438. package/lib/utils/money/shipping.mjs +0 -6
  439. package/lib/utils/money/shipping.mjs.map +0 -1
  440. package/lib/utils/money/tax.private.d.ts +0 -17
  441. package/lib/utils/money/tax.private.js +0 -65
  442. package/lib/utils/money/tax.private.js.map +0 -1
  443. package/lib/utils/money/tax.private.mjs +0 -60
  444. package/lib/utils/money/tax.private.mjs.map +0 -1
  445. package/lib/utils/productSort.d.ts +0 -41
  446. package/lib/utils/productSort.js +0 -67
  447. package/lib/utils/productSort.js.map +0 -1
  448. package/lib/utils/productSort.mjs +0 -60
  449. package/lib/utils/productSort.mjs.map +0 -1
  450. /package/lib/components/{HorizontalOptionSelect → ResourceCalculatorV1/components/HorizontalOptionSelect}/index.d.ts +0 -0
  451. /package/lib/components/{HorizontalOptionSelect → ResourceCalculatorV1/components/HorizontalOptionSelect}/index.js +0 -0
  452. /package/lib/components/{HorizontalOptionSelect → ResourceCalculatorV1/components/HorizontalOptionSelect}/index.js.map +0 -0
  453. /package/lib/components/{HorizontalOptionSelect → ResourceCalculatorV1/components/HorizontalOptionSelect}/index.mjs +0 -0
  454. /package/lib/components/{HorizontalOptionSelect → ResourceCalculatorV1/components/HorizontalOptionSelect}/index.mjs.map +0 -0
  455. /package/lib/components/{Header/Navigation/ProMenu → ResourceCalculatorV1/components}/index.mjs.map +0 -0
@@ -1 +1 @@
1
- {"version":3,"file":"tax.mjs","sources":["../../../src/utils/money/tax.ts"],"sourcesContent":["import {\n type Dinero,\n dinero,\n // FIXME: move usage to rounding\n down,\n // FIXME: move usage to rounding\n halfEven,\n multiply,\n toSnapshot,\n toUnit,\n} from \"dinero.js\";\n\nimport type { StoreId } from \"../../types\";\nimport { assert } from \"../errors\";\nimport { isFloat, toFixedRate } from \"../number\";\nimport {\n storesWithPerItemTaxRate,\n TAX_RATE_DINERO_CURRENCY,\n} from \"./constants\";\nimport {\n calculatePerQtyLineItemTax,\n calculateWholeQtyLineItemTax,\n} from \"./tax.private\";\nimport type { Cents, Dino, LineItemSummary, TaxRate } from \"./types\";\n\n/**\n * Function to calculate the tax amount for a given line item depending on the store's tax rate calculation strategy\n */\nexport const calculateLineItemTax = ({\n itemSummary,\n taxRate,\n storeId,\n}: {\n itemSummary: LineItemSummary;\n taxRate: TaxRate;\n storeId: StoreId;\n}) => {\n return storesWithPerItemTaxRate.has(storeId)\n ? calculatePerQtyLineItemTax(itemSummary, taxRate)\n : calculateWholeQtyLineItemTax(itemSummary, taxRate);\n};\n\nexport const removeTaxAmount = (\n baseAmountWithTaxObj: Dinero<Cents>,\n taxRate: TaxRate,\n) => {\n const snapshot = toSnapshot(baseAmountWithTaxObj);\n return dinero({\n ...snapshot,\n amount: down(snapshot.amount / (1 + taxRate)),\n });\n};\n\n/**\n * Will return a percentage tax rate from a decimal tax rate (usually returned by DB)\n *\n * Use for math-related calculations ONLY! Use `formatDecimalTaxRate` for display purposes e.g. invoices.\n *\n * @example convertDecimalTaxRateToPercentage(\"0.01\") // 1\n * @example convertDecimalTaxRateToPercentage(\"0.1023\") // 10.23\n * @example convertDecimalTaxRateToPercentage(\"0.12345678\") // 12.345678\n */\nexport const convertDecimalTaxRateToPercentage = (\n taxRate: string | number,\n): number => {\n const dineroObj = decimalTaxRateToDinero(taxRate);\n const t = multiply(dineroObj, 100);\n return toUnit(t, {\n digits: TAX_RATE_DINERO_CURRENCY.exponent,\n round: halfEven,\n });\n};\n\nexport const decimalTaxRateToDinero = (taxRate: string | number): Dino => {\n const parsedNumber =\n typeof taxRate === \"number\" ? taxRate : Number.parseFloat(taxRate);\n isFloat(parsedNumber);\n\n const parsedNumberInt = Number.parseInt(\n (\n parsedNumber *\n Math.pow(TAX_RATE_DINERO_CURRENCY.base, TAX_RATE_DINERO_CURRENCY.exponent)\n ).toFixed(0),\n );\n return dinero({\n amount: parsedNumberInt,\n currency: TAX_RATE_DINERO_CURRENCY,\n });\n};\n\n/**\n * Will return a percentage string from a decimal tax rate (usually returned by DB).\n *\n * Use for display purposes e.g. invoices.\n *\n * @example formatDecimalTaxRate(\"0.01\") // \"1%\"\n * @example formatDecimalTaxRate(\"0.1023\") // \"10.23%\"\n * @example formatDecimalTaxRate(\"0.12345678\") // \"12.345678%\"\n */\nexport const formatDecimalTaxRate = <TaxRateFloat extends string | number>(\n taxRate: TaxRateFloat,\n): `${number}%` => {\n return `${convertDecimalTaxRateToPercentage(taxRate)}%`;\n};\n\nexport const stringTaxRateToFloat = (rate: string): number =>\n toFixedRate(+rate, TAX_RATE_DINERO_CURRENCY.exponent, true);\n\n/**\n * Calculate total Tax(LV: \"PVN\") for country, which consists of multiple tax entries\n * Returning fixed to ${TAX_RATE_DINERO_CURRENCY.exponent} 4 decimal places, to for example 0.2100 represent 21.00%\n */\nexport const calculateTotalTaxRate = (rates: number[]): number => {\n const rateSum = rates.reduce((sum, rate) => sum + rate, 0);\n const result = toFixedRate(rateSum, TAX_RATE_DINERO_CURRENCY.exponent, true);\n assert(result >= 0, \"Tax rate must be positive\");\n assert(result < 1, \"Tax rate must be less than 1\");\n return result;\n};\n"],"names":["calculateLineItemTax","itemSummary","taxRate","storeId","storesWithPerItemTaxRate","has","calculatePerQtyLineItemTax","calculateWholeQtyLineItemTax","removeTaxAmount","baseAmountWithTaxObj","snapshot","toSnapshot","dinero","amount","down","convertDecimalTaxRateToPercentage","dineroObj","decimalTaxRateToDinero","t","multiply","toUnit","digits","TAX_RATE_DINERO_CURRENCY","exponent","round","halfEven","parsedNumber","Number","parseFloat","isFloat","parsedNumberInt","parseInt","Math","pow","base","toFixed","currency","formatDecimalTaxRate","stringTaxRateToFloat","rate","toFixedRate","calculateTotalTaxRate","rates","rateSum","reduce","sum","result","assert"],"mappings":";;;;;;AA4BO,MAAMA,uBAAuBA,CAAC;EACnCC,WAAA;EACAC,OAAA;EACAC;AACF,CAIM,KAAA;EACG,OAAAC,wBAAA,CAAyBC,GAAI,CAAAF,OAAO,CACvC,GAAAG,0BAAA,CAA2BL,aAAaC,OAAO,CAAA,GAC/CK,4BAA6B,CAAAN,WAAA,EAAaC,OAAO,CAAA;AACvD,CAAA;AAEa,MAAAM,eAAA,GAAkBA,CAC7BC,oBAAA,EACAP,OACG,KAAA;EACG,MAAAQ,QAAA,GAAWC,WAAWF,oBAAoB,CAAA;EAChD,OAAOG,MAAO,CAAA;IACZ,GAAGF,QAAA;IACHG,MAAQ,EAAAC,IAAA,CAAKJ,QAAS,CAAAG,MAAA,IAAU,IAAIX,OAAQ,CAAA;EAAA,CAC7C,CAAA;AACH,CAAA;AAW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AAAD,MAAA,GAAS,GAAG,8BAA8B,CAAA;EAC1C,OAAAA,MAAA;AACT,CAAA;"}
1
+ {"version":3,"file":"tax.mjs","sources":["../../../src/utils/money/tax.ts"],"sourcesContent":["import { allocate, type Dinero, dinero, down, toSnapshot } from \"dinero.js\";\n\nexport const allocateTaxAmount = (\n baseAmountObj: Dinero<number>,\n floatRate: number,\n) => {\n // FIXME: currently the API returns rate as a floating number, but the dinero lib expects be a integer number with some\n // scale so for now we attempt calculate the scale from the float rate\n // @see https://v2.dinerojs.com/docs/api/mutations/allocate\n const rateScale = String(floatRate).split(\".\")[1]?.length;\n if (rateScale === undefined) {\n throw new Error(`rateScale is unsupported ${floatRate}`);\n }\n const rateInt = Math.round(floatRate * Math.pow(10, rateScale));\n // eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n return allocate(baseAmountObj, [\n rateInt,\n Math.pow(10, rateScale) - rateInt,\n ])[0]!;\n};\n\nexport const removeTaxAmount = (\n baseAmountWithTaxObj: Dinero<number>,\n floatRate: number,\n) => {\n const snapshot = toSnapshot(baseAmountWithTaxObj);\n return dinero({\n ...snapshot,\n amount: down(snapshot.amount / (1 + floatRate)),\n });\n};\n"],"names":["allocateTaxAmount","baseAmountObj","floatRate","rateScale","String","split","length","Error","rateInt","Math","round","pow","allocate","removeTaxAmount","baseAmountWithTaxObj","snapshot","toSnapshot","dinero","amount","down"],"mappings":";;AAEa,MAAAA,iBAAA,GAAoBA,CAC/BC,aAAA,EACAC,SACG,KAAA;EAIG,MAAAC,SAAA,GAAYC,OAAOF,SAAS,CAAA,CAAEG,MAAM,GAAG,CAAA,CAAE,CAAC,CAAG,EAAAC,MAAA;EACnD,IAAIH,cAAc,KAAW,CAAA,EAAA;IAC3B,MAAM,IAAII,KAAA,CAAkC,4BAAAL,SAAW,EAAA,CAAA;EACzD;EACM,MAAAM,OAAA,GAAUC,KAAKC,KAAM,CAAAR,SAAA,GAAYO,KAAKE,GAAI,CAAA,EAAA,EAAIR,SAAS,CAAC,CAAA;EAE9D,OAAOS,SAASX,aAAe,EAAA,CAC7BO,OAAA,EACAC,IAAK,CAAAE,GAAA,CAAI,EAAI,EAAAR,SAAS,CAAI,GAAAK,OAAA,CAC3B,EAAE,CAAC,CAAA;AACN,CAAA;AAEa,MAAAK,eAAA,GAAkBA,CAC7BC,oBAAA,EACAZ,SACG,KAAA;EACG,MAAAa,QAAA,GAAWC,WAAWF,oBAAoB,CAAA;EAChD,OAAOG,MAAO,CAAA;IACZ,GAAGF,QAAA;IACHG,MAAQ,EAAAC,IAAA,CAAKJ,QAAS,CAAAG,MAAA,IAAU,IAAIhB,SAAU,CAAA;EAAA,CAC/C,CAAA;AACH,CAAA;"}
@@ -1,85 +1,10 @@
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
- }
1
+ import type { Currency as DineroCurrency } from "dinero.js";
39
2
  /**
40
3
  * Attempt to type out some locales `language-TERRITORY` which "we" as store care about
41
4
  * @see https://unicode-org.github.io/cldr-staging/charts/38/supplemental/territory_language_information.html
42
5
  */
43
6
  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;
44
- export type LocalizedCurrency = {
45
- currency: DinoCurrency;
7
+ export type CurrencyObj = {
8
+ currency: DineroCurrency<number>;
46
9
  locale: Locale;
47
10
  };
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, asNumber?: boolean): string;
34
+ export declare function toFixedRate(rate: number, scale: number): 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, asNumber) {
24
+ function toFixedRate(rate, scale = 0, asNumber = false) {
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(\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,c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S,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(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;I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AA,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, asNumber) {
23
+ function toFixedRate(rate, scale = 0, asNumber = false) {
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(\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,CAA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,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(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,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xD,MAAMK,YAAYlC,KAAQ,GAAA6B,EAAA;EAE1B,IAAIK,YAAY,CAAG,EAAA;IACjBJ,MAAA,CAAOK,KAAKD,SAAS,CAAA;EACvB;EAEO,OAAAJ,MAAA;AACT,CAAA;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;"}
@@ -0,0 +1,15 @@
1
+ /**
2
+ * Util to easily parse that any given input is a finite number (not NaN, Infinity, -Infinity, etc.)
3
+ * @throws If given input is not a finite number
4
+ */
5
+ export declare function isFiniteNumber(value: unknown, entity?: string, ErrorClass?: new (message: string) => void): asserts value is number;
6
+ /**
7
+ * Custom isInt validation function that returns a more fine-grained error message otherwise for type safety alone a
8
+ * Number.isSafeInteger would be sufficient.
9
+ *
10
+ * Code inspired from graphql-scalars library.
11
+ * @see
12
+ * https://github.com/Urigo/graphql-scalars/blob/c4fa3d27b965e39ceda6c33fc18041f112ecce49/src/scalars/utilities.ts#L20-L32
13
+ * @throws If given input is not a valid integer
14
+ */
15
+ export declare function isInt(value: unknown, entity?: string, ErrorClass?: new (message: string) => void): asserts value is number;
@@ -0,0 +1,23 @@
1
+ 'use strict';
2
+ "use strict";
3
+
4
+ function isFiniteNumber(value, entity = "Value", ErrorClass = TypeError) {
5
+ if (typeof value !== "number" || Number.isNaN(value)) {
6
+ throw new ErrorClass(`${entity} is not a number: ${value}`);
7
+ }
8
+ if (!Number.isFinite(value)) {
9
+ throw new ErrorClass(`${entity} is not a finite number: ${value}`);
10
+ }
11
+ }
12
+ function isInt(value, entity = "Value", ErrorClass = TypeError) {
13
+ isFiniteNumber(value, entity, ErrorClass);
14
+ if (!Number.isInteger(value)) {
15
+ throw new ErrorClass(`${entity} is not an integer: ${value}`);
16
+ }
17
+ if (!Number.isSafeInteger(value)) {
18
+ throw new ErrorClass(`${entity} is not a safe integer: ${value}`);
19
+ }
20
+ }
21
+ exports.isFiniteNumber = isFiniteNumber;
22
+ exports.isInt = isInt;
23
+ //# sourceMappingURL=validations.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"validations.js","sources":["../../src/utils/validations.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"],"names":["isFiniteNumber","value","entity","ErrorClass","TypeError","Number","isNaN","isFinite","isInt","isInteger","isSafeInteger"],"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;;"}
@@ -0,0 +1,21 @@
1
+ "use strict";
2
+
3
+ function isFiniteNumber(value, entity = "Value", ErrorClass = TypeError) {
4
+ if (typeof value !== "number" || Number.isNaN(value)) {
5
+ throw new ErrorClass(`${entity} is not a number: ${value}`);
6
+ }
7
+ if (!Number.isFinite(value)) {
8
+ throw new ErrorClass(`${entity} is not a finite number: ${value}`);
9
+ }
10
+ }
11
+ function isInt(value, entity = "Value", ErrorClass = TypeError) {
12
+ isFiniteNumber(value, entity, ErrorClass);
13
+ if (!Number.isInteger(value)) {
14
+ throw new ErrorClass(`${entity} is not an integer: ${value}`);
15
+ }
16
+ if (!Number.isSafeInteger(value)) {
17
+ throw new ErrorClass(`${entity} is not a safe integer: ${value}`);
18
+ }
19
+ }
20
+ export { isFiniteNumber, isInt };
21
+ //# sourceMappingURL=validations.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"validations.mjs","sources":["../../src/utils/validations.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"],"names":["isFiniteNumber","value","entity","ErrorClass","TypeError","Number","isNaN","isFinite","isInt","isInteger","isSafeInteger"],"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;"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ubnt/store.core",
3
- "version": "9.18.0-alpha.8",
3
+ "version": "9.18.0",
4
4
  "description": "",
5
5
  "sideEffects": false,
6
6
  "scripts": {
Binary file
Binary file
@@ -1,5 +0,0 @@
1
- <svg width="17" height="17" viewBox="0 0 17 17" fill="none"
2
- xmlns="http://www.w3.org/2000/svg">
3
- <path fill-rule="evenodd" clip-rule="evenodd" d="M11.0499 6.80268C11.0499 8.21196 9.90823 9.3544 8.4999 9.3544C7.09158 9.3544 5.9499 8.21196 5.9499 6.80268C5.9499 5.3934 7.09158 4.25095 8.4999 4.25095C9.90823 4.25095 11.0499 5.3934 11.0499 6.80268ZM10.1999 6.80268C10.1999 7.7422 9.43879 8.50383 8.4999 8.50383C7.56102 8.50383 6.7999 7.7422 6.7999 6.80268C6.7999 5.86316 7.56102 5.10152 8.4999 5.10152C9.43879 5.10152 10.1999 5.86316 10.1999 6.80268Z" fill="currentColor"/>
4
- <path fill-rule="evenodd" clip-rule="evenodd" d="M8.4999 1.69922C5.68325 1.69922 3.3999 3.98411 3.3999 6.80268C3.3999 8.76181 4.31062 10.6139 5.31026 12.0638C6.31479 13.5208 7.44298 14.6203 7.94931 15.0835C8.26361 15.3711 8.73619 15.3711 9.0505 15.0835C9.55683 14.6203 10.685 13.5208 11.6895 12.0638C12.6892 10.6139 13.5999 8.76181 13.5999 6.80268C13.5999 3.98411 11.3166 1.69922 8.4999 1.69922ZM4.2499 6.80268C4.2499 4.45387 6.15269 2.54979 8.4999 2.54979C10.8471 2.54979 12.7499 4.45387 12.7499 6.80268C12.7499 8.51023 11.9489 10.1898 10.9899 11.5808C10.0506 12.9431 8.99195 13.9825 8.4999 14.4347C8.00786 13.9825 6.94916 12.9431 6.00991 11.5808C5.0509 10.1898 4.2499 8.51023 4.2499 6.80268Z" fill="currentColor"/>
5
- </svg>
@@ -1,27 +0,0 @@
1
- 'use strict';
2
-
3
- Object.defineProperty(exports, '__esModule', {
4
- value: true
5
- });
6
- var LocationPinIcon = require("../../icon-location-pin.svg");
7
- function _interopDefault(e) {
8
- return e && e.__esModule ? e : {
9
- default: e
10
- };
11
- }
12
- var LocationPinIcon__default = /*#__PURE__*/_interopDefault(LocationPinIcon);
13
- Object.defineProperty(exports, "default", {
14
- enumerable: true,
15
- get: function () {
16
- return LocationPinIcon__default["default"];
17
- }
18
- });
19
- Object.keys(LocationPinIcon).forEach(function (k) {
20
- if (k !== 'default' && !Object.prototype.hasOwnProperty.call(exports, k)) Object.defineProperty(exports, k, {
21
- enumerable: true,
22
- get: function () {
23
- return LocationPinIcon[k];
24
- }
25
- });
26
- });
27
- //# sourceMappingURL=icon-location-pin.svg.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"icon-location-pin.svg.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;"}
@@ -1,3 +0,0 @@
1
- export * from "../../icon-location-pin.svg";
2
- export { default } from "../../icon-location-pin.svg";
3
- //# sourceMappingURL=icon-location-pin.svg.mjs.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"icon-location-pin.svg.mjs","sources":[],"sourcesContent":[],"names":[],"mappings":";"}
Binary file
@@ -1,2 +0,0 @@
1
- import type { NavigationProMenuPrivateProps } from "./ProMenu.types";
2
- export declare const NavigationProMenu: ({ show, currentCountryName, handleStorePickerClick, productLineValue, productLineOptions, onProductLineChange, }: NavigationProMenuPrivateProps) => JSX.Element;
@@ -1,103 +0,0 @@
1
- 'use strict';
2
-
3
- var jsxRuntime = require('react/jsx-runtime');
4
- var react = require('react');
5
- var reactUse = require('react-use');
6
- require('../../../../contexts/MenuContext/index.js');
7
- require('../../../../contexts/MenuContext/mapping.js');
8
- require('../../../../hooks/index.js');
9
- var useHasTouch = require('../../../../hooks/useHasTouch.js');
10
- require('../../translations/index.js');
11
- var ProMenu_styles = require('./ProMenu.styles.js');
12
- var context = require('../../../../contexts/MenuContext/context.js');
13
- var useTranslation = require('../../../../hooks/useTranslation.js');
14
- var en = require('../../translations/en.json.js');
15
- var constants = require('../../../../types/constants.js');
16
- "use strict";
17
- const NavigationProMenu = ({
18
- show,
19
- currentCountryName,
20
- handleStorePickerClick,
21
- productLineValue,
22
- productLineOptions,
23
- onProductLineChange
24
- }) => {
25
- const {
26
- motif
27
- } = context.useMenu();
28
- const {
29
- formatMessage
30
- } = useTranslation.useTranslation({
31
- defaultTranslation: en["default"],
32
- additionalTranslations: {
33
- [constants.Language.Ja]: () => Promise.resolve().then(function () {
34
- return require('../../translations/ja.json.js');
35
- }).then(res => res.default),
36
- [constants.Language.Ar]: () => Promise.resolve().then(function () {
37
- return require('../../translations/ar.json.js');
38
- }).then(res => res.default),
39
- [constants.Language.De]: () => Promise.resolve().then(function () {
40
- return require('../../translations/de.json.js');
41
- }).then(res => res.default),
42
- [constants.Language.Es]: () => Promise.resolve().then(function () {
43
- return require('../../translations/es.json.js');
44
- }).then(res => res.default),
45
- [constants.Language.El]: () => Promise.resolve().then(function () {
46
- return require('../../translations/el.json.js');
47
- }).then(res => res.default),
48
- [constants.Language.It]: () => Promise.resolve().then(function () {
49
- return require('../../translations/it.json.js');
50
- }).then(res => res.default),
51
- [constants.Language.Pt]: () => Promise.resolve().then(function () {
52
- return require('../../translations/pt-BR.json.js');
53
- }).then(res => res.default),
54
- [constants.Language.Zh]: () => Promise.resolve().then(function () {
55
- return require('../../translations/zh-Hans.json.js');
56
- }).then(res => res.default),
57
- [constants.Language.Fr]: () => Promise.resolve().then(function () {
58
- return require('../../translations/fr.json.js');
59
- }).then(res => res.default),
60
- [constants.Language.Tw]: () => Promise.resolve().then(function () {
61
- return require('../../translations/zh-Hant-TW.json.js');
62
- }).then(res => res.default)
63
- }
64
- });
65
- const wrapRef = react.useRef(null);
66
- const wrapHover = reactUse.useHoverDirty(wrapRef);
67
- const hasTouch = useHasTouch.useHasTouch();
68
- const slideInView = react.useMemo(() => {
69
- const hasHover = !hasTouch && wrapHover;
70
- return show || hasHover;
71
- }, [hasTouch, show, wrapHover]);
72
- return /* @__PURE__ */jsxRuntime.jsx(ProMenu_styles.Wrap, {
73
- ref: wrapRef,
74
- motif,
75
- slideInView,
76
- children: /* @__PURE__ */jsxRuntime.jsx(ProMenu_styles.MenuWrap, {
77
- motif,
78
- children: /* @__PURE__ */jsxRuntime.jsx(ProMenu_styles.MenuWrapInner, {
79
- children: /* @__PURE__ */jsxRuntime.jsxs(ProMenu_styles.Container, {
80
- size: "desktop",
81
- noVerticalMargin: true,
82
- children: [/* @__PURE__ */jsxRuntime.jsx(ProMenu_styles.ContainerRow, {
83
- children: productLineOptions.map(option => /* @__PURE__ */jsxRuntime.jsx(ProMenu_styles.LinkButton, {
84
- motif,
85
- $active: option.value === productLineValue,
86
- onClick: () => onProductLineChange?.(option.value),
87
- children: option.label
88
- }, option.value))
89
- }), currentCountryName && /* @__PURE__ */jsxRuntime.jsxs(ProMenu_styles.ContainerRow, {
90
- children: [currentCountryName, /* @__PURE__ */jsxRuntime.jsx(ProMenu_styles.LinkButton, {
91
- motif,
92
- $active: true,
93
- onClick: handleStorePickerClick,
94
- children: formatMessage("Change")
95
- })]
96
- })]
97
- })
98
- })
99
- })
100
- });
101
- };
102
- exports.NavigationProMenu = NavigationProMenu;
103
- //# sourceMappingURL=ProMenu.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"ProMenu.js","sources":["../../../../../src/components/Header/Navigation/ProMenu/ProMenu.tsx"],"sourcesContent":["import { useMemo, useRef } from \"react\";\nimport { useHoverDirty } from \"react-use\";\n\nimport { useMenu } from \"../../../../contexts/MenuContext\";\nimport { Language } from \"../../../../contexts/MenuContext/mapping\";\nimport { useTranslation } from \"../../../../hooks\";\nimport { useHasTouch } from \"../../../../hooks/useHasTouch\";\nimport { en as EN_TRANSLATION } from \"../../translations\";\nimport * as S from \"./ProMenu.styles\";\nimport type { NavigationProMenuPrivateProps } from \"./ProMenu.types\";\n\nexport const NavigationProMenu = ({\n show,\n currentCountryName,\n handleStorePickerClick,\n productLineValue,\n productLineOptions,\n onProductLineChange,\n}: NavigationProMenuPrivateProps) => {\n const { motif } = useMenu();\n const { formatMessage } = useTranslation({\n defaultTranslation: EN_TRANSLATION,\n additionalTranslations: {\n [Language.Ja]: () =>\n import(\"../../translations/ja.json\").then((res) => res.default),\n [Language.Ar]: () =>\n import(\"../../translations/ar.json\").then((res) => res.default),\n [Language.De]: () =>\n import(\"../../translations/de.json\").then((res) => res.default),\n [Language.Es]: () =>\n import(\"../../translations/es.json\").then((res) => res.default),\n [Language.El]: () =>\n import(\"../../translations/el.json\").then((res) => res.default),\n [Language.It]: () =>\n import(\"../../translations/it.json\").then((res) => res.default),\n [Language.Pt]: () =>\n import(\"../../translations/pt-BR.json\").then((res) => res.default),\n [Language.Zh]: () =>\n import(\"../../translations/zh-Hans.json\").then((res) => res.default),\n [Language.Fr]: () =>\n import(\"../../translations/fr.json\").then((res) => res.default),\n [Language.Tw]: () =>\n import(\"../../translations/zh-Hant-TW.json\").then((res) => res.default),\n },\n });\n\n // #############################################################################\n // Refs\n // #############################################################################\n const wrapRef = useRef<HTMLDivElement>(null);\n\n // #############################################################################\n // Handle show\n // #############################################################################\n const wrapHover = useHoverDirty(wrapRef);\n const hasTouch = useHasTouch();\n\n const slideInView = useMemo((): boolean => {\n // Ignore hover on touch devices\n const hasHover = !hasTouch && wrapHover;\n\n // Show when parent or wrap has hover\n return show || hasHover;\n }, [hasTouch, show, wrapHover]);\n\n // #############################################################################\n // Render\n // #############################################################################\n return (\n <S.Wrap ref={wrapRef} motif={motif} slideInView={slideInView}>\n <S.MenuWrap motif={motif}>\n <S.MenuWrapInner>\n <S.Container size=\"desktop\" noVerticalMargin>\n {/* Product line */}\n <S.ContainerRow>\n {productLineOptions.map((option) => (\n <S.LinkButton\n key={option.value}\n motif={motif}\n $active={option.value === productLineValue}\n onClick={() => onProductLineChange?.(option.value)}\n >\n {option.label}\n </S.LinkButton>\n ))}\n </S.ContainerRow>\n\n {/* Country */}\n {currentCountryName && (\n <S.ContainerRow>\n {currentCountryName}\n <S.LinkButton\n motif={motif}\n $active\n onClick={handleStorePickerClick}\n >\n {formatMessage(\"Change\")}\n </S.LinkButton>\n </S.ContainerRow>\n )}\n </S.Container>\n </S.MenuWrapInner>\n </S.MenuWrap>\n </S.Wrap>\n );\n};\n"],"names":["NavigationProMenu","show","currentCountryName","handleStorePickerClick","productLineValue","productLineOptions","onProductLineChange","motif","useMenu","formatMessage","useTranslation","defaultTranslation","EN_TRANSLATION","additionalTranslations","Language","Ja","Promise","then","res","default","Ar","De","Es","El","It","Pt","Zh","Fr","Tw","wrapRef","useRef","wrapHover","useHoverDirty","hasTouch","useHasTouch","slideInView","useMemo","hasHover","jsx","S.Wrap","ref","children","S.MenuWrap","S.MenuWrapInner","MenuWrapInner","jsxs","S.Container","size","noVerticalMargin","S.ContainerRow","ContainerRow","map","option","S.LinkButton","LinkButton","$active","value","onClick","label"],"mappings":";;;;;;;;;;;;;;;;AAWO,MAAMA,oBAAoBA,CAAC;EAChCC,IAAA;EACAC,kBAAA;EACAC,sBAAA;EACAC,gBAAA;EACAC,kBAAA;EACAC;AACF,CAAqC,KAAA;EAC7B,MAAA;IAAEC;GAAM,GAAIC,OAAAA,CAAAA,OAAQ,EAAA;EACpB,MAAA;IAAEC;EAAc,CAAA,GAAIC,6BAAe,CAAA;IACvCC,kBAAoB,EAAAC,EAAA,CAAA,SAAA,CAAA;IACpBC,sBAAwB,EAAA;MACtB,CAACC,SAAA,CAAAA,QAAA,CAASC,EAAE,GAAG,MACbC;uBAAO,+BAA4B,CAAA;MAAA,CAAA,CAAA,CAAEC,IAAK,CAACC,GAAQ,IAAAA,GAAA,CAAIC,O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AAA,CAAOI,KAAK,CAAA;cAEhDf,QAAO,EAAAW,MAAA,CAAAM;YAAA,CAAA,EALHN,MAAO,CAAAI,KAOf,CAAA;WACH,CAAA,EAGCtD,kBACC,mBAAA2C,UAAA,CAAAA,IAAA,CAACI,2BAAE,EAAF;YACER,QAAA,EAAA,CAAAvC,kBAAA,EAAA,eACDoC,UAAA,CAAAA,GAAA,CAACe,cAAE,CAAAC,UAAA,EAAF;cACC/C,KAAA;cACAgD,OAAO,EAAA,IAAA;cACPE,OAAS,EAAAtD,sBAAA;cAERsC,wBAAc,QAAQ;YAAA,CACzB,CAAA;WACF,CAAA;QAEJ,CAAA;MACF,CAAA;KACF;EACF,CAAA,CAAA;AAEJ,CAAA;"}
@@ -1,81 +0,0 @@
1
- import { jsx, jsxs } from 'react/jsx-runtime';
2
- import { useRef, useMemo } from 'react';
3
- import { useHoverDirty } from 'react-use';
4
- import '../../../../contexts/MenuContext/index.mjs';
5
- import '../../../../contexts/MenuContext/mapping.mjs';
6
- import '../../../../hooks/index.mjs';
7
- import { useHasTouch } from '../../../../hooks/useHasTouch.mjs';
8
- import '../../translations/index.mjs';
9
- import { Wrap, MenuWrap, MenuWrapInner, Container, ContainerRow, LinkButton } from './ProMenu.styles.mjs';
10
- import { useMenu } from '../../../../contexts/MenuContext/context.mjs';
11
- import { useTranslation } from '../../../../hooks/useTranslation.mjs';
12
- import EN_TRANSLATION from '../../translations/en.json.mjs';
13
- import { Language } from '../../../../types/constants.mjs';
14
- "use strict";
15
- const NavigationProMenu = ({
16
- show,
17
- currentCountryName,
18
- handleStorePickerClick,
19
- productLineValue,
20
- productLineOptions,
21
- onProductLineChange
22
- }) => {
23
- const {
24
- motif
25
- } = useMenu();
26
- const {
27
- formatMessage
28
- } = useTranslation({
29
- defaultTranslation: EN_TRANSLATION,
30
- additionalTranslations: {
31
- [Language.Ja]: () => import('../../translations/ja.json.mjs').then(res => res.default),
32
- [Language.Ar]: () => import('../../translations/ar.json.mjs').then(res => res.default),
33
- [Language.De]: () => import('../../translations/de.json.mjs').then(res => res.default),
34
- [Language.Es]: () => import('../../translations/es.json.mjs').then(res => res.default),
35
- [Language.El]: () => import('../../translations/el.json.mjs').then(res => res.default),
36
- [Language.It]: () => import('../../translations/it.json.mjs').then(res => res.default),
37
- [Language.Pt]: () => import('../../translations/pt-BR.json.mjs').then(res => res.default),
38
- [Language.Zh]: () => import('../../translations/zh-Hans.json.mjs').then(res => res.default),
39
- [Language.Fr]: () => import('../../translations/fr.json.mjs').then(res => res.default),
40
- [Language.Tw]: () => import('../../translations/zh-Hant-TW.json.mjs').then(res => res.default)
41
- }
42
- });
43
- const wrapRef = useRef(null);
44
- const wrapHover = useHoverDirty(wrapRef);
45
- const hasTouch = useHasTouch();
46
- const slideInView = useMemo(() => {
47
- const hasHover = !hasTouch && wrapHover;
48
- return show || hasHover;
49
- }, [hasTouch, show, wrapHover]);
50
- return /* @__PURE__ */jsx(Wrap, {
51
- ref: wrapRef,
52
- motif,
53
- slideInView,
54
- children: /* @__PURE__ */jsx(MenuWrap, {
55
- motif,
56
- children: /* @__PURE__ */jsx(MenuWrapInner, {
57
- children: /* @__PURE__ */jsxs(Container, {
58
- size: "desktop",
59
- noVerticalMargin: true,
60
- children: [/* @__PURE__ */jsx(ContainerRow, {
61
- children: productLineOptions.map(option => /* @__PURE__ */jsx(LinkButton, {
62
- motif,
63
- $active: option.value === productLineValue,
64
- onClick: () => onProductLineChange?.(option.value),
65
- children: option.label
66
- }, option.value))
67
- }), currentCountryName && /* @__PURE__ */jsxs(ContainerRow, {
68
- children: [currentCountryName, /* @__PURE__ */jsx(LinkButton, {
69
- motif,
70
- $active: true,
71
- onClick: handleStorePickerClick,
72
- children: formatMessage("Change")
73
- })]
74
- })]
75
- })
76
- })
77
- })
78
- });
79
- };
80
- export { NavigationProMenu };
81
- //# sourceMappingURL=ProMenu.mjs.map