@redneckz/wildless-cms-uni-blocks 0.14.595 → 0.14.596

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 (335) hide show
  1. package/bundle/EventBus/EventBus.d.ts +17 -4
  2. package/bundle/EventBus/defaultEventBus.d.ts +2 -13
  3. package/bundle/EventBus/useSubject.d.ts +2 -0
  4. package/bundle/EventBus/useSubjectState.d.ts +2 -0
  5. package/bundle/bundle.umd.js +131 -89
  6. package/bundle/bundle.umd.min.js +1 -1
  7. package/bundle/components/CarouselTariffsCard/CardCellsSection.d.ts +9 -0
  8. package/bundle/components/CarouselTariffsCard/carouselTariffsCardEventBus.d.ts +9 -0
  9. package/bundle/hooks/useLocation.d.ts +2 -1
  10. package/bundle/hooks/useReducer.d.ts +4 -0
  11. package/bundle/ui-kit/Foldable/Foldable.d.ts +11 -1
  12. package/bundle/ui-kit/LocationDialog/SelectedLocation.d.ts +5 -0
  13. package/dist/EventBus/EventBus.d.ts +17 -4
  14. package/dist/EventBus/EventBus.js +29 -10
  15. package/dist/EventBus/EventBus.js.map +1 -1
  16. package/dist/EventBus/defaultEventBus.d.ts +2 -13
  17. package/dist/EventBus/defaultEventBus.js.map +1 -1
  18. package/dist/EventBus/useSubject.d.ts +2 -0
  19. package/dist/EventBus/useSubject.js +17 -0
  20. package/dist/EventBus/useSubject.js.map +1 -0
  21. package/dist/EventBus/useSubjectState.d.ts +2 -0
  22. package/dist/EventBus/useSubjectState.js +10 -0
  23. package/dist/EventBus/useSubjectState.js.map +1 -0
  24. package/dist/components/CarouselTariffsCard/CardCellsSection.d.ts +9 -0
  25. package/dist/components/CarouselTariffsCard/CardCellsSection.js +18 -0
  26. package/dist/components/CarouselTariffsCard/CardCellsSection.js.map +1 -0
  27. package/dist/components/CarouselTariffsCard/CarouselTariffsCard.js +11 -25
  28. package/dist/components/CarouselTariffsCard/CarouselTariffsCard.js.map +1 -1
  29. package/dist/components/CarouselTariffsCard/carouselTariffsCardEventBus.d.ts +9 -0
  30. package/dist/components/CarouselTariffsCard/carouselTariffsCardEventBus.js +5 -0
  31. package/dist/components/CarouselTariffsCard/carouselTariffsCardEventBus.js.map +1 -0
  32. package/dist/components/ExchangeRateTile/ExchangeRateTile.js +1 -1
  33. package/dist/components/ExchangeRateTile/ExchangeRateTile.js.map +1 -1
  34. package/dist/components/Header/HeaderSecondaryMenu.js +1 -1
  35. package/dist/components/Header/HeaderSecondaryMenu.js.map +1 -1
  36. package/dist/components/OfficesAtmsMap/AtmsMap.js +1 -1
  37. package/dist/components/OfficesAtmsMap/AtmsMap.js.map +1 -1
  38. package/dist/components/OfficesAtmsMap/OfficesMap.js +1 -1
  39. package/dist/components/OfficesAtmsMap/OfficesMap.js.map +1 -1
  40. package/dist/components/StickyBottomMenu/BurgerMenuDialog.js +1 -1
  41. package/dist/components/StickyBottomMenu/BurgerMenuDialog.js.map +1 -1
  42. package/dist/hooks/useLocation.d.ts +2 -1
  43. package/dist/hooks/useLocation.js +27 -33
  44. package/dist/hooks/useLocation.js.map +1 -1
  45. package/dist/hooks/useReducer.d.ts +4 -0
  46. package/dist/hooks/useReducer.js +12 -0
  47. package/dist/hooks/useReducer.js.map +1 -0
  48. package/dist/hooks/useRegions.js +3 -1
  49. package/dist/hooks/useRegions.js.map +1 -1
  50. package/dist/ui-kit/DialogManager/useDialogManager.js +3 -3
  51. package/dist/ui-kit/DialogManager/useDialogManager.js.map +1 -1
  52. package/dist/ui-kit/DialogManager/useDialogsList.js +1 -1
  53. package/dist/ui-kit/DialogManager/useDialogsList.js.map +1 -1
  54. package/dist/ui-kit/Foldable/Foldable.d.ts +11 -1
  55. package/dist/ui-kit/Foldable/Foldable.js +10 -2
  56. package/dist/ui-kit/Foldable/Foldable.js.map +1 -1
  57. package/dist/ui-kit/FormField/constants.js +1 -0
  58. package/dist/ui-kit/FormField/constants.js.map +1 -1
  59. package/dist/ui-kit/FormField/getValidation.js +1 -0
  60. package/dist/ui-kit/FormField/getValidation.js.map +1 -1
  61. package/dist/ui-kit/LocationDialog/LocationDialog.js +9 -12
  62. package/dist/ui-kit/LocationDialog/LocationDialog.js.map +1 -1
  63. package/dist/ui-kit/LocationDialog/SelectedLocation.d.ts +5 -0
  64. package/dist/ui-kit/LocationDialog/SelectedLocation.js +15 -0
  65. package/dist/ui-kit/LocationDialog/SelectedLocation.js.map +1 -0
  66. package/dist/ui-kit/PopupManager/PopupManager.js +1 -1
  67. package/dist/ui-kit/PopupManager/PopupManager.js.map +1 -1
  68. package/dist/ui-kit/PopupManager/usePopupManager.js +3 -3
  69. package/dist/ui-kit/PopupManager/usePopupManager.js.map +1 -1
  70. package/lib/EventBus/EventBus.d.ts +17 -4
  71. package/lib/EventBus/EventBus.js +29 -10
  72. package/lib/EventBus/EventBus.js.map +1 -1
  73. package/lib/EventBus/defaultEventBus.d.ts +2 -13
  74. package/lib/EventBus/defaultEventBus.js.map +1 -1
  75. package/lib/EventBus/useSubject.d.ts +2 -0
  76. package/lib/EventBus/useSubject.js +14 -0
  77. package/lib/EventBus/useSubject.js.map +1 -0
  78. package/lib/EventBus/useSubjectState.d.ts +2 -0
  79. package/lib/EventBus/useSubjectState.js +7 -0
  80. package/lib/EventBus/useSubjectState.js.map +1 -0
  81. package/lib/common.css +1 -1
  82. package/lib/components/CarouselTariffsCard/CardCellsSection.d.ts +9 -0
  83. package/lib/components/CarouselTariffsCard/CardCellsSection.js +16 -0
  84. package/lib/components/CarouselTariffsCard/CardCellsSection.js.map +1 -0
  85. package/lib/components/CarouselTariffsCard/CarouselTariffsCard.js +12 -26
  86. package/lib/components/CarouselTariffsCard/CarouselTariffsCard.js.map +1 -1
  87. package/lib/components/CarouselTariffsCard/carouselTariffsCardEventBus.d.ts +9 -0
  88. package/lib/components/CarouselTariffsCard/carouselTariffsCardEventBus.js +3 -0
  89. package/lib/components/CarouselTariffsCard/carouselTariffsCardEventBus.js.map +1 -0
  90. package/lib/components/ExchangeRateTile/ExchangeRateTile.js +2 -2
  91. package/lib/components/ExchangeRateTile/ExchangeRateTile.js.map +1 -1
  92. package/lib/components/Header/HeaderSecondaryMenu.js +2 -2
  93. package/lib/components/Header/HeaderSecondaryMenu.js.map +1 -1
  94. package/lib/components/OfficesAtmsMap/AtmsMap.js +2 -2
  95. package/lib/components/OfficesAtmsMap/AtmsMap.js.map +1 -1
  96. package/lib/components/OfficesAtmsMap/OfficesMap.js +2 -2
  97. package/lib/components/OfficesAtmsMap/OfficesMap.js.map +1 -1
  98. package/lib/components/StickyBottomMenu/BurgerMenuDialog.js +2 -2
  99. package/lib/components/StickyBottomMenu/BurgerMenuDialog.js.map +1 -1
  100. package/lib/hooks/useLocation.d.ts +2 -1
  101. package/lib/hooks/useLocation.js +26 -33
  102. package/lib/hooks/useLocation.js.map +1 -1
  103. package/lib/hooks/useReducer.d.ts +4 -0
  104. package/lib/hooks/useReducer.js +9 -0
  105. package/lib/hooks/useReducer.js.map +1 -0
  106. package/lib/hooks/useRegions.js +3 -1
  107. package/lib/hooks/useRegions.js.map +1 -1
  108. package/lib/ui-kit/DialogManager/useDialogManager.js +3 -3
  109. package/lib/ui-kit/DialogManager/useDialogManager.js.map +1 -1
  110. package/lib/ui-kit/DialogManager/useDialogsList.js +1 -1
  111. package/lib/ui-kit/DialogManager/useDialogsList.js.map +1 -1
  112. package/lib/ui-kit/Foldable/Foldable.d.ts +11 -1
  113. package/lib/ui-kit/Foldable/Foldable.js +10 -2
  114. package/lib/ui-kit/Foldable/Foldable.js.map +1 -1
  115. package/lib/ui-kit/FormField/constants.js +1 -0
  116. package/lib/ui-kit/FormField/constants.js.map +1 -1
  117. package/lib/ui-kit/FormField/getValidation.js +1 -0
  118. package/lib/ui-kit/FormField/getValidation.js.map +1 -1
  119. package/lib/ui-kit/LocationDialog/LocationDialog.js +10 -13
  120. package/lib/ui-kit/LocationDialog/LocationDialog.js.map +1 -1
  121. package/lib/ui-kit/LocationDialog/SelectedLocation.d.ts +5 -0
  122. package/lib/ui-kit/LocationDialog/SelectedLocation.js +13 -0
  123. package/lib/ui-kit/LocationDialog/SelectedLocation.js.map +1 -0
  124. package/lib/ui-kit/PopupManager/PopupManager.js +1 -1
  125. package/lib/ui-kit/PopupManager/PopupManager.js.map +1 -1
  126. package/lib/ui-kit/PopupManager/usePopupManager.js +3 -3
  127. package/lib/ui-kit/PopupManager/usePopupManager.js.map +1 -1
  128. package/mobile/bundle/EventBus/EventBus.d.ts +17 -4
  129. package/mobile/bundle/EventBus/defaultEventBus.d.ts +2 -13
  130. package/mobile/bundle/EventBus/useSubject.d.ts +2 -0
  131. package/mobile/bundle/EventBus/useSubjectState.d.ts +2 -0
  132. package/mobile/bundle/bundle.umd.js +131 -89
  133. package/mobile/bundle/bundle.umd.min.js +1 -1
  134. package/mobile/bundle/components/CarouselTariffsCard/CardCellsSection.d.ts +9 -0
  135. package/mobile/bundle/components/CarouselTariffsCard/carouselTariffsCardEventBus.d.ts +9 -0
  136. package/mobile/bundle/hooks/useLocation.d.ts +2 -1
  137. package/mobile/bundle/hooks/useReducer.d.ts +4 -0
  138. package/mobile/bundle/ui-kit/Foldable/Foldable.d.ts +11 -1
  139. package/mobile/bundle/ui-kit/LocationDialog/SelectedLocation.d.ts +5 -0
  140. package/mobile/dist/EventBus/EventBus.d.ts +17 -4
  141. package/mobile/dist/EventBus/EventBus.js +29 -10
  142. package/mobile/dist/EventBus/EventBus.js.map +1 -1
  143. package/mobile/dist/EventBus/defaultEventBus.d.ts +2 -13
  144. package/mobile/dist/EventBus/defaultEventBus.js.map +1 -1
  145. package/mobile/dist/EventBus/useSubject.d.ts +2 -0
  146. package/mobile/dist/EventBus/useSubject.js +17 -0
  147. package/mobile/dist/EventBus/useSubject.js.map +1 -0
  148. package/mobile/dist/EventBus/useSubjectState.d.ts +2 -0
  149. package/mobile/dist/EventBus/useSubjectState.js +10 -0
  150. package/mobile/dist/EventBus/useSubjectState.js.map +1 -0
  151. package/mobile/dist/components/CarouselTariffsCard/CardCellsSection.d.ts +9 -0
  152. package/mobile/dist/components/CarouselTariffsCard/CardCellsSection.js +18 -0
  153. package/mobile/dist/components/CarouselTariffsCard/CardCellsSection.js.map +1 -0
  154. package/mobile/dist/components/CarouselTariffsCard/CarouselTariffsCard.js +11 -25
  155. package/mobile/dist/components/CarouselTariffsCard/CarouselTariffsCard.js.map +1 -1
  156. package/mobile/dist/components/CarouselTariffsCard/carouselTariffsCardEventBus.d.ts +9 -0
  157. package/mobile/dist/components/CarouselTariffsCard/carouselTariffsCardEventBus.js +5 -0
  158. package/mobile/dist/components/CarouselTariffsCard/carouselTariffsCardEventBus.js.map +1 -0
  159. package/mobile/dist/components/ExchangeRateTile/ExchangeRateTile.js +1 -1
  160. package/mobile/dist/components/ExchangeRateTile/ExchangeRateTile.js.map +1 -1
  161. package/mobile/dist/components/Header/HeaderSecondaryMenu.js +1 -1
  162. package/mobile/dist/components/Header/HeaderSecondaryMenu.js.map +1 -1
  163. package/mobile/dist/components/OfficesAtmsMap/AtmsMap.js +1 -1
  164. package/mobile/dist/components/OfficesAtmsMap/AtmsMap.js.map +1 -1
  165. package/mobile/dist/components/OfficesAtmsMap/OfficesMap.js +1 -1
  166. package/mobile/dist/components/OfficesAtmsMap/OfficesMap.js.map +1 -1
  167. package/mobile/dist/components/StickyBottomMenu/BurgerMenuDialog.js +1 -1
  168. package/mobile/dist/components/StickyBottomMenu/BurgerMenuDialog.js.map +1 -1
  169. package/mobile/dist/hooks/useLocation.d.ts +2 -1
  170. package/mobile/dist/hooks/useLocation.js +27 -33
  171. package/mobile/dist/hooks/useLocation.js.map +1 -1
  172. package/mobile/dist/hooks/useReducer.d.ts +4 -0
  173. package/mobile/dist/hooks/useReducer.js +12 -0
  174. package/mobile/dist/hooks/useReducer.js.map +1 -0
  175. package/mobile/dist/hooks/useRegions.js +3 -1
  176. package/mobile/dist/hooks/useRegions.js.map +1 -1
  177. package/mobile/dist/ui-kit/DialogManager/useDialogManager.js +3 -3
  178. package/mobile/dist/ui-kit/DialogManager/useDialogManager.js.map +1 -1
  179. package/mobile/dist/ui-kit/DialogManager/useDialogsList.js +1 -1
  180. package/mobile/dist/ui-kit/DialogManager/useDialogsList.js.map +1 -1
  181. package/mobile/dist/ui-kit/Foldable/Foldable.d.ts +11 -1
  182. package/mobile/dist/ui-kit/Foldable/Foldable.js +10 -2
  183. package/mobile/dist/ui-kit/Foldable/Foldable.js.map +1 -1
  184. package/mobile/dist/ui-kit/FormField/constants.js +1 -0
  185. package/mobile/dist/ui-kit/FormField/constants.js.map +1 -1
  186. package/mobile/dist/ui-kit/FormField/getValidation.js +1 -0
  187. package/mobile/dist/ui-kit/FormField/getValidation.js.map +1 -1
  188. package/mobile/dist/ui-kit/LocationDialog/LocationDialog.js +9 -12
  189. package/mobile/dist/ui-kit/LocationDialog/LocationDialog.js.map +1 -1
  190. package/mobile/dist/ui-kit/LocationDialog/SelectedLocation.d.ts +5 -0
  191. package/mobile/dist/ui-kit/LocationDialog/SelectedLocation.js +15 -0
  192. package/mobile/dist/ui-kit/LocationDialog/SelectedLocation.js.map +1 -0
  193. package/mobile/dist/ui-kit/PopupManager/PopupManager.js +1 -1
  194. package/mobile/dist/ui-kit/PopupManager/PopupManager.js.map +1 -1
  195. package/mobile/dist/ui-kit/PopupManager/usePopupManager.js +3 -3
  196. package/mobile/dist/ui-kit/PopupManager/usePopupManager.js.map +1 -1
  197. package/mobile/lib/EventBus/EventBus.d.ts +17 -4
  198. package/mobile/lib/EventBus/EventBus.js +29 -10
  199. package/mobile/lib/EventBus/EventBus.js.map +1 -1
  200. package/mobile/lib/EventBus/defaultEventBus.d.ts +2 -13
  201. package/mobile/lib/EventBus/defaultEventBus.js.map +1 -1
  202. package/mobile/lib/EventBus/useSubject.d.ts +2 -0
  203. package/mobile/lib/EventBus/useSubject.js +14 -0
  204. package/mobile/lib/EventBus/useSubject.js.map +1 -0
  205. package/mobile/lib/EventBus/useSubjectState.d.ts +2 -0
  206. package/mobile/lib/EventBus/useSubjectState.js +7 -0
  207. package/mobile/lib/EventBus/useSubjectState.js.map +1 -0
  208. package/mobile/lib/common.css +1 -1
  209. package/mobile/lib/components/CarouselTariffsCard/CardCellsSection.d.ts +9 -0
  210. package/mobile/lib/components/CarouselTariffsCard/CardCellsSection.js +16 -0
  211. package/mobile/lib/components/CarouselTariffsCard/CardCellsSection.js.map +1 -0
  212. package/mobile/lib/components/CarouselTariffsCard/CarouselTariffsCard.js +12 -26
  213. package/mobile/lib/components/CarouselTariffsCard/CarouselTariffsCard.js.map +1 -1
  214. package/mobile/lib/components/CarouselTariffsCard/carouselTariffsCardEventBus.d.ts +9 -0
  215. package/mobile/lib/components/CarouselTariffsCard/carouselTariffsCardEventBus.js +3 -0
  216. package/mobile/lib/components/CarouselTariffsCard/carouselTariffsCardEventBus.js.map +1 -0
  217. package/mobile/lib/components/ExchangeRateTile/ExchangeRateTile.js +2 -2
  218. package/mobile/lib/components/ExchangeRateTile/ExchangeRateTile.js.map +1 -1
  219. package/mobile/lib/components/Header/HeaderSecondaryMenu.js +2 -2
  220. package/mobile/lib/components/Header/HeaderSecondaryMenu.js.map +1 -1
  221. package/mobile/lib/components/OfficesAtmsMap/AtmsMap.js +2 -2
  222. package/mobile/lib/components/OfficesAtmsMap/AtmsMap.js.map +1 -1
  223. package/mobile/lib/components/OfficesAtmsMap/OfficesMap.js +2 -2
  224. package/mobile/lib/components/OfficesAtmsMap/OfficesMap.js.map +1 -1
  225. package/mobile/lib/components/StickyBottomMenu/BurgerMenuDialog.js +2 -2
  226. package/mobile/lib/components/StickyBottomMenu/BurgerMenuDialog.js.map +1 -1
  227. package/mobile/lib/hooks/useLocation.d.ts +2 -1
  228. package/mobile/lib/hooks/useLocation.js +26 -33
  229. package/mobile/lib/hooks/useLocation.js.map +1 -1
  230. package/mobile/lib/hooks/useReducer.d.ts +4 -0
  231. package/mobile/lib/hooks/useReducer.js +9 -0
  232. package/mobile/lib/hooks/useReducer.js.map +1 -0
  233. package/mobile/lib/hooks/useRegions.js +3 -1
  234. package/mobile/lib/hooks/useRegions.js.map +1 -1
  235. package/mobile/lib/ui-kit/DialogManager/useDialogManager.js +3 -3
  236. package/mobile/lib/ui-kit/DialogManager/useDialogManager.js.map +1 -1
  237. package/mobile/lib/ui-kit/DialogManager/useDialogsList.js +1 -1
  238. package/mobile/lib/ui-kit/DialogManager/useDialogsList.js.map +1 -1
  239. package/mobile/lib/ui-kit/Foldable/Foldable.d.ts +11 -1
  240. package/mobile/lib/ui-kit/Foldable/Foldable.js +10 -2
  241. package/mobile/lib/ui-kit/Foldable/Foldable.js.map +1 -1
  242. package/mobile/lib/ui-kit/FormField/constants.js +1 -0
  243. package/mobile/lib/ui-kit/FormField/constants.js.map +1 -1
  244. package/mobile/lib/ui-kit/FormField/getValidation.js +1 -0
  245. package/mobile/lib/ui-kit/FormField/getValidation.js.map +1 -1
  246. package/mobile/lib/ui-kit/LocationDialog/LocationDialog.js +10 -13
  247. package/mobile/lib/ui-kit/LocationDialog/LocationDialog.js.map +1 -1
  248. package/mobile/lib/ui-kit/LocationDialog/SelectedLocation.d.ts +5 -0
  249. package/mobile/lib/ui-kit/LocationDialog/SelectedLocation.js +13 -0
  250. package/mobile/lib/ui-kit/LocationDialog/SelectedLocation.js.map +1 -0
  251. package/mobile/lib/ui-kit/PopupManager/PopupManager.js +1 -1
  252. package/mobile/lib/ui-kit/PopupManager/PopupManager.js.map +1 -1
  253. package/mobile/lib/ui-kit/PopupManager/usePopupManager.js +3 -3
  254. package/mobile/lib/ui-kit/PopupManager/usePopupManager.js.map +1 -1
  255. package/mobile/src/EventBus/EventBus.ts +51 -15
  256. package/mobile/src/EventBus/defaultEventBus.ts +2 -14
  257. package/mobile/src/EventBus/useSubject.ts +19 -0
  258. package/mobile/src/EventBus/useSubjectState.ts +13 -0
  259. package/mobile/src/components/CarouselTariffsCard/CardCellsSection.tsx +54 -0
  260. package/mobile/src/components/CarouselTariffsCard/CarouselTariffsCard.tsx +23 -66
  261. package/mobile/src/components/CarouselTariffsCard/carouselTariffsCardEventBus.ts +11 -0
  262. package/mobile/src/components/ExchangeRateTile/ExchangeRateTile.tsx +2 -2
  263. package/mobile/src/components/Header/HeaderSecondaryMenu.tsx +2 -2
  264. package/mobile/src/components/OfficesAtmsMap/AtmsMap.tsx +2 -3
  265. package/mobile/src/components/OfficesAtmsMap/OfficesMap.tsx +2 -2
  266. package/mobile/src/components/StickyBottomMenu/BurgerMenuDialog.tsx +2 -2
  267. package/mobile/src/hooks/useLocation.ts +30 -44
  268. package/mobile/src/hooks/useReducer.ts +21 -0
  269. package/mobile/src/hooks/useRegions.ts +4 -1
  270. package/mobile/src/ui-kit/DialogManager/useDialogManager.ts +3 -3
  271. package/mobile/src/ui-kit/DialogManager/useDialogsList.ts +1 -1
  272. package/mobile/src/ui-kit/Foldable/Foldable.tsx +21 -5
  273. package/mobile/src/ui-kit/FormField/constants.tsx +1 -0
  274. package/mobile/src/ui-kit/FormField/getValidation.tsx +1 -0
  275. package/mobile/src/ui-kit/LocationDialog/LocationDialog.tsx +13 -25
  276. package/mobile/src/ui-kit/LocationDialog/SelectedLocation.tsx +27 -0
  277. package/mobile/src/ui-kit/PopupManager/PopupManager.tsx +1 -1
  278. package/mobile/src/ui-kit/PopupManager/usePopupManager.tsx +3 -3
  279. package/package.json +1 -1
  280. package/src/EventBus/EventBus.ts +51 -15
  281. package/src/EventBus/defaultEventBus.ts +2 -14
  282. package/src/EventBus/useSubject.ts +19 -0
  283. package/src/EventBus/useSubjectState.ts +13 -0
  284. package/src/components/CarouselTariffsCard/CardCellsSection.tsx +54 -0
  285. package/src/components/CarouselTariffsCard/CarouselTariffsCard.tsx +23 -66
  286. package/src/components/CarouselTariffsCard/carouselTariffsCardEventBus.ts +11 -0
  287. package/src/components/ExchangeRateTile/ExchangeRateTile.tsx +2 -2
  288. package/src/components/Header/HeaderSecondaryMenu.tsx +2 -2
  289. package/src/components/OfficesAtmsMap/AtmsMap.tsx +2 -3
  290. package/src/components/OfficesAtmsMap/OfficesMap.tsx +2 -2
  291. package/src/components/StickyBottomMenu/BurgerMenuDialog.tsx +2 -2
  292. package/src/hooks/useLocation.ts +30 -44
  293. package/src/hooks/useReducer.ts +21 -0
  294. package/src/hooks/useRegions.ts +4 -1
  295. package/src/ui-kit/DialogManager/useDialogManager.ts +3 -3
  296. package/src/ui-kit/DialogManager/useDialogsList.ts +1 -1
  297. package/src/ui-kit/Foldable/Foldable.tsx +21 -5
  298. package/src/ui-kit/FormField/constants.tsx +1 -0
  299. package/src/ui-kit/FormField/getValidation.tsx +1 -0
  300. package/src/ui-kit/LocationDialog/LocationDialog.tsx +13 -25
  301. package/src/ui-kit/LocationDialog/SelectedLocation.tsx +27 -0
  302. package/src/ui-kit/PopupManager/PopupManager.tsx +1 -1
  303. package/src/ui-kit/PopupManager/usePopupManager.tsx +3 -3
  304. package/bundle/EventBus/useLatestEvent.d.ts +0 -2
  305. package/bundle/components/CarouselTariffsCard/CarouselTariffsCardAction.d.ts +0 -6
  306. package/dist/EventBus/useLatestEvent.d.ts +0 -2
  307. package/dist/EventBus/useLatestEvent.js +0 -11
  308. package/dist/EventBus/useLatestEvent.js.map +0 -1
  309. package/dist/components/CarouselTariffsCard/CarouselTariffsCardAction.d.ts +0 -6
  310. package/dist/components/CarouselTariffsCard/CarouselTariffsCardAction.js +0 -2
  311. package/dist/components/CarouselTariffsCard/CarouselTariffsCardAction.js.map +0 -1
  312. package/lib/EventBus/useLatestEvent.d.ts +0 -2
  313. package/lib/EventBus/useLatestEvent.js +0 -8
  314. package/lib/EventBus/useLatestEvent.js.map +0 -1
  315. package/lib/components/CarouselTariffsCard/CarouselTariffsCardAction.d.ts +0 -6
  316. package/lib/components/CarouselTariffsCard/CarouselTariffsCardAction.js +0 -2
  317. package/lib/components/CarouselTariffsCard/CarouselTariffsCardAction.js.map +0 -1
  318. package/mobile/bundle/EventBus/useLatestEvent.d.ts +0 -2
  319. package/mobile/bundle/components/CarouselTariffsCard/CarouselTariffsCardAction.d.ts +0 -6
  320. package/mobile/dist/EventBus/useLatestEvent.d.ts +0 -2
  321. package/mobile/dist/EventBus/useLatestEvent.js +0 -11
  322. package/mobile/dist/EventBus/useLatestEvent.js.map +0 -1
  323. package/mobile/dist/components/CarouselTariffsCard/CarouselTariffsCardAction.d.ts +0 -6
  324. package/mobile/dist/components/CarouselTariffsCard/CarouselTariffsCardAction.js +0 -2
  325. package/mobile/dist/components/CarouselTariffsCard/CarouselTariffsCardAction.js.map +0 -1
  326. package/mobile/lib/EventBus/useLatestEvent.d.ts +0 -2
  327. package/mobile/lib/EventBus/useLatestEvent.js +0 -8
  328. package/mobile/lib/EventBus/useLatestEvent.js.map +0 -1
  329. package/mobile/lib/components/CarouselTariffsCard/CarouselTariffsCardAction.d.ts +0 -6
  330. package/mobile/lib/components/CarouselTariffsCard/CarouselTariffsCardAction.js +0 -2
  331. package/mobile/lib/components/CarouselTariffsCard/CarouselTariffsCardAction.js.map +0 -1
  332. package/mobile/src/EventBus/useLatestEvent.ts +0 -16
  333. package/mobile/src/components/CarouselTariffsCard/CarouselTariffsCardAction.ts +0 -6
  334. package/src/EventBus/useLatestEvent.ts +0 -16
  335. package/src/components/CarouselTariffsCard/CarouselTariffsCardAction.ts +0 -6
@@ -1,28 +1,22 @@
1
1
  import { JSX } from '@redneckz/uni-jsx';
2
- import { useEffect, useState } from '@redneckz/uni-jsx/lib/hooks';
3
- import { defaultEventBus } from '../../EventBus/defaultEventBus';
4
- import { type AspectsDef } from '../../model/AspectsProps';
5
- import { type Slot } from '../../model/ContentPageDef';
6
- import { type VNode } from '../../model/VNode';
2
+ import { useCallback } from '@redneckz/uni-jsx/lib/hooks';
3
+ import { useSubjectState } from '../../EventBus/useSubjectState';
7
4
  import { BlockWrapper } from '../../ui-kit/BlockWrapper';
8
- import { Foldable } from '../../ui-kit/Foldable/Foldable';
9
- import { FoldableSection } from '../../ui-kit/Foldable/FoldableSection';
10
5
  import { Heading } from '../../ui-kit/Heading/Heading';
11
- import { Icon } from '../../ui-kit/Icon/Icon';
12
6
  import { Img } from '../../ui-kit/Img/Img';
13
7
  import { LinkButton } from '../../ui-kit/LinkButton/LinkButton';
14
8
  import { type UniBlockProps } from '../../UniBlock/UniBlockProps';
15
- import { getAspectsAttributes } from '../../utils/dataAttributes';
16
9
  import { isIcon } from '../../utils/isIcon';
17
10
  import { style } from '../../utils/style';
11
+ import { CardCellsSection } from './CardCellsSection';
18
12
  import { type CarouselTariffsCardContent } from './CarouselTariffsCardContent';
19
- import { renderCardInfo } from './renderCardInfo';
13
+ import { carouselTariffsCardEventBus } from './carouselTariffsCardEventBus';
20
14
 
21
15
  export interface CarouselTariffsCardProps extends CarouselTariffsCardContent, UniBlockProps {}
22
16
 
23
17
  export const CarouselTariffsCard = JSX<CarouselTariffsCardProps>(
24
18
  ({
25
- className = '',
19
+ className,
26
20
  title,
27
21
  align = 'text-center',
28
22
  icon,
@@ -33,22 +27,20 @@ export const CarouselTariffsCard = JSX<CarouselTariffsCardProps>(
33
27
  data,
34
28
  ...rest
35
29
  }) => {
36
- const cellsNode = cardCells.map(renderCardInfo);
37
-
38
- const [visibleCells, hiddenCells] =
39
- visibleCellsCount > 0
40
- ? [cellsNode.slice(0, visibleCellsCount), cellsNode.slice(visibleCellsCount)]
41
- : [cellsNode, []];
42
- const [isVisible, setIsVisible] = useState(false);
30
+ const { isUnfolded, parent: firedParent } = useSubjectState(
31
+ carouselTariffsCardEventBus.observable,
32
+ 'fold',
33
+ {},
34
+ );
35
+ const isVisible = isUnfolded && firedParent === options?.parent;
43
36
 
44
- useEffect(
37
+ const toggle = useCallback(
45
38
  () =>
46
- defaultEventBus.subscribe('fold', (event) => {
47
- if (options?.parent !== undefined && event.parent === options?.parent) {
48
- setIsVisible(event.isUnfolded);
49
- }
39
+ carouselTariffsCardEventBus.emitter.fire('fold', {
40
+ isUnfolded: !isVisible,
41
+ parent: options?.parent,
50
42
  }),
51
- [options?.parent],
43
+ [isVisible, options?.parent],
52
44
  );
53
45
 
54
46
  return (
@@ -62,49 +54,14 @@ export const CarouselTariffsCard = JSX<CarouselTariffsCardProps>(
62
54
  <Heading className={style('pt-xs', align)} headingType="h5" title={title} />
63
55
  ) : null}
64
56
  {button?.text ? <LinkButton className="w-full mt-m mb-lg" {...button} /> : null}
65
- {hiddenCells.length ? (
66
- <Foldable
67
- renderFoldableSection={() => (
68
- <div>
69
- {visibleCells}
70
- <FoldableSection isUnfolded={isVisible}>{hiddenCells}</FoldableSection>
71
- </div>
72
- )}
73
- renderFoldButton={
74
- cardCells.length >= visibleCellsCount
75
- ? renderFoldButton(options?.parent, data, isVisible)
76
- : null
77
- }
78
- />
79
- ) : (
80
- <div>{visibleCells}</div>
81
- )}
57
+ <CardCellsSection
58
+ cardCells={cardCells}
59
+ visibleCellsCount={visibleCellsCount}
60
+ isUnfolded={isVisible}
61
+ data={data}
62
+ onToggle={toggle}
63
+ />
82
64
  </BlockWrapper>
83
65
  );
84
66
  },
85
67
  );
86
-
87
- const renderFoldButton =
88
- (parent?: Slot, data?: AspectsDef[], isUnfolded = false) =>
89
- (): VNode =>
90
- (
91
- <button
92
- className="w-full cursor-pointer text-primary-main pt-lg flex justify-between items-center"
93
- onClick={() => {
94
- if (parent !== undefined) {
95
- defaultEventBus.fire('fold', { type: 'fold', isUnfolded: !isUnfolded, parent });
96
- }
97
- }}
98
- type="button"
99
- // eslint-disable-next-line react/jsx-props-no-spreading
100
- {...(isUnfolded ? getAspectsAttributes(data) : {})}
101
- >
102
- <div>{isUnfolded ? 'Скрыть' : 'Подробнее о тарифе'}</div>
103
- <Icon
104
- className="text-primary-text"
105
- name={isUnfolded ? 'ArrowUpIcon' : 'ArrowDownIcon'}
106
- width="16"
107
- height="16"
108
- />
109
- </button>
110
- );
@@ -0,0 +1,11 @@
1
+ import { EventBus } from '../../EventBus/EventBus';
2
+ import { type Slot } from '../../model/ContentPageDef';
3
+
4
+ export type CarouselTariffsCardFoldAction = {
5
+ isUnfolded?: boolean;
6
+ parent?: Slot;
7
+ };
8
+
9
+ export const carouselTariffsCardEventBus = new EventBus<{
10
+ fold: CarouselTariffsCardFoldAction;
11
+ }>();
@@ -1,5 +1,5 @@
1
1
  import { JSX } from '@redneckz/uni-jsx';
2
- import { useLocation } from '../../hooks/useLocation';
2
+ import { useLocationState } from '../../hooks/useLocation';
3
3
  import { BaseTile } from '../../ui-kit/BaseTile/BaseTile';
4
4
  import { BlockWrapper } from '../../ui-kit/BlockWrapper';
5
5
  import { Heading } from '../../ui-kit/Heading/Heading';
@@ -19,7 +19,7 @@ export interface ExchangeRateTileProps extends ExchangeRateTileContent, UniBlock
19
19
 
20
20
  export const ExchangeRateTile = JSX<ExchangeRateTileProps>(
21
21
  ({ className = '', title = 'Курсы обмена валют', button, ...rest }) => {
22
- const [currentLocation] = useLocation();
22
+ const currentLocation = useLocationState();
23
23
  const exchangeRates = useFetchExchangeRateData(currentLocation);
24
24
 
25
25
  const currencyRates = getCurrencyRates(exchangeRates?.exchangeRate?.currencies);
@@ -4,7 +4,7 @@ import { type SearchHeaderProps } from '../../data/CommonData';
4
4
  import { type HeaderData } from '../../data/HeaderData';
5
5
  import { type NavigationData } from '../../data/NavigationData';
6
6
  import { getAspectsWithInclude } from '../../hooks/useAspects/aspects/getAspectsWithInclude';
7
- import { useLocation } from '../../hooks/useLocation';
7
+ import { useLocationState } from '../../hooks/useLocation';
8
8
  import { type BlockVersion } from '../../model/BlockVersion';
9
9
  import { type IconVersion } from '../../model/IconVersion';
10
10
  import { useLocationDialog } from '../../ui-kit/LocationDialog/useLocationDialog';
@@ -22,7 +22,7 @@ export const HeaderSecondaryMenu = JSX<HeaderSecondaryMenuProps>(
22
22
  ({ className, version, ...rest }) => {
23
23
  const iconVersion: IconVersion = version === 'transparent' ? 'white' : 'black';
24
24
 
25
- const [currentLocation] = useLocation(rest?.branches?.default);
25
+ const currentLocation = useLocationState(rest?.branches?.default);
26
26
 
27
27
  const searchDialog = useSearchDialog(rest);
28
28
  const locationDialog = useLocationDialog(rest);
@@ -1,5 +1,5 @@
1
1
  import { JSX } from '@redneckz/uni-jsx';
2
- import { useLocation } from '../../hooks/useLocation';
2
+ import { useLocationState } from '../../hooks/useLocation';
3
3
  import { type AtmsDef } from './OfficesAtmsMapContent';
4
4
  import { OfficesAtmsMapLayout } from './OfficesAtmsMapLayout';
5
5
  import { type Atm } from './OfficesAtmsMapProps';
@@ -30,8 +30,7 @@ export interface AtmsMapProps {
30
30
  }
31
31
 
32
32
  export const AtmsMap = JSX<AtmsMapProps>(({ descriptionData, className }) => {
33
- const [currentLocation] = useLocation();
34
-
33
+ const currentLocation = useLocationState();
35
34
  const regionCode = currentLocation?.code ?? '000';
36
35
 
37
36
  const { data: officesData, isLoad } = useAtms(regionCode);
@@ -1,5 +1,5 @@
1
1
  import { JSX } from '@redneckz/uni-jsx';
2
- import { useLocation } from '../../hooks/useLocation';
2
+ import { useLocationState } from '../../hooks/useLocation';
3
3
  import { OfficesAtmsMapLayout } from './OfficesAtmsMapLayout';
4
4
  import { getOfficePoint, renderOfficeCard } from './renderOfficeCard';
5
5
  import { getRemoteWorkplacePoint, renderRemoteWorkplaceCard } from './renderRemoteWorkplaceCard';
@@ -10,7 +10,7 @@ export interface OfficesMapProps {
10
10
  }
11
11
 
12
12
  export const OfficesMap = JSX<OfficesMapProps>(({ className }) => {
13
- const [currentLocation] = useLocation();
13
+ const currentLocation = useLocationState();
14
14
  const regionCode = currentLocation?.code ?? '000';
15
15
  const { data, isLoad } = useOffices(regionCode);
16
16
 
@@ -4,7 +4,7 @@ import { type HeaderData } from '../../data/HeaderData';
4
4
  import { type JSONRefObject } from '../../data/JSONRefObject';
5
5
  import { type StickyMenuItem } from '../../data/StickyMobileData';
6
6
  import { env } from '../../Env';
7
- import { useLocation } from '../../hooks/useLocation';
7
+ import { useLocationState } from '../../hooks/useLocation';
8
8
  import { Heading } from '../../ui-kit/Heading/Heading';
9
9
  import { useLocationDialog } from '../../ui-kit/LocationDialog/useLocationDialog';
10
10
  import { getBasePath } from '../../utils/getBasePath';
@@ -22,7 +22,7 @@ export interface BurgerMenuDialogProps {
22
22
  export const BurgerMenuDialog = JSX<BurgerMenuDialogProps>(
23
23
  ({ menuRef, menuItem, locationDialogProps, closeAll }) => {
24
24
  const locationDialog = useLocationDialog(locationDialogProps || {});
25
- const [{ name: location }] = useLocation();
25
+ const { name: location } = useLocationState();
26
26
  const menuDimensions = menuRef?.current?.getBoundingClientRect();
27
27
  const basePath = getBasePath(env.SITE_URL);
28
28
 
@@ -1,54 +1,40 @@
1
- import { useCallback, useEffect } from '@redneckz/uni-jsx/lib/hooks';
2
- import { useAsyncData } from '@redneckz/uni-jsx/lib/hooks/useAsyncData';
1
+ import { useEffect } from '@redneckz/uni-jsx/lib/hooks';
3
2
  import { defaultEventBus } from '../EventBus/defaultEventBus';
4
- import { useLatestEvent } from '../EventBus/useLatestEvent';
5
- import { fetchJSONUnsafe, type FetchJSONUnsafeType } from '../utils/fetchJSON';
3
+ import { useSubject } from '../EventBus/useSubject';
4
+ import { useSubjectState } from '../EventBus/useSubjectState';
5
+ import { fetchJSON } from '../utils/fetchJSON';
6
6
  import { type Region } from './useRegions';
7
7
 
8
8
  const REGION_URL = '/api/v1/region';
9
9
  const LOCATION_STORAGE_KEY = 'location';
10
10
 
11
- export function useLocation(defaultLocation = 'Москва'): [Region, (_: Region) => void] {
12
- const [currentLocation, fireCurrentLocation] = useLatestEvent(
13
- defaultEventBus,
14
- 'location',
15
- restoreLocation() ?? { name: defaultLocation },
16
- );
17
-
18
- const selectCurrentLocation = useCallback((_: Region) => {
19
- storeLocation(_);
20
- fireCurrentLocation(_);
21
- }, []);
22
-
23
- const { data } = useAsyncData(
24
- hasStoredLocation() ? null : REGION_URL,
25
- fetchJSONUnsafe as FetchJSONUnsafeType<Region>,
26
- );
27
- useEffect(() => {
28
- if (data && !hasStoredLocation()) {
29
- fireCurrentLocation(data);
11
+ export function useLocation(defaultLocation = 'Москва'): (_: Region) => void {
12
+ useEffect(() => defaultEventBus.subscribe('location', storeLocation), []);
13
+
14
+ return useSubject(defaultEventBus.emitter, 'location', restoreLocation(defaultLocation));
15
+ }
16
+
17
+ export function useLocationState(defaultLocation = 'Москва'): Region {
18
+ return useSubjectState(defaultEventBus.observable, 'location', { name: defaultLocation });
19
+ }
20
+
21
+ function restoreLocation(defaultLocation: string) {
22
+ return async (): Promise<Region> => {
23
+ if (!globalThis.localStorage?.hasItem(LOCATION_STORAGE_KEY)) {
24
+ storeLocation(await fetchJSON<Region>(REGION_URL));
25
+ }
26
+
27
+ const storedLocation = globalThis.localStorage?.getItem(LOCATION_STORAGE_KEY);
28
+ try {
29
+ return storedLocation && JSON.parse(storedLocation);
30
+ } catch (ex) {
31
+ // Do nothing
30
32
  }
31
- }, [data]);
32
33
 
33
- return [currentLocation ?? { name: defaultLocation }, selectCurrentLocation];
34
+ return { name: defaultLocation };
35
+ };
34
36
  }
35
37
 
36
- const hasStoredLocation = () => Boolean(globalThis.localStorage?.getItem(LOCATION_STORAGE_KEY));
37
-
38
- const restoreLocation = (): Region | null => {
39
- try {
40
- const data = globalThis.localStorage?.getItem(LOCATION_STORAGE_KEY);
41
-
42
- return data && JSON.parse(data);
43
- } catch (ex) {
44
- return null;
45
- }
46
- };
47
-
48
- const storeLocation = (_: Region) => {
49
- try {
50
- globalThis.localStorage?.setItem(LOCATION_STORAGE_KEY, JSON.stringify(_));
51
- } catch (ex) {
52
- // Do nothing
53
- }
54
- };
38
+ function storeLocation(_: Region | null | undefined) {
39
+ _ && globalThis.localStorage?.setItem(LOCATION_STORAGE_KEY, JSON.stringify(_));
40
+ }
@@ -0,0 +1,21 @@
1
+ import { useCallback, useState } from '@redneckz/uni-jsx/lib/hooks';
2
+
3
+ export type NotUndefined = object | null;
4
+ export type Reducer<S, A extends NotUndefined> = (state: S, action: A) => S;
5
+ export type Dispatch<A extends NotUndefined> = (action: A) => void;
6
+
7
+ export function useReducer<S, A extends NotUndefined>(
8
+ reducer: Reducer<S, A>,
9
+ initialArg: S,
10
+ ): [state: S, dispatch: Dispatch<A>] {
11
+ const [state, setState] = useState(initialArg);
12
+
13
+ const dispatch = useCallback(
14
+ (action: A) => {
15
+ setState((_) => reducer(_, action));
16
+ },
17
+ [reducer],
18
+ );
19
+
20
+ return [state, dispatch];
21
+ }
@@ -11,8 +11,11 @@ export interface Region {
11
11
  localities?: string[];
12
12
  }
13
13
 
14
+ const EMPTY_REGIONS: Region[] = [];
15
+
16
+ // TODO Почему url можно менять? Разве смысл не в инкапсуляции api url. Тоже под рефакторинг попадает
14
17
  export function useRegions(url: string = REGIONS_URL): Region[] {
15
18
  const { data } = useAsyncData(url, fetchJSONUnsafe as FetchJSONUnsafeType<Region[]>);
16
19
 
17
- return Array.isArray(data) ? data : [];
20
+ return Array.isArray(data) ? data : EMPTY_REGIONS;
18
21
  }
@@ -8,7 +8,7 @@ export interface DialogOptions {
8
8
 
9
9
  export const useDialogManager = () => ({
10
10
  open: (dialog: VNode, options: DialogOptions = {}) =>
11
- defaultEventBus.fire('dialog', { type: 'open', dialog, ...options }),
12
- close: () => defaultEventBus.fire('dialog', { type: 'close' }),
13
- closeAll: () => defaultEventBus.fire('dialog', { type: 'close', all: true }),
11
+ defaultEventBus.emitter.fire('dialog', { type: 'open', dialog, ...options }),
12
+ close: () => defaultEventBus.emitter.fire('dialog', { type: 'close' }),
13
+ closeAll: () => defaultEventBus.emitter.fire('dialog', { type: 'close', all: true }),
14
14
  });
@@ -27,7 +27,7 @@ export const useDialogsList = ({
27
27
 
28
28
  useEffect(
29
29
  () =>
30
- defaultEventBus.subscribe('dialog', (action) => {
30
+ defaultEventBus.observable.subscribe('dialog', (action) => {
31
31
  switch (action.type) {
32
32
  case 'open':
33
33
  push(action);
@@ -3,14 +3,30 @@ import { useCallback, useState } from '@redneckz/uni-jsx/lib/hooks';
3
3
  import { type VNode } from '../../model/VNode';
4
4
  import { type FoldablePartProps } from './FoldablePartProps';
5
5
 
6
- export interface FoldableProps {
6
+ export interface FoldableWrapperProps {
7
7
  className?: string;
8
+ }
9
+
10
+ export interface FoldableProps extends FoldableWrapperProps {
8
11
  unfoldedByDefault?: boolean;
9
12
  isFoldButtonOnTop?: boolean;
10
13
  renderFoldableSection: (props: FoldablePartProps) => VNode;
11
14
  renderFoldButton?: ((props: FoldablePartProps) => VNode) | null;
12
15
  }
13
16
 
17
+ export const FoldableWrapper = JSX<FoldableWrapperProps>(({ className, children }) => (
18
+ <div className={className} role="group">
19
+ {children}
20
+ </div>
21
+ ));
22
+
23
+ /**
24
+ * Какой то бесполезный компонент. Его можно заменить на useBool
25
+ * Лучше оставить только обёрточный div с необходимой атрибутикой
26
+ * и сделать пассивный компонент
27
+ *
28
+ * @deprecated
29
+ */
14
30
  export const Foldable = JSX<FoldableProps>(
15
31
  ({
16
32
  className = '',
@@ -29,15 +45,15 @@ export const Foldable = JSX<FoldableProps>(
29
45
  const buttonNode = renderFoldButton ? renderFoldButton({ isUnfolded, onToggle }) : null;
30
46
 
31
47
  return isFoldButtonOnTop ? (
32
- <div className={className} role="group">
48
+ <FoldableWrapper className={className}>
33
49
  {buttonNode}
34
50
  {sectionNode}
35
- </div>
51
+ </FoldableWrapper>
36
52
  ) : (
37
- <div className={className} role="group">
53
+ <FoldableWrapper className={className}>
38
54
  {sectionNode}
39
55
  {buttonNode}
40
- </div>
56
+ </FoldableWrapper>
41
57
  );
42
58
  },
43
59
  );
@@ -26,4 +26,5 @@ export const FEEDBACK_METHOD: Option[] = [
26
26
  { key: 'email', text: 'Электронное сообщение' },
27
27
  ];
28
28
 
29
+ // TODO Тоже надо рефакторить - файлик constants
29
30
  export const OUT_SERVICE_URL = '/api/v1/outservice/outserviceregions';
@@ -2,5 +2,6 @@ import { type FieldProps } from '../../hooks/useForm';
2
2
  import { type Validator } from '../../validation/validator';
3
3
  import { withValidator } from '../../validation/withValidator';
4
4
 
5
+ // TODO Зачем это?
5
6
  export const getValidation = (field: FieldProps<any>, validator: Validator, required = false) =>
6
7
  required ? withValidator(field, validator) : field;
@@ -1,20 +1,18 @@
1
1
  import { JSX } from '@redneckz/uni-jsx';
2
- import { useCallback, useState } from '@redneckz/uni-jsx/lib/hooks';
2
+ import { useCallback, useMemo, useState } from '@redneckz/uni-jsx/lib/hooks';
3
3
  import { type BranchesHeader, type ForeignOfficeProps } from '../../data/HeaderData';
4
- import { useLink } from '../../hooks/useLink';
5
4
  import { useLocation } from '../../hooks/useLocation';
6
5
  import { useRegions, type Region } from '../../hooks/useRegions';
7
6
  import { groupBy } from '../../utils/groupBy';
8
7
  import { jaroWinklerDistance } from '../../utils/jaroWinklerDistance';
9
8
  import { Dialog } from '../DialogManager/Dialog';
10
9
  import { useDialogManager } from '../DialogManager/useDialogManager';
11
- import { LinkWrapper } from '../LinkWrapper/LinkWrapper';
12
- import { Paragraph } from '../Paragraph/Paragraph';
13
10
  import { Text } from '../Text/Text';
14
11
  import { renderForeignOffices } from './renderForeignOffices';
15
12
  import { renderRegion } from './renderRegion';
16
13
  import { renderRegionGroup } from './renderRegionGroup';
17
14
  import { SearchBar } from './SearchBar';
15
+ import { SelectedLocation } from './SelectedLocation';
18
16
 
19
17
  const SEARCH_TERM_MIN_LENGTH = 3;
20
18
 
@@ -24,22 +22,21 @@ export interface LocationDialogProps {
24
22
  }
25
23
 
26
24
  export const LocationDialog = JSX<LocationDialogProps>(({ foreignOffices, branches }) => {
27
- const [currentLocation, selectCurrentLocation] = useLocation(branches?.default);
28
-
29
- const link = useLink();
30
- const { href } = link({ href: `/branches/${currentLocation.slug}` });
25
+ const selectLocation = useLocation(branches?.default);
31
26
 
32
27
  const [query, setQuery] = useState('');
33
28
 
34
- const regions: Region[] = cleanUpRegions(useRegions()).sort((a, b) =>
35
- a.name.localeCompare(b.name),
29
+ const rawRegions = useRegions();
30
+ const regions = useMemo(
31
+ () => cleanUpRegions(rawRegions).sort((a, b) => (a.name ?? '').localeCompare(b.name ?? '')),
32
+ [rawRegions],
36
33
  );
37
- const regionsGroupByLetter: Map<string, Region[]> = groupBy(regions, regionFirstLetter);
34
+ const regionsGroupByLetter = useMemo(() => groupBy(regions, regionFirstLetter), [regions]);
38
35
 
39
36
  const { close } = useDialogManager();
40
37
 
41
38
  const handleChangeLocation = useCallback((region: Region) => {
42
- selectCurrentLocation(region);
39
+ selectLocation(region);
43
40
  close();
44
41
  }, []);
45
42
 
@@ -51,16 +48,7 @@ export const LocationDialog = JSX<LocationDialogProps>(({ foreignOffices, branch
51
48
  <Text size="text-h4" color="text-primary-text">
52
49
  Выберите филиал
53
50
  </Text>
54
- {currentLocation ? (
55
- <div className="mb-s">
56
- <Paragraph size="text-l" color="text-primary-text">
57
- Сейчас выбран:
58
- <LinkWrapper href={href} className="inline mx-2xs text-primary-main">
59
- {currentLocation.name}
60
- </LinkWrapper>
61
- </Paragraph>
62
- </div>
63
- ) : null}
51
+ <SelectedLocation defaultLocation={branches?.default} />
64
52
  <SearchBar onSearch={setQuery} searchTerm={query} />
65
53
  </div>
66
54
  }
@@ -86,10 +74,10 @@ export const LocationDialog = JSX<LocationDialogProps>(({ foreignOffices, branch
86
74
  );
87
75
  });
88
76
 
89
- const regionFirstLetter = (region: Region) => region.name?.charAt(0) || '';
77
+ const regionFirstLetter = (region: Region) => region.name?.charAt(0) ?? '';
90
78
 
91
- const cleanUpRegions = (regions: Region[]) =>
79
+ const cleanUpRegions = (regions: Region[]): Region[] =>
92
80
  regions.map((region) => ({
93
81
  ...region,
94
- name: region.name?.replace(/республика|область|край'/gi, '').trim() || '',
82
+ name: region.name?.replace(/республика|область|край'/gi, '').trim() ?? '',
95
83
  }));
@@ -0,0 +1,27 @@
1
+ import { JSX } from '@redneckz/uni-jsx';
2
+ import { useLink } from '../../hooks/useLink';
3
+ import { useLocationState } from '../../hooks/useLocation';
4
+ import { LinkWrapper } from '../LinkWrapper/LinkWrapper';
5
+ import { Paragraph } from '../Paragraph/Paragraph';
6
+
7
+ interface SelectedLocationProps {
8
+ defaultLocation?: string;
9
+ }
10
+
11
+ export const SelectedLocation = JSX<SelectedLocationProps>(({ defaultLocation }) => {
12
+ const currentLocation = useLocationState(defaultLocation);
13
+
14
+ const link = useLink();
15
+ const { href } = link({ href: `/branches/${currentLocation.slug}` });
16
+
17
+ return currentLocation ? (
18
+ <div className="mb-s">
19
+ <Paragraph size="text-l" color="text-primary-text">
20
+ Сейчас выбран:
21
+ <LinkWrapper href={href} className="inline mx-2xs text-primary-main">
22
+ {currentLocation.name}
23
+ </LinkWrapper>
24
+ </Paragraph>
25
+ </div>
26
+ ) : null;
27
+ });
@@ -15,7 +15,7 @@ export const PopupManager = JSX(() => {
15
15
 
16
16
  useEffect(
17
17
  () =>
18
- defaultEventBus.subscribe('popup', (action) => {
18
+ defaultEventBus.observable.subscribe('popup', (action) => {
19
19
  switch (action.type) {
20
20
  case 'open':
21
21
  case 'update':
@@ -4,8 +4,8 @@ import { type PopupOptions } from './PopupAction';
4
4
 
5
5
  export const usePopupManager = () => ({
6
6
  open: (popup: VNode, options: PopupOptions) =>
7
- defaultEventBus.fire('popup', { type: 'open', popup, ...options }),
7
+ defaultEventBus.emitter.fire('popup', { type: 'open', popup, ...options }),
8
8
  update: (popup: VNode, options: PopupOptions) =>
9
- defaultEventBus.fire('popup', { type: 'update', popup, ...options }),
10
- close: () => defaultEventBus.fire('popup', { type: 'close' }),
9
+ defaultEventBus.emitter.fire('popup', { type: 'update', popup, ...options }),
10
+ close: () => defaultEventBus.emitter.fire('popup', { type: 'close' }),
11
11
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@redneckz/wildless-cms-uni-blocks",
3
- "version": "0.14.595",
3
+ "version": "0.14.596",
4
4
  "private": false,
5
5
  "license": "MIT",
6
6
  "author": "ЦК",