@ubnt/store.core 9.44.2 → 9.45.0-alpha.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (916) hide show
  1. package/CHANGELOG.md +63 -0
  2. package/lib/_virtual/_virtual_multi-entry.js +44 -40
  3. package/lib/_virtual/_virtual_multi-entry.js.map +1 -1
  4. package/lib/_virtual/_virtual_multi-entry.mjs +44 -40
  5. package/lib/_virtual/_virtual_multi-entry.mjs.map +1 -1
  6. package/lib/apis/smartcat.d.ts +4 -4
  7. package/lib/apis/smartcat.js +1 -1
  8. package/lib/apis/smartcat.js.map +1 -1
  9. package/lib/apis/smartcat.mjs +1 -1
  10. package/lib/apis/smartcat.mjs.map +1 -1
  11. package/lib/assets/attention.svg +5 -5
  12. package/lib/assets/attention2.svg +5 -5
  13. package/lib/assets/cart-secondary.svg +5 -0
  14. package/lib/assets/consolidatedSpecialDevices.svg +5 -0
  15. package/lib/assets/doorAccess.svg +5 -0
  16. package/lib/assets/education.jpg +0 -0
  17. package/lib/assets/enterprise.jpg +0 -0
  18. package/lib/assets/flagship.jpg +0 -0
  19. package/lib/assets/flexible-outdoor.jpg +0 -0
  20. package/lib/assets/hospitality.jpg +0 -0
  21. package/lib/assets/how-it-works.jpg +0 -0
  22. package/lib/assets/icon-location-pin.svg +5 -0
  23. package/lib/{components/MobileModal/assets → assets/icons}/arrowDown.svg.js +1 -1
  24. package/lib/assets/icons/arrowDown.svg.mjs +3 -0
  25. package/lib/assets/icons/cart-secondary.svg.js +27 -0
  26. package/lib/assets/icons/cart-secondary.svg.js.map +1 -0
  27. package/lib/assets/icons/cart-secondary.svg.mjs +3 -0
  28. package/lib/assets/icons/cart-secondary.svg.mjs.map +1 -0
  29. package/lib/assets/icons/menu/icon-location-pin.svg.js +27 -0
  30. package/lib/assets/icons/menu/icon-location-pin.svg.js.map +1 -0
  31. package/lib/assets/icons/menu/icon-location-pin.svg.mjs +3 -0
  32. package/lib/assets/icons/menu/icon-location-pin.svg.mjs.map +1 -0
  33. package/lib/assets/icons/zoomOut.svg.js +27 -0
  34. package/lib/assets/icons/zoomOut.svg.js.map +1 -0
  35. package/lib/assets/icons/zoomOut.svg.mjs +3 -0
  36. package/lib/assets/icons/zoomOut.svg.mjs.map +1 -0
  37. package/lib/assets/industrial.jpg +0 -0
  38. package/lib/assets/industrial2.jpg +0 -0
  39. package/lib/assets/logoUnifi.svg +10 -2
  40. package/lib/assets/mega-capacity.jpg +0 -0
  41. package/lib/assets/nextai-camera.jpg +0 -0
  42. package/lib/assets/nextai-cyber.jpg +0 -0
  43. package/lib/assets/overview.svg +3 -0
  44. package/lib/assets/pause.svg +3 -3
  45. package/lib/assets/pause2.svg +3 -3
  46. package/lib/assets/plus2.svg +1 -4
  47. package/lib/assets/plus3.svg +4 -1
  48. package/lib/assets/port.svg +4 -2
  49. package/lib/assets/port2.svg +2 -4
  50. package/lib/assets/retail.jpg +0 -0
  51. package/lib/assets/sd-wan-sase.jpg +0 -0
  52. package/lib/assets/site-manager.jpg +0 -0
  53. package/lib/assets/stadium.jpg +0 -0
  54. package/lib/assets/tco-calculator.jpg +0 -0
  55. package/lib/assets/wall.jpg +0 -0
  56. package/lib/assets/zoomOut.svg +3 -0
  57. package/lib/components/Accordion/Accordion.js +2 -2
  58. package/lib/components/Accordion/Accordion.js.map +1 -1
  59. package/lib/components/Accordion/Accordion.mjs +2 -2
  60. package/lib/components/Accordion/Accordion.mjs.map +1 -1
  61. package/lib/components/BackInStock/BackInStock.types.d.ts +1 -0
  62. package/lib/components/Button/Button.js +7 -0
  63. package/lib/components/Button/Button.js.map +1 -1
  64. package/lib/components/Button/Button.mjs +8 -1
  65. package/lib/components/Button/Button.mjs.map +1 -1
  66. package/lib/components/Button/CartButton.d.ts +3 -1
  67. package/lib/components/Button/CartButton.js +9 -4
  68. package/lib/components/Button/CartButton.js.map +1 -1
  69. package/lib/components/Button/CartButton.mjs +8 -4
  70. package/lib/components/Button/CartButton.mjs.map +1 -1
  71. package/lib/components/ButtonGroup/ButtonGroup.d.ts +1 -1
  72. package/lib/components/ButtonGroup/ButtonGroup.js +16 -9
  73. package/lib/components/ButtonGroup/ButtonGroup.js.map +1 -1
  74. package/lib/components/ButtonGroup/ButtonGroup.mjs +16 -9
  75. package/lib/components/ButtonGroup/ButtonGroup.mjs.map +1 -1
  76. package/lib/components/ButtonGroup/ButtonGroup.styles.d.ts +10 -6
  77. package/lib/components/ButtonGroup/ButtonGroup.styles.js +60 -20
  78. package/lib/components/ButtonGroup/ButtonGroup.styles.js.map +1 -1
  79. package/lib/components/ButtonGroup/ButtonGroup.styles.mjs +60 -20
  80. package/lib/components/ButtonGroup/ButtonGroup.styles.mjs.map +1 -1
  81. package/lib/components/ButtonGroup/ButtonGroup.types.d.ts +5 -0
  82. package/lib/components/ButtonGroupBasic/ButtonGroupBasic.d.ts +1 -1
  83. package/lib/components/ButtonGroupBasic/ButtonGroupBasic.js +16 -4
  84. package/lib/components/ButtonGroupBasic/ButtonGroupBasic.js.map +1 -1
  85. package/lib/components/ButtonGroupBasic/ButtonGroupBasic.mjs +17 -5
  86. package/lib/components/ButtonGroupBasic/ButtonGroupBasic.mjs.map +1 -1
  87. package/lib/components/ButtonGroupBasic/ButtonGroupBasic.styles.d.ts +5 -1
  88. package/lib/components/ButtonGroupBasic/ButtonGroupBasic.styles.js +82 -17
  89. package/lib/components/ButtonGroupBasic/ButtonGroupBasic.styles.js.map +1 -1
  90. package/lib/components/ButtonGroupBasic/ButtonGroupBasic.styles.mjs +82 -17
  91. package/lib/components/ButtonGroupBasic/ButtonGroupBasic.styles.mjs.map +1 -1
  92. package/lib/components/ButtonGroupBasic/ButtonGroupBasic.types.d.ts +4 -0
  93. package/lib/components/CardSection/CardSection.styles.d.ts +1 -1
  94. package/lib/components/CategoryTabs/CategoryTabs.styles.d.ts +4 -2
  95. package/lib/components/CategoryTabs/CategoryTabs.styles.js +8 -5
  96. package/lib/components/CategoryTabs/CategoryTabs.styles.js.map +1 -1
  97. package/lib/components/CategoryTabs/CategoryTabs.styles.mjs +7 -6
  98. package/lib/components/CategoryTabs/CategoryTabs.styles.mjs.map +1 -1
  99. package/lib/components/Compare/Compare.styles.d.ts +5 -5
  100. package/lib/components/Container/Container.d.ts +1 -1
  101. package/lib/components/Container/Container.js +4 -3
  102. package/lib/components/Container/Container.js.map +1 -1
  103. package/lib/components/Container/Container.mjs +5 -4
  104. package/lib/components/Container/Container.mjs.map +1 -1
  105. package/lib/components/CustomImage/CustomImage.js +4 -4
  106. package/lib/components/CustomImage/CustomImage.js.map +1 -1
  107. package/lib/components/CustomImage/CustomImage.mjs +4 -4
  108. package/lib/components/CustomImage/CustomImage.mjs.map +1 -1
  109. package/lib/components/Explore/ExploreData.js +12 -12
  110. package/lib/components/Explore/ExploreData.js.map +1 -1
  111. package/lib/components/Explore/ExploreData.mjs +12 -12
  112. package/lib/components/Explore/ExploreData.mjs.map +1 -1
  113. package/lib/components/FeaturesSection_deprecated/AllFeaturesButton/AllFeaturesButton.js +1 -1
  114. package/lib/components/FeaturesSection_deprecated/AllFeaturesButton/AllFeaturesButton.mjs +1 -1
  115. package/lib/components/FeaturesSection_deprecated/FeaturesSection.js +1 -1
  116. package/lib/components/FeaturesSection_deprecated/FeaturesSection.js.map +1 -1
  117. package/lib/components/FeaturesSection_deprecated/FeaturesSection.mjs +1 -1
  118. package/lib/components/FeaturesSection_deprecated/FeaturesSection.mjs.map +1 -1
  119. package/lib/components/FeaturesSection_deprecated/assets/plus.svg.js +1 -1
  120. package/lib/components/FeaturesSection_deprecated/assets/plus.svg.mjs +2 -2
  121. package/lib/components/Gallery/Gallery.context.js.map +1 -1
  122. package/lib/components/Gallery/Gallery.context.mjs.map +1 -1
  123. package/lib/components/Gallery/GalleryItem/GalleryItem.js +3 -1
  124. package/lib/components/Gallery/GalleryItem/GalleryItem.js.map +1 -1
  125. package/lib/components/Gallery/GalleryItem/GalleryItem.mjs +3 -1
  126. package/lib/components/Gallery/GalleryItem/GalleryItem.mjs.map +1 -1
  127. package/lib/components/Header/AccountFrame/AccountFrame.js +3 -3
  128. package/lib/components/Header/AccountFrame/AccountFrame.js.map +1 -1
  129. package/lib/components/Header/AccountFrame/AccountFrame.mjs +3 -3
  130. package/lib/components/Header/AccountFrame/AccountFrame.mjs.map +1 -1
  131. package/lib/components/Header/AccountMenu/AccountMenu.js +14 -4
  132. package/lib/components/Header/AccountMenu/AccountMenu.js.map +1 -1
  133. package/lib/components/Header/AccountMenu/AccountMenu.mjs +15 -5
  134. package/lib/components/Header/AccountMenu/AccountMenu.mjs.map +1 -1
  135. package/lib/components/Header/CartModalV2/Item/Item.js +3 -3
  136. package/lib/components/Header/CartModalV2/Item/Item.mjs +2 -2
  137. package/lib/components/Header/CartModalV2/Item/Item.styles.d.ts +1 -1
  138. package/lib/components/Header/Header.js +22 -21
  139. package/lib/components/Header/Header.js.map +1 -1
  140. package/lib/components/Header/Header.mjs +19 -18
  141. package/lib/components/Header/Header.mjs.map +1 -1
  142. package/lib/components/Header/Header.styles.d.ts +7 -12
  143. package/lib/components/Header/Header.styles.js +10 -32
  144. package/lib/components/Header/Header.styles.js.map +1 -1
  145. package/lib/components/Header/Header.styles.mjs +10 -31
  146. package/lib/components/Header/Header.styles.mjs.map +1 -1
  147. package/lib/components/Header/Header.types.d.ts +30 -6
  148. package/lib/components/Header/Header.types.js +2 -1
  149. package/lib/components/Header/Header.types.js.map +1 -1
  150. package/lib/components/Header/Header.types.mjs +2 -1
  151. package/lib/components/Header/Header.types.mjs.map +1 -1
  152. package/lib/components/Header/IsolatedHeader.d.ts +1 -0
  153. package/lib/components/Header/IsolatedHeader.js +47 -47
  154. package/lib/components/Header/IsolatedHeader.js.map +1 -1
  155. package/lib/components/Header/IsolatedHeader.mjs +49 -48
  156. package/lib/components/Header/IsolatedHeader.mjs.map +1 -1
  157. package/lib/components/Header/LanguageFrame/LanguageFrame.js.map +1 -1
  158. package/lib/components/Header/LanguageFrame/LanguageFrame.mjs.map +1 -1
  159. package/lib/components/Header/LogoIcon/LogoIcon.d.ts +7 -0
  160. package/lib/components/Header/LogoIcon/LogoIcon.js +46 -0
  161. package/lib/components/Header/LogoIcon/LogoIcon.js.map +1 -0
  162. package/lib/components/Header/LogoIcon/LogoIcon.mjs +36 -0
  163. package/lib/components/Header/LogoIcon/LogoIcon.mjs.map +1 -0
  164. package/lib/components/Header/LogoIcon/index.d.ts +1 -0
  165. package/lib/components/Header/LogoIcon/index.js +6 -0
  166. package/lib/components/Header/LogoIcon/index.js.map +1 -0
  167. package/lib/components/Header/LogoIcon/index.mjs +3 -0
  168. package/lib/components/Header/LogoIcon/index.mjs.map +1 -0
  169. package/lib/components/Header/MenuItem/MenuItem.styles.d.ts +1 -1
  170. package/lib/components/Header/MenuItem/MenuItem.styles.js +3 -3
  171. package/lib/components/Header/MenuItem/MenuItem.styles.js.map +1 -1
  172. package/lib/components/Header/MenuItem/MenuItem.styles.mjs +3 -3
  173. package/lib/components/Header/MenuItem/MenuItem.styles.mjs.map +1 -1
  174. package/lib/components/Header/MenuItem/MenuItem.types.d.ts +1 -0
  175. package/lib/components/Header/Navigation/MicrositeMenu/MicrositeMenu.js +2 -2
  176. package/lib/components/Header/Navigation/MicrositeMenu/MicrositeMenu.js.map +1 -1
  177. package/lib/components/Header/Navigation/MicrositeMenu/MicrositeMenu.mjs +2 -2
  178. package/lib/components/Header/Navigation/MicrositeMenu/MicrositeMenu.mjs.map +1 -1
  179. package/lib/components/Header/Navigation/MicrositeMenu/MicrositeMenu.styles.d.ts +1 -1
  180. package/lib/components/Header/Navigation/MicrositeMenu/MicrositeMenu.styles.js +7 -5
  181. package/lib/components/Header/Navigation/MicrositeMenu/MicrositeMenu.styles.js.map +1 -1
  182. package/lib/components/Header/Navigation/MicrositeMenu/MicrositeMenu.styles.mjs +7 -5
  183. package/lib/components/Header/Navigation/MicrositeMenu/MicrositeMenu.styles.mjs.map +1 -1
  184. package/lib/components/Header/Navigation/MobileMenu/MobileMenu.styles.d.ts +1 -1
  185. package/lib/components/Header/Navigation/ProMobileMenu/ProMobileMenu.d.ts +1 -1
  186. package/lib/components/Header/Navigation/ProMobileMenu/ProMobileMenu.js +110 -103
  187. package/lib/components/Header/Navigation/ProMobileMenu/ProMobileMenu.js.map +1 -1
  188. package/lib/components/Header/Navigation/ProMobileMenu/ProMobileMenu.mjs +111 -104
  189. package/lib/components/Header/Navigation/ProMobileMenu/ProMobileMenu.mjs.map +1 -1
  190. package/lib/components/Header/Navigation/ProMobileMenu/ProMobileMenu.styles.d.ts +9 -0
  191. package/lib/components/Header/Navigation/ProMobileMenu/ProMobileMenu.styles.js +15 -1
  192. package/lib/components/Header/Navigation/ProMobileMenu/ProMobileMenu.styles.js.map +1 -1
  193. package/lib/components/Header/Navigation/ProMobileMenu/ProMobileMenu.styles.mjs +13 -2
  194. package/lib/components/Header/Navigation/ProMobileMenu/ProMobileMenu.styles.mjs.map +1 -1
  195. package/lib/components/Header/Navigation/ProMobileMenu/ProMobileMenu.types.d.ts +12 -6
  196. package/lib/components/Header/ProHeader/ProHeader.d.ts +9 -5
  197. package/lib/components/Header/ProHeader/ProHeader.js +265 -180
  198. package/lib/components/Header/ProHeader/ProHeader.js.map +1 -1
  199. package/lib/components/Header/ProHeader/ProHeader.mjs +264 -180
  200. package/lib/components/Header/ProHeader/ProHeader.mjs.map +1 -1
  201. package/lib/components/Header/ProHeader/ProHeader.styles.d.ts +30 -25
  202. package/lib/components/Header/ProHeader/ProHeader.styles.js +119 -66
  203. package/lib/components/Header/ProHeader/ProHeader.styles.js.map +1 -1
  204. package/lib/components/Header/ProHeader/ProHeader.styles.mjs +112 -65
  205. package/lib/components/Header/ProHeader/ProHeader.styles.mjs.map +1 -1
  206. package/lib/components/Header/translations/ar.json.js +4 -1
  207. package/lib/components/Header/translations/ar.json.js.map +1 -1
  208. package/lib/components/Header/translations/ar.json.mjs +4 -2
  209. package/lib/components/Header/translations/ar.json.mjs.map +1 -1
  210. package/lib/components/Header/translations/de.json.js +4 -1
  211. package/lib/components/Header/translations/de.json.js.map +1 -1
  212. package/lib/components/Header/translations/de.json.mjs +4 -2
  213. package/lib/components/Header/translations/de.json.mjs.map +1 -1
  214. package/lib/components/Header/translations/el.json.js +4 -1
  215. package/lib/components/Header/translations/el.json.js.map +1 -1
  216. package/lib/components/Header/translations/el.json.mjs +4 -2
  217. package/lib/components/Header/translations/el.json.mjs.map +1 -1
  218. package/lib/components/Header/translations/en.json.js +7 -1
  219. package/lib/components/Header/translations/en.json.js.map +1 -1
  220. package/lib/components/Header/translations/en.json.mjs +6 -2
  221. package/lib/components/Header/translations/en.json.mjs.map +1 -1
  222. package/lib/components/Header/translations/es.json.js +4 -1
  223. package/lib/components/Header/translations/es.json.js.map +1 -1
  224. package/lib/components/Header/translations/es.json.mjs +4 -2
  225. package/lib/components/Header/translations/es.json.mjs.map +1 -1
  226. package/lib/components/Header/translations/fr.json.js +4 -1
  227. package/lib/components/Header/translations/fr.json.js.map +1 -1
  228. package/lib/components/Header/translations/fr.json.mjs +4 -2
  229. package/lib/components/Header/translations/fr.json.mjs.map +1 -1
  230. package/lib/components/Header/translations/it.json.js +4 -1
  231. package/lib/components/Header/translations/it.json.js.map +1 -1
  232. package/lib/components/Header/translations/it.json.mjs +4 -2
  233. package/lib/components/Header/translations/it.json.mjs.map +1 -1
  234. package/lib/components/Header/translations/ja.json.js +4 -1
  235. package/lib/components/Header/translations/ja.json.js.map +1 -1
  236. package/lib/components/Header/translations/ja.json.mjs +4 -2
  237. package/lib/components/Header/translations/ja.json.mjs.map +1 -1
  238. package/lib/components/Header/translations/pt-BR.json.js +4 -1
  239. package/lib/components/Header/translations/pt-BR.json.js.map +1 -1
  240. package/lib/components/Header/translations/pt-BR.json.mjs +4 -2
  241. package/lib/components/Header/translations/pt-BR.json.mjs.map +1 -1
  242. package/lib/components/Header/translations/zh-Hans.json.js +4 -1
  243. package/lib/components/Header/translations/zh-Hans.json.js.map +1 -1
  244. package/lib/components/Header/translations/zh-Hans.json.mjs +4 -2
  245. package/lib/components/Header/translations/zh-Hans.json.mjs.map +1 -1
  246. package/lib/components/Header/translations/zh-Hant-TW.json.js +4 -1
  247. package/lib/components/Header/translations/zh-Hant-TW.json.js.map +1 -1
  248. package/lib/components/Header/translations/zh-Hant-TW.json.mjs +4 -2
  249. package/lib/components/Header/translations/zh-Hant-TW.json.mjs.map +1 -1
  250. package/lib/components/Hero/Hero.js +1 -1
  251. package/lib/components/Hero/Hero.js.map +1 -1
  252. package/lib/components/Hero/Hero.mjs +1 -1
  253. package/lib/components/Hero/Hero.mjs.map +1 -1
  254. package/lib/components/Hero/Hero.styles.d.ts +2 -2
  255. package/lib/components/HeroFadeGallery/HeroFadeGallery.styles.d.ts +1 -1
  256. package/lib/components/HeroVideo/HeroVideo.js +5 -5
  257. package/lib/components/HeroVideo/HeroVideo.js.map +1 -1
  258. package/lib/components/HeroVideo/HeroVideo.mjs +5 -5
  259. package/lib/components/HeroVideo/HeroVideo.mjs.map +1 -1
  260. package/lib/components/HowToUseSection/HowToUseSection.styles.d.ts +2 -2
  261. package/lib/components/ImageCarousel/ImageCarousel.js.map +1 -1
  262. package/lib/components/ImageCarousel/ImageCarousel.mjs.map +1 -1
  263. package/lib/components/LandingPage/Cards/Cards.js +4 -4
  264. package/lib/components/LandingPage/Cards/Cards.js.map +1 -1
  265. package/lib/components/LandingPage/Cards/Cards.mjs +3 -3
  266. package/lib/components/LandingPage/Cards/Cards.mjs.map +1 -1
  267. package/lib/components/LandingPagePro/LandingPagePro.js +4 -1
  268. package/lib/components/LandingPagePro/LandingPagePro.js.map +1 -1
  269. package/lib/components/LandingPagePro/LandingPagePro.mjs +4 -1
  270. package/lib/components/LandingPagePro/LandingPagePro.mjs.map +1 -1
  271. package/lib/components/LandingPagePro/LandingPagePro.styles.d.ts +1 -1
  272. package/lib/components/LandingPageSidebar/LandingPageSidebar.js +8 -8
  273. package/lib/components/LandingPageSidebar/LandingPageSidebar.js.map +1 -1
  274. package/lib/components/LandingPageSidebar/LandingPageSidebar.mjs +8 -8
  275. package/lib/components/LandingPageSidebar/LandingPageSidebar.mjs.map +1 -1
  276. package/lib/components/LayoutRenderer/LayoutRenderer.styles.d.ts +1 -1
  277. package/lib/components/LayoutRendererV1/LayoutRenderer.styles.d.ts +3 -3
  278. package/lib/components/LayoutRendererV2/LayoutRenderer.styles.d.ts +3 -3
  279. package/lib/components/LoaderDots/LoaderDots.d.ts +1 -1
  280. package/lib/components/LoaderDots/LoaderDots.js +3 -1
  281. package/lib/components/LoaderDots/LoaderDots.js.map +1 -1
  282. package/lib/components/LoaderDots/LoaderDots.mjs +3 -1
  283. package/lib/components/LoaderDots/LoaderDots.mjs.map +1 -1
  284. package/lib/components/LoaderDots/LoaderDots.styles.d.ts +2 -1
  285. package/lib/components/LoaderDots/LoaderDots.styles.js +11 -1
  286. package/lib/components/LoaderDots/LoaderDots.styles.js.map +1 -1
  287. package/lib/components/LoaderDots/LoaderDots.styles.mjs +11 -1
  288. package/lib/components/LoaderDots/LoaderDots.styles.mjs.map +1 -1
  289. package/lib/components/LoaderDots/LoaderDots.types.d.ts +2 -0
  290. package/lib/components/MeetUniFiVideoPlayer/MeetUniFiVideoPlayer.js +4 -4
  291. package/lib/components/MeetUniFiVideoPlayer/MeetUniFiVideoPlayer.js.map +1 -1
  292. package/lib/components/MeetUniFiVideoPlayer/MeetUniFiVideoPlayer.mjs +4 -4
  293. package/lib/components/MeetUniFiVideoPlayer/MeetUniFiVideoPlayer.mjs.map +1 -1
  294. package/lib/components/MeetUniFiVideoPlayer/MeetUniFiVideoPlayer.styles.d.ts +1 -1
  295. package/lib/components/MicrositeHeader/MicrositeHeader.d.ts +2 -0
  296. package/lib/components/MicrositeHeader/MicrositeHeader.js +35 -0
  297. package/lib/components/MicrositeHeader/MicrositeHeader.js.map +1 -0
  298. package/lib/components/MicrositeHeader/MicrositeHeader.mjs +33 -0
  299. package/lib/components/MicrositeHeader/MicrositeHeader.mjs.map +1 -0
  300. package/lib/components/MicrositeHeader/MicrositeHeader.styles.d.ts +2 -0
  301. package/lib/components/MicrositeHeader/MicrositeHeader.styles.js +29 -0
  302. package/lib/components/MicrositeHeader/MicrositeHeader.styles.js.map +1 -0
  303. package/lib/components/MicrositeHeader/MicrositeHeader.styles.mjs +20 -0
  304. package/lib/components/MicrositeHeader/MicrositeHeader.styles.mjs.map +1 -0
  305. package/lib/components/MicrositeHeader/MicrositeHeader.types.d.ts +5 -0
  306. package/lib/components/MicrositeHeader/components/DropdownMenu/DropdownMenu.d.ts +2 -0
  307. package/lib/components/MicrositeHeader/components/DropdownMenu/DropdownMenu.js +185 -0
  308. package/lib/components/MicrositeHeader/components/DropdownMenu/DropdownMenu.js.map +1 -0
  309. package/lib/components/MicrositeHeader/components/DropdownMenu/DropdownMenu.mjs +176 -0
  310. package/lib/components/MicrositeHeader/components/DropdownMenu/DropdownMenu.mjs.map +1 -0
  311. package/lib/components/MicrositeHeader/components/DropdownMenu/DropdownMenu.styles.d.ts +52 -0
  312. package/lib/components/MicrositeHeader/components/DropdownMenu/DropdownMenu.styles.js +425 -0
  313. package/lib/components/MicrositeHeader/components/DropdownMenu/DropdownMenu.styles.js.map +1 -0
  314. package/lib/components/MicrositeHeader/components/DropdownMenu/DropdownMenu.styles.mjs +391 -0
  315. package/lib/components/MicrositeHeader/components/DropdownMenu/DropdownMenu.styles.mjs.map +1 -0
  316. package/lib/components/MicrositeHeader/components/DropdownMenu/DropdownMenu.types.d.ts +20 -0
  317. package/lib/components/MicrositeHeader/components/DropdownMenu/index.d.ts +1 -0
  318. package/lib/components/MicrositeHeader/components/FirstLevelMenu/FirstLevelMenu.d.ts +2 -0
  319. package/lib/components/MicrositeHeader/components/FirstLevelMenu/FirstLevelMenu.js +209 -0
  320. package/lib/components/MicrositeHeader/components/FirstLevelMenu/FirstLevelMenu.js.map +1 -0
  321. package/lib/components/MicrositeHeader/components/FirstLevelMenu/FirstLevelMenu.mjs +198 -0
  322. package/lib/components/MicrositeHeader/components/FirstLevelMenu/FirstLevelMenu.mjs.map +1 -0
  323. package/lib/components/MicrositeHeader/components/FirstLevelMenu/FirstLevelMenu.styles.d.ts +22 -0
  324. package/lib/components/MicrositeHeader/components/FirstLevelMenu/FirstLevelMenu.styles.js +148 -0
  325. package/lib/components/MicrositeHeader/components/FirstLevelMenu/FirstLevelMenu.styles.js.map +1 -0
  326. package/lib/components/MicrositeHeader/components/FirstLevelMenu/FirstLevelMenu.styles.mjs +126 -0
  327. package/lib/components/MicrositeHeader/components/FirstLevelMenu/FirstLevelMenu.styles.mjs.map +1 -0
  328. package/lib/components/MicrositeHeader/components/FirstLevelMenu/FirstLevelMenu.types.d.ts +10 -0
  329. package/lib/components/MicrositeHeader/components/FirstLevelMenu/index.d.ts +1 -0
  330. package/lib/components/MicrositeHeader/components/FirstLevelMenu/index.js +6 -0
  331. package/lib/components/MicrositeHeader/components/FirstLevelMenu/index.js.map +1 -0
  332. package/lib/components/MicrositeHeader/components/FirstLevelMenu/index.mjs +3 -0
  333. package/lib/components/MicrositeHeader/components/FirstLevelMenu/index.mjs.map +1 -0
  334. package/lib/components/MicrositeHeader/components/SecondLevelMenu/SecondLevelMenu.d.ts +2 -0
  335. package/lib/components/MicrositeHeader/components/SecondLevelMenu/SecondLevelMenu.js +71 -0
  336. package/lib/components/MicrositeHeader/components/SecondLevelMenu/SecondLevelMenu.js.map +1 -0
  337. package/lib/components/MicrositeHeader/components/SecondLevelMenu/SecondLevelMenu.mjs +69 -0
  338. package/lib/components/MicrositeHeader/components/SecondLevelMenu/SecondLevelMenu.mjs.map +1 -0
  339. package/lib/components/MicrositeHeader/components/SecondLevelMenu/SecondLevelMenu.styles.d.ts +13 -0
  340. package/lib/components/MicrositeHeader/components/SecondLevelMenu/SecondLevelMenu.styles.js +104 -0
  341. package/lib/components/MicrositeHeader/components/SecondLevelMenu/SecondLevelMenu.styles.js.map +1 -0
  342. package/lib/components/MicrositeHeader/components/SecondLevelMenu/SecondLevelMenu.styles.mjs +89 -0
  343. package/lib/components/MicrositeHeader/components/SecondLevelMenu/SecondLevelMenu.styles.mjs.map +1 -0
  344. package/lib/components/MicrositeHeader/components/SecondLevelMenu/SecondLevelMenu.types.d.ts +11 -0
  345. package/lib/components/MicrositeHeader/components/SecondLevelMenu/index.d.ts +1 -0
  346. package/lib/components/MicrositeHeader/components/SecondLevelMenu/index.js +6 -0
  347. package/lib/components/MicrositeHeader/components/SecondLevelMenu/index.js.map +1 -0
  348. package/lib/components/MicrositeHeader/components/SecondLevelMenu/index.mjs +3 -0
  349. package/lib/components/MicrositeHeader/components/SecondLevelMenu/index.mjs.map +1 -0
  350. package/lib/components/MicrositeHeader/components/SiteMapColumns/SiteMapColumns.d.ts +17 -0
  351. package/lib/components/MicrositeHeader/components/SiteMapColumns/SiteMapColumns.styles.d.ts +13 -0
  352. package/lib/components/MicrositeHeader/components/SiteMapColumns/index.d.ts +1 -0
  353. package/lib/components/MicrositeHeader/index.d.ts +1 -0
  354. package/lib/components/MicrositeHeader/index.js +6 -0
  355. package/lib/components/MicrositeHeader/index.js.map +1 -0
  356. package/lib/components/MicrositeHeader/index.mjs +3 -0
  357. package/lib/components/MicrositeHeader/index.mjs.map +1 -0
  358. package/lib/components/MicrositeHero/MicrositeHero.js +2 -2
  359. package/lib/components/MicrositeHero/MicrositeHero.js.map +1 -1
  360. package/lib/components/MicrositeHero/MicrositeHero.mjs +2 -2
  361. package/lib/components/MicrositeHero/MicrositeHero.mjs.map +1 -1
  362. package/lib/components/MicrositeSectionWrap/MicrositeSectionWrap.styles.d.ts +1 -1
  363. package/lib/components/MicrositeVideoSlideshow/MicrositeVideoSlideshow.js +1 -1
  364. package/lib/components/MicrositeVideoSlideshow/MicrositeVideoSlideshow.mjs +1 -1
  365. package/lib/components/MicrositeVideoSlideshow/assets/pause.svg.js +1 -1
  366. package/lib/components/MicrositeVideoSlideshow/assets/pause.svg.mjs +2 -2
  367. package/lib/components/Microsites/Microsites.types.js.map +1 -1
  368. package/lib/components/Microsites/Microsites.types.mjs.map +1 -1
  369. package/lib/components/MobileModal/MobileModal.js +1 -1
  370. package/lib/components/MobileModal/MobileModal.js.map +1 -1
  371. package/lib/components/MobileModal/MobileModal.mjs +1 -1
  372. package/lib/components/MobileModal/MobileModal.mjs.map +1 -1
  373. package/lib/components/ModelCompareV3/ModelComparePropertyValueGridItem.js +37 -26
  374. package/lib/components/ModelCompareV3/ModelComparePropertyValueGridItem.js.map +1 -1
  375. package/lib/components/ModelCompareV3/ModelComparePropertyValueGridItem.mjs +37 -26
  376. package/lib/components/ModelCompareV3/ModelComparePropertyValueGridItem.mjs.map +1 -1
  377. package/lib/components/ModelCompareV3/ModelCompareV3.types.d.ts +5 -1
  378. package/lib/components/ModelCompareV3/StickyGrid/StickyGridItem.js +16 -8
  379. package/lib/components/ModelCompareV3/StickyGrid/StickyGridItem.js.map +1 -1
  380. package/lib/components/ModelCompareV3/StickyGrid/StickyGridItem.mjs +16 -8
  381. package/lib/components/ModelCompareV3/StickyGrid/StickyGridItem.mjs.map +1 -1
  382. package/lib/components/ModelCompareV3/StickyGrid/context.d.ts +3 -3
  383. package/lib/components/ModelCompareV3/StickyGrid/context.js.map +1 -1
  384. package/lib/components/ModelCompareV3/StickyGrid/context.mjs.map +1 -1
  385. package/lib/components/ModelCompareV3/assets/Switching/industrial.jpg.js +1 -1
  386. package/lib/components/ModelCompareV3/assets/Switching/industrial.jpg.mjs +2 -2
  387. package/lib/{assets/icons/menu/icon-globe.svg.js → components/ModelCompareV3/assets/WiFi/flagship.jpg.js} +6 -6
  388. package/lib/components/ModelCompareV3/assets/WiFi/flagship.jpg.js.map +1 -0
  389. package/lib/components/ModelCompareV3/assets/WiFi/flagship.jpg.mjs +3 -0
  390. package/lib/components/ModelCompareV3/assets/WiFi/flagship.jpg.mjs.map +1 -0
  391. package/lib/components/ModelCompareV3/assets/WiFi/flexible-outdoor.jpg.js +27 -0
  392. package/lib/components/ModelCompareV3/assets/WiFi/flexible-outdoor.jpg.js.map +1 -0
  393. package/lib/components/ModelCompareV3/assets/WiFi/flexible-outdoor.jpg.mjs +3 -0
  394. package/lib/components/ModelCompareV3/assets/WiFi/flexible-outdoor.jpg.mjs.map +1 -0
  395. package/lib/components/ModelCompareV3/assets/WiFi/mega-capacity.jpg.js +27 -0
  396. package/lib/components/ModelCompareV3/assets/WiFi/mega-capacity.jpg.js.map +1 -0
  397. package/lib/components/ModelCompareV3/assets/WiFi/mega-capacity.jpg.mjs +3 -0
  398. package/lib/components/ModelCompareV3/assets/WiFi/mega-capacity.jpg.mjs.map +1 -0
  399. package/lib/components/ModelCompareV3/assets/WiFi/wall.jpg.js +27 -0
  400. package/lib/components/ModelCompareV3/assets/WiFi/wall.jpg.js.map +1 -0
  401. package/lib/components/ModelCompareV3/assets/WiFi/wall.jpg.mjs +3 -0
  402. package/lib/components/ModelCompareV3/assets/WiFi/wall.jpg.mjs.map +1 -0
  403. package/lib/components/ModelCompareV3/assets/port.svg.js +1 -1
  404. package/lib/components/ModelCompareV3/assets/port.svg.mjs +2 -2
  405. package/lib/components/ModelCompareV3/data/Ptz.d.ts +2 -0
  406. package/lib/components/ModelCompareV3/data/Ptz.js +13 -0
  407. package/lib/components/ModelCompareV3/data/Ptz.js.map +1 -0
  408. package/lib/components/ModelCompareV3/data/Ptz.mjs +11 -0
  409. package/lib/components/ModelCompareV3/data/Ptz.mjs.map +1 -0
  410. package/lib/components/ModelCompareV3/data/WiFi.d.ts +2 -0
  411. package/lib/components/ModelCompareV3/data/WiFi.js +23 -0
  412. package/lib/components/ModelCompareV3/data/WiFi.js.map +1 -0
  413. package/lib/components/ModelCompareV3/data/WiFi.mjs +21 -0
  414. package/lib/components/ModelCompareV3/data/WiFi.mjs.map +1 -0
  415. package/lib/components/ModelCompareV3/data/index.d.ts +50 -48
  416. package/lib/components/ModelCompareV3/data/index.js +102 -96
  417. package/lib/components/ModelCompareV3/data/index.js.map +1 -1
  418. package/lib/components/ModelCompareV3/data/index.mjs +102 -96
  419. package/lib/components/ModelCompareV3/data/index.mjs.map +1 -1
  420. package/lib/components/ModelCompareV3/data/products/cloudKeyEnterprise.js +4 -2
  421. package/lib/components/ModelCompareV3/data/products/cloudKeyEnterprise.js.map +1 -1
  422. package/lib/components/ModelCompareV3/data/products/cloudKeyEnterprise.mjs +4 -2
  423. package/lib/components/ModelCompareV3/data/products/cloudKeyEnterprise.mjs.map +1 -1
  424. package/lib/components/ModelCompareV3/data/products/cloudKeyG2Plus.js +2 -2
  425. package/lib/components/ModelCompareV3/data/products/cloudKeyG2Plus.js.map +1 -1
  426. package/lib/components/ModelCompareV3/data/products/cloudKeyG2Plus.mjs +2 -2
  427. package/lib/components/ModelCompareV3/data/products/cloudKeyG2Plus.mjs.map +1 -1
  428. package/lib/components/ModelCompareV3/data/products/express.js +3 -3
  429. package/lib/components/ModelCompareV3/data/products/express.js.map +1 -1
  430. package/lib/components/ModelCompareV3/data/products/express.mjs +3 -3
  431. package/lib/components/ModelCompareV3/data/products/express.mjs.map +1 -1
  432. package/lib/components/ModelCompareV3/data/products/gatewayEnterprise.js +4 -2
  433. package/lib/components/ModelCompareV3/data/products/gatewayEnterprise.js.map +1 -1
  434. package/lib/components/ModelCompareV3/data/products/gatewayEnterprise.mjs +4 -2
  435. package/lib/components/ModelCompareV3/data/products/gatewayEnterprise.mjs.map +1 -1
  436. package/lib/components/ModelCompareV3/data/products/gatewayLite.js +4 -2
  437. package/lib/components/ModelCompareV3/data/products/gatewayLite.js.map +1 -1
  438. package/lib/components/ModelCompareV3/data/products/gatewayLite.mjs +4 -2
  439. package/lib/components/ModelCompareV3/data/products/gatewayLite.mjs.map +1 -1
  440. package/lib/components/ModelCompareV3/data/products/gatewayMax.js +4 -2
  441. package/lib/components/ModelCompareV3/data/products/gatewayMax.js.map +1 -1
  442. package/lib/components/ModelCompareV3/data/products/gatewayMax.mjs +4 -2
  443. package/lib/components/ModelCompareV3/data/products/gatewayMax.mjs.map +1 -1
  444. package/lib/components/ModelCompareV3/data/products/gatewayProfessional.js +4 -2
  445. package/lib/components/ModelCompareV3/data/products/gatewayProfessional.js.map +1 -1
  446. package/lib/components/ModelCompareV3/data/products/gatewayProfessional.mjs +4 -2
  447. package/lib/components/ModelCompareV3/data/products/gatewayProfessional.mjs.map +1 -1
  448. package/lib/components/ModelCompareV3/data/products/industrial.js +1 -1
  449. package/lib/components/ModelCompareV3/data/products/industrial.mjs +1 -1
  450. package/lib/components/ModelCompareV3/data/products/officialUniFiHosting.js +3 -1
  451. package/lib/components/ModelCompareV3/data/products/officialUniFiHosting.js.map +1 -1
  452. package/lib/components/ModelCompareV3/data/products/officialUniFiHosting.mjs +3 -1
  453. package/lib/components/ModelCompareV3/data/products/officialUniFiHosting.mjs.map +1 -1
  454. package/lib/components/ModelCompareV3/data/products/ucgMax.js +1 -1
  455. package/lib/components/ModelCompareV3/data/products/ucgMax.js.map +1 -1
  456. package/lib/components/ModelCompareV3/data/products/ucgMax.mjs +1 -1
  457. package/lib/components/ModelCompareV3/data/products/ucgMax.mjs.map +1 -1
  458. package/lib/components/ModelCompareV3/data/products/ucgUltra.js +3 -3
  459. package/lib/components/ModelCompareV3/data/products/ucgUltra.js.map +1 -1
  460. package/lib/components/ModelCompareV3/data/products/ucgUltra.mjs +3 -3
  461. package/lib/components/ModelCompareV3/data/products/ucgUltra.mjs.map +1 -1
  462. package/lib/components/ModelCompareV3/data/products/udmPro.js +3 -3
  463. package/lib/components/ModelCompareV3/data/products/udmPro.js.map +1 -1
  464. package/lib/components/ModelCompareV3/data/products/udmPro.mjs +3 -3
  465. package/lib/components/ModelCompareV3/data/products/udmPro.mjs.map +1 -1
  466. package/lib/components/ModelCompareV3/data/products/udmProMax.js +3 -3
  467. package/lib/components/ModelCompareV3/data/products/udmProMax.js.map +1 -1
  468. package/lib/components/ModelCompareV3/data/products/udmProMax.mjs +3 -3
  469. package/lib/components/ModelCompareV3/data/products/udmProMax.mjs.map +1 -1
  470. package/lib/components/ModelCompareV3/data/products/udmProSpecial.js +3 -3
  471. package/lib/components/ModelCompareV3/data/products/udmProSpecial.js.map +1 -1
  472. package/lib/components/ModelCompareV3/data/products/udmProSpecial.mjs +3 -3
  473. package/lib/components/ModelCompareV3/data/products/udmProSpecial.mjs.map +1 -1
  474. package/lib/components/ModelCompareV3/data/products/udr.js +5 -41
  475. package/lib/components/ModelCompareV3/data/products/udr.js.map +1 -1
  476. package/lib/components/ModelCompareV3/data/products/udr.mjs +5 -21
  477. package/lib/components/ModelCompareV3/data/products/udr.mjs.map +1 -1
  478. package/lib/components/ModelCompareV3/data/products/udw.js +4 -3
  479. package/lib/components/ModelCompareV3/data/products/udw.js.map +1 -1
  480. package/lib/components/ModelCompareV3/data/products/udw.mjs +4 -3
  481. package/lib/components/ModelCompareV3/data/products/udw.mjs.map +1 -1
  482. package/lib/components/ModelCompareV3/data/products/wifiFlagship.d.ts +2 -0
  483. package/lib/components/ModelCompareV3/data/products/wifiFlagship.js +70 -0
  484. package/lib/components/ModelCompareV3/data/products/wifiFlagship.js.map +1 -0
  485. package/lib/components/ModelCompareV3/data/products/wifiFlagship.mjs +62 -0
  486. package/lib/components/ModelCompareV3/data/products/wifiFlagship.mjs.map +1 -0
  487. package/lib/components/ModelCompareV3/data/products/wifiFlexibleOutdoor.d.ts +2 -0
  488. package/lib/components/ModelCompareV3/data/products/wifiFlexibleOutdoor.js +73 -0
  489. package/lib/components/ModelCompareV3/data/products/wifiFlexibleOutdoor.js.map +1 -0
  490. package/lib/components/ModelCompareV3/data/products/wifiFlexibleOutdoor.mjs +65 -0
  491. package/lib/components/ModelCompareV3/data/products/wifiFlexibleOutdoor.mjs.map +1 -0
  492. package/lib/components/ModelCompareV3/data/products/wifiMegaCapacity.d.ts +2 -0
  493. package/lib/components/ModelCompareV3/data/products/wifiMegaCapacity.js +73 -0
  494. package/lib/components/ModelCompareV3/data/products/wifiMegaCapacity.js.map +1 -0
  495. package/lib/components/ModelCompareV3/data/products/wifiMegaCapacity.mjs +65 -0
  496. package/lib/components/ModelCompareV3/data/products/wifiMegaCapacity.mjs.map +1 -0
  497. package/lib/components/ModelCompareV3/data/products/wifiWall.d.ts +2 -0
  498. package/lib/components/ModelCompareV3/data/products/wifiWall.js +74 -0
  499. package/lib/components/ModelCompareV3/data/products/wifiWall.js.map +1 -0
  500. package/lib/components/ModelCompareV3/data/products/wifiWall.mjs +66 -0
  501. package/lib/components/ModelCompareV3/data/products/wifiWall.mjs.map +1 -0
  502. package/lib/components/ModelCompareV3/data/properties/redundantRj45Port.js +1 -1
  503. package/lib/components/ModelCompareV3/data/properties/redundantRj45Port.mjs +1 -1
  504. package/lib/components/ModelCompareV3/translations/ar.json.js +1 -1
  505. package/lib/components/ModelCompareV3/translations/ar.json.mjs +1 -1
  506. package/lib/components/ModelCompareV3/translations/de.json.js +1 -1
  507. package/lib/components/ModelCompareV3/translations/de.json.mjs +1 -1
  508. package/lib/components/ModelCompareV3/translations/el.json.js +1 -1
  509. package/lib/components/ModelCompareV3/translations/el.json.mjs +1 -1
  510. package/lib/components/ModelCompareV3/translations/en.json.js +61 -6
  511. package/lib/components/ModelCompareV3/translations/en.json.js.map +1 -1
  512. package/lib/components/ModelCompareV3/translations/en.json.mjs +61 -6
  513. package/lib/components/ModelCompareV3/translations/en.json.mjs.map +1 -1
  514. package/lib/components/ModelCompareV3/translations/es.json.js +1 -1
  515. package/lib/components/ModelCompareV3/translations/es.json.mjs +1 -1
  516. package/lib/components/ModelCompareV3/translations/fr.json.js +1 -1
  517. package/lib/components/ModelCompareV3/translations/fr.json.mjs +1 -1
  518. package/lib/components/ModelCompareV3/translations/it.json.js +1 -1
  519. package/lib/components/ModelCompareV3/translations/it.json.mjs +1 -1
  520. package/lib/components/ModelCompareV3/translations/ja.json.js +1 -1
  521. package/lib/components/ModelCompareV3/translations/ja.json.mjs +1 -1
  522. package/lib/components/ModelCompareV3/translations/pt-BR.json.js +1 -1
  523. package/lib/components/ModelCompareV3/translations/pt-BR.json.mjs +1 -1
  524. package/lib/components/ModelCompareV3/translations/useModelCompareTranslation.d.ts +2 -2
  525. package/lib/components/ModelCompareV3/translations/zh-Hans.json.js +1 -1
  526. package/lib/components/ModelCompareV3/translations/zh-Hans.json.mjs +1 -1
  527. package/lib/components/ModelCompareV3/translations/zh-Hant-TW.json.js +1 -1
  528. package/lib/components/ModelCompareV3/translations/zh-Hant-TW.json.mjs +1 -1
  529. package/lib/components/PriceRangeSlider/PriceRangeSlider.types.d.ts +2 -2
  530. package/lib/components/PriceRangeSlider/PriceRangeSlider.types.js.map +1 -1
  531. package/lib/components/PriceRangeSlider/PriceRangeSlider.types.mjs.map +1 -1
  532. package/lib/components/ProductCard/ProductCard.js +1 -1
  533. package/lib/components/ProductCard/ProductCard.js.map +1 -1
  534. package/lib/components/ProductCard/ProductCard.mjs +2 -2
  535. package/lib/components/ProductCard/ProductCard.mjs.map +1 -1
  536. package/lib/components/ProductCardPopup/ProductCardPopup.js +2 -2
  537. package/lib/components/ProductCardPopup/ProductCardPopup.js.map +1 -1
  538. package/lib/components/ProductCardPopup/ProductCardPopup.mjs +2 -2
  539. package/lib/components/ProductCardPopup/ProductCardPopup.mjs.map +1 -1
  540. package/lib/components/ProductSectionNavigation/ProductSectionNavigation.styles.d.ts +1 -1
  541. package/lib/components/ProductSectionNavigationV2/ProductSectionNavigation.styles.d.ts +1 -1
  542. package/lib/components/ProductSectionTabs/ProductSectionTabs.js +6 -1
  543. package/lib/components/ProductSectionTabs/ProductSectionTabs.js.map +1 -1
  544. package/lib/components/ProductSectionTabs/ProductSectionTabs.mjs +6 -1
  545. package/lib/components/ProductSectionTabs/ProductSectionTabs.mjs.map +1 -1
  546. package/lib/components/ProductTechSpecs/ProductTechSpecs.styles.d.ts +2 -2
  547. package/lib/components/ProductWizard/ProductWizard.js +3 -3
  548. package/lib/components/ProductWizard/ProductWizard.js.map +1 -1
  549. package/lib/components/ProductWizard/ProductWizard.mjs +3 -3
  550. package/lib/components/ProductWizard/ProductWizard.mjs.map +1 -1
  551. package/lib/components/ProductWizardFootnotes/ProductWizardFootnotes.js +17 -4
  552. package/lib/components/ProductWizardFootnotes/ProductWizardFootnotes.js.map +1 -1
  553. package/lib/components/ProductWizardFootnotes/ProductWizardFootnotes.mjs +17 -4
  554. package/lib/components/ProductWizardFootnotes/ProductWizardFootnotes.mjs.map +1 -1
  555. package/lib/components/QuantityControls/QuantityControls.js +2 -2
  556. package/lib/components/QuantityControls/QuantityControls.js.map +1 -1
  557. package/lib/components/QuantityControls/QuantityControls.mjs +2 -2
  558. package/lib/components/QuantityControls/QuantityControls.mjs.map +1 -1
  559. package/lib/components/QuantityControls/QuantityControls.types.d.ts +1 -1
  560. package/lib/components/QuantityInput/QuantityInput.js +6 -1
  561. package/lib/components/QuantityInput/QuantityInput.js.map +1 -1
  562. package/lib/components/QuantityInput/QuantityInput.mjs +6 -1
  563. package/lib/components/QuantityInput/QuantityInput.mjs.map +1 -1
  564. package/lib/components/ResourceCalculatorV1/ComputeResourceCalculator/ComputeResourceCalculator.js +4 -4
  565. package/lib/components/ResourceCalculatorV1/ComputeResourceCalculator/ComputeResourceCalculator.js.map +1 -1
  566. package/lib/components/ResourceCalculatorV1/ComputeResourceCalculator/ComputeResourceCalculator.mjs +4 -4
  567. package/lib/components/ResourceCalculatorV1/ComputeResourceCalculator/ComputeResourceCalculator.mjs.map +1 -1
  568. package/lib/components/ResourceCalculatorV1/ComputeResourceCalculator/components/InputCard/InputCard.js +1 -1
  569. package/lib/components/ResourceCalculatorV1/ComputeResourceCalculator/components/InputCard/InputCard.mjs +1 -1
  570. package/lib/components/ResourceCalculatorV1/ComputeResourceCalculator/components/InputCard/assets/attention.svg.js +1 -1
  571. package/lib/components/ResourceCalculatorV1/ComputeResourceCalculator/components/InputCard/assets/attention.svg.mjs +2 -2
  572. package/lib/components/ResourceCalculatorV1/ComputeResourceCalculator/components/ProgressBarChart/ProgressBarChart.js +1 -1
  573. package/lib/components/ResourceCalculatorV1/ComputeResourceCalculator/components/ProgressBarChart/ProgressBarChart.mjs +1 -1
  574. package/lib/components/ResourceCalculatorV1/ComputeResourceCalculator/components/ProgressBarChart/assets/attention.svg.js +1 -1
  575. package/lib/components/ResourceCalculatorV1/ComputeResourceCalculator/components/ProgressBarChart/assets/attention.svg.mjs +2 -2
  576. package/lib/components/ResourceCalculatorV1/PoeCalculator/components/RecommendedPoeSwitches/RecommendedPoeSwitches.js +1 -1
  577. package/lib/components/ResourceCalculatorV1/PoeCalculator/components/RecommendedPoeSwitches/RecommendedPoeSwitches.mjs +1 -1
  578. package/lib/components/ResourceCalculatorV1/PoeCalculator/components/RecommendedPoeSwitches/assets/port.svg.js +1 -1
  579. package/lib/components/ResourceCalculatorV1/PoeCalculator/components/RecommendedPoeSwitches/assets/port.svg.mjs +2 -2
  580. package/lib/components/ScrollWrapper/ScrollWrapper.d.ts +1 -1
  581. package/lib/components/ScrollWrapper/ScrollWrapper.js +16 -8
  582. package/lib/components/ScrollWrapper/ScrollWrapper.js.map +1 -1
  583. package/lib/components/ScrollWrapper/ScrollWrapper.mjs +16 -8
  584. package/lib/components/ScrollWrapper/ScrollWrapper.mjs.map +1 -1
  585. package/lib/components/ScrollWrapper/ScrollWrapper.styles.js +87 -64
  586. package/lib/components/ScrollWrapper/ScrollWrapper.styles.js.map +1 -1
  587. package/lib/components/ScrollWrapper/ScrollWrapper.styles.mjs +87 -64
  588. package/lib/components/ScrollWrapper/ScrollWrapper.styles.mjs.map +1 -1
  589. package/lib/components/ScrollWrapper/ScrollWrapper.types.d.ts +2 -0
  590. package/lib/components/Search/Input/Input.d.ts +1 -1
  591. package/lib/components/Search/Input/Input.js +4 -4
  592. package/lib/components/Search/Input/Input.js.map +1 -1
  593. package/lib/components/Search/Input/Input.mjs +4 -4
  594. package/lib/components/Search/Input/Input.mjs.map +1 -1
  595. package/lib/components/Search/Input/Input.styles.js +0 -1
  596. package/lib/components/Search/Input/Input.styles.js.map +1 -1
  597. package/lib/components/Search/Input/Input.styles.mjs +0 -1
  598. package/lib/components/Search/Input/Input.styles.mjs.map +1 -1
  599. package/lib/components/Search/Input/Input.types.d.ts +3 -2
  600. package/lib/components/StorageSliders/StorageSliders.context.js +17 -14
  601. package/lib/components/StorageSliders/StorageSliders.context.js.map +1 -1
  602. package/lib/components/StorageSliders/StorageSliders.context.mjs +17 -14
  603. package/lib/components/StorageSliders/StorageSliders.context.mjs.map +1 -1
  604. package/lib/components/StorybookUtils/StoryFaker.js.map +1 -1
  605. package/lib/components/StorybookUtils/StoryFaker.mjs.map +1 -1
  606. package/lib/components/VariantSelector/VariantSelector.js +4 -4
  607. package/lib/components/VariantSelector/VariantSelector.js.map +1 -1
  608. package/lib/components/VariantSelector/VariantSelector.mjs +4 -4
  609. package/lib/components/VariantSelector/VariantSelector.mjs.map +1 -1
  610. package/lib/components/VideoPlayerNew/VideoPlayer.js +13 -15
  611. package/lib/components/VideoPlayerNew/VideoPlayer.js.map +1 -1
  612. package/lib/components/VideoPlayerNew/VideoPlayer.mjs +13 -15
  613. package/lib/components/VideoPlayerNew/VideoPlayer.mjs.map +1 -1
  614. package/lib/components/VideoPlayerNew/assets/pause.svg.js +1 -1
  615. package/lib/components/VideoPlayerNew/assets/pause.svg.mjs +2 -2
  616. package/lib/components/index.d.ts +1 -0
  617. package/lib/components/index.js +32 -30
  618. package/lib/components/index.js.map +1 -1
  619. package/lib/components/index.mjs +32 -30
  620. package/lib/components/index.mjs.map +1 -1
  621. package/lib/constants/address.d.ts +1 -1
  622. package/lib/constants/address.js +34 -34
  623. package/lib/constants/address.js.map +1 -1
  624. package/lib/constants/address.mjs +34 -34
  625. package/lib/constants/address.mjs.map +1 -1
  626. package/lib/constants/icons/generic/carouselArrowRight.svg.js +5 -5
  627. package/lib/constants/icons/generic/index.js +6 -6
  628. package/lib/constants/icons/generic/index.mjs +1 -1
  629. package/lib/constants/icons/generic/plus.svg.js +5 -5
  630. package/lib/constants/icons/generic/plus.svg.mjs +2 -2
  631. package/lib/constants/icons/header/account.svg.js +5 -5
  632. package/lib/constants/icons/header/globe.svg.js +5 -5
  633. package/lib/constants/icons/header/index.js +9 -9
  634. package/lib/constants/icons/header/logoUnifi.svg.js +5 -5
  635. package/lib/constants/icons/menu/consolidatedSpecialDevices.svg.js +27 -0
  636. package/lib/constants/icons/menu/consolidatedSpecialDevices.svg.js.map +1 -0
  637. package/lib/constants/icons/menu/consolidatedSpecialDevices.svg.mjs +3 -0
  638. package/lib/constants/icons/menu/consolidatedSpecialDevices.svg.mjs.map +1 -0
  639. package/lib/constants/icons/menu/doorAccess.svg.js +27 -0
  640. package/lib/constants/icons/menu/doorAccess.svg.js.map +1 -0
  641. package/lib/constants/icons/menu/doorAccess.svg.mjs +3 -0
  642. package/lib/constants/icons/menu/doorAccess.svg.mjs.map +1 -0
  643. package/lib/constants/icons/menu/index.d.ts +3 -0
  644. package/lib/constants/icons/menu/index.js +27 -0
  645. package/lib/constants/icons/menu/index.js.map +1 -1
  646. package/lib/constants/icons/menu/index.mjs +6 -0
  647. package/lib/constants/icons/menu/index.mjs.map +1 -1
  648. package/lib/constants/icons/menu/overview.svg.js +27 -0
  649. package/lib/constants/icons/menu/overview.svg.js.map +1 -0
  650. package/lib/constants/icons/menu/overview.svg.mjs +3 -0
  651. package/lib/constants/icons/menu/overview.svg.mjs.map +1 -0
  652. package/lib/constants/icons/options/colors/black.svg.js +5 -5
  653. package/lib/constants/icons/options/colors/index.js +3 -3
  654. package/lib/constants/icons/options/styles/black.svg.js +5 -5
  655. package/lib/constants/icons/options/styles/index.js +3 -3
  656. package/lib/constants/optionIcons.js +6 -6
  657. package/lib/constants/optionIcons.mjs +4 -4
  658. package/lib/constants/postalCode.js +10 -10
  659. package/lib/constants/postalCode.js.map +1 -1
  660. package/lib/constants/postalCode.mjs +10 -10
  661. package/lib/constants/postalCode.mjs.map +1 -1
  662. package/lib/constants/proStoreCategories/mapping/filters.d.ts +16 -0
  663. package/lib/constants/proStoreCategories/mapping/filters.js +16 -0
  664. package/lib/constants/proStoreCategories/mapping/filters.js.map +1 -1
  665. package/lib/constants/proStoreCategories/mapping/filters.mjs +16 -0
  666. package/lib/constants/proStoreCategories/mapping/filters.mjs.map +1 -1
  667. package/lib/constants/proStoreCategories/mapping/index.d.ts +4 -2
  668. package/lib/constants/proStoreCategories/mapping/index.js +50 -51
  669. package/lib/constants/proStoreCategories/mapping/index.js.map +1 -1
  670. package/lib/constants/proStoreCategories/mapping/index.mjs +49 -49
  671. package/lib/constants/proStoreCategories/mapping/index.mjs.map +1 -1
  672. package/lib/constants/proStoreCategories/mapping/mapping.d.ts +5 -0
  673. package/lib/constants/proStoreCategories/mapping/redirects.js +18 -3
  674. package/lib/constants/proStoreCategories/mapping/redirects.js.map +1 -1
  675. package/lib/constants/proStoreCategories/mapping/redirects.mjs +18 -3
  676. package/lib/constants/proStoreCategories/mapping/redirects.mjs.map +1 -1
  677. package/lib/constants/proStoreCategories/mapping/unifi.d.ts +9 -9
  678. package/lib/constants/proStoreCategories/mapping/unifi.js +9 -9
  679. package/lib/constants/proStoreCategories/mapping/unifi.js.map +1 -1
  680. package/lib/constants/proStoreCategories/mapping/unifi.mjs +9 -9
  681. package/lib/constants/proStoreCategories/mapping/unifi.mjs.map +1 -1
  682. package/lib/constants/proStoreCategories/translations/ar.json.js +7 -3
  683. package/lib/constants/proStoreCategories/translations/ar.json.js.map +1 -1
  684. package/lib/constants/proStoreCategories/translations/ar.json.mjs +7 -4
  685. package/lib/constants/proStoreCategories/translations/ar.json.mjs.map +1 -1
  686. package/lib/constants/proStoreCategories/translations/de.json.js +7 -3
  687. package/lib/constants/proStoreCategories/translations/de.json.js.map +1 -1
  688. package/lib/constants/proStoreCategories/translations/de.json.mjs +7 -4
  689. package/lib/constants/proStoreCategories/translations/de.json.mjs.map +1 -1
  690. package/lib/constants/proStoreCategories/translations/el.json.js +7 -3
  691. package/lib/constants/proStoreCategories/translations/el.json.js.map +1 -1
  692. package/lib/constants/proStoreCategories/translations/el.json.mjs +7 -4
  693. package/lib/constants/proStoreCategories/translations/el.json.mjs.map +1 -1
  694. package/lib/constants/proStoreCategories/translations/en.json.js +7 -3
  695. package/lib/constants/proStoreCategories/translations/en.json.js.map +1 -1
  696. package/lib/constants/proStoreCategories/translations/en.json.mjs +7 -4
  697. package/lib/constants/proStoreCategories/translations/en.json.mjs.map +1 -1
  698. package/lib/constants/proStoreCategories/translations/es.json.js +7 -3
  699. package/lib/constants/proStoreCategories/translations/es.json.js.map +1 -1
  700. package/lib/constants/proStoreCategories/translations/es.json.mjs +7 -4
  701. package/lib/constants/proStoreCategories/translations/es.json.mjs.map +1 -1
  702. package/lib/constants/proStoreCategories/translations/fr.json.js +7 -3
  703. package/lib/constants/proStoreCategories/translations/fr.json.js.map +1 -1
  704. package/lib/constants/proStoreCategories/translations/fr.json.mjs +7 -4
  705. package/lib/constants/proStoreCategories/translations/fr.json.mjs.map +1 -1
  706. package/lib/constants/proStoreCategories/translations/it.json.js +7 -3
  707. package/lib/constants/proStoreCategories/translations/it.json.js.map +1 -1
  708. package/lib/constants/proStoreCategories/translations/it.json.mjs +7 -4
  709. package/lib/constants/proStoreCategories/translations/it.json.mjs.map +1 -1
  710. package/lib/constants/proStoreCategories/translations/ja.json.js +7 -3
  711. package/lib/constants/proStoreCategories/translations/ja.json.js.map +1 -1
  712. package/lib/constants/proStoreCategories/translations/ja.json.mjs +7 -4
  713. package/lib/constants/proStoreCategories/translations/ja.json.mjs.map +1 -1
  714. package/lib/constants/proStoreCategories/translations/pt-BR.json.js +7 -3
  715. package/lib/constants/proStoreCategories/translations/pt-BR.json.js.map +1 -1
  716. package/lib/constants/proStoreCategories/translations/pt-BR.json.mjs +7 -4
  717. package/lib/constants/proStoreCategories/translations/pt-BR.json.mjs.map +1 -1
  718. package/lib/constants/proStoreCategories/translations/zh-Hans.json.js +7 -3
  719. package/lib/constants/proStoreCategories/translations/zh-Hans.json.js.map +1 -1
  720. package/lib/constants/proStoreCategories/translations/zh-Hans.json.mjs +7 -4
  721. package/lib/constants/proStoreCategories/translations/zh-Hans.json.mjs.map +1 -1
  722. package/lib/constants/proStoreCategories/translations/zh-Hant-TW.json.js +7 -3
  723. package/lib/constants/proStoreCategories/translations/zh-Hant-TW.json.js.map +1 -1
  724. package/lib/constants/proStoreCategories/translations/zh-Hant-TW.json.mjs +7 -4
  725. package/lib/constants/proStoreCategories/translations/zh-Hant-TW.json.mjs.map +1 -1
  726. package/lib/constants/proStoreFilters/mapping.d.ts +45 -3
  727. package/lib/constants/proStoreFilters/mapping.js +119 -9
  728. package/lib/constants/proStoreFilters/mapping.js.map +1 -1
  729. package/lib/constants/proStoreFilters/mapping.mjs +119 -9
  730. package/lib/constants/proStoreFilters/mapping.mjs.map +1 -1
  731. package/lib/constants/theme.js +4 -0
  732. package/lib/constants/theme.js.map +1 -1
  733. package/lib/constants/theme.mjs +4 -0
  734. package/lib/constants/theme.mjs.map +1 -1
  735. package/lib/contexts/MenuContext/context.js +28 -27
  736. package/lib/contexts/MenuContext/context.js.map +1 -1
  737. package/lib/contexts/MenuContext/context.mjs +28 -27
  738. package/lib/contexts/MenuContext/context.mjs.map +1 -1
  739. package/lib/contexts/MenuContext/mapping.js.map +1 -1
  740. package/lib/contexts/MenuContext/mapping.mjs.map +1 -1
  741. package/lib/contexts/MenuContext/types.js.map +1 -1
  742. package/lib/contexts/MenuContext/types.mjs.map +1 -1
  743. package/lib/contexts/MenuContext/utils.d.ts +6 -1
  744. package/lib/contexts/MenuContext/utils.js +16 -0
  745. package/lib/contexts/MenuContext/utils.js.map +1 -1
  746. package/lib/contexts/MenuContext/utils.mjs +16 -1
  747. package/lib/contexts/MenuContext/utils.mjs.map +1 -1
  748. package/lib/contexts/MicrositeMenuContext/assets/education.jpg.js +27 -0
  749. package/lib/contexts/MicrositeMenuContext/assets/education.jpg.js.map +1 -0
  750. package/lib/contexts/MicrositeMenuContext/assets/education.jpg.mjs +3 -0
  751. package/lib/contexts/MicrositeMenuContext/assets/education.jpg.mjs.map +1 -0
  752. package/lib/contexts/MicrositeMenuContext/assets/enterprise.jpg.js +27 -0
  753. package/lib/contexts/MicrositeMenuContext/assets/enterprise.jpg.js.map +1 -0
  754. package/lib/contexts/MicrositeMenuContext/assets/enterprise.jpg.mjs +3 -0
  755. package/lib/contexts/MicrositeMenuContext/assets/enterprise.jpg.mjs.map +1 -0
  756. package/lib/contexts/MicrositeMenuContext/assets/hospitality.jpg.js +27 -0
  757. package/lib/contexts/MicrositeMenuContext/assets/hospitality.jpg.js.map +1 -0
  758. package/lib/contexts/MicrositeMenuContext/assets/hospitality.jpg.mjs +3 -0
  759. package/lib/contexts/MicrositeMenuContext/assets/hospitality.jpg.mjs.map +1 -0
  760. package/lib/contexts/MicrositeMenuContext/assets/how-it-works.jpg.js +27 -0
  761. package/lib/contexts/MicrositeMenuContext/assets/how-it-works.jpg.js.map +1 -0
  762. package/lib/contexts/MicrositeMenuContext/assets/how-it-works.jpg.mjs +3 -0
  763. package/lib/contexts/MicrositeMenuContext/assets/how-it-works.jpg.mjs.map +1 -0
  764. package/lib/contexts/MicrositeMenuContext/assets/index.d.ts +12 -0
  765. package/lib/contexts/MicrositeMenuContext/assets/index.js +16 -0
  766. package/lib/contexts/MicrositeMenuContext/assets/index.js.map +1 -0
  767. package/lib/contexts/MicrositeMenuContext/assets/index.mjs +14 -0
  768. package/lib/contexts/MicrositeMenuContext/assets/index.mjs.map +1 -0
  769. package/lib/contexts/MicrositeMenuContext/assets/industrial.jpg.js +27 -0
  770. package/lib/contexts/MicrositeMenuContext/assets/industrial.jpg.js.map +1 -0
  771. package/lib/contexts/MicrositeMenuContext/assets/industrial.jpg.mjs +3 -0
  772. package/lib/contexts/MicrositeMenuContext/assets/industrial.jpg.mjs.map +1 -0
  773. package/lib/contexts/MicrositeMenuContext/assets/nextai-camera.jpg.js +27 -0
  774. package/lib/contexts/MicrositeMenuContext/assets/nextai-camera.jpg.js.map +1 -0
  775. package/lib/contexts/MicrositeMenuContext/assets/nextai-camera.jpg.mjs +3 -0
  776. package/lib/contexts/MicrositeMenuContext/assets/nextai-camera.jpg.mjs.map +1 -0
  777. package/lib/contexts/MicrositeMenuContext/assets/nextai-cyber.jpg.js +27 -0
  778. package/lib/contexts/MicrositeMenuContext/assets/nextai-cyber.jpg.js.map +1 -0
  779. package/lib/contexts/MicrositeMenuContext/assets/nextai-cyber.jpg.mjs +3 -0
  780. package/lib/contexts/MicrositeMenuContext/assets/nextai-cyber.jpg.mjs.map +1 -0
  781. package/lib/contexts/MicrositeMenuContext/assets/retail.jpg.js +27 -0
  782. package/lib/contexts/MicrositeMenuContext/assets/retail.jpg.js.map +1 -0
  783. package/lib/contexts/MicrositeMenuContext/assets/retail.jpg.mjs +3 -0
  784. package/lib/contexts/MicrositeMenuContext/assets/retail.jpg.mjs.map +1 -0
  785. package/lib/contexts/MicrositeMenuContext/assets/sd-wan-sase.jpg.js +27 -0
  786. package/lib/contexts/MicrositeMenuContext/assets/sd-wan-sase.jpg.js.map +1 -0
  787. package/lib/contexts/MicrositeMenuContext/assets/sd-wan-sase.jpg.mjs +3 -0
  788. package/lib/contexts/MicrositeMenuContext/assets/sd-wan-sase.jpg.mjs.map +1 -0
  789. package/lib/contexts/MicrositeMenuContext/assets/site-manager.jpg.js +27 -0
  790. package/lib/contexts/MicrositeMenuContext/assets/site-manager.jpg.js.map +1 -0
  791. package/lib/contexts/MicrositeMenuContext/assets/site-manager.jpg.mjs +3 -0
  792. package/lib/contexts/MicrositeMenuContext/assets/site-manager.jpg.mjs.map +1 -0
  793. package/lib/contexts/MicrositeMenuContext/assets/stadium.jpg.js +27 -0
  794. package/lib/contexts/MicrositeMenuContext/assets/stadium.jpg.js.map +1 -0
  795. package/lib/contexts/MicrositeMenuContext/assets/stadium.jpg.mjs +3 -0
  796. package/lib/contexts/MicrositeMenuContext/assets/stadium.jpg.mjs.map +1 -0
  797. package/lib/contexts/MicrositeMenuContext/assets/tco-calculator.jpg.js +27 -0
  798. package/lib/contexts/MicrositeMenuContext/assets/tco-calculator.jpg.js.map +1 -0
  799. package/lib/contexts/MicrositeMenuContext/assets/tco-calculator.jpg.mjs +3 -0
  800. package/lib/contexts/MicrositeMenuContext/assets/tco-calculator.jpg.mjs.map +1 -0
  801. package/lib/contexts/MicrositeMenuContext/context.d.ts +36 -0
  802. package/lib/contexts/MicrositeMenuContext/context.js +100 -0
  803. package/lib/contexts/MicrositeMenuContext/context.js.map +1 -0
  804. package/lib/contexts/MicrositeMenuContext/context.mjs +96 -0
  805. package/lib/contexts/MicrositeMenuContext/context.mjs.map +1 -0
  806. package/lib/contexts/MicrositeMenuContext/index.d.ts +1 -0
  807. package/lib/contexts/MicrositeMenuContext/index.js +8 -0
  808. package/lib/contexts/MicrositeMenuContext/index.js.map +1 -0
  809. package/lib/contexts/MicrositeMenuContext/index.mjs +3 -0
  810. package/lib/contexts/MicrositeMenuContext/index.mjs.map +1 -0
  811. package/lib/contexts/MicrositeMenuContext/mapping.d.ts +8 -0
  812. package/lib/contexts/MicrositeMenuContext/mapping.js +513 -0
  813. package/lib/contexts/MicrositeMenuContext/mapping.js.map +1 -0
  814. package/lib/contexts/MicrositeMenuContext/mapping.mjs +468 -0
  815. package/lib/contexts/MicrositeMenuContext/mapping.mjs.map +1 -0
  816. package/lib/contexts/MicrositeMenuContext/translations/ar.json.js +8 -0
  817. package/lib/contexts/MicrositeMenuContext/translations/ar.json.js.map +1 -0
  818. package/lib/contexts/MicrositeMenuContext/translations/ar.json.mjs +3 -0
  819. package/lib/contexts/MicrositeMenuContext/translations/ar.json.mjs.map +1 -0
  820. package/lib/contexts/MicrositeMenuContext/translations/de.json.js +8 -0
  821. package/lib/contexts/MicrositeMenuContext/translations/de.json.js.map +1 -0
  822. package/lib/contexts/MicrositeMenuContext/translations/de.json.mjs +3 -0
  823. package/lib/contexts/MicrositeMenuContext/translations/de.json.mjs.map +1 -0
  824. package/lib/contexts/MicrositeMenuContext/translations/el.json.js +8 -0
  825. package/lib/contexts/MicrositeMenuContext/translations/el.json.js.map +1 -0
  826. package/lib/contexts/MicrositeMenuContext/translations/el.json.mjs +3 -0
  827. package/lib/contexts/MicrositeMenuContext/translations/el.json.mjs.map +1 -0
  828. package/lib/contexts/MicrositeMenuContext/translations/en.json.js +84 -0
  829. package/lib/contexts/MicrositeMenuContext/translations/en.json.js.map +1 -0
  830. package/lib/contexts/MicrositeMenuContext/translations/en.json.mjs +79 -0
  831. package/lib/contexts/MicrositeMenuContext/translations/en.json.mjs.map +1 -0
  832. package/lib/contexts/MicrositeMenuContext/translations/es.json.js +8 -0
  833. package/lib/contexts/MicrositeMenuContext/translations/es.json.js.map +1 -0
  834. package/lib/contexts/MicrositeMenuContext/translations/es.json.mjs +3 -0
  835. package/lib/contexts/MicrositeMenuContext/translations/es.json.mjs.map +1 -0
  836. package/lib/contexts/MicrositeMenuContext/translations/fr.json.js +8 -0
  837. package/lib/contexts/MicrositeMenuContext/translations/fr.json.js.map +1 -0
  838. package/lib/contexts/MicrositeMenuContext/translations/fr.json.mjs +3 -0
  839. package/lib/contexts/MicrositeMenuContext/translations/fr.json.mjs.map +1 -0
  840. package/lib/contexts/MicrositeMenuContext/translations/it.json.js +8 -0
  841. package/lib/contexts/MicrositeMenuContext/translations/it.json.js.map +1 -0
  842. package/lib/contexts/MicrositeMenuContext/translations/it.json.mjs +3 -0
  843. package/lib/contexts/MicrositeMenuContext/translations/it.json.mjs.map +1 -0
  844. package/lib/contexts/MicrositeMenuContext/translations/ja.json.js +8 -0
  845. package/lib/contexts/MicrositeMenuContext/translations/ja.json.js.map +1 -0
  846. package/lib/contexts/MicrositeMenuContext/translations/ja.json.mjs +3 -0
  847. package/lib/contexts/MicrositeMenuContext/translations/ja.json.mjs.map +1 -0
  848. package/lib/contexts/MicrositeMenuContext/translations/pt-BR.json.js +8 -0
  849. package/lib/contexts/MicrositeMenuContext/translations/pt-BR.json.js.map +1 -0
  850. package/lib/contexts/MicrositeMenuContext/translations/pt-BR.json.mjs +3 -0
  851. package/lib/contexts/MicrositeMenuContext/translations/pt-BR.json.mjs.map +1 -0
  852. package/lib/contexts/MicrositeMenuContext/translations/zh-Hans.json.js +8 -0
  853. package/lib/contexts/MicrositeMenuContext/translations/zh-Hans.json.js.map +1 -0
  854. package/lib/contexts/MicrositeMenuContext/translations/zh-Hans.json.mjs +3 -0
  855. package/lib/contexts/MicrositeMenuContext/translations/zh-Hans.json.mjs.map +1 -0
  856. package/lib/contexts/MicrositeMenuContext/translations/zh-Hant-TW.json.js +8 -0
  857. package/lib/contexts/MicrositeMenuContext/translations/zh-Hant-TW.json.js.map +1 -0
  858. package/lib/contexts/MicrositeMenuContext/translations/zh-Hant-TW.json.mjs +3 -0
  859. package/lib/contexts/MicrositeMenuContext/translations/zh-Hant-TW.json.mjs.map +1 -0
  860. package/lib/contexts/MicrositeMenuContext/translations.d.ts +7 -0
  861. package/lib/contexts/MicrositeMenuContext/translations.js +47 -0
  862. package/lib/contexts/MicrositeMenuContext/translations.js.map +1 -0
  863. package/lib/contexts/MicrositeMenuContext/translations.mjs +25 -0
  864. package/lib/contexts/MicrositeMenuContext/translations.mjs.map +1 -0
  865. package/lib/contexts/MicrositeMenuContext/types.d.ts +100 -0
  866. package/lib/contexts/MicrositeMenuContext/types.js +16 -0
  867. package/lib/contexts/MicrositeMenuContext/types.js.map +1 -0
  868. package/lib/contexts/MicrositeMenuContext/types.mjs +15 -0
  869. package/lib/contexts/MicrositeMenuContext/types.mjs.map +1 -0
  870. package/lib/contexts/index.d.ts +1 -0
  871. package/lib/contexts/index.js +2 -0
  872. package/lib/contexts/index.js.map +1 -1
  873. package/lib/contexts/index.mjs +2 -0
  874. package/lib/contexts/index.mjs.map +1 -1
  875. package/lib/helpers/ux.d.ts +8 -11
  876. package/lib/helpers/ux.js +15 -4
  877. package/lib/helpers/ux.js.map +1 -1
  878. package/lib/helpers/ux.mjs +15 -4
  879. package/lib/helpers/ux.mjs.map +1 -1
  880. package/lib/hooks/useScrollToY.js.map +1 -1
  881. package/lib/hooks/useScrollToY.mjs.map +1 -1
  882. package/lib/utils/collectionSlug.js +2 -2
  883. package/lib/utils/collectionSlug.js.map +1 -1
  884. package/lib/utils/collectionSlug.mjs +2 -2
  885. package/lib/utils/collectionSlug.mjs.map +1 -1
  886. package/lib/utils/errors.js.map +1 -1
  887. package/lib/utils/errors.mjs.map +1 -1
  888. package/lib/utils/measures.js +1 -0
  889. package/lib/utils/measures.js.map +1 -1
  890. package/lib/utils/measures.mjs +1 -0
  891. package/lib/utils/measures.mjs.map +1 -1
  892. package/lib/utils/money/format.js.map +1 -1
  893. package/lib/utils/money/format.mjs.map +1 -1
  894. package/lib/utils/money/misc.js +1 -1
  895. package/lib/utils/money/misc.js.map +1 -1
  896. package/lib/utils/money/misc.mjs +1 -1
  897. package/lib/utils/money/misc.mjs.map +1 -1
  898. package/lib/utils/nextjs/ssr/transform-css-module.js.map +1 -1
  899. package/lib/utils/nextjs/ssr/transform-css-module.mjs.map +1 -1
  900. package/lib/utils/number.js.map +1 -1
  901. package/lib/utils/number.mjs.map +1 -1
  902. package/lib/utils/product.js +4 -4
  903. package/lib/utils/product.js.map +1 -1
  904. package/lib/utils/product.mjs +4 -4
  905. package/lib/utils/product.mjs.map +1 -1
  906. package/lib/utils/tags.js +2 -2
  907. package/lib/utils/tags.js.map +1 -1
  908. package/lib/utils/tags.mjs +2 -2
  909. package/lib/utils/tags.mjs.map +1 -1
  910. package/package.json +1 -1
  911. package/lib/assets/icons/menu/icon-globe.svg.js.map +0 -1
  912. package/lib/assets/icons/menu/icon-globe.svg.mjs +0 -3
  913. package/lib/assets/icons/menu/icon-globe.svg.mjs.map +0 -1
  914. package/lib/components/MobileModal/assets/arrowDown.svg.mjs +0 -3
  915. /package/lib/{components/MobileModal/assets → assets/icons}/arrowDown.svg.js.map +0 -0
  916. /package/lib/{components/MobileModal/assets → assets/icons}/arrowDown.svg.mjs.map +0 -0
@@ -1,6 +1,8 @@
1
1
  'use strict';
2
2
 
3
3
  var index = require('./MenuContext/index.js');
4
+ var index$1 = require('./MicrositeMenuContext/index.js');
4
5
  "use strict";
5
6
  exports.MenuContext = index;
7
+ exports.MicrositeMenuContext = index$1;
6
8
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;"}
1
+ {"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;"}
@@ -1,4 +1,6 @@
1
1
  import * as index from './MenuContext/index.mjs';
2
2
  export { index as MenuContext };
3
+ import * as index$1 from './MicrositeMenuContext/index.mjs';
4
+ export { index$1 as MicrositeMenuContext };
3
5
  "use strict";
4
6
  //# sourceMappingURL=index.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.mjs","sources":[],"sourcesContent":[],"names":[],"mappings":";;"}
1
+ {"version":3,"file":"index.mjs","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;"}
@@ -1,4 +1,3 @@
1
- import type { FlattenSimpleInterpolation } from "styled-components";
2
1
  /**
3
2
  * Same as `window.scrollTo` but allows custom duration
4
3
  *
@@ -14,17 +13,15 @@ export declare const scrollToY: (targetY: number, duration: number) => void;
14
13
  * @todo use Element.scrollIntoView() or Element.scrollIntoViewIfNeeded() when it's fully supported
15
14
  */
16
15
  export declare const scrollIntoView: (element: Element | null, duration?: number) => void;
17
- /**
18
- * For use in styled components to reduce switch noise
19
- *
20
- * @deprecated Let's replace this with native switches - if ain't broke...
21
- * @example styledSwitch(variableWithMultipleCases, {
22
- * whenValueIsX: css`background: red;`,
23
- * whenValueIsY: css`background: blue;`,
24
- * })
25
- */
26
- export declare function styledSwitch(value: string, cases: Record<string, FlattenSimpleInterpolation | string>): string | FlattenSimpleInterpolation | undefined;
27
16
  /**
28
17
  * Get true page offset Y summing own and all parent offsets
29
18
  */
30
19
  export declare const getTrueOffsetY: (el: HTMLElement) => number;
20
+ /**
21
+ * Get true element width and height, including all margins and paddings.
22
+ * Uses computed styles, and supports only margins that use px.
23
+ */
24
+ export declare const getTrueSize: (el: HTMLElement) => {
25
+ width: number;
26
+ height: number;
27
+ };
package/lib/helpers/ux.js CHANGED
@@ -36,9 +36,6 @@ const scrollIntoView = (element, duration = SCROLL_INTO_VIEW_DEFAULT_DURATION) =
36
36
  const y = elementWindowY - window.innerHeight * (1 / 3);
37
37
  scrollToY(y, duration);
38
38
  };
39
- function styledSwitch(value, cases) {
40
- return cases[value];
41
- }
42
39
  const getTrueOffsetY = el => {
43
40
  let offset = el.offsetTop;
44
41
  if (el.parentElement) {
@@ -46,8 +43,22 @@ const getTrueOffsetY = el => {
46
43
  }
47
44
  return offset;
48
45
  };
46
+ const getTrueSize = el => {
47
+ if (typeof window === "undefined") {
48
+ return {
49
+ width: 0,
50
+ height: 0
51
+ };
52
+ }
53
+ const style = window.getComputedStyle(el);
54
+ const px = value => /^\d+px$/.test(value) ? parseFloat(value) : 0;
55
+ return {
56
+ width: el.offsetWidth + px(style.marginLeft) + px(style.marginRight),
57
+ height: el.offsetHeight + px(style.marginTop) + px(style.marginBottom)
58
+ };
59
+ };
49
60
  exports.getTrueOffsetY = getTrueOffsetY;
61
+ exports.getTrueSize = getTrueSize;
50
62
  exports.scrollIntoView = scrollIntoView;
51
63
  exports.scrollToY = scrollToY;
52
- exports.styledSwitch = styledSwitch;
53
64
  //# sourceMappingURL=ux.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"ux.js","sources":["../../src/helpers/ux.ts"],"sourcesContent":["import type { FlattenSimpleInterpolation } from \"styled-components\";\n\nconst SCROLL_INTO_VIEW_DEFAULT_DURATION = 600;\n\n/**\n * Same as `window.scrollTo` but allows custom duration\n *\n * ! The scroll action won't be replaced if called multiple times\n * ? Instead `useScrollToY` hook will do that if needed\n */\nexport const scrollToY = (targetY: number, duration: number) => {\n let start: number;\n let previousTimeStamp: number;\n const initY = window.scrollY;\n const limit =\n document.documentElement.scrollHeight -\n document.documentElement.clientHeight;\n\n function step(timestamp: number) {\n if (start === undefined) {\n start = timestamp;\n }\n const elapsed = timestamp - start;\n const progress = (timestamp - start) / duration;\n\n if (previousTimeStamp !== timestamp) {\n window.scroll({\n top: ((targetY > limit ? limit : targetY) - initY) * progress + initY,\n });\n }\n\n if (elapsed < duration) {\n previousTimeStamp = timestamp;\n window.requestAnimationFrame(step);\n } else {\n window.scroll({\n top: targetY,\n });\n }\n }\n\n window.requestAnimationFrame(step);\n};\n\n/**\n * Scrolls to the element on the page\n *\n * ! This will scroll the entire page, do not use for inline scrolling\n *\n * @todo use Element.scrollIntoView() or Element.scrollIntoViewIfNeeded() when it's fully supported\n */\nexport const scrollIntoView = (\n element: Element | null,\n duration = SCROLL_INTO_VIEW_DEFAULT_DURATION,\n) => {\n if (typeof window === \"undefined\") return;\n if (!element) return;\n\n // Get scroll y target position\n const elementWindowY = element.getBoundingClientRect().top + window.scrollY;\n // Scroll to the element minus one third of the window height (so that it's at an optimal eye level)\n const y = elementWindowY - window.innerHeight * (1 / 3);\n\n // Animate\n scrollToY(y, duration);\n};\n\n/**\n * For use in styled components to reduce switch noise\n *\n * @deprecated Let's replace this with native switches - if ain't broke...\n * @example styledSwitch(variableWithMultipleCases, {\n * whenValueIsX: css`background: red;`,\n * whenValueIsY: css`background: blue;`,\n * })\n */\nexport function styledSwitch(\n value: string,\n cases: Record<string, FlattenSimpleInterpolation | string>,\n) {\n return cases[value];\n}\n\n/**\n * Get true page offset Y summing own and all parent offsets\n */\nexport const getTrueOffsetY = (el: HTMLElement) => {\n let offset = el.offsetTop;\n\n if (el.parentElement) {\n offset += getTrueOffsetY(el.parentElement);\n }\n\n return offset;\n};\n"],"names":["SCROLL_INTO_VIEW_DEFAULT_DURATION","scrollToY","targetY","duration","start","previousTimeStamp","initY","window","scrollY","limit","document","documentElement","scrollHeight","clientHeight","step","timestamp","elapsed","progress","scroll","top","requestAnimationFrame","scrollIntoView","element","elementWindowY","getBoundingClientRect","y","innerHeight","styledSwitch","value","cases","getTrueOffsetY","el","offset","offsetTop","parentElement"],"mappings":";;;AAEA,MAAMA,iCAAoC,GAAA,GAAA;AAQ7B,MAAAC,SAAA,GAAYA,CAACC,OAAA,EAAiBC,QAAqB,KAAA;EAC1D,IAAAC,KAAA;EACA,IAAAC,iBAAA;EACJ,MAAMC,QAAQC,MAAO,CAAAC,OAAA;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AAA;EACjD,IAAIC,SAASD,EAAG,CAAAE,SAAA;EAEhB,IAAIF,GAAGG,aAAe,EAAA;IACVF,MAAA,IAAAF,cAAA,CAAeC,GAAGG,aAAa,CAAA;EAC3C;EAEO,OAAAF,MAAA;AACT,CAAA;;;;"}
1
+ {"version":3,"file":"ux.js","sources":["../../src/helpers/ux.ts"],"sourcesContent":["const SCROLL_INTO_VIEW_DEFAULT_DURATION = 600;\n\n/**\n * Same as `window.scrollTo` but allows custom duration\n *\n * ! The scroll action won't be replaced if called multiple times\n * ? Instead `useScrollToY` hook will do that if needed\n */\nexport const scrollToY = (targetY: number, duration: number) => {\n let start: number | undefined;\n let previousTimeStamp: number;\n const initY = window.scrollY;\n const limit =\n document.documentElement.scrollHeight -\n document.documentElement.clientHeight;\n\n function step(timestamp: number) {\n if (start === undefined) {\n start = timestamp;\n }\n const elapsed = timestamp - start;\n const progress = (timestamp - start) / duration;\n\n if (previousTimeStamp !== timestamp) {\n window.scroll({\n top: ((targetY > limit ? limit : targetY) - initY) * progress + initY,\n });\n }\n\n if (elapsed < duration) {\n previousTimeStamp = timestamp;\n window.requestAnimationFrame(step);\n } else {\n window.scroll({\n top: targetY,\n });\n }\n }\n\n window.requestAnimationFrame(step);\n};\n\n/**\n * Scrolls to the element on the page\n *\n * ! This will scroll the entire page, do not use for inline scrolling\n *\n * @todo use Element.scrollIntoView() or Element.scrollIntoViewIfNeeded() when it's fully supported\n */\nexport const scrollIntoView = (\n element: Element | null,\n duration = SCROLL_INTO_VIEW_DEFAULT_DURATION,\n) => {\n if (typeof window === \"undefined\") return;\n if (!element) return;\n\n // Get scroll y target position\n const elementWindowY = element.getBoundingClientRect().top + window.scrollY;\n // Scroll to the element minus one third of the window height (so that it's at an optimal eye level)\n const y = elementWindowY - window.innerHeight * (1 / 3);\n\n // Animate\n scrollToY(y, duration);\n};\n\n/**\n * Get true page offset Y summing own and all parent offsets\n */\nexport const getTrueOffsetY = (el: HTMLElement) => {\n let offset = el.offsetTop;\n\n if (el.parentElement) {\n offset += getTrueOffsetY(el.parentElement);\n }\n\n return offset;\n};\n\n/**\n * Get true element width and height, including all margins and paddings.\n * Uses computed styles, and supports only margins that use px.\n */\nexport const getTrueSize = (\n el: HTMLElement,\n): { width: number; height: number } => {\n if (typeof window === \"undefined\") {\n return { width: 0, height: 0 };\n }\n\n const style = window.getComputedStyle(el);\n const px = (value: string): number =>\n /^\\d+px$/.test(value) ? parseFloat(value) : 0;\n\n return {\n width: el.offsetWidth + px(style.marginLeft) + px(style.marginRight),\n height: el.offsetHeight + px(style.marginTop) + px(style.marginBottom),\n };\n};\n"],"names":["SCROLL_INTO_VIEW_DEFAULT_DURATION","scrollToY","targetY","duration","start","previousTimeStamp","initY","window","scrollY","limit","document","documentElement","scrollHeight","clientHeight","step","timestamp","elapsed","progress","scroll","top","requestAnimationFrame","scrollIntoView","element","elementWindowY","getBoundingClientRect","y","innerHeight","getTrueOffsetY","el","offset","offsetTop","parentElement","getTrueSize","width","height","style","getComputedStyle","px","value","test","parseFloat","offsetWidth","marginLeft","marginRight","offsetHeight","marginTop","marginBottom"],"mappings":";;;AAAA,MAAMA,iCAAoC,GAAA,GAAA;AAQ7B,MAAAC,SAAA,GAAYA,CAACC,OAAA,EAAiBC,QAAqB,KAAA;EAC1D,IAAAC,KAAA;EACA,IAAAC,iBAAA;EACJ,MAAMC,QAAQC,MAAO,CAAAC,OAAA;EACrB,MAAMC,KACJ,GAAAC,QAAA,CAASC,eAAgB,CAAAC,YAAA,GACzBF,SAASC,eAAgB,CAAAE,YAAA;EAE3B,SAASC,KAAKC,SAAmB,EAAA;IAC/B,IAAIX,UAAU,KAAW,CAAA,EAAA;MACfA,KAAA,GAAAW,SAAA;IACV;IACA,MAAMC,UAAUD,SAAY,GAAAX,KAAA;IACtB,MAAAa,QAAA,GAAA,CAAYF,YAAYX,KAAS,IAAAD,QAAA;IAEvC,IAAIE,sBAAsBU,SAAW,EAAA;MACnCR,MAAA,CAAOW,MAAO,CAAA;QACZC,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,KAAK,CAAA,GAAIE,UAAW,CAAAF,KAAK,CAAI,GAAA,CAAA;EAEvC,OAAA;IACLL,KAAA,EAAOL,GAAGa,WAAc,GAAAJ,EAAA,CAAGF,MAAMO,UAAU,CAAA,GAAIL,EAAG,CAAAF,KAAA,CAAMQ,WAAW,CAAA;IACnET,MAAA,EAAQN,GAAGgB,YAAe,GAAAP,EAAA,CAAGF,MAAMU,SAAS,CAAA,GAAIR,EAAG,CAAAF,KAAA,CAAMW,YAAY;EAAA,CACvE;AACF,CAAA;;;;"}
@@ -35,9 +35,6 @@ const scrollIntoView = (element, duration = SCROLL_INTO_VIEW_DEFAULT_DURATION) =
35
35
  const y = elementWindowY - window.innerHeight * (1 / 3);
36
36
  scrollToY(y, duration);
37
37
  };
38
- function styledSwitch(value, cases) {
39
- return cases[value];
40
- }
41
38
  const getTrueOffsetY = el => {
42
39
  let offset = el.offsetTop;
43
40
  if (el.parentElement) {
@@ -45,5 +42,19 @@ const getTrueOffsetY = el => {
45
42
  }
46
43
  return offset;
47
44
  };
48
- export { getTrueOffsetY, scrollIntoView, scrollToY, styledSwitch };
45
+ const getTrueSize = el => {
46
+ if (typeof window === "undefined") {
47
+ return {
48
+ width: 0,
49
+ height: 0
50
+ };
51
+ }
52
+ const style = window.getComputedStyle(el);
53
+ const px = value => /^\d+px$/.test(value) ? parseFloat(value) : 0;
54
+ return {
55
+ width: el.offsetWidth + px(style.marginLeft) + px(style.marginRight),
56
+ height: el.offsetHeight + px(style.marginTop) + px(style.marginBottom)
57
+ };
58
+ };
59
+ export { getTrueOffsetY, getTrueSize, scrollIntoView, scrollToY };
49
60
  //# sourceMappingURL=ux.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"ux.mjs","sources":["../../src/helpers/ux.ts"],"sourcesContent":["import type { FlattenSimpleInterpolation } from \"styled-components\";\n\nconst SCROLL_INTO_VIEW_DEFAULT_DURATION = 600;\n\n/**\n * Same as `window.scrollTo` but allows custom duration\n *\n * ! The scroll action won't be replaced if called multiple times\n * ? Instead `useScrollToY` hook will do that if needed\n */\nexport const scrollToY = (targetY: number, duration: number) => {\n let start: number;\n let previousTimeStamp: number;\n const initY = window.scrollY;\n const limit =\n document.documentElement.scrollHeight -\n document.documentElement.clientHeight;\n\n function step(timestamp: number) {\n if (start === undefined) {\n start = timestamp;\n }\n const elapsed = timestamp - start;\n const progress = (timestamp - start) / duration;\n\n if (previousTimeStamp !== timestamp) {\n window.scroll({\n top: ((targetY > limit ? limit : targetY) - initY) * progress + initY,\n });\n }\n\n if (elapsed < duration) {\n previousTimeStamp = timestamp;\n window.requestAnimationFrame(step);\n } else {\n window.scroll({\n top: targetY,\n });\n }\n }\n\n window.requestAnimationFrame(step);\n};\n\n/**\n * Scrolls to the element on the page\n *\n * ! This will scroll the entire page, do not use for inline scrolling\n *\n * @todo use Element.scrollIntoView() or Element.scrollIntoViewIfNeeded() when it's fully supported\n */\nexport const scrollIntoView = (\n element: Element | null,\n duration = SCROLL_INTO_VIEW_DEFAULT_DURATION,\n) => {\n if (typeof window === \"undefined\") return;\n if (!element) return;\n\n // Get scroll y target position\n const elementWindowY = element.getBoundingClientRect().top + window.scrollY;\n // Scroll to the element minus one third of the window height (so that it's at an optimal eye level)\n const y = elementWindowY - window.innerHeight * (1 / 3);\n\n // Animate\n scrollToY(y, duration);\n};\n\n/**\n * For use in styled components to reduce switch noise\n *\n * @deprecated Let's replace this with native switches - if ain't broke...\n * @example styledSwitch(variableWithMultipleCases, {\n * whenValueIsX: css`background: red;`,\n * whenValueIsY: css`background: blue;`,\n * })\n */\nexport function styledSwitch(\n value: string,\n cases: Record<string, FlattenSimpleInterpolation | string>,\n) {\n return cases[value];\n}\n\n/**\n * Get true page offset Y summing own and all parent offsets\n */\nexport const getTrueOffsetY = (el: HTMLElement) => {\n let offset = el.offsetTop;\n\n if (el.parentElement) {\n offset += getTrueOffsetY(el.parentElement);\n }\n\n return offset;\n};\n"],"names":["SCROLL_INTO_VIEW_DEFAULT_DURATION","scrollToY","targetY","duration","start","previousTimeStamp","initY","window","scrollY","limit","document","documentElement","scrollHeight","clientHeight","step","timestamp","elapsed","progress","scroll","top","requestAnimationFrame","scrollIntoView","element","elementWindowY","getBoundingClientRect","y","innerHeight","styledSwitch","value","cases","getTrueOffsetY","el","offset","offsetTop","parentElement"],"mappings":";;AAEA,MAAMA,iCAAoC,GAAA,GAAA;AAQ7B,MAAAC,SAAA,GAAYA,CAACC,OAAA,EAAiBC,QAAqB,KAAA;EAC1D,IAAAC,KAAA;EACA,IAAAC,iBAAA;EACJ,MAAMC,QAAQC,MAAO,CAAAC,OAAA;EACrB,MAAMC,KACJ,GAAAC,QAAA,CAASC,eAAgB,CAAAC,YAAA,GACzBF,SAASC,eAAgB,CAAAE,YAAA;EAE3B,SAASC,KAAKC,SAAmB,EAAA;IAC/B,IAAIX,UAAU,KAAW,CAAA,EAAA;MACfA,KAAA,GAAAW,SAAA;IACV;IACA,MAAMC,UAAUD,SAAY,GAAAX,KAAA;IACtB,MAAAa,QAAA,GAAA,CAAYF,YAAYX,KAAS,IAAAD,QAAA;IAEvC,IAAIE,sBAAsBU,SAAW,EAAA;MACnCR,MAAA,CAAOW,MAAO,CAAA;QACZC,OAAOjB,OAAU,GAAAO,KAAA,GAAQA,KAAQ,GAAAP,OAAA,IAAWI,SAASW,QAAW,GAAAX;MAAA,CACjE,CAAA;IACH;IAEA,IAAIU,UAAUb,QAAU,EAAA;MACFE,iBAAA,GAAAU,SAAA;MACpBR,MAAA,CAAOa,sBAAsBN,IAAI,CAAA;IAAA,CAC5B,MAAA;MACLP,MAAA,CAAOW,MAAO,CAAA;QACZC,GAAK,EAAAjB;MAAA,CACN,CAAA;IACH;EACF;EAEAK,MAAA,CAAOa,sBAAsBN,IAAI,CAAA;AACnC,CAAA;AASO,MAAMO,cAAiB,GAAAA,CAC5BC,OACA,EAAAnB,QAAA,GAAWH,iCACR,KAAA;EACC,IAAA,OAAOO,WAAW,WAAa,EAAA;EACnC,IAAI,CAACe,OAAS,EAAA;EAGd,MAAMC,cAAiB,GAAAD,OAAA,CAAQE,qBAAsB,CAAA,CAAA,CAAEL,MAAMZ,MAAO,CAAAC,OAAA;EAEpE,MAAMiB,CAAI,GAAAF,cAAA,GAAiBhB,MAAO,CAAAmB,WAAA,IAAe,CAAI,GAAA,CAAA,CAAA;EAGrDzB,SAAA,CAAUwB,GAAGtB,QAAQ,CAAA;AACvB,CAAA;AAWgB,SAAAwB,YAAAA,CACdC,OACAC,KACA,EAAA;EACA,OAAOA,MAAMD,KAAK,CAAA;AACpB;AAKa,MAAAE,cAAA,GAAkBC,EAAoB,IAAA;EACjD,IAAIC,SAASD,EAAG,CAAAE,SAAA;EAEhB,IAAIF,GAAGG,aAAe,EAAA;IACVF,MAAA,IAAAF,cAAA,CAAeC,GAAGG,aAAa,CAAA;EAC3C;EAEO,OAAAF,MAAA;AACT,CAAA;"}
1
+ {"version":3,"file":"ux.mjs","sources":["../../src/helpers/ux.ts"],"sourcesContent":["const SCROLL_INTO_VIEW_DEFAULT_DURATION = 600;\n\n/**\n * Same as `window.scrollTo` but allows custom duration\n *\n * ! The scroll action won't be replaced if called multiple times\n * ? Instead `useScrollToY` hook will do that if needed\n */\nexport const scrollToY = (targetY: number, duration: number) => {\n let start: number | undefined;\n let previousTimeStamp: number;\n const initY = window.scrollY;\n const limit =\n document.documentElement.scrollHeight -\n document.documentElement.clientHeight;\n\n function step(timestamp: number) {\n if (start === undefined) {\n start = timestamp;\n }\n const elapsed = timestamp - start;\n const progress = (timestamp - start) / duration;\n\n if (previousTimeStamp !== timestamp) {\n window.scroll({\n top: ((targetY > limit ? limit : targetY) - initY) * progress + initY,\n });\n }\n\n if (elapsed < duration) {\n previousTimeStamp = timestamp;\n window.requestAnimationFrame(step);\n } else {\n window.scroll({\n top: targetY,\n });\n }\n }\n\n window.requestAnimationFrame(step);\n};\n\n/**\n * Scrolls to the element on the page\n *\n * ! This will scroll the entire page, do not use for inline scrolling\n *\n * @todo use Element.scrollIntoView() or Element.scrollIntoViewIfNeeded() when it's fully supported\n */\nexport const scrollIntoView = (\n element: Element | null,\n duration = SCROLL_INTO_VIEW_DEFAULT_DURATION,\n) => {\n if (typeof window === \"undefined\") return;\n if (!element) return;\n\n // Get scroll y target position\n const elementWindowY = element.getBoundingClientRect().top + window.scrollY;\n // Scroll to the element minus one third of the window height (so that it's at an optimal eye level)\n const y = elementWindowY - window.innerHeight * (1 / 3);\n\n // Animate\n scrollToY(y, duration);\n};\n\n/**\n * Get true page offset Y summing own and all parent offsets\n */\nexport const getTrueOffsetY = (el: HTMLElement) => {\n let offset = el.offsetTop;\n\n if (el.parentElement) {\n offset += getTrueOffsetY(el.parentElement);\n }\n\n return offset;\n};\n\n/**\n * Get true element width and height, including all margins and paddings.\n * Uses computed styles, and supports only margins that use px.\n */\nexport const getTrueSize = (\n el: HTMLElement,\n): { width: number; height: number } => {\n if (typeof window === \"undefined\") {\n return { width: 0, height: 0 };\n }\n\n const style = window.getComputedStyle(el);\n const px = (value: string): number =>\n /^\\d+px$/.test(value) ? parseFloat(value) : 0;\n\n return {\n width: el.offsetWidth + px(style.marginLeft) + px(style.marginRight),\n height: el.offsetHeight + px(style.marginTop) + px(style.marginBottom),\n };\n};\n"],"names":["SCROLL_INTO_VIEW_DEFAULT_DURATION","scrollToY","targetY","duration","start","previousTimeStamp","initY","window","scrollY","limit","document","documentElement","scrollHeight","clientHeight","step","timestamp","elapsed","progress","scroll","top","requestAnimationFrame","scrollIntoView","element","elementWindowY","getBoundingClientRect","y","innerHeight","getTrueOffsetY","el","offset","offsetTop","parentElement","getTrueSize","width","height","style","getComputedStyle","px","value","test","parseFloat","offsetWidth","marginLeft","marginRight","offsetHeight","marginTop","marginBottom"],"mappings":";;AAAA,MAAMA,iCAAoC,GAAA,GAAA;AAQ7B,MAAAC,SAAA,GAAYA,CAACC,OAAA,EAAiBC,QAAqB,KAAA;EAC1D,IAAAC,KAAA;EACA,IAAAC,iBAAA;EACJ,MAAMC,QAAQC,MAAO,CAAAC,OAAA;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,MAAA,IAAAF,cAAA,CAAeC,GAAGG,aAAa,CAAA;EAC3C;EAEO,OAAAF,MAAA;AACT,CAAA;AAMa,MAAAG,WAAA,GACXJ,EACsC,IAAA;EAClC,IAAA,OAAOrB,WAAW,WAAa,EAAA;IACjC,OAAO;MAAE0B,KAAA,EAAO,CAAG;MAAAC,MAAA,EAAQ;IAAE,CAAA;EAC/B;EAEM,MAAAC,KAAA,GAAQ5B,MAAO,CAAA6B,gBAAA,CAAiBR,EAAE,CAAA;EAClC,MAAAS,EAAA,GAAMC,KACV,IAAA,SAAA,CAAUC,KAAKD,KAAK,CAAA,GAAIE,UAAW,CAAAF,KAAK,CAAI,GAAA,CAAA;EAEvC,OAAA;IACLL,KAAA,EAAOL,GAAGa,WAAc,GAAAJ,EAAA,CAAGF,MAAMO,UAAU,CAAA,GAAIL,EAAG,CAAAF,KAAA,CAAMQ,WAAW,CAAA;IACnET,MAAA,EAAQN,GAAGgB,YAAe,GAAAP,EAAA,CAAGF,MAAMU,SAAS,CAAA,GAAIR,EAAG,CAAAF,KAAA,CAAMW,YAAY;EAAA,CACvE;AACF,CAAA;"}
@@ -1 +1 @@
1
- {"version":3,"file":"useScrollToY.js","sources":["../../src/hooks/useScrollToY.tsx"],"sourcesContent":["import { useRef } from \"react\";\n\nexport interface ScrollToYOptions {\n targetY: number;\n duration: number;\n callback?: () => void;\n}\n\nexport const useScrollToY = () => {\n const rafRef = useRef(0);\n\n const cancelScrollToY = () => {\n window.cancelAnimationFrame(rafRef.current);\n };\n\n const scrollToY = ({ targetY, duration, callback }: ScrollToYOptions) => {\n // Clear existing raf\n cancelScrollToY();\n\n // Calc positions\n let start: number;\n let previousTimeStamp: number;\n const initY = window.scrollY;\n const limit =\n document.documentElement.scrollHeight -\n document.documentElement.clientHeight;\n\n function step(timestamp: number) {\n if (start === undefined) {\n start = timestamp;\n }\n const elapsed = timestamp - start;\n const progress = (timestamp - start) / duration;\n\n if (previousTimeStamp !== timestamp) {\n window.scroll({\n top: ((targetY > limit ? limit : targetY) - initY) * progress + initY,\n });\n }\n\n if (elapsed < duration) {\n // Loop self until done\n previousTimeStamp = timestamp;\n rafRef.current = window.requestAnimationFrame(step);\n } else {\n window.scroll({\n top: targetY,\n });\n callback?.();\n }\n }\n\n rafRef.current = window.requestAnimationFrame(step);\n };\n\n return {\n scrollToY,\n cancelScrollToY,\n };\n};\n"],"names":["useScrollToY","rafRef","useRef","cancelScrollToY","window","cancelAnimationFrame","current","scrollToY","targetY","duration","callback","start","previousTimeStamp","initY","scrollY","limit","document","documentElement","scrollHeight","clientHeight","step","timestamp","elapsed","progress","scroll","top","requestAnimationFrame"],"mappings":";;;;AAQO,MAAMA,eAAeA,CAAA,KAAM;EAC1B,MAAAC,MAAA,GAASC,aAAO,CAAC,CAAA;EAEvB,MAAMC,kBAAkBA,CAAA,KAAM;IACrBC,MAAA,CAAAC,oBAAA,CAAqBJ,OAAOK,OAAO,CAAA;EAAA,CAC5C;EAEA,MAAMC,YAAYA,CAAC;IAAEC,OAAS;IAAAC,QAAA;IAAUC;GAAiC,KAAA;IAEvDP,eAAA,EAAA;IAGZ,IAAAQ,KAAA;IACA,IAAAC,iBAAA;IACJ,MAAMC,QAAQT,MAAO,CAAAU,OAAA;IACrB,MAAMC,KACJ,GAAAC,QAAA,CAASC,eAAgB,CAAAC,YAAA,GACzBF,SAASC,eAAgB,CAAAE,YAAA;IAE3B,SAASC,KAAKC,SAAmB,EAAA;MAC/B,IAAIV,UAAU,KAAW,CAAA,EAAA;QACfA,KAAA,GAAAU,SAAA;MACV;MACA,MAAMC,UAAUD,SAAY,GAAAV,KAAA;MACtB,MAAAY,QAAA,GAAA,CAAYF,YAAYV,KAAS,IAAAF,QAAA;MAEvC,IAAIG,sBAAsBS,SAAW,EAAA;QACnCjB,MAAA,CAAOoB,MAAO,CAAA;UACZC,OAAOjB,OAAU,GAAAO,KAAA,GAAQA,KAAQ,GAAAP,OAAA,IAAWK,SAASU,QAAW,GAAAV;QAAA,CACjE,CAAA;MACH;MAEA,IAAIS,UAAUb,QAAU,EAAA;QAEFG,iBAAA,GAAAS,SAAA;QACbpB,MAAA,CAAAK,OAAA,GAAUF,MAAO,CAAAsB,qBAAA,CAAsBN,IAAI,CAAA;MAAA,CAC7C,MAAA;QACLhB,MAAA,CAAOoB,MAAO,CAAA;UACZC,GAAK,EAAAjB;QAAA,CACN,CAAA;QACUE,QAAA,IAAA;MACb;IACF;IAEOT,MAAA,CAAAK,OAAA,GAAUF,MAAO,CAAAsB,qBAAA,CAAsBN,IAAI,CAAA;EAAA,CACpD;EAEO,OAAA;IACLb,SAAA;IACAJ;EAAA,CACF;AACF,CAAA;"}
1
+ {"version":3,"file":"useScrollToY.js","sources":["../../src/hooks/useScrollToY.tsx"],"sourcesContent":["import { useRef } from \"react\";\n\nexport interface ScrollToYOptions {\n targetY: number;\n duration: number;\n callback?: () => void;\n}\n\nexport const useScrollToY = () => {\n const rafRef = useRef(0);\n\n const cancelScrollToY = () => {\n window.cancelAnimationFrame(rafRef.current);\n };\n\n const scrollToY = ({ targetY, duration, callback }: ScrollToYOptions) => {\n // Clear existing raf\n cancelScrollToY();\n\n // Calc positions\n let start: number | undefined;\n let previousTimeStamp: number;\n const initY = window.scrollY;\n const limit =\n document.documentElement.scrollHeight -\n document.documentElement.clientHeight;\n\n function step(timestamp: number) {\n if (start === undefined) {\n start = timestamp;\n }\n const elapsed = timestamp - start;\n const progress = (timestamp - start) / duration;\n\n if (previousTimeStamp !== timestamp) {\n window.scroll({\n top: ((targetY > limit ? limit : targetY) - initY) * progress + initY,\n });\n }\n\n if (elapsed < duration) {\n // Loop self until done\n previousTimeStamp = timestamp;\n rafRef.current = window.requestAnimationFrame(step);\n } else {\n window.scroll({\n top: targetY,\n });\n callback?.();\n }\n }\n\n rafRef.current = window.requestAnimationFrame(step);\n };\n\n return {\n scrollToY,\n cancelScrollToY,\n };\n};\n"],"names":["useScrollToY","rafRef","useRef","cancelScrollToY","window","cancelAnimationFrame","current","scrollToY","targetY","duration","callback","start","previousTimeStamp","initY","scrollY","limit","document","documentElement","scrollHeight","clientHeight","step","timestamp","elapsed","progress","scroll","top","requestAnimationFrame"],"mappings":";;;;AAQO,MAAMA,eAAeA,CAAA,KAAM;EAC1B,MAAAC,MAAA,GAASC,aAAO,CAAC,CAAA;EAEvB,MAAMC,kBAAkBA,CAAA,KAAM;IACrBC,MAAA,CAAAC,oBAAA,CAAqBJ,OAAOK,OAAO,CAAA;EAAA,CAC5C;EAEA,MAAMC,YAAYA,CAAC;IAAEC,OAAS;IAAAC,QAAA;IAAUC;GAAiC,KAAA;IAEvDP,eAAA,EAAA;IAGZ,IAAAQ,KAAA;IACA,IAAAC,iBAAA;IACJ,MAAMC,QAAQT,MAAO,CAAAU,OAAA;IACrB,MAAMC,KACJ,GAAAC,QAAA,CAASC,eAAgB,CAAAC,YAAA,GACzBF,SAASC,eAAgB,CAAAE,YAAA;IAE3B,SAASC,KAAKC,SAAmB,EAAA;MAC/B,IAAIV,UAAU,KAAW,CAAA,EAAA;QACfA,KAAA,GAAAU,SAAA;MACV;MACA,MAAMC,UAAUD,SAAY,GAAAV,KAAA;MACtB,MAAAY,QAAA,GAAA,CAAYF,YAAYV,KAAS,IAAAF,QAAA;MAEvC,IAAIG,sBAAsBS,SAAW,EAAA;QACnCjB,MAAA,CAAOoB,MAAO,CAAA;UACZC,OAAOjB,OAAU,GAAAO,KAAA,GAAQA,KAAQ,GAAAP,OAAA,IAAWK,SAASU,QAAW,GAAAV;QAAA,CACjE,CAAA;MACH;MAEA,IAAIS,UAAUb,QAAU,EAAA;QAEFG,iBAAA,GAAAS,SAAA;QACbpB,MAAA,CAAAK,OAAA,GAAUF,MAAO,CAAAsB,qBAAA,CAAsBN,IAAI,CAAA;MAAA,CAC7C,MAAA;QACLhB,MAAA,CAAOoB,MAAO,CAAA;UACZC,GAAK,EAAAjB;QAAA,CACN,CAAA;QACUE,QAAA,IAAA;MACb;IACF;IAEOT,MAAA,CAAAK,OAAA,GAAUF,MAAO,CAAAsB,qBAAA,CAAsBN,IAAI,CAAA;EAAA,CACpD;EAEO,OAAA;IACLb,SAAA;IACAJ;EAAA,CACF;AACF,CAAA;"}
@@ -1 +1 @@
1
- {"version":3,"file":"useScrollToY.mjs","sources":["../../src/hooks/useScrollToY.tsx"],"sourcesContent":["import { useRef } from \"react\";\n\nexport interface ScrollToYOptions {\n targetY: number;\n duration: number;\n callback?: () => void;\n}\n\nexport const useScrollToY = () => {\n const rafRef = useRef(0);\n\n const cancelScrollToY = () => {\n window.cancelAnimationFrame(rafRef.current);\n };\n\n const scrollToY = ({ targetY, duration, callback }: ScrollToYOptions) => {\n // Clear existing raf\n cancelScrollToY();\n\n // Calc positions\n let start: number;\n let previousTimeStamp: number;\n const initY = window.scrollY;\n const limit =\n document.documentElement.scrollHeight -\n document.documentElement.clientHeight;\n\n function step(timestamp: number) {\n if (start === undefined) {\n start = timestamp;\n }\n const elapsed = timestamp - start;\n const progress = (timestamp - start) / duration;\n\n if (previousTimeStamp !== timestamp) {\n window.scroll({\n top: ((targetY > limit ? limit : targetY) - initY) * progress + initY,\n });\n }\n\n if (elapsed < duration) {\n // Loop self until done\n previousTimeStamp = timestamp;\n rafRef.current = window.requestAnimationFrame(step);\n } else {\n window.scroll({\n top: targetY,\n });\n callback?.();\n }\n }\n\n rafRef.current = window.requestAnimationFrame(step);\n };\n\n return {\n scrollToY,\n cancelScrollToY,\n };\n};\n"],"names":["useScrollToY","rafRef","useRef","cancelScrollToY","window","cancelAnimationFrame","current","scrollToY","targetY","duration","callback","start","previousTimeStamp","initY","scrollY","limit","document","documentElement","scrollHeight","clientHeight","step","timestamp","elapsed","progress","scroll","top","requestAnimationFrame"],"mappings":";;AAQO,MAAMA,eAAeA,CAAA,KAAM;EAC1B,MAAAC,MAAA,GAASC,OAAO,CAAC,CAAA;EAEvB,MAAMC,kBAAkBA,CAAA,KAAM;IACrBC,MAAA,CAAAC,oBAAA,CAAqBJ,OAAOK,OAAO,CAAA;EAAA,CAC5C;EAEA,MAAMC,YAAYA,CAAC;IAAEC,OAAS;IAAAC,QAAA;IAAUC;GAAiC,KAAA;IAEvDP,eAAA,EAAA;IAGZ,IAAAQ,KAAA;IACA,IAAAC,iBAAA;IACJ,MAAMC,QAAQT,MAAO,CAAAU,OAAA;IACrB,MAAMC,KACJ,GAAAC,QAAA,CAASC,eAAgB,CAAAC,YAAA,GACzBF,SAASC,eAAgB,CAAAE,YAAA;IAE3B,SAASC,KAAKC,SAAmB,EAAA;MAC/B,IAAIV,UAAU,KAAW,CAAA,EAAA;QACfA,KAAA,GAAAU,SAAA;MACV;MACA,MAAMC,UAAUD,SAAY,GAAAV,KAAA;MACtB,MAAAY,QAAA,GAAA,CAAYF,YAAYV,KAAS,IAAAF,QAAA;MAEvC,IAAIG,sBAAsBS,SAAW,EAAA;QACnCjB,MAAA,CAAOoB,MAAO,CAAA;UACZC,OAAOjB,OAAU,GAAAO,KAAA,GAAQA,KAAQ,GAAAP,OAAA,IAAWK,SAASU,QAAW,GAAAV;QAAA,CACjE,CAAA;MACH;MAEA,IAAIS,UAAUb,QAAU,EAAA;QAEFG,iBAAA,GAAAS,SAAA;QACbpB,MAAA,CAAAK,OAAA,GAAUF,MAAO,CAAAsB,qBAAA,CAAsBN,IAAI,CAAA;MAAA,CAC7C,MAAA;QACLhB,MAAA,CAAOoB,MAAO,CAAA;UACZC,GAAK,EAAAjB;QAAA,CACN,CAAA;QACUE,QAAA,IAAA;MACb;IACF;IAEOT,MAAA,CAAAK,OAAA,GAAUF,MAAO,CAAAsB,qBAAA,CAAsBN,IAAI,CAAA;EAAA,CACpD;EAEO,OAAA;IACLb,SAAA;IACAJ;EAAA,CACF;AACF,CAAA;"}
1
+ {"version":3,"file":"useScrollToY.mjs","sources":["../../src/hooks/useScrollToY.tsx"],"sourcesContent":["import { useRef } from \"react\";\n\nexport interface ScrollToYOptions {\n targetY: number;\n duration: number;\n callback?: () => void;\n}\n\nexport const useScrollToY = () => {\n const rafRef = useRef(0);\n\n const cancelScrollToY = () => {\n window.cancelAnimationFrame(rafRef.current);\n };\n\n const scrollToY = ({ targetY, duration, callback }: ScrollToYOptions) => {\n // Clear existing raf\n cancelScrollToY();\n\n // Calc positions\n let start: number | undefined;\n let previousTimeStamp: number;\n const initY = window.scrollY;\n const limit =\n document.documentElement.scrollHeight -\n document.documentElement.clientHeight;\n\n function step(timestamp: number) {\n if (start === undefined) {\n start = timestamp;\n }\n const elapsed = timestamp - start;\n const progress = (timestamp - start) / duration;\n\n if (previousTimeStamp !== timestamp) {\n window.scroll({\n top: ((targetY > limit ? limit : targetY) - initY) * progress + initY,\n });\n }\n\n if (elapsed < duration) {\n // Loop self until done\n previousTimeStamp = timestamp;\n rafRef.current = window.requestAnimationFrame(step);\n } else {\n window.scroll({\n top: targetY,\n });\n callback?.();\n }\n }\n\n rafRef.current = window.requestAnimationFrame(step);\n };\n\n return {\n scrollToY,\n cancelScrollToY,\n };\n};\n"],"names":["useScrollToY","rafRef","useRef","cancelScrollToY","window","cancelAnimationFrame","current","scrollToY","targetY","duration","callback","start","previousTimeStamp","initY","scrollY","limit","document","documentElement","scrollHeight","clientHeight","step","timestamp","elapsed","progress","scroll","top","requestAnimationFrame"],"mappings":";;AAQO,MAAMA,eAAeA,CAAA,KAAM;EAC1B,MAAAC,MAAA,GAASC,OAAO,CAAC,CAAA;EAEvB,MAAMC,kBAAkBA,CAAA,KAAM;IACrBC,MAAA,CAAAC,oBAAA,CAAqBJ,OAAOK,OAAO,CAAA;EAAA,CAC5C;EAEA,MAAMC,YAAYA,CAAC;IAAEC,OAAS;IAAAC,QAAA;IAAUC;GAAiC,KAAA;IAEvDP,eAAA,EAAA;IAGZ,IAAAQ,KAAA;IACA,IAAAC,iBAAA;IACJ,MAAMC,QAAQT,MAAO,CAAAU,OAAA;IACrB,MAAMC,KACJ,GAAAC,QAAA,CAASC,eAAgB,CAAAC,YAAA,GACzBF,SAASC,eAAgB,CAAAE,YAAA;IAE3B,SAASC,KAAKC,SAAmB,EAAA;MAC/B,IAAIV,UAAU,KAAW,CAAA,EAAA;QACfA,KAAA,GAAAU,SAAA;MACV;MACA,MAAMC,UAAUD,SAAY,GAAAV,KAAA;MACtB,MAAAY,QAAA,GAAA,CAAYF,YAAYV,KAAS,IAAAF,QAAA;MAEvC,IAAIG,sBAAsBS,SAAW,EAAA;QACnCjB,MAAA,CAAOoB,MAAO,CAAA;UACZC,OAAOjB,OAAU,GAAAO,KAAA,GAAQA,KAAQ,GAAAP,OAAA,IAAWK,SAASU,QAAW,GAAAV;QAAA,CACjE,CAAA;MACH;MAEA,IAAIS,UAAUb,QAAU,EAAA;QAEFG,iBAAA,GAAAS,SAAA;QACbpB,MAAA,CAAAK,OAAA,GAAUF,MAAO,CAAAsB,qBAAA,CAAsBN,IAAI,CAAA;MAAA,CAC7C,MAAA;QACLhB,MAAA,CAAOoB,MAAO,CAAA;UACZC,GAAK,EAAAjB;QAAA,CACN,CAAA;QACUE,QAAA,IAAA;MACb;IACF;IAEOT,MAAA,CAAAK,OAAA,GAAUF,MAAO,CAAAsB,qBAAA,CAAsBN,IAAI,CAAA;EAAA,CACpD;EAEO,OAAA;IACLb,SAAA;IACAJ;EAAA,CACF;AACF,CAAA;"}
@@ -6,8 +6,8 @@ const getCollectionSlugFromPath = path => {
6
6
  if (!path) {
7
7
  return "";
8
8
  }
9
- const match = path.match(COLLECTION_SLUG_REGEX);
10
- return match?.[2] || "";
9
+ const match = COLLECTION_SLUG_REGEX.exec(path);
10
+ return match?.[2] ?? "";
11
11
  };
12
12
  exports.getCollectionSlugFromPath = getCollectionSlugFromPath;
13
13
  //# sourceMappingURL=collectionSlug.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"collectionSlug.js","sources":["../../src/utils/collectionSlug.ts"],"sourcesContent":["import type { Nullish } from \"../types\";\n\nconst COLLECTION_SLUG_REGEX = /(\\/)?collections\\/(.*)/;\n\n/**\n * Extracts the collection slug from a path\n */\nexport const getCollectionSlugFromPath = (path: Nullish<string>): string => {\n if (!path) {\n return \"\";\n }\n\n const match = path.match(COLLECTION_SLUG_REGEX);\n return match?.[2] || \"\";\n};\n"],"names":["COLLECTION_SLUG_REGEX","getCollectionSlugFromPath","path","match"],"mappings":";;;AAEA,MAAMA,qBAAwB,GAAA,wBAAA;AAKjB,MAAAC,yBAAA,GAA6BC,IAAkC,IAAA;EAC1E,IAAI,CAACA,IAAM,EAAA;IACF,OAAA,EAAA;EACT;EAEM,MAAAC,KAAA,GAAQD,IAAK,CAAAC,KAAA,CAAMH,qBAAqB,CAAA;EACvC,OAAAG,KAAA,GAAQ,CAAC,CAAK,IAAA,EAAA;AACvB,CAAA;"}
1
+ {"version":3,"file":"collectionSlug.js","sources":["../../src/utils/collectionSlug.ts"],"sourcesContent":["import type { Nullish } from \"../types\";\n\nconst COLLECTION_SLUG_REGEX = /(\\/)?collections\\/(.*)/;\n\n/**\n * Extracts the collection slug from a path\n */\nexport const getCollectionSlugFromPath = (path: Nullish<string>): string => {\n if (!path) {\n return \"\";\n }\n\n const match = COLLECTION_SLUG_REGEX.exec(path);\n return match?.[2] ?? \"\";\n};\n"],"names":["COLLECTION_SLUG_REGEX","getCollectionSlugFromPath","path","match","exec"],"mappings":";;;AAEA,MAAMA,qBAAwB,GAAA,wBAAA;AAKjB,MAAAC,yBAAA,GAA6BC,IAAkC,IAAA;EAC1E,IAAI,CAACA,IAAM,EAAA;IACF,OAAA,EAAA;EACT;EAEM,MAAAC,KAAA,GAAQH,qBAAsB,CAAAI,IAAA,CAAKF,IAAI,CAAA;EACtC,OAAAC,KAAA,GAAQ,CAAC,CAAK,IAAA,EAAA;AACvB,CAAA;"}
@@ -5,8 +5,8 @@ const getCollectionSlugFromPath = path => {
5
5
  if (!path) {
6
6
  return "";
7
7
  }
8
- const match = path.match(COLLECTION_SLUG_REGEX);
9
- return match?.[2] || "";
8
+ const match = COLLECTION_SLUG_REGEX.exec(path);
9
+ return match?.[2] ?? "";
10
10
  };
11
11
  export { getCollectionSlugFromPath };
12
12
  //# sourceMappingURL=collectionSlug.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"collectionSlug.mjs","sources":["../../src/utils/collectionSlug.ts"],"sourcesContent":["import type { Nullish } from \"../types\";\n\nconst COLLECTION_SLUG_REGEX = /(\\/)?collections\\/(.*)/;\n\n/**\n * Extracts the collection slug from a path\n */\nexport const getCollectionSlugFromPath = (path: Nullish<string>): string => {\n if (!path) {\n return \"\";\n }\n\n const match = path.match(COLLECTION_SLUG_REGEX);\n return match?.[2] || \"\";\n};\n"],"names":["COLLECTION_SLUG_REGEX","getCollectionSlugFromPath","path","match"],"mappings":";;AAEA,MAAMA,qBAAwB,GAAA,wBAAA;AAKjB,MAAAC,yBAAA,GAA6BC,IAAkC,IAAA;EAC1E,IAAI,CAACA,IAAM,EAAA;IACF,OAAA,EAAA;EACT;EAEM,MAAAC,KAAA,GAAQD,IAAK,CAAAC,KAAA,CAAMH,qBAAqB,CAAA;EACvC,OAAAG,KAAA,GAAQ,CAAC,CAAK,IAAA,EAAA;AACvB,CAAA;"}
1
+ {"version":3,"file":"collectionSlug.mjs","sources":["../../src/utils/collectionSlug.ts"],"sourcesContent":["import type { Nullish } from \"../types\";\n\nconst COLLECTION_SLUG_REGEX = /(\\/)?collections\\/(.*)/;\n\n/**\n * Extracts the collection slug from a path\n */\nexport const getCollectionSlugFromPath = (path: Nullish<string>): string => {\n if (!path) {\n return \"\";\n }\n\n const match = COLLECTION_SLUG_REGEX.exec(path);\n return match?.[2] ?? \"\";\n};\n"],"names":["COLLECTION_SLUG_REGEX","getCollectionSlugFromPath","path","match","exec"],"mappings":";;AAEA,MAAMA,qBAAwB,GAAA,wBAAA;AAKjB,MAAAC,yBAAA,GAA6BC,IAAkC,IAAA;EAC1E,IAAI,CAACA,IAAM,EAAA;IACF,OAAA,EAAA;EACT;EAEM,MAAAC,KAAA,GAAQH,qBAAsB,CAAAI,IAAA,CAAKF,IAAI,CAAA;EACtC,OAAAC,KAAA,GAAQ,CAAC,CAAK,IAAA,EAAA;AACvB,CAAA;"}
@@ -1 +1 @@
1
- {"version":3,"file":"errors.js","sources":["../../src/utils/errors.ts"],"sourcesContent":["/**\n * Throw on falsy helper\n */\nexport function assert(\n condition: boolean,\n message = \"'condition' is falsy.\",\n ErrorClass: new (message: string) => void = Error,\n): asserts condition {\n if (!condition) {\n throw new ErrorClass(message);\n }\n}\n\n/**\n * Ensures that the path where this function is used will never be reached.\n * Useful for exhausted switch..case..default checks\n * For more info see https://tinytip.co/tips/ts-switch-assert-unreachable/\n * @throws {Error}\n */\n//eslint-disable-next-line @typescript-eslint/no-unused-vars\nexport function assertUnreachable(_value: never): never {\n throw new Error(\"Statement should be unreachable\");\n}\n\n/**\n * Similar `assertUnreachable` but instead of throwing an error if called it just calls adds type-guards for some cases\n * where we want switch-case type-safety but still want some controlled fallback mechanism. Especially useful in\n * scenario's where we work with \"unknowns\" from errors, api-responses, etc\n *\n * @example\n * enum MyEnum {\n * A = 'a',\n * B = 'b'\n * }\n *\n * switch (myEnumLikeInput) {\n * case MyEnum.A: return 'a';\n * // Explicitly missing \"case MyEnum.B: ...\"\n * default: {\n * checkUnreachable(myEnumLikeInput); // Typescript fill show error \"Argument of type 'MyEnum' is not assignable to parameter of type 'never'.\" as we didn't process `MyEnum.B`\n * return 'c';\n * }\n * }\n */\n// eslint-disable-next-line @typescript-eslint/no-empty-function, @typescript-eslint/no-unused-vars\nexport function checkUnreachable(_value: never): void {}\n\n/**\n * Semi-util that needs to be used together with Difference util type to ensure that in type-system two given objects\n * are the same shape\n *\n * @example\n * assertTypeEquality<Difference<{a: string}, {a: string}>>(); // OK\n * assertTypeEquality<Difference<{a: string, b: number}, {a: string, c: boolean}>>(); // Throws error\n */\n// @ts-expect-error Ignore unused generic parameter\n// eslint-disable-next-line @typescript-eslint/no-unused-vars\nexport function assertTypeEquality<T extends never>(): void {}\n"],"names":["assert","condition","message","ErrorClass","Error","assertUnreachable","_value","checkUnreachable","assertTypeEquality"],"mappings":";;;AAGO,SAASA,MACdA,CAAAC,SAAA,EACAC,OAAU,GAAA,uBAAA,EACVC,aAA4CC,KACzB,EAAA;EACnB,IAAI,CAACH,SAAW,EAAA;IACR,MAAA,IAAIE,WAAWD,OAAO,CAAA;EAC9B;AACF;AASO,SAASG,kBAAkBC,MAAsB,EAAA;EAChD,MAAA,IAAIF,MAAM,iCAAiC,CAAA;AACnD;AAuBO,SAASG,iBAAiBD,MAAqB,EAAA,CAAC;AAYhD,SAASE,kBAA4CA,CAAA,EAAA,CAAC;;;;"}
1
+ {"version":3,"file":"errors.js","sources":["../../src/utils/errors.ts"],"sourcesContent":["/**\n * Throw on falsy helper\n */\nexport function assert(\n condition: boolean,\n message = \"'condition' is falsy.\",\n ErrorClass: new (message: string) => void = Error,\n): asserts condition {\n if (!condition) {\n throw new ErrorClass(message);\n }\n}\n\n/**\n * Ensures that the path where this function is used will never be reached.\n * Useful for exhausted switch..case..default checks\n * For more info see https://tinytip.co/tips/ts-switch-assert-unreachable/\n * @throws {Error}\n */\n//eslint-disable-next-line @typescript-eslint/no-unused-vars\nexport function assertUnreachable(_value: never): never {\n throw new Error(\"Statement should be unreachable\");\n}\n\n/**\n * Similar `assertUnreachable` but instead of throwing an error if called it just calls adds type-guards for some cases\n * where we want switch-case type-safety but still want some controlled fallback mechanism. Especially useful in\n * scenario's where we work with \"unknowns\" from errors, api-responses, etc\n *\n * @example\n * enum MyEnum {\n * A = 'a',\n * B = 'b'\n * }\n *\n * switch (myEnumLikeInput) {\n * case MyEnum.A: return 'a';\n * // Explicitly missing \"case MyEnum.B: ...\"\n * default: {\n * checkUnreachable(myEnumLikeInput); // Typescript fill show error \"Argument of type 'MyEnum' is not assignable to parameter of type 'never'.\" as we didn't process `MyEnum.B`\n * return 'c';\n * }\n * }\n */\n// eslint-disable-next-line @typescript-eslint/no-empty-function, @typescript-eslint/no-unused-vars\nexport function checkUnreachable(_value: never): void {\n /* Intentional empty function as just for type assertion */\n}\n\n/**\n * Semi-util that needs to be used together with Difference util type to ensure that in type-system two given objects\n * are the same shape\n *\n * @example\n * assertTypeEquality<Difference<{a: string}, {a: string}>>(); // OK\n * assertTypeEquality<Difference<{a: string, b: number}, {a: string, c: boolean}>>(); // Throws error\n */\n// @ts-expect-error Ignore unused generic parameter\n// eslint-disable-next-line @typescript-eslint/no-unused-vars\nexport function assertTypeEquality<T extends never>(): void {\n /* Intentional empty function as just for type assertion */\n}\n"],"names":["assert","condition","message","ErrorClass","Error","assertUnreachable","_value","checkUnreachable","assertTypeEquality"],"mappings":";;;AAGO,SAASA,MACdA,CAAAC,SAAA,EACAC,OAAU,GAAA,uBAAA,EACVC,aAA4CC,KACzB,EAAA;EACnB,IAAI,CAACH,SAAW,EAAA;IACR,MAAA,IAAIE,WAAWD,OAAO,CAAA;EAC9B;AACF;AASO,SAASG,kBAAkBC,MAAsB,EAAA;EAChD,MAAA,IAAIF,MAAM,iCAAiC,CAAA;AACnD;AAuBO,SAASG,iBAAiBD,MAAqB,EAAA,CAEtD;AAYO,SAASE,kBAA4CA,CAAA,EAAA,CAE5D;;;;"}
@@ -1 +1 @@
1
- {"version":3,"file":"errors.mjs","sources":["../../src/utils/errors.ts"],"sourcesContent":["/**\n * Throw on falsy helper\n */\nexport function assert(\n condition: boolean,\n message = \"'condition' is falsy.\",\n ErrorClass: new (message: string) => void = Error,\n): asserts condition {\n if (!condition) {\n throw new ErrorClass(message);\n }\n}\n\n/**\n * Ensures that the path where this function is used will never be reached.\n * Useful for exhausted switch..case..default checks\n * For more info see https://tinytip.co/tips/ts-switch-assert-unreachable/\n * @throws {Error}\n */\n//eslint-disable-next-line @typescript-eslint/no-unused-vars\nexport function assertUnreachable(_value: never): never {\n throw new Error(\"Statement should be unreachable\");\n}\n\n/**\n * Similar `assertUnreachable` but instead of throwing an error if called it just calls adds type-guards for some cases\n * where we want switch-case type-safety but still want some controlled fallback mechanism. Especially useful in\n * scenario's where we work with \"unknowns\" from errors, api-responses, etc\n *\n * @example\n * enum MyEnum {\n * A = 'a',\n * B = 'b'\n * }\n *\n * switch (myEnumLikeInput) {\n * case MyEnum.A: return 'a';\n * // Explicitly missing \"case MyEnum.B: ...\"\n * default: {\n * checkUnreachable(myEnumLikeInput); // Typescript fill show error \"Argument of type 'MyEnum' is not assignable to parameter of type 'never'.\" as we didn't process `MyEnum.B`\n * return 'c';\n * }\n * }\n */\n// eslint-disable-next-line @typescript-eslint/no-empty-function, @typescript-eslint/no-unused-vars\nexport function checkUnreachable(_value: never): void {}\n\n/**\n * Semi-util that needs to be used together with Difference util type to ensure that in type-system two given objects\n * are the same shape\n *\n * @example\n * assertTypeEquality<Difference<{a: string}, {a: string}>>(); // OK\n * assertTypeEquality<Difference<{a: string, b: number}, {a: string, c: boolean}>>(); // Throws error\n */\n// @ts-expect-error Ignore unused generic parameter\n// eslint-disable-next-line @typescript-eslint/no-unused-vars\nexport function assertTypeEquality<T extends never>(): void {}\n"],"names":["assert","condition","message","ErrorClass","Error","assertUnreachable","_value","checkUnreachable","assertTypeEquality"],"mappings":";;AAGO,SAASA,MACdA,CAAAC,SAAA,EACAC,OAAU,GAAA,uBAAA,EACVC,aAA4CC,KACzB,EAAA;EACnB,IAAI,CAACH,SAAW,EAAA;IACR,MAAA,IAAIE,WAAWD,OAAO,CAAA;EAC9B;AACF;AASO,SAASG,kBAAkBC,MAAsB,EAAA;EAChD,MAAA,IAAIF,MAAM,iCAAiC,CAAA;AACnD;AAuBO,SAASG,iBAAiBD,MAAqB,EAAA,CAAC;AAYhD,SAASE,kBAA4CA,CAAA,EAAA,CAAC;"}
1
+ {"version":3,"file":"errors.mjs","sources":["../../src/utils/errors.ts"],"sourcesContent":["/**\n * Throw on falsy helper\n */\nexport function assert(\n condition: boolean,\n message = \"'condition' is falsy.\",\n ErrorClass: new (message: string) => void = Error,\n): asserts condition {\n if (!condition) {\n throw new ErrorClass(message);\n }\n}\n\n/**\n * Ensures that the path where this function is used will never be reached.\n * Useful for exhausted switch..case..default checks\n * For more info see https://tinytip.co/tips/ts-switch-assert-unreachable/\n * @throws {Error}\n */\n//eslint-disable-next-line @typescript-eslint/no-unused-vars\nexport function assertUnreachable(_value: never): never {\n throw new Error(\"Statement should be unreachable\");\n}\n\n/**\n * Similar `assertUnreachable` but instead of throwing an error if called it just calls adds type-guards for some cases\n * where we want switch-case type-safety but still want some controlled fallback mechanism. Especially useful in\n * scenario's where we work with \"unknowns\" from errors, api-responses, etc\n *\n * @example\n * enum MyEnum {\n * A = 'a',\n * B = 'b'\n * }\n *\n * switch (myEnumLikeInput) {\n * case MyEnum.A: return 'a';\n * // Explicitly missing \"case MyEnum.B: ...\"\n * default: {\n * checkUnreachable(myEnumLikeInput); // Typescript fill show error \"Argument of type 'MyEnum' is not assignable to parameter of type 'never'.\" as we didn't process `MyEnum.B`\n * return 'c';\n * }\n * }\n */\n// eslint-disable-next-line @typescript-eslint/no-empty-function, @typescript-eslint/no-unused-vars\nexport function checkUnreachable(_value: never): void {\n /* Intentional empty function as just for type assertion */\n}\n\n/**\n * Semi-util that needs to be used together with Difference util type to ensure that in type-system two given objects\n * are the same shape\n *\n * @example\n * assertTypeEquality<Difference<{a: string}, {a: string}>>(); // OK\n * assertTypeEquality<Difference<{a: string, b: number}, {a: string, c: boolean}>>(); // Throws error\n */\n// @ts-expect-error Ignore unused generic parameter\n// eslint-disable-next-line @typescript-eslint/no-unused-vars\nexport function assertTypeEquality<T extends never>(): void {\n /* Intentional empty function as just for type assertion */\n}\n"],"names":["assert","condition","message","ErrorClass","Error","assertUnreachable","_value","checkUnreachable","assertTypeEquality"],"mappings":";;AAGO,SAASA,MACdA,CAAAC,SAAA,EACAC,OAAU,GAAA,uBAAA,EACVC,aAA4CC,KACzB,EAAA;EACnB,IAAI,CAACH,SAAW,EAAA;IACR,MAAA,IAAIE,WAAWD,OAAO,CAAA;EAC9B;AACF;AASO,SAASG,kBAAkBC,MAAsB,EAAA;EAChD,MAAA,IAAIF,MAAM,iCAAiC,CAAA;AACnD;AAuBO,SAASG,iBAAiBD,MAAqB,EAAA,CAEtD;AAYO,SAASE,kBAA4CA,CAAA,EAAA,CAE5D;"}
@@ -35,6 +35,7 @@ const dineroBigint = dinero_js.createDinero({
35
35
  });
36
36
  const DINERO_WEIGHT_G = {
37
37
  code: "WEIGHT_G",
38
+ // eslint-disable-next-line sonarjs/inconsistent-function-call
38
39
  base: big_js.Big(10),
39
40
  exponent: big_js.Big(0)
40
41
  };
@@ -1 +1 @@
1
- {"version":3,"file":"measures.js","sources":["../../src/utils/measures.ts"],"sourcesContent":["import { Big } from \"big.js\";\nimport type {\n LengthSystems,\n LengthUnits,\n MassSystems,\n MassUnits,\n} from \"convert-units\";\nimport configureMeasurements, { length, mass } from \"convert-units\";\nimport type { Calculator, ComparisonOperator, Transformer } from \"dinero.js\";\nimport { createDinero, toFormat } from \"dinero.js\";\n\nimport { UnitSystem } from \"../types\";\nimport { assert, assertUnreachable } from \"./errors\";\n\n// Measures: The names of the measures being used\ntype Measures = \"length\" | \"mass\";\n// Systems: The systems being used across all measures\ntype Systems = LengthSystems | MassSystems;\n// Units: All the units across all measures and their systems\ntype Units = LengthUnits | MassUnits;\n\nexport const convert = configureMeasurements<Measures, Systems, Units>({\n length,\n mass,\n});\n\nconst calculator: Calculator<Big> = {\n add: (a, b) => a.plus(b),\n compare: (a, b) => a.cmp(b) as unknown as ComparisonOperator,\n decrement: (v) => v.minus(new Big(1)),\n increment: (v) => v.plus(new Big(1)),\n integerDivide: (a, b) => a.div(b).round(0, Big.roundDown),\n modulo: (a, b) => a.mod(b),\n multiply: (a, b) => a.times(b),\n power: (a, b) => a.pow(Number(b)),\n subtract: (a, b) => a.minus(b),\n zero: () => new Big(0),\n toNumber: () => NaN,\n};\n\nconst dineroBigint = createDinero({ calculator });\n\n// type ConvertMassFromTo =\n// | { from: Unit.G; to: Unit.Kg }\n// | { from: Unit.Kg; to: Unit. }\n// | { from: Unit.G; to: Unit.Kg }\n// | { from: Unit.G; to: Unit.Kg }\n// | { from: Unit.G; to: Unit.Kg }\n// | { from: Unit.G; to: Unit.Kg }\n// export const convertMass = (value: number, {from, to}: ConvertMassFromTo) => {\n// return convert(value).from(from).to(to)\n// }\n\nconst DINERO_WEIGHT_G = {\n code: \"WEIGHT_G\",\n base: Big(10),\n exponent: Big(0),\n};\nconst DINERO_WEIGHT_OZ = {\n code: \"WEIGHT_OZ\",\n base: Big(10),\n exponent: Big(6),\n};\n\ntype TransformerOptions = Parameters<Transformer<Big>>[0];\nconst transformer = ({ currency, dineroObject }: TransformerOptions) => {\n const exponent = currency.exponent;\n const multiplier = Big(0.1).pow(exponent.toNumber());\n\n const jsonObject = dineroObject.toJSON();\n const formattedWeight = jsonObject.amount\n .mul(multiplier)\n .toFixed(exponent.toNumber());\n\n return formattedWeight.toString();\n};\n\n/**\n * In database we store weight in \"weird\" format.\n * For metric we store weight in grams as is.\n * For imperial we store weight in oz with \"virtual scale/exponent\" => 6.\n * e.g. 1_000_000 => '1'\n * e.g. 300_000 => '0.3'\n *\n * Database weight is stored either in g or oz\n */\nexport const transformDatabaseWeightToFormat = (\n databaseWeight: string,\n system: UnitSystem,\n): string => {\n switch (system) {\n case UnitSystem.Metric:\n return toFormat(\n dineroBigint({\n amount: Big(databaseWeight),\n currency: DINERO_WEIGHT_G,\n }),\n transformer,\n );\n case UnitSystem.Imperial: {\n return toFormat(\n dineroBigint({\n amount: Big(databaseWeight),\n currency: DINERO_WEIGHT_OZ,\n }),\n transformer,\n );\n }\n default:\n assertUnreachable(system);\n }\n};\n\n/**\n * Executes transformDatabaseWeightToFormat and returns it as number if safe integer\n *\n * Database weight is stored either in g or oz\n */\nexport const transformDatabaseWeightToNumber = (\n databaseWeight: string,\n system: UnitSystem,\n): number => {\n const formattedBig = Big(\n transformDatabaseWeightToFormat(databaseWeight, system),\n );\n\n assert(\n formattedBig.lte(Number.MAX_SAFE_INTEGER),\n \"Weight is not in safe integer range\",\n );\n return parseFloat(formattedBig.toString());\n};\n\n/**\n * Prepares floating number to be stored in database as normalized bigint\n *\n * Database weights are stored either in g or oz\n */\nexport const transformNumberToDatabaseWeight = (\n numberWeight: number,\n system: UnitSystem,\n): string => {\n switch (system) {\n case UnitSystem.Metric: {\n /**\n * convert(1).from(oz).to(g) is 28.34952g.\n * We are stripping sub-gram measures, because database is storing grams\n */\n const numberWeightInt = parseInt(numberWeight.toFixed(0));\n\n assert(\n !!Number.isSafeInteger(numberWeightInt),\n \"Number is not safe integer\",\n );\n\n return numberWeightInt.toString();\n }\n case UnitSystem.Imperial: {\n const weightBig = Big(numberWeight);\n const multiplier = Big(10).pow(DINERO_WEIGHT_OZ.exponent.toNumber());\n return weightBig.mul(multiplier).toFixed(0);\n }\n default:\n assertUnreachable(system);\n }\n};\n\n/**\n * Shorthand function to transform weight number to formatted string.\n *\n * ! Use only with base weights g/oz\n */\nexport const transformBaseWeightNumberToFormat = (\n databaseWeight: number,\n system: UnitSystem,\n): string =>\n transformDatabaseWeightToFormat(\n transformNumberToDatabaseWeight(databaseWeight, system),\n system,\n );\n"],"names":["convert","configureMeasurements","length","mass","calculator","add","a","b","plus","compare","cmp","decrement","v","minus","Big","increment","integerDivide","div","round","roundDown","modulo","mod","multiply","times","power","pow","Number","subtract","zero","toNumber","NaN","dineroBigint","createDinero","DINERO_WEIGHT_G","code","base","exponent","DINERO_WEIGHT_OZ","transformer","currency","dineroObject","multiplier","jsonObject","toJSON","formattedWeight","amount","mul","toFixed","toString","transformDatabaseWeightToFormat","databaseWeight","system","UnitSystem","Metric","toFormat","Imperial","assertUnreachable","transformDatabaseWeightToNumber","formattedBig","assert","lte","MAX_SAFE_INTEGER","parseFloat","transformNumberToDatabaseWeight","numberWeight","numberWeightInt","parseInt","isSafeInteger","weightBig","transformBaseWeightNumberToFormat"],"mappings":";;;;;;;;;;;;;;;AAqBO,MAAMA,UAAUC,8BAAAA,CAAAA,SAAAA,CAAgD,CAAA;EAAAC,MAAA,EACrEA,qBAAA,CAAAA,MAAA;EAAAC,IAAA,EACAA,qBAAA,CAAAA;AACF,CAAC,CAAA;AAED,MAAMC,UAA8B,GAAA;EAClCC,KAAK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AM,CAAA,CACxD;EAEAQ,MAAA,CAAAA,MAAA,CACED,YAAA,CAAaE,GAAI,CAAAlC,MAAA,CAAOmC,gBAAgB,CAAA,EACxC,qCAAA,CACF;EACO,OAAAC,UAAA,CAAWJ,YAAa,CAAAV,QAAA,CAAA,CAAU,CAAA;AAC3C,CAAA;AAOa,MAAAe,+BAAA,GAAkCA,CAC7CC,YAAA,EACAb,MACW,KAAA;EACX,QAAQA,MAAQ;IACd,KAAKC,SAAAA,CAAAA,WAAWC,MAAQ;MAAA;QAKtB,MAAMY,eAAkB,GAAAC,QAAA,CAASF,YAAa,CAAAjB,OAAA,CAAQ,CAAC,CAAC,CAAA;QAExDY,MAAA,CAAAA,MAAA,CACE,CAAC,CAACjC,MAAO,CAAAyC,aAAA,CAAcF,eAAe,CAAA,EACtC,4BAAA,CACF;QAEA,OAAOA,gBAAgBjB,QAAS,EAAA;MAClC;IACA,KAAKI,SAAAA,CAAAA,WAAWG,QAAU;MAAA;QAClB,MAAAa,SAAA,GAAYtD,WAAIkD,YAAY,CAAA;QAC5B,MAAAvB,UAAA,GAAa3B,WAAI,EAAE,CAAA,CAAEW,IAAIY,gBAAiB,CAAAD,QAAA,CAASP,UAAU,CAAA;QACnE,OAAOuC,SAAU,CAAAtB,GAAA,CAAIL,UAAU,CAAA,CAAEM,QAAQ,CAAC,CAAA;MAC5C;IACA;MACES,MAAA,CAAAA,iBAAA,CAAkBL,MAAM,CAAA;EAC5B;AACF,CAAA;AAOa,MAAAkB,iCAAA,GAAoCA,CAC/CnB,cAAA,EACAC,MAEA,KAAAF,+BAAA,CACEc,+BAAA,CAAgCb,gBAAgBC,MAAM,CAAA,EACtDA,MACF,CAAA;;;;;"}
1
+ {"version":3,"file":"measures.js","sources":["../../src/utils/measures.ts"],"sourcesContent":["import { Big } from \"big.js\";\nimport type {\n LengthSystems,\n LengthUnits,\n MassSystems,\n MassUnits,\n} from \"convert-units\";\nimport configureMeasurements, { length, mass } from \"convert-units\";\nimport type { Calculator, ComparisonOperator, Transformer } from \"dinero.js\";\nimport { createDinero, toFormat } from \"dinero.js\";\n\nimport { UnitSystem } from \"../types\";\nimport { assert, assertUnreachable } from \"./errors\";\n\n// Measures: The names of the measures being used\ntype Measures = \"length\" | \"mass\";\n// Systems: The systems being used across all measures\ntype Systems = LengthSystems | MassSystems;\n// Units: All the units across all measures and their systems\ntype Units = LengthUnits | MassUnits;\n\nexport const convert = configureMeasurements<Measures, Systems, Units>({\n length,\n mass,\n});\n\nconst calculator: Calculator<Big> = {\n add: (a, b) => a.plus(b),\n compare: (a, b) => a.cmp(b) as unknown as ComparisonOperator,\n decrement: (v) => v.minus(new Big(1)),\n increment: (v) => v.plus(new Big(1)),\n integerDivide: (a, b) => a.div(b).round(0, Big.roundDown),\n modulo: (a, b) => a.mod(b),\n multiply: (a, b) => a.times(b),\n power: (a, b) => a.pow(Number(b)),\n subtract: (a, b) => a.minus(b),\n zero: () => new Big(0),\n toNumber: () => NaN,\n};\n\nconst dineroBigint = createDinero({ calculator });\n\n// type ConvertMassFromTo =\n// | { from: Unit.G; to: Unit.Kg }\n// | { from: Unit.Kg; to: Unit. }\n// | { from: Unit.G; to: Unit.Kg }\n// | { from: Unit.G; to: Unit.Kg }\n// | { from: Unit.G; to: Unit.Kg }\n// | { from: Unit.G; to: Unit.Kg }\n// export const convertMass = (value: number, {from, to}: ConvertMassFromTo) => {\n// return convert(value).from(from).to(to)\n// }\n\nconst DINERO_WEIGHT_G = {\n code: \"WEIGHT_G\",\n // eslint-disable-next-line sonarjs/inconsistent-function-call\n base: Big(10),\n exponent: Big(0),\n};\nconst DINERO_WEIGHT_OZ = {\n code: \"WEIGHT_OZ\",\n base: Big(10),\n exponent: Big(6),\n};\n\ntype TransformerOptions = Parameters<Transformer<Big>>[0];\nconst transformer = ({ currency, dineroObject }: TransformerOptions) => {\n const exponent = currency.exponent;\n const multiplier = Big(0.1).pow(exponent.toNumber());\n\n const jsonObject = dineroObject.toJSON();\n const formattedWeight = jsonObject.amount\n .mul(multiplier)\n .toFixed(exponent.toNumber());\n\n return formattedWeight.toString();\n};\n\n/**\n * In database we store weight in \"weird\" format.\n * For metric we store weight in grams as is.\n * For imperial we store weight in oz with \"virtual scale/exponent\" => 6.\n * e.g. 1_000_000 => '1'\n * e.g. 300_000 => '0.3'\n *\n * Database weight is stored either in g or oz\n */\nexport const transformDatabaseWeightToFormat = (\n databaseWeight: string,\n system: UnitSystem,\n): string => {\n switch (system) {\n case UnitSystem.Metric:\n return toFormat(\n dineroBigint({\n amount: Big(databaseWeight),\n currency: DINERO_WEIGHT_G,\n }),\n transformer,\n );\n case UnitSystem.Imperial: {\n return toFormat(\n dineroBigint({\n amount: Big(databaseWeight),\n currency: DINERO_WEIGHT_OZ,\n }),\n transformer,\n );\n }\n default:\n assertUnreachable(system);\n }\n};\n\n/**\n * Executes transformDatabaseWeightToFormat and returns it as number if safe integer\n *\n * Database weight is stored either in g or oz\n */\nexport const transformDatabaseWeightToNumber = (\n databaseWeight: string,\n system: UnitSystem,\n): number => {\n const formattedBig = Big(\n transformDatabaseWeightToFormat(databaseWeight, system),\n );\n\n assert(\n formattedBig.lte(Number.MAX_SAFE_INTEGER),\n \"Weight is not in safe integer range\",\n );\n return parseFloat(formattedBig.toString());\n};\n\n/**\n * Prepares floating number to be stored in database as normalized bigint\n *\n * Database weights are stored either in g or oz\n */\nexport const transformNumberToDatabaseWeight = (\n numberWeight: number,\n system: UnitSystem,\n): string => {\n switch (system) {\n case UnitSystem.Metric: {\n /**\n * convert(1).from(oz).to(g) is 28.34952g.\n * We are stripping sub-gram measures, because database is storing grams\n */\n const numberWeightInt = parseInt(numberWeight.toFixed(0));\n\n assert(\n !!Number.isSafeInteger(numberWeightInt),\n \"Number is not safe integer\",\n );\n\n return numberWeightInt.toString();\n }\n case UnitSystem.Imperial: {\n const weightBig = Big(numberWeight);\n const multiplier = Big(10).pow(DINERO_WEIGHT_OZ.exponent.toNumber());\n return weightBig.mul(multiplier).toFixed(0);\n }\n default:\n assertUnreachable(system);\n }\n};\n\n/**\n * Shorthand function to transform weight number to formatted string.\n *\n * ! Use only with base weights g/oz\n */\nexport const transformBaseWeightNumberToFormat = (\n databaseWeight: number,\n system: UnitSystem,\n): string =>\n transformDatabaseWeightToFormat(\n transformNumberToDatabaseWeight(databaseWeight, system),\n system,\n );\n"],"names":["convert","configureMeasurements","length","mass","calculator","add","a","b","plus","compare","cmp","decrement","v","minus","Big","increment","integerDivide","div","round","roundDown","modulo","mod","multiply","times","power","pow","Number","subtract","zero","toNumber","NaN","dineroBigint","createDinero","DINERO_WEIGHT_G","code","base","exponent","DINERO_WEIGHT_OZ","transformer","currency","dineroObject","multiplier","jsonObject","toJSON","formattedWeight","amount","mul","toFixed","toString","transformDatabaseWeightToFormat","databaseWeight","system","UnitSystem","Metric","toFormat","Imperial","assertUnreachable","transformDatabaseWeightToNumber","formattedBig","assert","lte","MAX_SAFE_INTEGER","parseFloat","transformNumberToDatabaseWeight","numberWeight","numberWeightInt","parseInt","isSafeInteger","weightBig","transformBaseWeightNumberToFormat"],"mappings":";;;;;;;;;;;;;;;AAqBO,MAAMA,UAAUC,8BAAAA,CAAAA,SAAAA,CAAgD,CAAA;EAAAC,MAAA,EACrEA,qBAAA,CAAAA,MAAA;EAAAC,IAAA,EACAA,qBAAA,CAAAA;AACF,CAAC,CAAA;AAED,MAAMC,UAA8B,GAAA;EAClCC,KAAKA,CAACC,CAAA,EAAGC,CAAM,KAAAD,CAAA,CAAEE,KAAKD,CAAC,CAAA;EACvBE,SAASA,CAACH,CAAA,EAAGC,CAAM,KAAAD,CAAA,CAAEI,IAAIH,CAAC,CAAA;EAC1BI,SAAA,EAAYC,CAAM,IAAAA,CAAA,CAAEC,MAAM,IAAIC,MAAAA,CAAAA,GAAA,CAAI,CAAC,CAAC,CAAA;EACpCC,SAAA,EAAYH,CAAM,IAAAA,CAAA,CAAEJ,KAAK,IAAIM,MAAAA,CAAAA,GAAA,CAAI,CAAC,CAAC,CAAA;EACnCE,aAAA,EAAe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Aa,CAAAjB,OAAA,CAAQ,CAAC,CAAC,CAAA;QAExDY,MAAA,CAAAA,MAAA,CACE,CAAC,CAACjC,MAAO,CAAAyC,aAAA,CAAcF,eAAe,CAAA,EACtC,4BAAA,CACF;QAEA,OAAOA,gBAAgBjB,QAAS,EAAA;MAClC;IACA,KAAKI,SAAAA,CAAAA,WAAWG,QAAU;MAAA;QAClB,MAAAa,SAAA,GAAYtD,WAAIkD,YAAY,CAAA;QAC5B,MAAAvB,UAAA,GAAa3B,WAAI,EAAE,CAAA,CAAEW,IAAIY,gBAAiB,CAAAD,QAAA,CAASP,UAAU,CAAA;QACnE,OAAOuC,SAAU,CAAAtB,GAAA,CAAIL,UAAU,CAAA,CAAEM,QAAQ,CAAC,CAAA;MAC5C;IACA;MACES,MAAA,CAAAA,iBAAA,CAAkBL,MAAM,CAAA;EAC5B;AACF,CAAA;AAOa,MAAAkB,iCAAA,GAAoCA,CAC/CnB,cAAA,EACAC,MAEA,KAAAF,+BAAA,CACEc,+BAAA,CAAgCb,gBAAgBC,MAAM,CAAA,EACtDA,MACF,CAAA;;;;;"}
@@ -27,6 +27,7 @@ const dineroBigint = createDinero({
27
27
  });
28
28
  const DINERO_WEIGHT_G = {
29
29
  code: "WEIGHT_G",
30
+ // eslint-disable-next-line sonarjs/inconsistent-function-call
30
31
  base: Big(10),
31
32
  exponent: Big(0)
32
33
  };
@@ -1 +1 @@
1
- {"version":3,"file":"measures.mjs","sources":["../../src/utils/measures.ts"],"sourcesContent":["import { Big } from \"big.js\";\nimport type {\n LengthSystems,\n LengthUnits,\n MassSystems,\n MassUnits,\n} from \"convert-units\";\nimport configureMeasurements, { length, mass } from \"convert-units\";\nimport type { Calculator, ComparisonOperator, Transformer } from \"dinero.js\";\nimport { createDinero, toFormat } from \"dinero.js\";\n\nimport { UnitSystem } from \"../types\";\nimport { assert, assertUnreachable } from \"./errors\";\n\n// Measures: The names of the measures being used\ntype Measures = \"length\" | \"mass\";\n// Systems: The systems being used across all measures\ntype Systems = LengthSystems | MassSystems;\n// Units: All the units across all measures and their systems\ntype Units = LengthUnits | MassUnits;\n\nexport const convert = configureMeasurements<Measures, Systems, Units>({\n length,\n mass,\n});\n\nconst calculator: Calculator<Big> = {\n add: (a, b) => a.plus(b),\n compare: (a, b) => a.cmp(b) as unknown as ComparisonOperator,\n decrement: (v) => v.minus(new Big(1)),\n increment: (v) => v.plus(new Big(1)),\n integerDivide: (a, b) => a.div(b).round(0, Big.roundDown),\n modulo: (a, b) => a.mod(b),\n multiply: (a, b) => a.times(b),\n power: (a, b) => a.pow(Number(b)),\n subtract: (a, b) => a.minus(b),\n zero: () => new Big(0),\n toNumber: () => NaN,\n};\n\nconst dineroBigint = createDinero({ calculator });\n\n// type ConvertMassFromTo =\n// | { from: Unit.G; to: Unit.Kg }\n// | { from: Unit.Kg; to: Unit. }\n// | { from: Unit.G; to: Unit.Kg }\n// | { from: Unit.G; to: Unit.Kg }\n// | { from: Unit.G; to: Unit.Kg }\n// | { from: Unit.G; to: Unit.Kg }\n// export const convertMass = (value: number, {from, to}: ConvertMassFromTo) => {\n// return convert(value).from(from).to(to)\n// }\n\nconst DINERO_WEIGHT_G = {\n code: \"WEIGHT_G\",\n base: Big(10),\n exponent: Big(0),\n};\nconst DINERO_WEIGHT_OZ = {\n code: \"WEIGHT_OZ\",\n base: Big(10),\n exponent: Big(6),\n};\n\ntype TransformerOptions = Parameters<Transformer<Big>>[0];\nconst transformer = ({ currency, dineroObject }: TransformerOptions) => {\n const exponent = currency.exponent;\n const multiplier = Big(0.1).pow(exponent.toNumber());\n\n const jsonObject = dineroObject.toJSON();\n const formattedWeight = jsonObject.amount\n .mul(multiplier)\n .toFixed(exponent.toNumber());\n\n return formattedWeight.toString();\n};\n\n/**\n * In database we store weight in \"weird\" format.\n * For metric we store weight in grams as is.\n * For imperial we store weight in oz with \"virtual scale/exponent\" => 6.\n * e.g. 1_000_000 => '1'\n * e.g. 300_000 => '0.3'\n *\n * Database weight is stored either in g or oz\n */\nexport const transformDatabaseWeightToFormat = (\n databaseWeight: string,\n system: UnitSystem,\n): string => {\n switch (system) {\n case UnitSystem.Metric:\n return toFormat(\n dineroBigint({\n amount: Big(databaseWeight),\n currency: DINERO_WEIGHT_G,\n }),\n transformer,\n );\n case UnitSystem.Imperial: {\n return toFormat(\n dineroBigint({\n amount: Big(databaseWeight),\n currency: DINERO_WEIGHT_OZ,\n }),\n transformer,\n );\n }\n default:\n assertUnreachable(system);\n }\n};\n\n/**\n * Executes transformDatabaseWeightToFormat and returns it as number if safe integer\n *\n * Database weight is stored either in g or oz\n */\nexport const transformDatabaseWeightToNumber = (\n databaseWeight: string,\n system: UnitSystem,\n): number => {\n const formattedBig = Big(\n transformDatabaseWeightToFormat(databaseWeight, system),\n );\n\n assert(\n formattedBig.lte(Number.MAX_SAFE_INTEGER),\n \"Weight is not in safe integer range\",\n );\n return parseFloat(formattedBig.toString());\n};\n\n/**\n * Prepares floating number to be stored in database as normalized bigint\n *\n * Database weights are stored either in g or oz\n */\nexport const transformNumberToDatabaseWeight = (\n numberWeight: number,\n system: UnitSystem,\n): string => {\n switch (system) {\n case UnitSystem.Metric: {\n /**\n * convert(1).from(oz).to(g) is 28.34952g.\n * We are stripping sub-gram measures, because database is storing grams\n */\n const numberWeightInt = parseInt(numberWeight.toFixed(0));\n\n assert(\n !!Number.isSafeInteger(numberWeightInt),\n \"Number is not safe integer\",\n );\n\n return numberWeightInt.toString();\n }\n case UnitSystem.Imperial: {\n const weightBig = Big(numberWeight);\n const multiplier = Big(10).pow(DINERO_WEIGHT_OZ.exponent.toNumber());\n return weightBig.mul(multiplier).toFixed(0);\n }\n default:\n assertUnreachable(system);\n }\n};\n\n/**\n * Shorthand function to transform weight number to formatted string.\n *\n * ! Use only with base weights g/oz\n */\nexport const transformBaseWeightNumberToFormat = (\n databaseWeight: number,\n system: UnitSystem,\n): string =>\n transformDatabaseWeightToFormat(\n transformNumberToDatabaseWeight(databaseWeight, system),\n system,\n );\n"],"names":["convert","configureMeasurements","length","mass","calculator","add","a","b","plus","compare","cmp","decrement","v","minus","Big","increment","integerDivide","div","round","roundDown","modulo","mod","multiply","times","power","pow","Number","subtract","zero","toNumber","NaN","dineroBigint","createDinero","DINERO_WEIGHT_G","code","base","exponent","DINERO_WEIGHT_OZ","transformer","currency","dineroObject","multiplier","jsonObject","toJSON","formattedWeight","amount","mul","toFixed","toString","transformDatabaseWeightToFormat","databaseWeight","system","UnitSystem","Metric","toFormat","Imperial","assertUnreachable","transformDatabaseWeightToNumber","formattedBig","assert","lte","MAX_SAFE_INTEGER","parseFloat","transformNumberToDatabaseWeight","numberWeight","numberWeightInt","parseInt","isSafeInteger","weightBig","transformBaseWeightNumberToFormat"],"mappings":";;;;;;;AAqBO,MAAMA,UAAUC,qBAAgD,CAAA;EACrEC,MAAA;EACAC;AACF,CAAC,CAAA;AAED,MAAMC,UAA8B,GAAA;EAClCC,KAAKA,CAACC,CAAA,EAAGC,CAAM,KAAAD,CAAA,CAAEE,KAAKD,CAAC,CAAA;EACvBE,SAASA,CAACH,CAAA,EAAGC,CAAM,KAAAD,CAAA,CAAEI,IAAIH,CAAC,CAAA;EAC1BI,SAAA,EAAYC,CAAM,IAAAA,CAAA,CAAEC,MAAM,IAAIC,GAAA,CAAI,CAAC,CAAC,CAAA;EACpCC,SAAA,EAAYH,CAAM,IAAAA,CAAA,CAAEJ,KAAK,IAAIM,GAAA,CAAI,CAAC,CAAC,CAAA;EACnCE,aAAA,EAAeA,CAACV,CAAA,EAAGC,CAAM,KAAAD,CAAA,CAAEW,GAAI,CAAAV,CAAC,CAAE,CAAAW,KAAA,CAAM,CAAG,EAAAJ,GAAA,CAAIK,SAAS,CAAA;EACxDC,QAAQA,CAACd,CAAA,EAAGC,CAAM,KAAAD,CAAA,CAAEe,IAAId,CAAC,CAAA;EACzBe,UAAUA,CAAChB,CAAA,EAAGC,CAAM,KAAAD,CAAA,CAAEiB,MAAMhB,CAAC,CAAA;EAC7BiB,KAAA,EAAOA,CAAClB,CAAG,E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AOa,MAAAkB,iCAAA,GAAoCA,CAC/CnB,cAAA,EACAC,MAEA,KAAAF,+BAAA,CACEc,+BAAA,CAAgCb,gBAAgBC,MAAM,CAAA,EACtDA,MACF,CAAA;"}
1
+ {"version":3,"file":"measures.mjs","sources":["../../src/utils/measures.ts"],"sourcesContent":["import { Big } from \"big.js\";\nimport type {\n LengthSystems,\n LengthUnits,\n MassSystems,\n MassUnits,\n} from \"convert-units\";\nimport configureMeasurements, { length, mass } from \"convert-units\";\nimport type { Calculator, ComparisonOperator, Transformer } from \"dinero.js\";\nimport { createDinero, toFormat } from \"dinero.js\";\n\nimport { UnitSystem } from \"../types\";\nimport { assert, assertUnreachable } from \"./errors\";\n\n// Measures: The names of the measures being used\ntype Measures = \"length\" | \"mass\";\n// Systems: The systems being used across all measures\ntype Systems = LengthSystems | MassSystems;\n// Units: All the units across all measures and their systems\ntype Units = LengthUnits | MassUnits;\n\nexport const convert = configureMeasurements<Measures, Systems, Units>({\n length,\n mass,\n});\n\nconst calculator: Calculator<Big> = {\n add: (a, b) => a.plus(b),\n compare: (a, b) => a.cmp(b) as unknown as ComparisonOperator,\n decrement: (v) => v.minus(new Big(1)),\n increment: (v) => v.plus(new Big(1)),\n integerDivide: (a, b) => a.div(b).round(0, Big.roundDown),\n modulo: (a, b) => a.mod(b),\n multiply: (a, b) => a.times(b),\n power: (a, b) => a.pow(Number(b)),\n subtract: (a, b) => a.minus(b),\n zero: () => new Big(0),\n toNumber: () => NaN,\n};\n\nconst dineroBigint = createDinero({ calculator });\n\n// type ConvertMassFromTo =\n// | { from: Unit.G; to: Unit.Kg }\n// | { from: Unit.Kg; to: Unit. }\n// | { from: Unit.G; to: Unit.Kg }\n// | { from: Unit.G; to: Unit.Kg }\n// | { from: Unit.G; to: Unit.Kg }\n// | { from: Unit.G; to: Unit.Kg }\n// export const convertMass = (value: number, {from, to}: ConvertMassFromTo) => {\n// return convert(value).from(from).to(to)\n// }\n\nconst DINERO_WEIGHT_G = {\n code: \"WEIGHT_G\",\n // eslint-disable-next-line sonarjs/inconsistent-function-call\n base: Big(10),\n exponent: Big(0),\n};\nconst DINERO_WEIGHT_OZ = {\n code: \"WEIGHT_OZ\",\n base: Big(10),\n exponent: Big(6),\n};\n\ntype TransformerOptions = Parameters<Transformer<Big>>[0];\nconst transformer = ({ currency, dineroObject }: TransformerOptions) => {\n const exponent = currency.exponent;\n const multiplier = Big(0.1).pow(exponent.toNumber());\n\n const jsonObject = dineroObject.toJSON();\n const formattedWeight = jsonObject.amount\n .mul(multiplier)\n .toFixed(exponent.toNumber());\n\n return formattedWeight.toString();\n};\n\n/**\n * In database we store weight in \"weird\" format.\n * For metric we store weight in grams as is.\n * For imperial we store weight in oz with \"virtual scale/exponent\" => 6.\n * e.g. 1_000_000 => '1'\n * e.g. 300_000 => '0.3'\n *\n * Database weight is stored either in g or oz\n */\nexport const transformDatabaseWeightToFormat = (\n databaseWeight: string,\n system: UnitSystem,\n): string => {\n switch (system) {\n case UnitSystem.Metric:\n return toFormat(\n dineroBigint({\n amount: Big(databaseWeight),\n currency: DINERO_WEIGHT_G,\n }),\n transformer,\n );\n case UnitSystem.Imperial: {\n return toFormat(\n dineroBigint({\n amount: Big(databaseWeight),\n currency: DINERO_WEIGHT_OZ,\n }),\n transformer,\n );\n }\n default:\n assertUnreachable(system);\n }\n};\n\n/**\n * Executes transformDatabaseWeightToFormat and returns it as number if safe integer\n *\n * Database weight is stored either in g or oz\n */\nexport const transformDatabaseWeightToNumber = (\n databaseWeight: string,\n system: UnitSystem,\n): number => {\n const formattedBig = Big(\n transformDatabaseWeightToFormat(databaseWeight, system),\n );\n\n assert(\n formattedBig.lte(Number.MAX_SAFE_INTEGER),\n \"Weight is not in safe integer range\",\n );\n return parseFloat(formattedBig.toString());\n};\n\n/**\n * Prepares floating number to be stored in database as normalized bigint\n *\n * Database weights are stored either in g or oz\n */\nexport const transformNumberToDatabaseWeight = (\n numberWeight: number,\n system: UnitSystem,\n): string => {\n switch (system) {\n case UnitSystem.Metric: {\n /**\n * convert(1).from(oz).to(g) is 28.34952g.\n * We are stripping sub-gram measures, because database is storing grams\n */\n const numberWeightInt = parseInt(numberWeight.toFixed(0));\n\n assert(\n !!Number.isSafeInteger(numberWeightInt),\n \"Number is not safe integer\",\n );\n\n return numberWeightInt.toString();\n }\n case UnitSystem.Imperial: {\n const weightBig = Big(numberWeight);\n const multiplier = Big(10).pow(DINERO_WEIGHT_OZ.exponent.toNumber());\n return weightBig.mul(multiplier).toFixed(0);\n }\n default:\n assertUnreachable(system);\n }\n};\n\n/**\n * Shorthand function to transform weight number to formatted string.\n *\n * ! Use only with base weights g/oz\n */\nexport const transformBaseWeightNumberToFormat = (\n databaseWeight: number,\n system: UnitSystem,\n): string =>\n transformDatabaseWeightToFormat(\n transformNumberToDatabaseWeight(databaseWeight, system),\n system,\n );\n"],"names":["convert","configureMeasurements","length","mass","calculator","add","a","b","plus","compare","cmp","decrement","v","minus","Big","increment","integerDivide","div","round","roundDown","modulo","mod","multiply","times","power","pow","Number","subtract","zero","toNumber","NaN","dineroBigint","createDinero","DINERO_WEIGHT_G","code","base","exponent","DINERO_WEIGHT_OZ","transformer","currency","dineroObject","multiplier","jsonObject","toJSON","formattedWeight","amount","mul","toFixed","toString","transformDatabaseWeightToFormat","databaseWeight","system","UnitSystem","Metric","toFormat","Imperial","assertUnreachable","transformDatabaseWeightToNumber","formattedBig","assert","lte","MAX_SAFE_INTEGER","parseFloat","transformNumberToDatabaseWeight","numberWeight","numberWeightInt","parseInt","isSafeInteger","weightBig","transformBaseWeightNumberToFormat"],"mappings":";;;;;;;AAqBO,MAAMA,UAAUC,qBAAgD,CAAA;EACrEC,MAAA;EACAC;AACF,CAAC,CAAA;AAED,MAAMC,UAA8B,GAAA;EAClCC,KAAKA,CAACC,CAAA,EAAGC,CAAM,KAAAD,CAAA,CAAEE,KAAKD,CAAC,CAAA;EACvBE,SAASA,CAACH,CAAA,EAAGC,CAAM,KAAAD,CAAA,CAAEI,IAAIH,CAAC,CAA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tB,MAAMY,eAAkB,GAAAC,QAAA,CAASF,YAAa,CAAAjB,OAAA,CAAQ,CAAC,CAAC,CAAA;QAExDY,MAAA,CACE,CAAC,CAACjC,MAAO,CAAAyC,aAAA,CAAcF,eAAe,CAAA,EACtC,4BAAA,CACF;QAEA,OAAOA,gBAAgBjB,QAAS,EAAA;MAClC;IACA,KAAKI,WAAWG,QAAU;MAAA;QAClB,MAAAa,SAAA,GAAYtD,IAAIkD,YAAY,CAAA;QAC5B,MAAAvB,UAAA,GAAa3B,IAAI,EAAE,CAAA,CAAEW,IAAIY,gBAAiB,CAAAD,QAAA,CAASP,UAAU,CAAA;QACnE,OAAOuC,SAAU,CAAAtB,GAAA,CAAIL,UAAU,CAAA,CAAEM,QAAQ,CAAC,CAAA;MAC5C;IACA;MACES,iBAAA,CAAkBL,MAAM,CAAA;EAC5B;AACF,CAAA;AAOa,MAAAkB,iCAAA,GAAoCA,CAC/CnB,cAAA,EACAC,MAEA,KAAAF,+BAAA,CACEc,+BAAA,CAAgCb,gBAAgBC,MAAM,CAAA,EACtDA,MACF,CAAA;"}
@@ -1 +1 @@
1
- {"version":3,"file":"format.js","sources":["../../../src/utils/money/format.ts"],"sourcesContent":["import { CAD, EUR, GBP } from \"@dinero.js/currencies\";\nimport { hasSubUnits, toFormat, toUnit } from \"dinero.js\";\n\nimport type { Currency, Nullish } from \"../../types\";\nimport { assert } from \"../errors\";\nimport {\n localizedCurrencyLookup,\n prettifyPriceLookup,\n Round,\n} from \"./constants\";\nimport { getDinero, roundDinero } from \"./misc\";\nimport type { Dino, LocalizedCurrency, Money } from \"./types\";\n\nexport const getLocalizedCurrency = (\n currencyCode: Nullish<Currency>,\n): LocalizedCurrency | undefined => {\n return currencyCode ? localizedCurrencyLookup.get(currencyCode) : undefined;\n};\n\n// #############################################################################\n// Formatter\n// #############################################################################\nconst currencyFormatterCache = new Map<string, Intl.NumberFormat>();\n/**\n * Function to get a Int.NumberFormat instance that can be reused to format currency over using\n * `Number.toLocaleString(...)` function, which makes more sense to use as we usually just display 1 or 2 currencies\n * MAX, so reusing the formatted makes a lot of sense\n * @see https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number/toLocaleString#performance\n */\nconst getCurrencyFormatter = (\n locale: string,\n currencyCode: string,\n): Intl.NumberFormat => {\n const cacheKey = `${locale}_${currencyCode}`;\n\n let formatter = currencyFormatterCache.get(cacheKey);\n if (formatter) {\n return formatter;\n }\n\n formatter = new Intl.NumberFormat(locale, {\n style: \"currency\",\n currency: currencyCode,\n /**\n * Explicitly define default behavior - just in case some runtime overrides it\n * @see https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/NumberFormat/NumberFormat#currencysign\n * @see https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/NumberFormat/NumberFormat#currencydisplay\n */\n currencySign: \"standard\",\n currencyDisplay: \"symbol\",\n });\n currencyFormatterCache.set(cacheKey, formatter);\n\n return formatter;\n};\n\nexport type FormatPriceOptions = {\n /**\n * Optionally remove trailing zeroes (only if all of them are 0)\n * @default false\n * @example\n * \"420,66 €\" => \"420,66 €\"\n * \"420,60 €\" => \"420,60 €\"\n * \"420,00 €\" => \"420 €\"\n */\n removeTrailingZeros?: boolean;\n /**\n * Optionally return currency rounded down to the nearest dollar-equivalent of a the given currency. Doesn't apply any\n * rounding just \"trims\" end decimal values\n *\n * ! Only use for display purposes where monetary precision is not required!\n *\n * @default false\n * @example\n * \"420,66 €\" => \"420 €\"\n * \"420,60 €\" => \"420 €\"\n * \"420,00 €\" => \"420 €\"\n */\n removeFractions?: boolean;\n};\n\n/**\n * Currency formatter based on dinero currency types and browser internationalizing functions\n *\n * Based on:\n * @see https://v2.dinerojs.com/docs/guides/formatting-in-a-multilingual-site#building-a-custom-internationalization-formatter\n * @protected\n * @deprecated Use `formatPrice` instead as this functions is for INTERNAL USE ONLY! (function not actual deprecated,\n * just marked so it discourages usage of it)\n */\nexport function formatPriceRaw(\n dinero: Dino,\n locale: string,\n options?: FormatPriceOptions,\n): string {\n return toFormat(dinero, ({ amount, currency }) => {\n const formatter = getCurrencyFormatter(locale, currency.code);\n const formatted = formatter.format(amount);\n\n return options?.removeFractions || options?.removeTrailingZeros\n ? /**\n * Regex to handle complex removing trailing zeros from currency\n * - Dynamically create regex based on currency as their exponent changes\n * - Also handles some currencies (e.g. EUR) having trailing currency symbol\n *\n * TODO: improve how we detect \"decimal separator\" for formatted currency, at least right now we have tests for it and doesn't seem like an issue\n */\n formatted.replace(\n // For some reason `\\.` need to be double-escaped `\\\\` when creating the regex from template string\n new RegExp(\n `(\\\\.|,)${\n // Depending options remove all trailing digits or just zeros, this way we don't need to do any rounding\n options?.removeFractions ? \"\\\\d\" : 0\n }{0,${currency.exponent}}(\\\\s\\\\D)?$`,\n ),\n // In the replaced using \"last capture group\" (if-exists) so we restore the trailing currency sign\n \"$2\",\n )\n : formatted;\n });\n}\n\n/**\n * Currency formatter based on dinero currency types and browser internationalizing functions\n *\n * In reality just a wrapper around `formatPriceRaw` that does the real formatting\n */\nexport const formatPrice = (\n money: Money,\n options?: FormatPriceOptions,\n): string => {\n const localizedCurrency = getLocalizedCurrency(money.currency);\n assert(!!localizedCurrency, `Currency ${money.currency} not supported`);\n\n return formatPriceRaw(\n getDinero(money.amount, money.currency),\n localizedCurrency.locale,\n options,\n );\n};\n\n/**\n * Prettify numbers depending on the currency using rounding down.\n * ! Should only be used to prettify storefront product prices after currency conversion but nothing else !\n */\nexport const prettifyTotal = (total: Dino): Dino => {\n const totalJson = total.toJSON();\n\n switch (totalJson.currency.code) {\n // @see: https://ubiquiti.atlassian.net/browse/NEP-3846\n case EUR.code:\n case GBP.code:\n case CAD.code: {\n const totalAsFloat = toUnit(total);\n\n if (totalAsFloat < 10) {\n return roundDinero(total, Round.PrettifyDecimalCents);\n } else if (totalAsFloat < 20) {\n return roundDinero(total, Round.PrettifyHalfUnitCents);\n } else if (totalAsFloat < 50) {\n return roundDinero(total, Round.Prettify);\n } else {\n return roundDinero(total, Round.PrettifyFull059);\n }\n }\n default: {\n // Nothing to round\n if (!hasSubUnits(total)) {\n return total;\n }\n\n const minValueInclusiveToRoundDownFrom = prettifyPriceLookup.get(\n totalJson.currency.code,\n );\n\n // Don't round if currency unsupported or value is below min threshold\n if (\n minValueInclusiveToRoundDownFrom == null ||\n toUnit(total) < minValueInclusiveToRoundDownFrom\n ) {\n return total;\n }\n\n return roundDinero(total, Round.Prettify);\n }\n }\n};\n"],"names":["getLocalizedCurrency","currencyCode","localizedCurrencyLookup","get","currencyFormatterCache","Map","getCurrencyFormatter","locale","cacheKey","formatter","Intl","NumberFormat","style","currency","currencySign","currencyDisplay","set","formatPriceRaw","dinero","options","toFormat","amount","code","formatted","format","removeFractions","removeTrailingZeros","replace","RegExp","exponent","formatPrice","money","localizedCurrency","assert","getDinero","prettifyTotal","total","totalJson","toJSON","EUR","GBP","CAD","totalAsFloat","toUnit","roundDinero","Round","PrettifyDecimalCents","PrettifyHalfUnitCents","Prettify","PrettifyFull059","hasSubUnits","minValueInclusiveToRoundDownFrom","prettifyPriceLookup"],"mappings":";;;;;;;;AAaa,MAAAA,oBAAA,GACXC,YACkC,IAAA;EAClC,OAAOA,YAAe,GAAAC,SAAAA,CAAAA,uBAAA,CAAwBC,GAAI,CAAAF,YAAY,CAAI,GAAA,KAAA,CAAA;AACpE,CAAA;AAKA,MAAMG,sBAAA,GAAA,mBAA6BC,GAA+B,EAAA;AAOlE,MAAMC,oBAAA,GAAuBA,CAC3BC,MAAA,EACAN,YACsB,KAAA;EACtB,MAAMO,QAAW,GAAA,GAAGD,MAAM,IAAIN,YAAY,EAAA;EAEtC,IAAAQ,SAAA,GAAYL,sBAAuB,CAAAD,GAAA,CAAIK,QAAQ,CAAA;EACnD,IAAIC,SAAW,EAAA;IACN,OAAAA,SAAA;EACT;EAEYA,SAAA,GAAA,IAAIC,IAAK,CAAAC,YAAA,CAAaJ,MAAQ,EAAA;IACxCK,KAAO,EAAA,UAAA;IAC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AD, EUR, GBP } from \"@dinero.js/currencies\";\nimport { hasSubUnits, toFormat, toUnit } from \"dinero.js\";\n\nimport type { Currency, Nullish } from \"../../types\";\nimport { assert } from \"../errors\";\nimport {\n localizedCurrencyLookup,\n prettifyPriceLookup,\n Round,\n} from \"./constants\";\nimport { getDinero, roundDinero } from \"./misc\";\nimport type { Dino, LocalizedCurrency, Money } from \"./types\";\n\nexport const getLocalizedCurrency = (\n currencyCode: Nullish<Currency>,\n): LocalizedCurrency | undefined => {\n return currencyCode ? localizedCurrencyLookup.get(currencyCode) : undefined;\n};\n\n// #############################################################################\n// Formatter\n// #############################################################################\nconst currencyFormatterCache = new Map<string, Intl.NumberFormat>();\n/**\n * Function to get a Int.NumberFormat instance that can be reused to format currency over using\n * `Number.toLocaleString(...)` function, which makes more sense to use as we usually just display 1 or 2 currencies\n * MAX, so reusing the formatted makes a lot of sense\n * @see https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number/toLocaleString#performance\n */\nconst getCurrencyFormatter = (\n locale: string,\n currencyCode: string,\n): Intl.NumberFormat => {\n const cacheKey = `${locale}_${currencyCode}`;\n\n let formatter = currencyFormatterCache.get(cacheKey);\n if (formatter) {\n return formatter;\n }\n\n formatter = new Intl.NumberFormat(locale, {\n style: \"currency\",\n currency: currencyCode,\n /**\n * Explicitly define default behavior - just in case some runtime overrides it\n * @see https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/NumberFormat/NumberFormat#currencysign\n * @see https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/NumberFormat/NumberFormat#currencydisplay\n */\n currencySign: \"standard\",\n currencyDisplay: \"symbol\",\n });\n currencyFormatterCache.set(cacheKey, formatter);\n\n return formatter;\n};\n\nexport type FormatPriceOptions = {\n /**\n * Optionally remove trailing zeroes (only if all of them are 0)\n * @default false\n * @example\n * \"420,66 €\" => \"420,66 €\"\n * \"420,60 €\" => \"420,60 €\"\n * \"420,00 €\" => \"420 €\"\n */\n removeTrailingZeros?: boolean;\n /**\n * Optionally return currency rounded down to the nearest dollar-equivalent of a the given currency. Doesn't apply any\n * rounding just \"trims\" end decimal values\n *\n * ! Only use for display purposes where monetary precision is not required!\n *\n * @default false\n * @example\n * \"420,66 €\" => \"420 €\"\n * \"420,60 €\" => \"420 €\"\n * \"420,00 €\" => \"420 €\"\n */\n removeFractions?: boolean;\n};\n\n/**\n * Currency formatter based on dinero currency types and browser internationalizing functions\n *\n * Based on:\n * @see https://v2.dinerojs.com/docs/guides/formatting-in-a-multilingual-site#building-a-custom-internationalization-formatter\n * @protected\n * @deprecated Use `formatPrice` instead as this functions is for INTERNAL USE ONLY! (function not actual deprecated,\n * just marked so it discourages usage of it)\n */\nexport function formatPriceRaw(\n dinero: Dino,\n locale: string,\n options?: FormatPriceOptions,\n): string {\n return toFormat(dinero, ({ amount, currency }) => {\n const formatter = getCurrencyFormatter(locale, currency.code);\n const formatted = formatter.format(amount);\n\n return options?.removeFractions || options?.removeTrailingZeros\n ? /**\n * Regex to handle complex removing trailing zeros from currency\n * - Dynamically create regex based on currency as their exponent changes\n * - Also handles some currencies (e.g. EUR) having trailing currency symbol\n *\n * TODO: improve how we detect \"decimal separator\" for formatted currency, at least right now we have tests for it and doesn't seem like an issue\n */\n formatted.replace(\n // For some reason `\\.` need to be double-escaped `\\\\` when creating the regex from template string\n new RegExp(\n `(\\\\.|,)${\n // Depending options remove all trailing digits or just zeros, this way we don't need to do any rounding\n options?.removeFractions ? \"\\\\d\" : 0\n }{0,${currency.exponent}}(\\\\s\\\\D)?$`,\n ),\n // In the replaced using \"last capture group\" (if-exists) so we restore the trailing currency sign\n \"$2\",\n )\n : formatted;\n });\n}\n\n/**\n * Currency formatter based on dinero currency types and browser internationalizing functions\n *\n * In reality just a wrapper around `formatPriceRaw` that does the real formatting\n */\nexport const formatPrice = (\n money: Money,\n options?: FormatPriceOptions,\n): string => {\n const localizedCurrency = getLocalizedCurrency(money.currency);\n assert(!!localizedCurrency, `Currency ${money.currency} not supported`);\n\n // eslint-disable-next-line sonarjs/deprecation\n return formatPriceRaw(\n getDinero(money.amount, money.currency),\n localizedCurrency.locale,\n options,\n );\n};\n\n/**\n * Prettify numbers depending on the currency using rounding down.\n * ! Should only be used to prettify storefront product prices after currency conversion but nothing else !\n */\nexport const prettifyTotal = (total: Dino): Dino => {\n const totalJson = total.toJSON();\n\n switch (totalJson.currency.code) {\n // @see: https://ubiquiti.atlassian.net/browse/NEP-3846\n case EUR.code:\n case GBP.code:\n case CAD.code: {\n const totalAsFloat = toUnit(total);\n\n if (totalAsFloat < 10) {\n return roundDinero(total, Round.PrettifyDecimalCents);\n } else if (totalAsFloat < 20) {\n return roundDinero(total, Round.PrettifyHalfUnitCents);\n } else if (totalAsFloat < 50) {\n return roundDinero(total, Round.Prettify);\n } else {\n return roundDinero(total, Round.PrettifyFull059);\n }\n }\n default: {\n // Nothing to round\n if (!hasSubUnits(total)) {\n return total;\n }\n\n const minValueInclusiveToRoundDownFrom = prettifyPriceLookup.get(\n totalJson.currency.code,\n );\n\n // Don't round if currency unsupported or value is below min threshold\n if (\n minValueInclusiveToRoundDownFrom == null ||\n toUnit(total) < minValueInclusiveToRoundDownFrom\n ) {\n return total;\n }\n\n return roundDinero(total, Round.Prettify);\n }\n }\n};\n"],"names":["getLocalizedCurrency","currencyCode","localizedCurrencyLookup","get","currencyFormatterCache","Map","getCurrencyFormatter","locale","cacheKey","formatter","Intl","NumberFormat","style","currency","currencySign","currencyDisplay","set","formatPriceRaw","dinero","options","toFormat","amount","code","formatted","format","removeFractions","removeTrailingZeros","replace","RegExp","exponent","formatPrice","money","localizedCurrency","assert","getDinero","prettifyTotal","total","totalJson","toJSON","EUR","GBP","CAD","totalAsFloat","toUnit","roundDinero","Round","PrettifyDecimalCents","PrettifyHalfUnitCents","Prettify","PrettifyFull059","hasSubUnits","minValueInclusiveToRoundDownFrom","prettifyPriceLookup"],"mappings":";;;;;;;;AAaa,MAAAA,oBAAA,GACX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e,CAAA;QACjD;MACF;IACA;MAAS;QAEH,IAAA,CAACC,SAAAA,CAAAA,WAAY,CAAAd,KAAK,CAAG,EAAA;UAChB,OAAAA,KAAA;QACT;QAEA,MAAMe,mCAAmCC,SAAAA,CAAAA,mBAAoB,CAAAjD,GAAA,CAC3DkC,UAAUxB,QAAS,CAAAS,IAAA,CACrB;QAGA,IACE6B,gCAAoC,IAAA,IAAA,IACpCR,SAAO,CAAAA,MAAA,CAAAP,KAAK,IAAIe,gCAChB,EAAA;UACO,OAAAf,KAAA;QACT;QAEO,OAAAQ,gBAAA,CAAYR,KAAO,EAAAS,SAAA,CAAAA,KAAA,CAAMG,QAAQ,CAAA;MAC1C;EACF;AACF,CAAA;;;;"}
@@ -1 +1 @@
1
- {"version":3,"file":"format.mjs","sources":["../../../src/utils/money/format.ts"],"sourcesContent":["import { CAD, EUR, GBP } from \"@dinero.js/currencies\";\nimport { hasSubUnits, toFormat, toUnit } from \"dinero.js\";\n\nimport type { Currency, Nullish } from \"../../types\";\nimport { assert } from \"../errors\";\nimport {\n localizedCurrencyLookup,\n prettifyPriceLookup,\n Round,\n} from \"./constants\";\nimport { getDinero, roundDinero } from \"./misc\";\nimport type { Dino, LocalizedCurrency, Money } from \"./types\";\n\nexport const getLocalizedCurrency = (\n currencyCode: Nullish<Currency>,\n): LocalizedCurrency | undefined => {\n return currencyCode ? localizedCurrencyLookup.get(currencyCode) : undefined;\n};\n\n// #############################################################################\n// Formatter\n// #############################################################################\nconst currencyFormatterCache = new Map<string, Intl.NumberFormat>();\n/**\n * Function to get a Int.NumberFormat instance that can be reused to format currency over using\n * `Number.toLocaleString(...)` function, which makes more sense to use as we usually just display 1 or 2 currencies\n * MAX, so reusing the formatted makes a lot of sense\n * @see https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number/toLocaleString#performance\n */\nconst getCurrencyFormatter = (\n locale: string,\n currencyCode: string,\n): Intl.NumberFormat => {\n const cacheKey = `${locale}_${currencyCode}`;\n\n let formatter = currencyFormatterCache.get(cacheKey);\n if (formatter) {\n return formatter;\n }\n\n formatter = new Intl.NumberFormat(locale, {\n style: \"currency\",\n currency: currencyCode,\n /**\n * Explicitly define default behavior - just in case some runtime overrides it\n * @see https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/NumberFormat/NumberFormat#currencysign\n * @see https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/NumberFormat/NumberFormat#currencydisplay\n */\n currencySign: \"standard\",\n currencyDisplay: \"symbol\",\n });\n currencyFormatterCache.set(cacheKey, formatter);\n\n return formatter;\n};\n\nexport type FormatPriceOptions = {\n /**\n * Optionally remove trailing zeroes (only if all of them are 0)\n * @default false\n * @example\n * \"420,66 €\" => \"420,66 €\"\n * \"420,60 €\" => \"420,60 €\"\n * \"420,00 €\" => \"420 €\"\n */\n removeTrailingZeros?: boolean;\n /**\n * Optionally return currency rounded down to the nearest dollar-equivalent of a the given currency. Doesn't apply any\n * rounding just \"trims\" end decimal values\n *\n * ! Only use for display purposes where monetary precision is not required!\n *\n * @default false\n * @example\n * \"420,66 €\" => \"420 €\"\n * \"420,60 €\" => \"420 €\"\n * \"420,00 €\" => \"420 €\"\n */\n removeFractions?: boolean;\n};\n\n/**\n * Currency formatter based on dinero currency types and browser internationalizing functions\n *\n * Based on:\n * @see https://v2.dinerojs.com/docs/guides/formatting-in-a-multilingual-site#building-a-custom-internationalization-formatter\n * @protected\n * @deprecated Use `formatPrice` instead as this functions is for INTERNAL USE ONLY! (function not actual deprecated,\n * just marked so it discourages usage of it)\n */\nexport function formatPriceRaw(\n dinero: Dino,\n locale: string,\n options?: FormatPriceOptions,\n): string {\n return toFormat(dinero, ({ amount, currency }) => {\n const formatter = getCurrencyFormatter(locale, currency.code);\n const formatted = formatter.format(amount);\n\n return options?.removeFractions || options?.removeTrailingZeros\n ? /**\n * Regex to handle complex removing trailing zeros from currency\n * - Dynamically create regex based on currency as their exponent changes\n * - Also handles some currencies (e.g. EUR) having trailing currency symbol\n *\n * TODO: improve how we detect \"decimal separator\" for formatted currency, at least right now we have tests for it and doesn't seem like an issue\n */\n formatted.replace(\n // For some reason `\\.` need to be double-escaped `\\\\` when creating the regex from template string\n new RegExp(\n `(\\\\.|,)${\n // Depending options remove all trailing digits or just zeros, this way we don't need to do any rounding\n options?.removeFractions ? \"\\\\d\" : 0\n }{0,${currency.exponent}}(\\\\s\\\\D)?$`,\n ),\n // In the replaced using \"last capture group\" (if-exists) so we restore the trailing currency sign\n \"$2\",\n )\n : formatted;\n });\n}\n\n/**\n * Currency formatter based on dinero currency types and browser internationalizing functions\n *\n * In reality just a wrapper around `formatPriceRaw` that does the real formatting\n */\nexport const formatPrice = (\n money: Money,\n options?: FormatPriceOptions,\n): string => {\n const localizedCurrency = getLocalizedCurrency(money.currency);\n assert(!!localizedCurrency, `Currency ${money.currency} not supported`);\n\n return formatPriceRaw(\n getDinero(money.amount, money.currency),\n localizedCurrency.locale,\n options,\n );\n};\n\n/**\n * Prettify numbers depending on the currency using rounding down.\n * ! Should only be used to prettify storefront product prices after currency conversion but nothing else !\n */\nexport const prettifyTotal = (total: Dino): Dino => {\n const totalJson = total.toJSON();\n\n switch (totalJson.currency.code) {\n // @see: https://ubiquiti.atlassian.net/browse/NEP-3846\n case EUR.code:\n case GBP.code:\n case CAD.code: {\n const totalAsFloat = toUnit(total);\n\n if (totalAsFloat < 10) {\n return roundDinero(total, Round.PrettifyDecimalCents);\n } else if (totalAsFloat < 20) {\n return roundDinero(total, Round.PrettifyHalfUnitCents);\n } else if (totalAsFloat < 50) {\n return roundDinero(total, Round.Prettify);\n } else {\n return roundDinero(total, Round.PrettifyFull059);\n }\n }\n default: {\n // Nothing to round\n if (!hasSubUnits(total)) {\n return total;\n }\n\n const minValueInclusiveToRoundDownFrom = prettifyPriceLookup.get(\n totalJson.currency.code,\n );\n\n // Don't round if currency unsupported or value is below min threshold\n if (\n minValueInclusiveToRoundDownFrom == null ||\n toUnit(total) < minValueInclusiveToRoundDownFrom\n ) {\n return total;\n }\n\n return roundDinero(total, Round.Prettify);\n }\n }\n};\n"],"names":["getLocalizedCurrency","currencyCode","localizedCurrencyLookup","get","currencyFormatterCache","Map","getCurrencyFormatter","locale","cacheKey","formatter","Intl","NumberFormat","style","currency","currencySign","currencyDisplay","set","formatPriceRaw","dinero","options","toFormat","amount","code","formatted","format","removeFractions","removeTrailingZeros","replace","RegExp","exponent","formatPrice","money","localizedCurrency","assert","getDinero","prettifyTotal","total","totalJson","toJSON","EUR","GBP","CAD","totalAsFloat","toUnit","roundDinero","Round","PrettifyDecimalCents","PrettifyHalfUnitCents","Prettify","PrettifyFull059","hasSubUnits","minValueInclusiveToRoundDownFrom","prettifyPriceLookup"],"mappings":";;;;;;AAaa,MAAAA,oBAAA,GACXC,YACkC,IAAA;EAClC,OAAOA,YAAe,GAAAC,uBAAA,CAAwBC,GAAI,CAAAF,YAAY,CAAI,GAAA,KAAA,CAAA;AACpE,CAAA;AAKA,MAAMG,sBAAA,GAAA,mBAA6BC,GAA+B,EAAA;AAOlE,MAAMC,oBAAA,GAAuBA,CAC3BC,MAAA,EACAN,YACsB,KAAA;EACtB,MAAMO,QAAW,GAAA,GAAGD,MAAM,IAAIN,YAAY,EAAA;EAEtC,IAAAQ,SAAA,GAAYL,sBAAuB,CAAAD,GAAA,CAAIK,QAAQ,CAAA;EACnD,IAAIC,SAAW,EAAA;IACN,OAAAA,SAAA;EACT;EAEYA,SAAA,GAAA,IAAIC,IAAK,CAAAC,YAAA,CAAaJ,MAAQ,EAAA;IACxCK,KAAO,EAAA,UAAA;IACPC,QAAU,EAAAZ,YAAA;IAAA;AAAA;AAAA;AAAA;AAAA;IAMVa,YAAc,EAAA,UAAA;IACdC,eAAiB,EAAA;EAAA,CAClB,CAAA;EACsBX,sBAAA,CAAAY,GAAA,CAAIR,UAAUC,SAAS,CAAA;EAEvC,OAAAA,SAAA;AACT,CAAA;AAoCgB,SAAAQ,cAAAA,CACdC,MACA,EAA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A;UACd,OAAAE,WAAA,CAAYR,KAAO,EAAAS,KAAA,CAAMC,oBAAoB,CAAA;QAAA,CACtD,MAAA,IAAWJ,eAAe,EAAI,EAAA;UACrB,OAAAE,WAAA,CAAYR,KAAO,EAAAS,KAAA,CAAME,qBAAqB,CAAA;QAAA,CACvD,MAAA,IAAWL,eAAe,EAAI,EAAA;UACrB,OAAAE,WAAA,CAAYR,KAAO,EAAAS,KAAA,CAAMG,QAAQ,CAAA;QAAA,CACnC,MAAA;UACE,OAAAJ,WAAA,CAAYR,KAAO,EAAAS,KAAA,CAAMI,eAAe,CAAA;QACjD;MACF;IACA;MAAS;QAEH,IAAA,CAACC,WAAY,CAAAd,KAAK,CAAG,EAAA;UAChB,OAAAA,KAAA;QACT;QAEA,MAAMe,mCAAmCC,mBAAoB,CAAAjD,GAAA,CAC3DkC,UAAUxB,QAAS,CAAAS,IAAA,CACrB;QAGA,IACE6B,gCAAoC,IAAA,IAAA,IACpCR,MAAO,CAAAP,KAAK,IAAIe,gCAChB,EAAA;UACO,OAAAf,KAAA;QACT;QAEO,OAAAQ,WAAA,CAAYR,KAAO,EAAAS,KAAA,CAAMG,QAAQ,CAAA;MAC1C;EACF;AACF,CAAA;"}
1
+ {"version":3,"file":"format.mjs","sources":["../../../src/utils/money/format.ts"],"sourcesContent":["import { CAD, EUR, GBP } from \"@dinero.js/currencies\";\nimport { hasSubUnits, toFormat, toUnit } from \"dinero.js\";\n\nimport type { Currency, Nullish } from \"../../types\";\nimport { assert } from \"../errors\";\nimport {\n localizedCurrencyLookup,\n prettifyPriceLookup,\n Round,\n} from \"./constants\";\nimport { getDinero, roundDinero } from \"./misc\";\nimport type { Dino, LocalizedCurrency, Money } from \"./types\";\n\nexport const getLocalizedCurrency = (\n currencyCode: Nullish<Currency>,\n): LocalizedCurrency | undefined => {\n return currencyCode ? localizedCurrencyLookup.get(currencyCode) : undefined;\n};\n\n// #############################################################################\n// Formatter\n// #############################################################################\nconst currencyFormatterCache = new Map<string, Intl.NumberFormat>();\n/**\n * Function to get a Int.NumberFormat instance that can be reused to format currency over using\n * `Number.toLocaleString(...)` function, which makes more sense to use as we usually just display 1 or 2 currencies\n * MAX, so reusing the formatted makes a lot of sense\n * @see https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number/toLocaleString#performance\n */\nconst getCurrencyFormatter = (\n locale: string,\n currencyCode: string,\n): Intl.NumberFormat => {\n const cacheKey = `${locale}_${currencyCode}`;\n\n let formatter = currencyFormatterCache.get(cacheKey);\n if (formatter) {\n return formatter;\n }\n\n formatter = new Intl.NumberFormat(locale, {\n style: \"currency\",\n currency: currencyCode,\n /**\n * Explicitly define default behavior - just in case some runtime overrides it\n * @see https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/NumberFormat/NumberFormat#currencysign\n * @see https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/NumberFormat/NumberFormat#currencydisplay\n */\n currencySign: \"standard\",\n currencyDisplay: \"symbol\",\n });\n currencyFormatterCache.set(cacheKey, formatter);\n\n return formatter;\n};\n\nexport type FormatPriceOptions = {\n /**\n * Optionally remove trailing zeroes (only if all of them are 0)\n * @default false\n * @example\n * \"420,66 €\" => \"420,66 €\"\n * \"420,60 €\" => \"420,60 €\"\n * \"420,00 €\" => \"420 €\"\n */\n removeTrailingZeros?: boolean;\n /**\n * Optionally return currency rounded down to the nearest dollar-equivalent of a the given currency. Doesn't apply any\n * rounding just \"trims\" end decimal values\n *\n * ! Only use for display purposes where monetary precision is not required!\n *\n * @default false\n * @example\n * \"420,66 €\" => \"420 €\"\n * \"420,60 €\" => \"420 €\"\n * \"420,00 €\" => \"420 €\"\n */\n removeFractions?: boolean;\n};\n\n/**\n * Currency formatter based on dinero currency types and browser internationalizing functions\n *\n * Based on:\n * @see https://v2.dinerojs.com/docs/guides/formatting-in-a-multilingual-site#building-a-custom-internationalization-formatter\n * @protected\n * @deprecated Use `formatPrice` instead as this functions is for INTERNAL USE ONLY! (function not actual deprecated,\n * just marked so it discourages usage of it)\n */\nexport function formatPriceRaw(\n dinero: Dino,\n locale: string,\n options?: FormatPriceOptions,\n): string {\n return toFormat(dinero, ({ amount, currency }) => {\n const formatter = getCurrencyFormatter(locale, currency.code);\n const formatted = formatter.format(amount);\n\n return options?.removeFractions || options?.removeTrailingZeros\n ? /**\n * Regex to handle complex removing trailing zeros from currency\n * - Dynamically create regex based on currency as their exponent changes\n * - Also handles some currencies (e.g. EUR) having trailing currency symbol\n *\n * TODO: improve how we detect \"decimal separator\" for formatted currency, at least right now we have tests for it and doesn't seem like an issue\n */\n formatted.replace(\n // For some reason `\\.` need to be double-escaped `\\\\` when creating the regex from template string\n new RegExp(\n `(\\\\.|,)${\n // Depending options remove all trailing digits or just zeros, this way we don't need to do any rounding\n options?.removeFractions ? \"\\\\d\" : 0\n }{0,${currency.exponent}}(\\\\s\\\\D)?$`,\n ),\n // In the replaced using \"last capture group\" (if-exists) so we restore the trailing currency sign\n \"$2\",\n )\n : formatted;\n });\n}\n\n/**\n * Currency formatter based on dinero currency types and browser internationalizing functions\n *\n * In reality just a wrapper around `formatPriceRaw` that does the real formatting\n */\nexport const formatPrice = (\n money: Money,\n options?: FormatPriceOptions,\n): string => {\n const localizedCurrency = getLocalizedCurrency(money.currency);\n assert(!!localizedCurrency, `Currency ${money.currency} not supported`);\n\n // eslint-disable-next-line sonarjs/deprecation\n return formatPriceRaw(\n getDinero(money.amount, money.currency),\n localizedCurrency.locale,\n options,\n );\n};\n\n/**\n * Prettify numbers depending on the currency using rounding down.\n * ! Should only be used to prettify storefront product prices after currency conversion but nothing else !\n */\nexport const prettifyTotal = (total: Dino): Dino => {\n const totalJson = total.toJSON();\n\n switch (totalJson.currency.code) {\n // @see: https://ubiquiti.atlassian.net/browse/NEP-3846\n case EUR.code:\n case GBP.code:\n case CAD.code: {\n const totalAsFloat = toUnit(total);\n\n if (totalAsFloat < 10) {\n return roundDinero(total, Round.PrettifyDecimalCents);\n } else if (totalAsFloat < 20) {\n return roundDinero(total, Round.PrettifyHalfUnitCents);\n } else if (totalAsFloat < 50) {\n return roundDinero(total, Round.Prettify);\n } else {\n return roundDinero(total, Round.PrettifyFull059);\n }\n }\n default: {\n // Nothing to round\n if (!hasSubUnits(total)) {\n return total;\n }\n\n const minValueInclusiveToRoundDownFrom = prettifyPriceLookup.get(\n totalJson.currency.code,\n );\n\n // Don't round if currency unsupported or value is below min threshold\n if (\n minValueInclusiveToRoundDownFrom == null ||\n toUnit(total) < minValueInclusiveToRoundDownFrom\n ) {\n return total;\n }\n\n return roundDinero(total, Round.Prettify);\n }\n }\n};\n"],"names":["getLocalizedCurrency","currencyCode","localizedCurrencyLookup","get","currencyFormatterCache","Map","getCurrencyFormatter","locale","cacheKey","formatter","Intl","NumberFormat","style","currency","currencySign","currencyDisplay","set","formatPriceRaw","dinero","options","toFormat","amount","code","formatted","format","removeFractions","removeTrailingZeros","replace","RegExp","exponent","formatPrice","money","localizedCurrency","assert","getDinero","prettifyTotal","total","totalJson","toJSON","EUR","GBP","CAD","totalAsFloat","toUnit","roundDinero","Round","PrettifyDecimalCents","PrettifyHalfUnitCents","Prettify","PrettifyFull059","hasSubUnits","minValueInclusiveToRoundDownFrom","prettifyPriceLookup"],"mappings":";;;;;;AAaa,MAAAA,oBAAA,GACXC,YACkC,IAAA;EAClC,OAAOA,YAAe,GAAAC,uBAAA,CAAwBC,GAAI,CAAAF,YAAY,CAAI,GAAA,KAAA,CAAA;AACpE,CAAA;AAKA,MAAMG,sBAAA,GAAA,mBAA6BC,GAA+B,EAAA;AAOlE,MAAMC,oBAAA,GAAuBA,CAC3BC,MAAA,EACAN,YACsB,KAAA;EACtB,MAAMO,QAAW,GAAA,GAAGD,MAAM,IAAIN,YAAY,EAAA;EAEtC,IAAAQ,SAAA,GAAYL,sBAAuB,CAAAD,GAAA,CAAIK,QAAQ,CAAA;EACnD,IAAIC,SAAW,EAAA;IACN,OAAAA,SAAA;EACT;EAEYA,SAAA,GAAA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AAA;AAMa,MAAAgB,aAAA,GAAiBC,KAAsB,IAAA;EAC5C,MAAAC,SAAA,GAAYD,MAAME,MAAO,EAAA;EAEvB,QAAAD,SAAA,CAAUxB,SAASS,IAAM;IAAA;IAE/B,KAAKiB,GAAI,CAAAjB,IAAA;IACT,KAAKkB,GAAI,CAAAlB,IAAA;IACT,KAAKmB,IAAInB,IAAM;MAAA;QACP,MAAAoB,YAAA,GAAeC,OAAOP,KAAK,CAAA;QAEjC,IAAIM,eAAe,EAAI,EAAA;UACd,OAAAE,WAAA,CAAYR,KAAO,EAAAS,KAAA,CAAMC,oBAAoB,CAAA;QAAA,CACtD,MAAA,IAAWJ,eAAe,EAAI,EAAA;UACrB,OAAAE,WAAA,CAAYR,KAAO,EAAAS,KAAA,CAAME,qBAAqB,CAAA;QAAA,CACvD,MAAA,IAAWL,eAAe,EAAI,EAAA;UACrB,OAAAE,WAAA,CAAYR,KAAO,EAAAS,KAAA,CAAMG,QAAQ,CAAA;QAAA,CACnC,MAAA;UACE,OAAAJ,WAAA,CAAYR,KAAO,EAAAS,KAAA,CAAMI,eAAe,CAAA;QACjD;MACF;IACA;MAAS;QAEH,IAAA,CAACC,WAAY,CAAAd,KAAK,CAAG,EAAA;UAChB,OAAAA,KAAA;QACT;QAEA,MAAMe,mCAAmCC,mBAAoB,CAAAjD,GAAA,CAC3DkC,UAAUxB,QAAS,CAAAS,IAAA,CACrB;QAGA,IACE6B,gCAAoC,IAAA,IAAA,IACpCR,MAAO,CAAAP,KAAK,IAAIe,gCAChB,EAAA;UACO,OAAAf,KAAA;QACT;QAEO,OAAAQ,WAAA,CAAYR,KAAO,EAAAS,KAAA,CAAMG,QAAQ,CAAA;MAC1C;EACF;AACF,CAAA;"}
@@ -88,7 +88,7 @@ const money = dinero2 => {
88
88
  currency: parseCurrencyCode(currency2.code)
89
89
  };
90
90
  };
91
- const addMany = (addends, defaultCurrency) => [...addends, getDinero(0, defaultCurrency)].reduce(dinero_js.add);
91
+ const addMany = (addends, defaultCurrency) => addends.reduce(dinero_js.add, getDinero(0, defaultCurrency));
92
92
  const subtractMany = (subtractions, defaultCurrency) => [...subtractions, getDinero(0, defaultCurrency)].reduce(dinero_js.subtract);
93
93
  const stringAmountToDinero = (price, currency2) =>
94
94
  // FIXME: parseFloat seems dangerous O_O