@redneckz/wildless-cms-uni-blocks 0.2.99 → 0.2.103

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 (288) hide show
  1. package/bundle/blocks.schema.json +1 -1
  2. package/bundle/bundle.umd.js +126 -63
  3. package/bundle/bundle.umd.min.js +1 -1
  4. package/dist/components/BlockContent.d.ts +3 -2
  5. package/dist/components/Blocks.d.ts +1 -0
  6. package/dist/components/Blocks.js +2 -0
  7. package/dist/components/Blocks.js.map +1 -1
  8. package/dist/components/CreditCalculator/CreditCalculator.js +2 -2
  9. package/dist/components/CreditCalculator/CreditCalculator.js.map +1 -1
  10. package/dist/components/Footer/FooterContent.d.ts +1 -1
  11. package/dist/components/Footer/Sitemap.d.ts +1 -1
  12. package/dist/components/Footer/Sitemap.js +2 -2
  13. package/dist/components/Footer/Sitemap.js.map +1 -1
  14. package/dist/components/Header/Header.js +13 -9
  15. package/dist/components/Header/Header.js.map +1 -1
  16. package/dist/components/Header/HeaderContent.d.ts +8 -1
  17. package/dist/components/Header/HeaderSecondaryMenu.d.ts +2 -1
  18. package/dist/components/Header/HeaderSecondaryMenu.js +14 -2
  19. package/dist/components/Header/HeaderSecondaryMenu.js.map +1 -1
  20. package/dist/components/Header/HeaderSecondaryMenuButton.js +1 -1
  21. package/dist/components/Header/HeaderSecondaryMenuButton.js.map +1 -1
  22. package/dist/components/Headline/HeadlineContent.d.ts +2 -9
  23. package/dist/components/MobileBlocks.d.ts +1 -0
  24. package/dist/components/MobileBlocks.js +2 -0
  25. package/dist/components/MobileBlocks.js.map +1 -1
  26. package/dist/components/Navigation/Navigation.d.ts +5 -0
  27. package/dist/components/Navigation/Navigation.js +16 -0
  28. package/dist/components/Navigation/Navigation.js.map +1 -0
  29. package/dist/components/Navigation/NavigationContent.d.ts +10 -0
  30. package/dist/components/Navigation/NavigationContent.js +2 -0
  31. package/dist/components/Navigation/NavigationContent.js.map +1 -0
  32. package/dist/components/Navigation/NavigationItem.d.ts +4 -0
  33. package/dist/components/Navigation/NavigationItem.js +6 -0
  34. package/dist/components/Navigation/NavigationItem.js.map +1 -0
  35. package/dist/components/StepsBlock/StepsBlock.d.ts +1 -1
  36. package/dist/components/StepsBlock/StepsBlock.js +3 -3
  37. package/dist/components/StepsBlock/StepsBlock.js.map +1 -1
  38. package/dist/components/StepsBlock/StepsBlockContent.d.ts +5 -2
  39. package/dist/hooks/useLink.js +2 -1
  40. package/dist/hooks/useLink.js.map +1 -1
  41. package/dist/index.d.ts +1 -1
  42. package/dist/index.js.map +1 -1
  43. package/dist/model/BgColorVersion.d.ts +8 -0
  44. package/dist/model/BgColorVersion.js +2 -0
  45. package/dist/model/BgColorVersion.js.map +1 -0
  46. package/dist/services/sitemap/SitemapProps.d.ts +13 -0
  47. package/dist/services/sitemap/SitemapProps.js +2 -0
  48. package/dist/services/sitemap/SitemapProps.js.map +1 -0
  49. package/dist/services/sitemap/findActiveSubItem.d.ts +3 -0
  50. package/dist/services/sitemap/findActiveSubItem.js +13 -0
  51. package/dist/services/sitemap/findActiveSubItem.js.map +1 -0
  52. package/dist/services/sitemap/isHrefActive.d.ts +4 -0
  53. package/dist/services/sitemap/isHrefActive.js +9 -0
  54. package/dist/services/sitemap/isHrefActive.js.map +1 -0
  55. package/dist/services/sitemap/isSubItemActive.d.ts +3 -0
  56. package/dist/services/sitemap/isSubItemActive.js +6 -0
  57. package/dist/services/sitemap/isSubItemActive.js.map +1 -0
  58. package/dist/services/sitemap/isTopItemActive.d.ts +3 -0
  59. package/dist/services/sitemap/isTopItemActive.js +7 -0
  60. package/dist/services/sitemap/isTopItemActive.js.map +1 -0
  61. package/dist/services/sitemap/mergeTopItems.d.ts +2 -0
  62. package/dist/{mergeTopItems.js → services/sitemap/mergeTopItems.js} +1 -3
  63. package/dist/services/sitemap/mergeTopItems.js.map +1 -0
  64. package/dist/services/sitemap/useSitemap.d.ts +3 -0
  65. package/dist/{hooks → services/sitemap}/useSitemap.js +1 -1
  66. package/dist/services/sitemap/useSitemap.js.map +1 -0
  67. package/dist/ui-kit/Button/ButtonProps.d.ts +1 -1
  68. package/dist/ui-kit/HeaderItem/HeaderItem.js +16 -4
  69. package/dist/ui-kit/HeaderItem/HeaderItem.js.map +1 -1
  70. package/dist/ui-kit/Icon/IconProps.d.ts +83 -45
  71. package/dist/ui-kit/Icon/IconProps.js +62 -43
  72. package/dist/ui-kit/Icon/IconProps.js.map +1 -1
  73. package/dist/ui-kit/Logo/Logo.d.ts +1 -0
  74. package/dist/ui-kit/Logo/Logo.js +10 -2
  75. package/dist/ui-kit/Logo/Logo.js.map +1 -1
  76. package/dist/ui-kit/TopItem/TopItem.d.ts +2 -0
  77. package/dist/ui-kit/TopItem/TopItem.js +19 -7
  78. package/dist/ui-kit/TopItem/TopItem.js.map +1 -1
  79. package/dist/utils/adjustHref.d.ts +4 -0
  80. package/dist/utils/adjustHref.js +21 -0
  81. package/dist/utils/adjustHref.js.map +1 -0
  82. package/dist/utils/maxBy.d.ts +2 -0
  83. package/dist/utils/maxBy.js +7 -0
  84. package/dist/utils/maxBy.js.map +1 -0
  85. package/dist/utils/url.d.ts +0 -13
  86. package/dist/utils/url.js +2 -26
  87. package/dist/utils/url.js.map +1 -1
  88. package/dist/utils/withoutMobilePath.d.ts +2 -0
  89. package/dist/utils/withoutMobilePath.js +6 -0
  90. package/dist/utils/withoutMobilePath.js.map +1 -0
  91. package/lib/common.css +1 -1
  92. package/lib/components/BlockContent.d.ts +3 -2
  93. package/lib/components/Blocks.d.ts +1 -0
  94. package/lib/components/Blocks.js +2 -0
  95. package/lib/components/Blocks.js.map +1 -1
  96. package/lib/components/CreditCalculator/CreditCalculator.js +2 -2
  97. package/lib/components/CreditCalculator/CreditCalculator.js.map +1 -1
  98. package/lib/components/Footer/FooterContent.d.ts +1 -1
  99. package/lib/components/Footer/Sitemap.d.ts +1 -1
  100. package/lib/components/Footer/Sitemap.js +2 -2
  101. package/lib/components/Footer/Sitemap.js.map +1 -1
  102. package/lib/components/Header/Header.fixture.d.ts +4 -1
  103. package/lib/components/Header/Header.js +13 -9
  104. package/lib/components/Header/Header.js.map +1 -1
  105. package/lib/components/Header/HeaderContent.d.ts +8 -1
  106. package/lib/components/Header/HeaderSecondaryMenu.d.ts +2 -1
  107. package/lib/components/Header/HeaderSecondaryMenu.js +14 -2
  108. package/lib/components/Header/HeaderSecondaryMenu.js.map +1 -1
  109. package/lib/components/Header/HeaderSecondaryMenuButton.js +1 -1
  110. package/lib/components/Header/HeaderSecondaryMenuButton.js.map +1 -1
  111. package/lib/components/Headline/HeadlineContent.d.ts +2 -9
  112. package/lib/components/MobileBlocks.d.ts +1 -0
  113. package/lib/components/MobileBlocks.js +2 -0
  114. package/lib/components/MobileBlocks.js.map +1 -1
  115. package/lib/components/Navigation/Navigation.d.ts +5 -0
  116. package/lib/components/Navigation/Navigation.fixture.d.ts +2 -0
  117. package/lib/components/Navigation/Navigation.js +14 -0
  118. package/lib/components/Navigation/Navigation.js.map +1 -0
  119. package/lib/components/Navigation/NavigationContent.d.ts +10 -0
  120. package/lib/components/Navigation/NavigationContent.js +2 -0
  121. package/lib/components/Navigation/NavigationContent.js.map +1 -0
  122. package/lib/components/Navigation/NavigationItem.d.ts +4 -0
  123. package/lib/components/Navigation/NavigationItem.js +4 -0
  124. package/lib/components/Navigation/NavigationItem.js.map +1 -0
  125. package/lib/components/StepsBlock/StepsBlock.d.ts +1 -1
  126. package/lib/components/StepsBlock/StepsBlock.js +3 -3
  127. package/lib/components/StepsBlock/StepsBlock.js.map +1 -1
  128. package/lib/components/StepsBlock/StepsBlockContent.d.ts +5 -2
  129. package/lib/hooks/useLink.js +2 -1
  130. package/lib/hooks/useLink.js.map +1 -1
  131. package/lib/index.d.ts +1 -1
  132. package/lib/index.js.map +1 -1
  133. package/lib/model/BgColorVersion.d.ts +8 -0
  134. package/lib/model/BgColorVersion.js +2 -0
  135. package/lib/model/BgColorVersion.js.map +1 -0
  136. package/lib/services/sitemap/SitemapProps.d.ts +13 -0
  137. package/lib/services/sitemap/SitemapProps.js +2 -0
  138. package/lib/services/sitemap/SitemapProps.js.map +1 -0
  139. package/lib/services/sitemap/findActiveSubItem.d.ts +3 -0
  140. package/lib/services/sitemap/findActiveSubItem.js +10 -0
  141. package/lib/services/sitemap/findActiveSubItem.js.map +1 -0
  142. package/lib/services/sitemap/isHrefActive.d.ts +4 -0
  143. package/lib/services/sitemap/isHrefActive.js +6 -0
  144. package/lib/services/sitemap/isHrefActive.js.map +1 -0
  145. package/lib/services/sitemap/isSubItemActive.d.ts +3 -0
  146. package/lib/services/sitemap/isSubItemActive.js +3 -0
  147. package/lib/services/sitemap/isSubItemActive.js.map +1 -0
  148. package/lib/services/sitemap/isTopItemActive.d.ts +3 -0
  149. package/lib/services/sitemap/isTopItemActive.js +4 -0
  150. package/lib/services/sitemap/isTopItemActive.js.map +1 -0
  151. package/lib/services/sitemap/mergeTopItems.d.ts +2 -0
  152. package/lib/{mergeTopItems.js → services/sitemap/mergeTopItems.js} +1 -3
  153. package/lib/services/sitemap/mergeTopItems.js.map +1 -0
  154. package/lib/services/sitemap/useSitemap.d.ts +3 -0
  155. package/lib/{hooks → services/sitemap}/useSitemap.js +1 -1
  156. package/lib/services/sitemap/useSitemap.js.map +1 -0
  157. package/lib/ui-kit/Button/ButtonProps.d.ts +1 -1
  158. package/lib/ui-kit/HeaderItem/HeaderItem.js +16 -4
  159. package/lib/ui-kit/HeaderItem/HeaderItem.js.map +1 -1
  160. package/lib/ui-kit/Icon/IconProps.d.ts +83 -45
  161. package/lib/ui-kit/Icon/IconProps.js +62 -43
  162. package/lib/ui-kit/Icon/IconProps.js.map +1 -1
  163. package/lib/ui-kit/Logo/Logo.d.ts +1 -0
  164. package/lib/ui-kit/Logo/Logo.js +10 -2
  165. package/lib/ui-kit/Logo/Logo.js.map +1 -1
  166. package/lib/ui-kit/TopItem/TopItem.d.ts +2 -0
  167. package/lib/ui-kit/TopItem/TopItem.js +19 -7
  168. package/lib/ui-kit/TopItem/TopItem.js.map +1 -1
  169. package/lib/utils/adjustHref.d.ts +4 -0
  170. package/lib/utils/adjustHref.js +18 -0
  171. package/lib/utils/adjustHref.js.map +1 -0
  172. package/lib/utils/maxBy.d.ts +2 -0
  173. package/lib/utils/maxBy.js +3 -0
  174. package/lib/utils/maxBy.js.map +1 -0
  175. package/lib/utils/url.d.ts +0 -13
  176. package/lib/utils/url.js +1 -21
  177. package/lib/utils/url.js.map +1 -1
  178. package/lib/utils/withoutMobilePath.d.ts +2 -0
  179. package/lib/utils/withoutMobilePath.js +3 -0
  180. package/lib/utils/withoutMobilePath.js.map +1 -0
  181. package/package.json +4 -2
  182. package/src/components/BlockContent.ts +4 -2
  183. package/src/components/Blocks.ts +2 -0
  184. package/src/components/ContentPage/ContentPage.page.json +28 -15
  185. package/src/components/CreditCalculator/CreditCalculator.tsx +4 -6
  186. package/src/components/Footer/FooterContent.ts +1 -1
  187. package/src/components/Footer/Sitemap.tsx +4 -3
  188. package/src/components/Header/Header.fixture.tsx +4 -18
  189. package/src/components/Header/Header.tsx +56 -45
  190. package/src/components/Header/HeaderContent.ts +8 -1
  191. package/src/components/Header/HeaderSecondaryMenu.tsx +25 -12
  192. package/src/components/Header/HeaderSecondaryMenuButton.tsx +2 -4
  193. package/src/components/Headline/HeadlineContent.ts +2 -10
  194. package/src/components/MobileBlocks.ts +2 -0
  195. package/src/components/Navigation/Navigation.fixture.tsx +28 -0
  196. package/src/components/Navigation/Navigation.tsx +39 -0
  197. package/src/components/Navigation/NavigationContent.ts +11 -0
  198. package/src/components/Navigation/NavigationItem.tsx +17 -0
  199. package/src/components/PictureText/PictureText.example.json +2 -2
  200. package/src/components/PictureText/PictureText.fixture.tsx +2 -2
  201. package/src/components/StepsBlock/StepsBlock.example.json +3 -1
  202. package/src/components/StepsBlock/StepsBlock.tsx +21 -16
  203. package/src/components/StepsBlock/StepsBlockContent.ts +5 -2
  204. package/src/hooks/useLink.ts +2 -1
  205. package/src/icons/Calendar2Icon.svg +1 -0
  206. package/src/icons/CalendarCircleIcon.svg +1 -0
  207. package/src/icons/CalendarTickIcon.svg +1 -0
  208. package/src/icons/CardIcon.svg +1 -0
  209. package/src/icons/CardPosIcon.svg +1 -0
  210. package/src/icons/CardTickIcon.svg +1 -0
  211. package/src/icons/CardWithGemIcon.svg +1 -0
  212. package/src/icons/ChartSquareIcon.svg +1 -0
  213. package/src/icons/CreditCardsIcon.svg +1 -0
  214. package/src/icons/DischountStarIcon.svg +1 -0
  215. package/src/icons/{DocumentText.svg → DocumentTextIcon.svg} +0 -0
  216. package/src/icons/EarthIcon.svg +1 -0
  217. package/src/icons/EmptyWalletChangeIcon.svg +1 -0
  218. package/src/icons/GlobalIcon.svg +1 -0
  219. package/src/icons/GridIcon.svg +1 -1
  220. package/src/icons/GridIconWhite.svg +4 -0
  221. package/src/icons/InterestGrowthIcon.svg +1 -0
  222. package/src/icons/InterestIcon.svg +1 -0
  223. package/src/icons/JCBIcon.svg +1 -0
  224. package/src/icons/MasterCardIcon.svg +1 -0
  225. package/src/icons/MinusIcon.svg +1 -0
  226. package/src/icons/MirIcon.svg +1 -0
  227. package/src/icons/MoneyIcon.svg +1 -0
  228. package/src/icons/MoneyInsuranceIcon.svg +1 -0
  229. package/src/icons/MonitorMobileIcon.svg +1 -0
  230. package/src/icons/OfficeIcon.svg +1 -0
  231. package/src/icons/PercentageRoundIcon.svg +1 -0
  232. package/src/icons/PersonalCardIcon.svg +1 -0
  233. package/src/icons/PlusIcon.svg +1 -0
  234. package/src/icons/Profile2UserIcon.svg +1 -0
  235. package/src/icons/RoundRubleIcon.svg +1 -0
  236. package/src/icons/SafeIcon.svg +1 -0
  237. package/src/icons/ShieldTickIcon.svg +1 -0
  238. package/src/icons/SmallClockIcon.svg +1 -0
  239. package/src/icons/UnionPayIcon.svg +1 -0
  240. package/src/icons/UserTickIcon.svg +1 -0
  241. package/src/icons/VisaIcon.svg +1 -0
  242. package/src/icons/WalletAdd2Icon.svg +1 -0
  243. package/src/icons/WalletAddIcon.svg +1 -0
  244. package/src/icons/WalletWithMoneyIcon.svg +1 -0
  245. package/src/index.ts +1 -1
  246. package/src/model/BgColorVersion.ts +8 -0
  247. package/src/services/sitemap/SitemapProps.ts +15 -0
  248. package/src/services/sitemap/findActiveSubItem.ts +14 -0
  249. package/src/services/sitemap/isHrefActive.ts +13 -0
  250. package/src/services/sitemap/isSubItemActive.ts +8 -0
  251. package/src/services/sitemap/isTopItemActive.ts +9 -0
  252. package/src/{mergeTopItems.spec.ts → services/sitemap/mergeTopItems.spec.ts} +0 -0
  253. package/src/{mergeTopItems.ts → services/sitemap/mergeTopItems.ts} +3 -4
  254. package/src/{hooks → services/sitemap}/useSitemap.ts +3 -3
  255. package/src/ui-kit/Button/ButtonProps.ts +1 -1
  256. package/src/ui-kit/HeaderItem/HeaderItem.tsx +32 -18
  257. package/src/ui-kit/Icon/IconProps.ts +44 -6
  258. package/src/ui-kit/Logo/Logo.tsx +30 -18
  259. package/src/ui-kit/TopItem/TopItem.tsx +46 -19
  260. package/src/utils/adjustHref.spec.ts +25 -0
  261. package/src/utils/adjustHref.ts +24 -0
  262. package/src/utils/maxBy.spec.ts +11 -0
  263. package/src/utils/maxBy.ts +7 -0
  264. package/src/utils/url.spec.ts +1 -37
  265. package/src/utils/url.ts +2 -39
  266. package/src/utils/withoutMobilePath.ts +3 -0
  267. package/dist/components/Header/isSubItemActive.d.ts +0 -3
  268. package/dist/components/Header/isSubItemActive.js +0 -8
  269. package/dist/components/Header/isSubItemActive.js.map +0 -1
  270. package/dist/components/Header/isTopItemActive.d.ts +0 -3
  271. package/dist/components/Header/isTopItemActive.js +0 -8
  272. package/dist/components/Header/isTopItemActive.js.map +0 -1
  273. package/dist/hooks/useSitemap.d.ts +0 -3
  274. package/dist/hooks/useSitemap.js.map +0 -1
  275. package/dist/mergeTopItems.d.ts +0 -2
  276. package/dist/mergeTopItems.js.map +0 -1
  277. package/lib/components/Header/isSubItemActive.d.ts +0 -3
  278. package/lib/components/Header/isSubItemActive.js +0 -5
  279. package/lib/components/Header/isSubItemActive.js.map +0 -1
  280. package/lib/components/Header/isTopItemActive.d.ts +0 -3
  281. package/lib/components/Header/isTopItemActive.js +0 -5
  282. package/lib/components/Header/isTopItemActive.js.map +0 -1
  283. package/lib/hooks/useSitemap.d.ts +0 -3
  284. package/lib/hooks/useSitemap.js.map +0 -1
  285. package/lib/mergeTopItems.d.ts +0 -2
  286. package/lib/mergeTopItems.js.map +0 -1
  287. package/src/components/Header/isSubItemActive.ts +0 -7
  288. package/src/components/Header/isTopItemActive.ts +0 -8
@@ -0,0 +1 @@
1
+ <svg id="icon" width="24" height="24" fill="none" xmlns="http://www.w3.org/2000/svg"><path d="M15.02 3.01A4.944 4.944 0 0 0 12 2C9.24 2 7 4.24 7 7s2.24 5 5 5 5-2.24 5-5M3.41 22c0-3.87 3.85-7 8.59-7 .96 0 1.89.13 2.76.37" stroke="#1C1C1C" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/><path d="M22 18c0 .75-.21 1.46-.58 2.06-.21.36-.48.68-.79.94-.7.63-1.62 1-2.63 1a3.97 3.97 0 0 1-3.42-1.94A3.92 3.92 0 0 1 14 18c0-1.26.58-2.39 1.5-3.12A3.999 3.999 0 0 1 22 18Z" stroke="#42AB44" stroke-width="2" stroke-miterlimit="10" stroke-linecap="round" stroke-linejoin="round"/><path d="m16.44 18 .99.99 2.13-1.97" stroke="#42AB44" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/></svg>
@@ -0,0 +1 @@
1
+ <svg id="icon" width="52" height="17" fill="none" xmlns="http://www.w3.org/2000/svg"><path d="M18.37 16.407 21 .729h4.206l-2.632 15.678h-4.205ZM37.77 1.067C36.939.75 35.633.41 34 .41c-4.156 0-7.084 2.126-7.109 5.173-.023 2.253 2.09 3.51 3.686 4.26 1.638.768 2.188 1.258 2.18 1.944-.01 1.051-1.307 1.531-2.516 1.531-1.684 0-2.579-.238-3.96-.823l-.542-.249-.59 3.51c.982.437 2.799.816 4.685.836 4.422 0 7.293-2.102 7.325-5.356.016-1.784-1.105-3.14-3.532-4.26-1.47-.725-2.37-1.209-2.36-1.943 0-.652.762-1.349 2.408-1.349a7.655 7.655 0 0 1 3.149.601l.377.18.57-3.397ZM48.595.729h-3.25c-1.007 0-1.761.28-2.203 1.3l-6.248 14.367h4.418s.722-1.932.885-2.356l5.388.007c.126.549.511 2.35.511 2.35H52L48.595.728Zm-5.157 10.123c.348-.903 1.676-4.382 1.676-4.382-.025.041.345-.908.558-1.497l.284 1.352.974 4.527h-3.492ZM.054.73 0 1.055c1.663.409 3.148 1 4.448 1.737l3.733 13.589 4.45-.005L19.255.729h-4.456L10.68 11.42l-.439-2.172a7.126 7.126 0 0 0-.066-.202L8.744 2.053C8.489 1.06 7.75.764 6.837.729H.054Z" fill="#0E4595"/></svg>
@@ -0,0 +1 @@
1
+ <svg width="24" height="24" fill="none" xmlns="http://www.w3.org/2000/svg"><path d="M6.19 7.06C6.45 7.02 6.72 7 7 7h10c.26 0 .51.01.75.05C20.33 7.35 22 9.26 22 12v5c0 3-2 5-5 5H7.63c.31-.26.58-.58.79-.94.37-.6.58-1.31.58-2.06 0-2.21-1.79-4-4-4-1.2 0-2.27.53-3 1.36V12c0-.87.17-1.66.48-2.33" stroke="#1C1C1C" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/><path d="M17.75 7.05C17.51 7.01 17.26 7 17 7H7c-.28 0-.55.02-.81.06.14-.28.34-.54.58-.78l3.25-3.26a3.525 3.525 0 0 1 4.96 0l1.75 1.77c.64.63.98 1.43 1.02 2.26Z" stroke="#1C1C1C" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/><path d="M9 19c0 .75-.21 1.46-.58 2.06A3.97 3.97 0 0 1 5 23a3.97 3.97 0 0 1-3.42-1.94A3.92 3.92 0 0 1 1 19c0-2.21 1.79-4 4-4s4 1.79 4 4ZM6.49 18.98H3.51M5 17.52v2.99" stroke="#42AB44" stroke-width="2" stroke-miterlimit="10" stroke-linecap="round" stroke-linejoin="round"/><path d="M22 12.5h-3c-1.1 0-2 .9-2 2s.9 2 2 2h3" stroke="#1C1C1C" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/></svg>
@@ -0,0 +1 @@
1
+ <svg width="24" height="24" fill="none" xmlns="http://www.w3.org/2000/svg"><path d="M14.5 15.44h-5M12 13v5" stroke="#42AB44" stroke-width="2" stroke-miterlimit="10" stroke-linecap="round" stroke-linejoin="round"/><path d="M12 22H8.1c-.24 0-.48-.02-.71-.05-3.18-.21-4.88-1.91-5.09-5.09-.03-.23-.05-.47-.05-.71V14.2c0-2.01 1.22-3.74 2.96-4.49.6-.25 1.24-.39 1.92-.39h9.76c.49 0 .97.07 1.41.2 2 .6 3.46 2.47 3.46 4.67v1.95c0 .2-.01.4-.02.6-.19 3.5-2.14 5.26-5.84 5.26" stroke="#1C1C1C" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/><path d="m12.9 2.52-.03.07-2.9 6.73H7.12c-.68 0-1.33.14-1.92.39l1.75-4.18.04-.1.07-.16c.02-.06.04-.12.07-.17 1.31-3.03 2.79-3.72 5.77-2.58Z" stroke="#1C1C1C" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/><path d="M18.29 9.52c-.45-.14-.93-.2-1.41-.2H9.97l2.9-6.73.03-.07c.15.05.29.12.44.18l2.21.93c1.23.51 2.09 1.04 2.61 1.68.1.12.18.23.25.36.09.14.16.28.2.43.04.09.07.18.09.26.27.84.11 1.87-.41 3.16ZM6.95 5.53 5.2 9.71a4.894 4.894 0 0 0-2.96 4.49v-2.93c0-2.84 2.02-5.21 4.71-5.74Z" stroke="#1C1C1C" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/><path d="M21.76 11.27v2.93c0-2.2-1.46-4.07-3.46-4.67.52-1.3.67-2.32.42-3.17-.02-.09-.05-.18-.09-.26 1.86.96 3.13 2.93 3.13 5.17Z" stroke="#1C1C1C" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/></svg>
@@ -0,0 +1 @@
1
+ <svg width="24" height="24" fill="none" xmlns="http://www.w3.org/2000/svg"><path d="M20 12.063V11a2 2 0 0 0-2-2H4a2 2 0 0 0-2 2v10a2 2 0 0 0 2 2h14a2 2 0 0 0 2-2v-1.063" stroke="#1C1C1C" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/><path d="m5 7 8.571-5L15 4.308M10 7l8-4 2 2.91" stroke="#42AB44" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"/><path d="M16.56 18H21a1 1 0 0 0 1-1v-2a1 1 0 0 0-1-1h-7a1 1 0 0 0-1 1v3" stroke="#1C1C1C" stroke-width="2" stroke-linecap="round"/></svg>
package/src/index.ts CHANGED
@@ -18,9 +18,9 @@ export { ContentPageHead } from './components/ContentPage/ContentPageHead';
18
18
  export { toMobilePage } from './components/ContentPage/toMobilePage';
19
19
  export { MobileBlocks } from './components/MobileBlocks';
20
20
  export type { Img, ImgSource, Picture } from './model/Picture';
21
- export type { SitemapProps as SitemapContent } from './model/SitemapProps';
22
21
  export { projectSettings } from './ProjectSettings';
23
22
  export type { ProjectSettings } from './ProjectSettings';
23
+ export type { SitemapProps as SitemapContent } from './services/sitemap/SitemapProps';
24
24
  export type { BlockDef, ContentPageDef, ContentPageMeta, UniBlockProps } from './types';
25
25
  export { joinList } from './utils/joinList';
26
26
  export * as url from './utils/url';
@@ -0,0 +1,8 @@
1
+ /**
2
+ * @title Цвет фона
3
+ * @enumNames [
4
+ * "Прозрачный",
5
+ * "Белый"
6
+ * ]
7
+ */
8
+ export type BgColorVersion = 'transparent' | 'bg-white';
@@ -0,0 +1,15 @@
1
+ import type { LinkProps } from '../../model/LinkProps';
2
+
3
+ /**
4
+ * @title Ссылка
5
+ * @required ["text", "href"]
6
+ */
7
+ export interface TopMenuItem extends LinkProps {
8
+ /** @hidden */
9
+ items?: LinkProps[];
10
+ }
11
+
12
+ export interface SitemapProps {
13
+ /** @title Дополнительное меню */
14
+ topItems?: TopMenuItem[];
15
+ }
@@ -0,0 +1,14 @@
1
+ import type { Router } from '../../components/ContentPage/ContentPageContext';
2
+ import type { LinkProps } from '../../model/LinkProps';
3
+ import { maxBy } from '../../utils/maxBy';
4
+ import { isSubItemActive } from './isSubItemActive';
5
+
6
+ export const findActiveSubItem =
7
+ (router: Router) =>
8
+ <T extends LinkProps>(items: T[] = []): T | null => {
9
+ const possibleActiveSubItems = items?.filter(isSubItemActive(router));
10
+ const activeSubItem = possibleActiveSubItems?.length
11
+ ? maxBy((_: T) => _.href?.length || 0)(possibleActiveSubItems) // More specific item with max length
12
+ : null;
13
+ return activeSubItem;
14
+ };
@@ -0,0 +1,13 @@
1
+ import { isURL, withoutQuery } from '../../utils/url';
2
+ import { withoutMobilePath } from '../../utils/withoutMobilePath';
3
+
4
+ export const isHrefActive = (
5
+ href: string | undefined,
6
+ router: { pathname?: string; href?: string },
7
+ cmp: (href: string, baseHref: string) => boolean = (href, baseHref) => baseHref.startsWith(href),
8
+ ) => {
9
+ return cmp(
10
+ withoutQuery(href),
11
+ withoutMobilePath(withoutQuery(isURL(href) ? router.href : router.pathname)),
12
+ );
13
+ };
@@ -0,0 +1,8 @@
1
+ import type { Router } from '../../components/ContentPage/ContentPageContext';
2
+ import type { LinkProps } from '../../model/LinkProps';
3
+ import { isHrefActive } from './isHrefActive';
4
+
5
+ export const isSubItemActive =
6
+ (router: Router) =>
7
+ (subItem: LinkProps): boolean =>
8
+ isHrefActive(subItem.href, router);
@@ -0,0 +1,9 @@
1
+ import type { Router } from '../../components/ContentPage/ContentPageContext';
2
+ import { isHrefActive } from './isHrefActive';
3
+ import { isSubItemActive } from './isSubItemActive';
4
+ import { TopMenuItem } from './SitemapProps';
5
+
6
+ export const isTopItemActive =
7
+ (router: Router) =>
8
+ (topItem: TopMenuItem): boolean =>
9
+ topItem.items?.some(isSubItemActive(router)) || isHrefActive(topItem.href, router);
@@ -1,4 +1,4 @@
1
- import type { LinkProps } from './model/LinkProps';
1
+ import type { LinkProps } from '../../model/LinkProps';
2
2
 
3
3
  const cmp = (a?: LinkProps) => (b?: LinkProps) => a?.href === b?.href;
4
4
 
@@ -8,6 +8,5 @@ const substitute = <L extends LinkProps>(items?: L[], substitution?: L[]): L[] =
8
8
  const subtract = <L extends LinkProps>(minuend?: L[], subtrahend?: L[]): L[] =>
9
9
  (minuend || []).filter((_) => !subtrahend?.find(cmp(_)));
10
10
 
11
- export function mergeTopItems<L extends LinkProps>(left?: L[], right?: L[]): L[] {
12
- return substitute(left, right).concat(subtract(right, left));
13
- }
11
+ export const mergeTopItems = <L extends LinkProps>(left?: L[], right?: L[]): L[] =>
12
+ substitute(left, right).concat(subtract(right, left));
@@ -1,6 +1,6 @@
1
- import type { AsyncDataHook } from '../components/ContentPage/ContentPageContext';
2
- import type { HeaderContent } from '../components/Header/HeaderContent';
3
- import { projectSettings } from '../ProjectSettings';
1
+ import type { AsyncDataHook } from '../../components/ContentPage/ContentPageContext';
2
+ import type { HeaderContent } from '../../components/Header/HeaderContent';
3
+ import { projectSettings } from '../../ProjectSettings';
4
4
 
5
5
  export function useSitemap(useAsyncData: AsyncDataHook): HeaderContent {
6
6
  const { data } = useAsyncData(sitemapURL(), fetchSitemap);
@@ -26,7 +26,7 @@ export interface ButtonWithIconProps extends ButtonProps {
26
26
  aboveText?: string;
27
27
  /** @hidden */
28
28
  appendLeft?: any;
29
- /** @hidden */
29
+ /** @title Закругленные углы */
30
30
  rounded?: boolean;
31
31
  /** @hidden */
32
32
  asSVG?: boolean;
@@ -1,25 +1,39 @@
1
1
  import { JSX } from '@redneckz/uni-jsx';
2
+ import { BgColorVersion } from '../../model/BgColorVersion';
2
3
  import type { TopItemProps } from '../TopItem/TopItem';
3
4
 
4
5
  export type HeaderItemProps = TopItemProps;
5
6
 
7
+ const TEXT_CLASSES = 'font-sans font-normal text-base';
8
+ const BORDER_CLASSES = 'absolute left-0 -bottom-2 w-full h-[2px]';
9
+
6
10
  export const HeaderItem = JSX<HeaderItemProps>(
7
- ({ className, text, href, target, active, onClick, children }) => {
8
- const textStyle = active ? 'text-primary-main' : 'text-primary-text hover:text-primary-main';
9
- return (
10
- <a
11
- className={`relative inline-block bg-transparent text-center no-underline ${
12
- className || ''
13
- }`}
14
- href={href}
15
- target={target}
16
- onClick={onClick}
17
- >
18
- <span className={`font-sans font-normal text-base ${textStyle}`}>{text || children}</span>
19
- {active ? (
20
- <div className="absolute left-0 -bottom-2 w-full h-[2px] bg-primary-main" />
21
- ) : null}
22
- </a>
23
- );
24
- },
11
+ ({ className, text, href, target, active, onClick, children, bgColor = 'bg-white' }) => (
12
+ <a
13
+ className={`relative inline-block bg-transparent text-center no-underline ${className || ''}`}
14
+ href={href}
15
+ target={target}
16
+ onClick={onClick}
17
+ >
18
+ <span className={getTextClasses(bgColor, active)}>{text || children}</span>
19
+ {active ? <div className={getBorderClasses(bgColor, active)} /> : null}
20
+ </a>
21
+ ),
25
22
  );
23
+
24
+ const getTextClasses = (bgColor: BgColorVersion, active?: boolean) => {
25
+ let classes = 'text-white';
26
+ if (bgColor === 'bg-white') {
27
+ classes = active ? 'text-primary-main' : 'text-primary-text hover:text-primary-main';
28
+ }
29
+
30
+ return `${classes} ${TEXT_CLASSES}`;
31
+ };
32
+
33
+ const getBorderClasses = (bgColor: BgColorVersion, active?: boolean) => {
34
+ if (!active) {
35
+ return BORDER_CLASSES;
36
+ }
37
+
38
+ return `${bgColor === 'bg-white' ? bgColor : 'bg-primary-main'} ${BORDER_CLASSES}`;
39
+ };
@@ -2,101 +2,139 @@
2
2
  * Icons sorted by name
3
3
  */
4
4
  export enum IconMap {
5
- '',
6
5
  'ActualBalanceIcon',
7
6
  'AppleIcon',
7
+ 'Calendar2Icon',
8
8
  'CalendarCircleIcon',
9
9
  'CalendarIcon',
10
+ 'CalendarTickIcon',
10
11
  'CalendarWhiteIcon',
12
+ 'CardWithGemIcon',
13
+ 'ChartSquareIcon',
11
14
  'CardIcon',
12
15
  'CardPosIcon',
13
16
  'CardTickIcon',
14
17
  'ClockIcon',
15
18
  'ComfortableCompIcon',
16
- 'DiscountShape',
19
+ 'CreditCardsIcon',
20
+ 'DiscountShapeIcon',
17
21
  'DocIcon',
18
- 'DocumentText',
22
+ 'DocumentTextIcon',
19
23
  'DollarIcon',
24
+ 'EarthIcon',
20
25
  'EmptyWalletChangeIcon',
21
26
  'EmptyWalletIcon',
22
27
  'EmptyWalletWhiteIcon',
23
28
  'EuroIcon',
24
29
  'GlassIcon',
30
+ 'GlobalIcon',
25
31
  'GridIcon',
32
+ 'GridIconWhite',
33
+ 'InterestGrowthIcon',
34
+ 'InterestIcon',
26
35
  'JCBIcon',
27
36
  'LoupeIcon',
28
37
  'MasterCardIcon',
29
38
  'MinusIcon',
30
39
  'MirIcon',
31
40
  'MoneyIcon',
41
+ 'MoneyInsuranceIcon',
32
42
  'MonitorMobileIcon',
33
43
  'NewDocIcon',
44
+ 'OfficeIcon',
34
45
  'OkIcon',
35
46
  'PassSendIcon',
47
+ 'PercentageRoundIcon',
36
48
  'PercentageSquareIcon',
37
49
  'PercentageSquareWhiteIcon',
50
+ 'PersonalCardIcon',
38
51
  'PlayMarketIcon',
39
52
  'PlusIcon',
40
53
  'Profile2UserIcon',
41
54
  'ProfileIcon',
55
+ 'RoundRubleIcon',
56
+ 'SafeIcon',
42
57
  'ShieldTickIcon',
43
58
  'SignDocsIcon',
59
+ 'SmallClockIcon',
44
60
  'TelegramIcon',
45
61
  'UnionPayIcon',
46
- 'UserIcon',
62
+ 'UserTickIcon',
47
63
  'VisaIcon',
48
64
  'VKIcon',
65
+ 'WalletAdd',
66
+ 'WalletAdd2',
49
67
  'WalletIcon',
68
+ 'WalletWithMoneyIcon',
50
69
  }
51
70
 
52
71
  /**
53
72
  * @title Иконка
54
73
  * @enumNames [
55
- * "",
56
74
  * "Деньги",
57
75
  * "Лого «Apple»",
76
+ * "Календарь 2",
58
77
  * "Скруглённый календарь",
59
78
  * "Календарь",
79
+ * "Календарь с галочкой",
60
80
  * "Календарь белый",
81
+ * "Карта с драгоценностями",
82
+ * "Деньги внутри кошелька",
61
83
  * "Кред. карта",
62
84
  * "Кред. карта под наклоном",
63
85
  * "Кред. карта с галочкой",
64
86
  * "Часы",
65
87
  * "Кресло",
66
88
  * "Скидка",
89
+ * "Кредитные карты",
90
+ * "Огромная скидка",
67
91
  * "Документ",
68
92
  * "Документ с текстом",
69
93
  * "Доллар",
70
94
  * "Пустой кошелёк с возвратом",
71
95
  * "Пустой кошелёк",
72
- * "Пустой кошелёк белый",
96
+ * "Пустой кошелёк (белый)",
73
97
  * "Евро",
74
98
  * "Зеркало",
99
+ * "Глобус",
75
100
  * "Сетка",
101
+ * "Сетка (белая)",
102
+ * "Диаграмма роста",
103
+ * "Скидка",
76
104
  * "JCB",
77
105
  * "Лупа",
78
106
  * "MasterCard",
79
107
  * "Минус",
80
108
  * "МИР",
81
109
  * "Деньги",
110
+ * "Денежное страхование",
82
111
  * "Монитор и мобильный",
83
112
  * "Новый документ",
113
+ * "Офис",
84
114
  * "Лого «Одноклассники»",
85
115
  * "Бизнес",
116
+ * "Проценты (круг.)",
86
117
  * "Проценты",
87
118
  * "Проценты белые",
119
+ * "Персональная карта",
88
120
  * "Лого «PlayMarket»",
89
121
  * "Плюс",
90
122
  * "Профиль, 2 персоны",
91
123
  * "Профиль",
124
+ * "Рубль (круг.)",
125
+ * "Сейф",
92
126
  * "Безопасность",
93
127
  * "Подписанные документы",
128
+ * "Маленькие часы",
94
129
  * "Лого «Telegram»",
95
130
  * "UnionPay",
96
131
  * "Пользователь",
97
132
  * "Visa",
98
133
  * "Лого «VK»",
134
+ * "Пополнение карты",
135
+ * "Кошелёк с плюсом",
99
136
  * "Кошелёк",
137
+ * "Кошелёк с деньгами",
100
138
  * ]
101
139
  */
102
140
  export type IconName = keyof typeof IconMap;
@@ -1,10 +1,12 @@
1
1
  import { JSX } from '@redneckz/uni-jsx';
2
+ import { BgColorVersion } from '../../model/BgColorVersion';
2
3
  import { SVG } from '../SVG';
3
4
 
4
5
  export interface LogoProps {
5
6
  className: string;
6
7
  href: string;
7
8
  targetBlank: boolean;
9
+ bgColor?: string;
8
10
  }
9
11
 
10
12
  const LOGO_PATHS = [
@@ -14,22 +16,32 @@ const LOGO_PATHS = [
14
16
  'M14.7 27.83h2.58c.67 0 1.14.14 1.4.4.27.25.4.72.4 1.38v7.4c0 .66-.12 1.12-.4 1.38-.4.41-1.16.41-1.78.41l-.4-.01v3.5l.78.14v-2.88c1.2 0 1.97-.4 2.34-1.22v4.29h.26l.5-.01V29.74c0-.68.13-1.16.4-1.43.25-.27.72-.4 1.37-.4.67 0 1.65-.1 2.16.4.26.27.38.76.38 1.43v3.8h-1.77v-4.06h-.77v12.99c.26-.03.5-.07.77-.12V34.3h1.77v7.64c.36-.1.72-.21 1.08-.34v-7c0-.8.19-1.4 1-1.67l-.9-4.87h1.8l.3 5.31h.22l.3-5.31h1.88l-1.01 4.87c.84.3 1.01.81 1.01 1.66v4.53a16.63 16.63 0 0 0 1.5-1.27v-9.83h5.25l.1-.72H24.93l.17.89c-.38-.72-1.12-1.08-2.2-1.08h-.77c-1.3 0-2.1.52-2.4 1.55-.27-1.08-1.1-1.62-2.46-1.62h-3.36v14.52c.26.09.52.18.78.25V27.84Zm16.29 5.58-.85-.8.85-4.37v5.17Z',
15
17
  'M27.66 40.79c.27-.14.55-.28.8-.43v-5.98h-.8v6.4Z',
16
18
  ];
19
+ const SVG_COLOR: Record<BgColorVersion, string> = {
20
+ 'bg-white': 'text-primary-main',
21
+ transparent: 'text-white',
22
+ };
23
+ const TEXT_COLOR: Record<BgColorVersion, string> = {
24
+ 'bg-white': 'text-black',
25
+ transparent: 'text-white',
26
+ };
17
27
 
18
- export const Logo = JSX<Partial<LogoProps>>(({ className, href, children, targetBlank }) => {
19
- return (
20
- <a
21
- className={`inline-flex items-center font-sans no-underline ${className || ''}`}
22
- href={href || 'https://rshb.ru/'}
23
- target={targetBlank ? '_blank' : '_self'}
24
- >
25
- <SVG
26
- className="text-primary-main w-10"
27
- viewBox="0 0 40 45"
28
- paths={LOGO_PATHS.map((d) => ({ d }))}
29
- />
30
- <span className="text-black text-base font-medium ml-2.5">
31
- {children || 'Россельхозбанк'}
32
- </span>
33
- </a>
34
- );
35
- });
28
+ export const Logo = JSX<Partial<LogoProps>>(
29
+ ({ className, href, children, targetBlank, bgColor = 'bg-white' }) => {
30
+ return (
31
+ <a
32
+ className={`inline-flex items-center font-sans no-underline ${className || ''}`}
33
+ href={href || 'https://rshb.ru/'}
34
+ target={targetBlank ? '_blank' : '_self'}
35
+ >
36
+ <SVG
37
+ className={`${SVG_COLOR[bgColor]} w-10`}
38
+ viewBox="0 0 40 45"
39
+ paths={LOGO_PATHS.map((d) => ({ d }))}
40
+ />
41
+ <span className={`${TEXT_COLOR[bgColor]} text-base font-medium ml-2.5`}>
42
+ {children || 'Россельхозбанк'}
43
+ </span>
44
+ </a>
45
+ );
46
+ },
47
+ );
@@ -1,4 +1,5 @@
1
1
  import { JSX } from '@redneckz/uni-jsx';
2
+ import { BgColorVersion } from '../../model/BgColorVersion';
2
3
  import type { LinkProps } from '../../model/LinkProps';
3
4
 
4
5
  export interface TopItemContent extends LinkProps {
@@ -10,28 +11,54 @@ export interface TopItemProps extends TopItemContent {
10
11
  flat?: boolean;
11
12
  ariaLabel?: string;
12
13
  onClick?: (ev: MouseEvent) => any;
14
+ bgColor?: BgColorVersion;
13
15
  }
14
16
 
17
+ const TEXT_CLASSES = 'font-sans font-normal text-sm';
18
+ const LINK_CLASSES = 'inline-block border border-solid bg-transparent text-center no-underline';
19
+
15
20
  export const TopItem = JSX<TopItemProps>(
16
- ({ className, text, href, target, active, flat, onClick, children, ariaLabel }) => {
17
- const linkStyle = active ? 'border-primary-main rounded-md' : 'border-transparent';
18
- const textStyle = active
21
+ ({
22
+ className = '',
23
+ text,
24
+ href,
25
+ target,
26
+ active,
27
+ flat,
28
+ onClick,
29
+ children,
30
+ ariaLabel,
31
+ bgColor = 'bg-white',
32
+ }) => (
33
+ <a
34
+ className={`${getLinkClasses(bgColor, active, flat)} ${className}`}
35
+ href={href}
36
+ target={target}
37
+ onClick={onClick}
38
+ rel="noopener noreferrer"
39
+ aria-label={ariaLabel}
40
+ >
41
+ <span className={getTextClasses(bgColor, active, flat)}>{text || children}</span>
42
+ </a>
43
+ ),
44
+ );
45
+
46
+ const getLinkClasses = (bgColor: BgColorVersion, active?: boolean, flat?: boolean) => {
47
+ let classes = 'border-transparent';
48
+ if (active) {
49
+ classes = `rounded-md ${bgColor === 'bg-white' ? 'border-primary-main' : 'border-white'}`;
50
+ }
51
+
52
+ return `${classes} ${LINK_CLASSES} ${flat ? '' : 'px-4 py-2'}`;
53
+ };
54
+
55
+ const getTextClasses = (bgColor: BgColorVersion, active?: boolean, flat?: boolean) => {
56
+ let classes = 'text-white';
57
+ if (bgColor === 'bg-white') {
58
+ classes = active
19
59
  ? 'text-primary-main'
20
60
  : `${flat ? 'text-primary-text' : 'text-secondary-text'} hover:text-primary-main`;
61
+ }
21
62
 
22
- return (
23
- <a
24
- className={`inline-block border border-solid bg-transparent text-center no-underline ${
25
- flat ? '' : 'px-4 py-2'
26
- } ${linkStyle} ${className || ''}`}
27
- href={href}
28
- target={target}
29
- onClick={onClick}
30
- rel="noopener noreferrer"
31
- aria-label={ariaLabel}
32
- >
33
- <span className={`font-sans font-normal text-sm ${textStyle}`}>{text || children}</span>
34
- </a>
35
- );
36
- },
37
- );
63
+ return `${classes} ${TEXT_CLASSES}`;
64
+ };
@@ -0,0 +1,25 @@
1
+ import { adjustHref } from './adjustHref';
2
+
3
+ describe('adjustHref', () => {
4
+ it('should compute URL relative to some base URL', () => {
5
+ expect(
6
+ adjustHref('http://foo.ru/other/path', {
7
+ pathname: '/some/path',
8
+ href: 'http://foo.ru/some/path',
9
+ }),
10
+ ).toBe('/other/path');
11
+ });
12
+
13
+ it('should compute mobile URL for mobile pages', () => {
14
+ expect(
15
+ adjustHref('http://foo.ru/other/path', {
16
+ pathname: '/mobile/some/path',
17
+ href: 'http://foo.ru/mobile/some/path',
18
+ }),
19
+ ).toBe('/mobile/other/path');
20
+ });
21
+
22
+ it('should return nothing if nothing provided', () => {
23
+ expect(adjustHref(undefined, { pathname: '/mobile/some/path' })).toBe(undefined);
24
+ });
25
+ });
@@ -0,0 +1,24 @@
1
+ import { getOrigin, isURL } from './url';
2
+ import { MOBILE_URL_PATH } from './withoutMobilePath';
3
+
4
+ export const adjustHref = (
5
+ href: string | undefined,
6
+ router: { pathname: string; href?: string },
7
+ ) => {
8
+ if (!href) {
9
+ return href;
10
+ }
11
+
12
+ const relativeHref = toRelativeHref(href, router) || '';
13
+ const isMobilePage = router?.pathname.startsWith(MOBILE_URL_PATH);
14
+ return isMobilePage && !isURL(relativeHref) ? `${MOBILE_URL_PATH}${relativeHref}` : relativeHref;
15
+ };
16
+
17
+ const toRelativeHref = (href: string | undefined, router: { href?: string }) => {
18
+ if (!href) {
19
+ return href;
20
+ }
21
+
22
+ const origin = getOrigin(router?.href);
23
+ return origin ? href.replace(origin, '') || '/' : href;
24
+ };
@@ -0,0 +1,11 @@
1
+ import { maxBy } from './maxBy';
2
+
3
+ describe('maxBy', () => {
4
+ it('should return max value', () => {
5
+ expect(maxBy((_: number) => _)([1, 3, 2])).toBe(3);
6
+ });
7
+
8
+ it('should return max value with respect to discriminator', () => {
9
+ expect(maxBy((_: string) => _.length)(['123', '123456789', '123456'])).toBe('123456789');
10
+ });
11
+ });
@@ -0,0 +1,7 @@
1
+ export const maxBy =
2
+ <Item, Value>(discriminator: (item: Item) => Value) =>
3
+ (list: Item[]): Item =>
4
+ list.reduceRight((a, b) => (discriminator(a) > discriminator(b) ? a : b));
5
+
6
+ export const minBy = <Item, Value>(discriminator: (item: Item) => Value) =>
7
+ maxBy((_: Item) => -discriminator(_));
@@ -1,4 +1,4 @@
1
- import { adjustHref, getOrigin, toRelativeHref, withoutQuery } from './url';
1
+ import { getOrigin, withoutQuery } from './url';
2
2
 
3
3
  describe('url', () => {
4
4
  describe('withoutQuery', () => {
@@ -14,40 +14,4 @@ describe('url', () => {
14
14
  expect(getOrigin('http://foo.ru/other/path?first=1&second=2')).toBe('http://foo.ru');
15
15
  });
16
16
  });
17
-
18
- describe('adjustHref', () => {
19
- it('should compute URL relative to some base URL', () => {
20
- expect(
21
- adjustHref('http://foo.ru/other/path', {
22
- pathname: '/some/path',
23
- href: 'http://foo.ru/some/path',
24
- }),
25
- ).toBe('/other/path');
26
- });
27
-
28
- it('should compute mobile URL for mobile pages', () => {
29
- expect(
30
- adjustHref('http://foo.ru/other/path', {
31
- pathname: '/mobile/some/path',
32
- href: 'http://foo.ru/mobile/some/path',
33
- }),
34
- ).toBe('/mobile/other/path');
35
- });
36
-
37
- it('should return nothing if nothing provided', () => {
38
- expect(adjustHref(undefined, { pathname: '/mobile/some/path' })).toBe(undefined);
39
- });
40
- });
41
-
42
- describe('toRelativeHref', () => {
43
- it('should compute URL relative to some base URL', () => {
44
- expect(toRelativeHref('http://foo.ru/other/path', { href: 'http://foo.ru/some/path' })).toBe(
45
- '/other/path',
46
- );
47
- });
48
-
49
- it('should return nothing if nothing provided', () => {
50
- expect(toRelativeHref(undefined, {})).toBe(undefined);
51
- });
52
- });
53
17
  });