@redneckz/wildless-cms-uni-blocks 0.14.899 → 0.14.901

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 (236) hide show
  1. package/bin/migration-scripts/0.14.900.js +18 -0
  2. package/bundle/blocks.schema.json +1 -1
  3. package/bundle/bundle.umd.js +221 -28
  4. package/bundle/bundle.umd.min.js +1 -1
  5. package/bundle/components/ApplicationForm/ApplicationFormContent.d.ts +2 -1
  6. package/bundle/components/ExchangeRateTile/CurrencyProps.d.ts +6 -0
  7. package/bundle/components/ExchangeRateTile/CurrencyTable.d.ts +7 -0
  8. package/bundle/components/ExchangeRateTile/CurrentLocation.d.ts +6 -0
  9. package/bundle/components/ExchangeRateTile/ExchangeCurrencyCalculator.d.ts +24 -0
  10. package/bundle/components/ExchangeRateTile/ExchangeRateTile.d.ts +5 -0
  11. package/bundle/components/ExchangeRateTile/ExchangeRateTileContent.d.ts +9 -0
  12. package/bundle/components/ExchangeRateTile/calculateResult.d.ts +2 -0
  13. package/bundle/components/ExchangeRateTile/callbackCurrencySelect.d.ts +8 -0
  14. package/bundle/components/ExchangeRateTile/formatCurrency.d.ts +1 -0
  15. package/bundle/components/ExchangeRateTile/renderInput.d.ts +11 -0
  16. package/bundle/components/ExchangeRateTile/useFetchExchangeRateData.d.ts +9 -0
  17. package/dist/components/ApplicationForm/ApplicationFormContent.d.ts +2 -1
  18. package/dist/components/ApplicationLeadForm/consents.js +1 -1
  19. package/dist/components/ApplicationLeadForm/useInitApplicationLead.js +8 -7
  20. package/dist/components/ApplicationLeadForm/useInitApplicationLead.js.map +1 -1
  21. package/dist/components/Blocks.js +2 -0
  22. package/dist/components/Blocks.js.map +1 -1
  23. package/dist/components/Blocks.mobile.js +2 -0
  24. package/dist/components/Blocks.mobile.js.map +1 -1
  25. package/dist/components/ExchangeRateTile/CurrencyProps.d.ts +6 -0
  26. package/dist/components/ExchangeRateTile/CurrencyProps.js +10 -0
  27. package/dist/components/ExchangeRateTile/CurrencyProps.js.map +1 -0
  28. package/dist/components/ExchangeRateTile/CurrencyTable.d.ts +7 -0
  29. package/dist/components/ExchangeRateTile/CurrencyTable.js +23 -0
  30. package/dist/components/ExchangeRateTile/CurrencyTable.js.map +1 -0
  31. package/dist/components/ExchangeRateTile/CurrentLocation.d.ts +6 -0
  32. package/dist/components/ExchangeRateTile/CurrentLocation.js +10 -0
  33. package/dist/components/ExchangeRateTile/CurrentLocation.js.map +1 -0
  34. package/dist/components/ExchangeRateTile/ExchangeCurrencyCalculator.d.ts +24 -0
  35. package/dist/components/ExchangeRateTile/ExchangeCurrencyCalculator.js +73 -0
  36. package/dist/components/ExchangeRateTile/ExchangeCurrencyCalculator.js.map +1 -0
  37. package/dist/components/ExchangeRateTile/ExchangeRateTile.d.ts +5 -0
  38. package/dist/components/ExchangeRateTile/ExchangeRateTile.js +26 -0
  39. package/dist/components/ExchangeRateTile/ExchangeRateTile.js.map +1 -0
  40. package/dist/components/ExchangeRateTile/ExchangeRateTileContent.d.ts +9 -0
  41. package/dist/components/ExchangeRateTile/ExchangeRateTileContent.js +2 -0
  42. package/dist/components/ExchangeRateTile/ExchangeRateTileContent.js.map +1 -0
  43. package/dist/components/ExchangeRateTile/calculateResult.d.ts +2 -0
  44. package/dist/components/ExchangeRateTile/calculateResult.js +11 -0
  45. package/dist/components/ExchangeRateTile/calculateResult.js.map +1 -0
  46. package/dist/components/ExchangeRateTile/callbackCurrencySelect.d.ts +8 -0
  47. package/dist/components/ExchangeRateTile/callbackCurrencySelect.js +21 -0
  48. package/dist/components/ExchangeRateTile/callbackCurrencySelect.js.map +1 -0
  49. package/dist/components/ExchangeRateTile/formatCurrency.d.ts +1 -0
  50. package/dist/components/ExchangeRateTile/formatCurrency.js +10 -0
  51. package/dist/components/ExchangeRateTile/formatCurrency.js.map +1 -0
  52. package/dist/components/ExchangeRateTile/renderInput.d.ts +11 -0
  53. package/dist/components/ExchangeRateTile/renderInput.js +16 -0
  54. package/dist/components/ExchangeRateTile/renderInput.js.map +1 -0
  55. package/dist/components/ExchangeRateTile/useFetchExchangeRateData.d.ts +9 -0
  56. package/dist/components/ExchangeRateTile/useFetchExchangeRateData.js +13 -0
  57. package/dist/components/ExchangeRateTile/useFetchExchangeRateData.js.map +1 -0
  58. package/lib/common.css +1 -1
  59. package/lib/components/ApplicationForm/ApplicationFormContent.d.ts +2 -1
  60. package/lib/components/ApplicationLeadForm/consents.js +1 -1
  61. package/lib/components/ApplicationLeadForm/useInitApplicationLead.js +8 -7
  62. package/lib/components/ApplicationLeadForm/useInitApplicationLead.js.map +1 -1
  63. package/lib/components/Blocks.js +2 -0
  64. package/lib/components/Blocks.js.map +1 -1
  65. package/lib/components/Blocks.mobile.js +2 -0
  66. package/lib/components/Blocks.mobile.js.map +1 -1
  67. package/lib/components/ExchangeRateTile/CurrencyProps.d.ts +6 -0
  68. package/lib/components/ExchangeRateTile/CurrencyProps.js +8 -0
  69. package/lib/components/ExchangeRateTile/CurrencyProps.js.map +1 -0
  70. package/lib/components/ExchangeRateTile/CurrencyTable.d.ts +7 -0
  71. package/lib/components/ExchangeRateTile/CurrencyTable.js +21 -0
  72. package/lib/components/ExchangeRateTile/CurrencyTable.js.map +1 -0
  73. package/lib/components/ExchangeRateTile/CurrentLocation.d.ts +6 -0
  74. package/lib/components/ExchangeRateTile/CurrentLocation.js +8 -0
  75. package/lib/components/ExchangeRateTile/CurrentLocation.js.map +1 -0
  76. package/lib/components/ExchangeRateTile/ExchangeCurrencyCalculator.d.ts +24 -0
  77. package/lib/components/ExchangeRateTile/ExchangeCurrencyCalculator.js +71 -0
  78. package/lib/components/ExchangeRateTile/ExchangeCurrencyCalculator.js.map +1 -0
  79. package/lib/components/ExchangeRateTile/ExchangeRateTile.d.ts +5 -0
  80. package/lib/components/ExchangeRateTile/ExchangeRateTile.fixture.d.ts +5 -0
  81. package/lib/components/ExchangeRateTile/ExchangeRateTile.fixture.mobile.d.ts +5 -0
  82. package/lib/components/ExchangeRateTile/ExchangeRateTile.js +24 -0
  83. package/lib/components/ExchangeRateTile/ExchangeRateTile.js.map +1 -0
  84. package/lib/components/ExchangeRateTile/ExchangeRateTileContent.d.ts +9 -0
  85. package/lib/components/ExchangeRateTile/ExchangeRateTileContent.js +2 -0
  86. package/lib/components/ExchangeRateTile/ExchangeRateTileContent.js.map +1 -0
  87. package/lib/components/ExchangeRateTile/calculateResult.d.ts +2 -0
  88. package/lib/components/ExchangeRateTile/calculateResult.js +7 -0
  89. package/lib/components/ExchangeRateTile/calculateResult.js.map +1 -0
  90. package/lib/components/ExchangeRateTile/callbackCurrencySelect.d.ts +8 -0
  91. package/lib/components/ExchangeRateTile/callbackCurrencySelect.js +18 -0
  92. package/lib/components/ExchangeRateTile/callbackCurrencySelect.js.map +1 -0
  93. package/lib/components/ExchangeRateTile/formatCurrency.d.ts +1 -0
  94. package/lib/components/ExchangeRateTile/formatCurrency.js +7 -0
  95. package/lib/components/ExchangeRateTile/formatCurrency.js.map +1 -0
  96. package/lib/components/ExchangeRateTile/renderInput.d.ts +11 -0
  97. package/lib/components/ExchangeRateTile/renderInput.js +13 -0
  98. package/lib/components/ExchangeRateTile/renderInput.js.map +1 -0
  99. package/lib/components/ExchangeRateTile/useFetchExchangeRateData.d.ts +9 -0
  100. package/lib/components/ExchangeRateTile/useFetchExchangeRateData.js +10 -0
  101. package/lib/components/ExchangeRateTile/useFetchExchangeRateData.js.map +1 -0
  102. package/mobile/bundle/bundle.umd.js +221 -28
  103. package/mobile/bundle/bundle.umd.min.js +1 -1
  104. package/mobile/bundle/components/ApplicationForm/ApplicationFormContent.d.ts +2 -1
  105. package/mobile/bundle/components/ExchangeRateTile/CurrencyProps.d.ts +6 -0
  106. package/mobile/bundle/components/ExchangeRateTile/CurrencyTable.d.ts +7 -0
  107. package/mobile/bundle/components/ExchangeRateTile/CurrentLocation.d.ts +6 -0
  108. package/mobile/bundle/components/ExchangeRateTile/ExchangeCurrencyCalculator.d.ts +24 -0
  109. package/mobile/bundle/components/ExchangeRateTile/ExchangeRateTile.d.ts +5 -0
  110. package/mobile/bundle/components/ExchangeRateTile/ExchangeRateTileContent.d.ts +9 -0
  111. package/mobile/bundle/components/ExchangeRateTile/calculateResult.d.ts +2 -0
  112. package/mobile/bundle/components/ExchangeRateTile/callbackCurrencySelect.d.ts +8 -0
  113. package/mobile/bundle/components/ExchangeRateTile/formatCurrency.d.ts +1 -0
  114. package/mobile/bundle/components/ExchangeRateTile/renderInput.d.ts +11 -0
  115. package/mobile/bundle/components/ExchangeRateTile/useFetchExchangeRateData.d.ts +9 -0
  116. package/mobile/dist/components/ApplicationForm/ApplicationFormContent.d.ts +2 -1
  117. package/mobile/dist/components/ApplicationLeadForm/consents.js +1 -1
  118. package/mobile/dist/components/ApplicationLeadForm/useInitApplicationLead.js +8 -7
  119. package/mobile/dist/components/ApplicationLeadForm/useInitApplicationLead.js.map +1 -1
  120. package/mobile/dist/components/Blocks.js +2 -0
  121. package/mobile/dist/components/Blocks.js.map +1 -1
  122. package/mobile/dist/components/ExchangeRateTile/CurrencyProps.d.ts +6 -0
  123. package/mobile/dist/components/ExchangeRateTile/CurrencyProps.js +10 -0
  124. package/mobile/dist/components/ExchangeRateTile/CurrencyProps.js.map +1 -0
  125. package/mobile/dist/components/ExchangeRateTile/CurrencyTable.d.ts +7 -0
  126. package/mobile/dist/components/ExchangeRateTile/CurrencyTable.js +23 -0
  127. package/mobile/dist/components/ExchangeRateTile/CurrencyTable.js.map +1 -0
  128. package/mobile/dist/components/ExchangeRateTile/CurrentLocation.d.ts +6 -0
  129. package/mobile/dist/components/ExchangeRateTile/CurrentLocation.js +10 -0
  130. package/mobile/dist/components/ExchangeRateTile/CurrentLocation.js.map +1 -0
  131. package/mobile/dist/components/ExchangeRateTile/ExchangeCurrencyCalculator.d.ts +24 -0
  132. package/mobile/dist/components/ExchangeRateTile/ExchangeCurrencyCalculator.js +73 -0
  133. package/mobile/dist/components/ExchangeRateTile/ExchangeCurrencyCalculator.js.map +1 -0
  134. package/mobile/dist/components/ExchangeRateTile/ExchangeRateTile.d.ts +5 -0
  135. package/mobile/dist/components/ExchangeRateTile/ExchangeRateTile.js +26 -0
  136. package/mobile/dist/components/ExchangeRateTile/ExchangeRateTile.js.map +1 -0
  137. package/mobile/dist/components/ExchangeRateTile/ExchangeRateTileContent.d.ts +9 -0
  138. package/mobile/dist/components/ExchangeRateTile/ExchangeRateTileContent.js +2 -0
  139. package/mobile/dist/components/ExchangeRateTile/ExchangeRateTileContent.js.map +1 -0
  140. package/mobile/dist/components/ExchangeRateTile/calculateResult.d.ts +2 -0
  141. package/mobile/dist/components/ExchangeRateTile/calculateResult.js +11 -0
  142. package/mobile/dist/components/ExchangeRateTile/calculateResult.js.map +1 -0
  143. package/mobile/dist/components/ExchangeRateTile/callbackCurrencySelect.d.ts +8 -0
  144. package/mobile/dist/components/ExchangeRateTile/callbackCurrencySelect.js +21 -0
  145. package/mobile/dist/components/ExchangeRateTile/callbackCurrencySelect.js.map +1 -0
  146. package/mobile/dist/components/ExchangeRateTile/formatCurrency.d.ts +1 -0
  147. package/mobile/dist/components/ExchangeRateTile/formatCurrency.js +10 -0
  148. package/mobile/dist/components/ExchangeRateTile/formatCurrency.js.map +1 -0
  149. package/mobile/dist/components/ExchangeRateTile/renderInput.d.ts +11 -0
  150. package/mobile/dist/components/ExchangeRateTile/renderInput.js +16 -0
  151. package/mobile/dist/components/ExchangeRateTile/renderInput.js.map +1 -0
  152. package/mobile/dist/components/ExchangeRateTile/useFetchExchangeRateData.d.ts +9 -0
  153. package/mobile/dist/components/ExchangeRateTile/useFetchExchangeRateData.js +13 -0
  154. package/mobile/dist/components/ExchangeRateTile/useFetchExchangeRateData.js.map +1 -0
  155. package/mobile/lib/common.css +1 -1
  156. package/mobile/lib/components/ApplicationForm/ApplicationFormContent.d.ts +2 -1
  157. package/mobile/lib/components/ApplicationLeadForm/consents.js +1 -1
  158. package/mobile/lib/components/ApplicationLeadForm/useInitApplicationLead.js +8 -7
  159. package/mobile/lib/components/ApplicationLeadForm/useInitApplicationLead.js.map +1 -1
  160. package/mobile/lib/components/Blocks.js +2 -0
  161. package/mobile/lib/components/Blocks.js.map +1 -1
  162. package/mobile/lib/components/ExchangeRateTile/CurrencyProps.d.ts +6 -0
  163. package/mobile/lib/components/ExchangeRateTile/CurrencyProps.js +8 -0
  164. package/mobile/lib/components/ExchangeRateTile/CurrencyProps.js.map +1 -0
  165. package/mobile/lib/components/ExchangeRateTile/CurrencyTable.d.ts +7 -0
  166. package/mobile/lib/components/ExchangeRateTile/CurrencyTable.js +21 -0
  167. package/mobile/lib/components/ExchangeRateTile/CurrencyTable.js.map +1 -0
  168. package/mobile/lib/components/ExchangeRateTile/CurrentLocation.d.ts +6 -0
  169. package/mobile/lib/components/ExchangeRateTile/CurrentLocation.js +8 -0
  170. package/mobile/lib/components/ExchangeRateTile/CurrentLocation.js.map +1 -0
  171. package/mobile/lib/components/ExchangeRateTile/ExchangeCurrencyCalculator.d.ts +24 -0
  172. package/mobile/lib/components/ExchangeRateTile/ExchangeCurrencyCalculator.js +71 -0
  173. package/mobile/lib/components/ExchangeRateTile/ExchangeCurrencyCalculator.js.map +1 -0
  174. package/mobile/lib/components/ExchangeRateTile/ExchangeRateTile.d.ts +5 -0
  175. package/mobile/lib/components/ExchangeRateTile/ExchangeRateTile.js +24 -0
  176. package/mobile/lib/components/ExchangeRateTile/ExchangeRateTile.js.map +1 -0
  177. package/mobile/lib/components/ExchangeRateTile/ExchangeRateTileContent.d.ts +9 -0
  178. package/mobile/lib/components/ExchangeRateTile/ExchangeRateTileContent.js +2 -0
  179. package/mobile/lib/components/ExchangeRateTile/ExchangeRateTileContent.js.map +1 -0
  180. package/mobile/lib/components/ExchangeRateTile/calculateResult.d.ts +2 -0
  181. package/mobile/lib/components/ExchangeRateTile/calculateResult.js +7 -0
  182. package/mobile/lib/components/ExchangeRateTile/calculateResult.js.map +1 -0
  183. package/mobile/lib/components/ExchangeRateTile/callbackCurrencySelect.d.ts +8 -0
  184. package/mobile/lib/components/ExchangeRateTile/callbackCurrencySelect.js +18 -0
  185. package/mobile/lib/components/ExchangeRateTile/callbackCurrencySelect.js.map +1 -0
  186. package/mobile/lib/components/ExchangeRateTile/formatCurrency.d.ts +1 -0
  187. package/mobile/lib/components/ExchangeRateTile/formatCurrency.js +7 -0
  188. package/mobile/lib/components/ExchangeRateTile/formatCurrency.js.map +1 -0
  189. package/mobile/lib/components/ExchangeRateTile/renderInput.d.ts +11 -0
  190. package/mobile/lib/components/ExchangeRateTile/renderInput.js +13 -0
  191. package/mobile/lib/components/ExchangeRateTile/renderInput.js.map +1 -0
  192. package/mobile/lib/components/ExchangeRateTile/useFetchExchangeRateData.d.ts +9 -0
  193. package/mobile/lib/components/ExchangeRateTile/useFetchExchangeRateData.js +10 -0
  194. package/mobile/lib/components/ExchangeRateTile/useFetchExchangeRateData.js.map +1 -0
  195. package/mobile/src/components/ApplicationForm/ApplicationForm.example.json +92 -29
  196. package/mobile/src/components/ApplicationForm/ApplicationFormContent.ts +2 -1
  197. package/mobile/src/components/ApplicationLeadForm/consents.ts +1 -1
  198. package/mobile/src/components/ApplicationLeadForm/useInitApplicationLead.ts +10 -7
  199. package/mobile/src/components/Blocks.ts +2 -0
  200. package/mobile/src/components/ExchangeRateTile/CurrencyProps.ts +6 -0
  201. package/mobile/src/components/ExchangeRateTile/CurrencyTable.tsx +64 -0
  202. package/mobile/src/components/ExchangeRateTile/CurrentLocation.tsx +28 -0
  203. package/mobile/src/components/ExchangeRateTile/ExchangeCurrencyCalculator.tsx +155 -0
  204. package/mobile/src/components/ExchangeRateTile/ExchangeRateTile.example.json +12 -0
  205. package/mobile/src/components/ExchangeRateTile/ExchangeRateTile.tsx +60 -0
  206. package/mobile/src/components/ExchangeRateTile/ExchangeRateTile.ui.json +8 -0
  207. package/mobile/src/components/ExchangeRateTile/ExchangeRateTileContent.ts +11 -0
  208. package/mobile/src/components/ExchangeRateTile/calculateResult.ts +9 -0
  209. package/mobile/src/components/ExchangeRateTile/callbackCurrencySelect.ts +25 -0
  210. package/mobile/src/components/ExchangeRateTile/formatCurrency.ts +8 -0
  211. package/mobile/src/components/ExchangeRateTile/renderInput.tsx +43 -0
  212. package/mobile/src/components/ExchangeRateTile/useFetchExchangeRateData.ts +25 -0
  213. package/package.json +2 -2
  214. package/src/components/ApplicationForm/ApplicationForm.example.json +92 -29
  215. package/src/components/ApplicationForm/ApplicationForm.fixture.mobile.tsx +11 -11
  216. package/src/components/ApplicationForm/ApplicationForm.fixture.tsx +11 -11
  217. package/src/components/ApplicationForm/ApplicationFormContent.ts +2 -1
  218. package/src/components/ApplicationLeadForm/consents.ts +1 -1
  219. package/src/components/ApplicationLeadForm/useInitApplicationLead.ts +10 -7
  220. package/src/components/Blocks.mobile.ts +2 -0
  221. package/src/components/Blocks.ts +2 -0
  222. package/src/components/ExchangeRateTile/CurrencyProps.ts +6 -0
  223. package/src/components/ExchangeRateTile/CurrencyTable.tsx +64 -0
  224. package/src/components/ExchangeRateTile/CurrentLocation.tsx +28 -0
  225. package/src/components/ExchangeRateTile/ExchangeCurrencyCalculator.tsx +155 -0
  226. package/src/components/ExchangeRateTile/ExchangeRateTile.example.json +12 -0
  227. package/src/components/ExchangeRateTile/ExchangeRateTile.fixture.mobile.tsx +21 -0
  228. package/src/components/ExchangeRateTile/ExchangeRateTile.fixture.tsx +21 -0
  229. package/src/components/ExchangeRateTile/ExchangeRateTile.tsx +60 -0
  230. package/src/components/ExchangeRateTile/ExchangeRateTile.ui.json +8 -0
  231. package/src/components/ExchangeRateTile/ExchangeRateTileContent.ts +11 -0
  232. package/src/components/ExchangeRateTile/calculateResult.ts +9 -0
  233. package/src/components/ExchangeRateTile/callbackCurrencySelect.ts +25 -0
  234. package/src/components/ExchangeRateTile/formatCurrency.ts +8 -0
  235. package/src/components/ExchangeRateTile/renderInput.tsx +43 -0
  236. package/src/components/ExchangeRateTile/useFetchExchangeRateData.ts +25 -0
@@ -0,0 +1,71 @@
1
+ import { jsxs as _jsxs, jsx as _jsx } from "@redneckz/uni-jsx/jsx-runtime";
2
+ import { JSX } from '@redneckz/uni-jsx';
3
+ import { useCallback, useState } from '@redneckz/uni-jsx/lib/hooks';
4
+ import { LinkButton } from '../../ui-kit/LinkButton/LinkButton.js';
5
+ import { calculateResult, formatValue } from './calculateResult.js';
6
+ import { callbackCurrencySelect } from './callbackCurrencySelect.js';
7
+ import { Currency } from './CurrencyProps.js';
8
+ import { renderInput } from './renderInput.js';
9
+ export const ExchangeCurrencyCalculator = JSX(({ className = '', currencyRatesBuy, currencyRatesSell, button }) => {
10
+ const [calcState, setCalcState] = useState({
11
+ inputSell: '',
12
+ inputBuy: '',
13
+ selectSell: currencyRatesBuy?.[0]?.currency?.currency || Currency.RUB,
14
+ selectBuy: currencyRatesSell?.[0]?.currency?.currency || Currency.USD,
15
+ });
16
+ const handleSetCalcState = useCallback((newState) => setCalcState((oldState) => ({ ...oldState, ...newState })), []);
17
+ return (_jsxs("div", { className: `flex flex-col gap-m pt-2xl ${className}`, children: [currencyRatesBuy && currencyRatesSell ? (_jsxs("div", { className: "grid gap-m", children: [renderInput({
18
+ placeholder: 'Хочу продать',
19
+ rates: currencyRatesSell,
20
+ selected: calcState.selectSell,
21
+ setSelected: handleSelectSell(calcState, handleSetCalcState, currencyRatesSell),
22
+ value: calcState.inputSell,
23
+ onChange: (value) => handleInputSell(handleSetCalcState, currencyRatesSell)(value, calcState.selectSell, calcState.selectBuy),
24
+ }), renderInput({
25
+ placeholder: 'Получу',
26
+ rates: currencyRatesBuy,
27
+ selected: calcState.selectBuy,
28
+ setSelected: handleSelectBuy(calcState, handleSetCalcState, currencyRatesBuy),
29
+ value: calcState.inputBuy,
30
+ onChange: (value) => handleInputBuy(handleSetCalcState, currencyRatesBuy)(value, calcState.selectBuy, calcState.selectSell),
31
+ })] })) : null, button?.text ? (_jsx(LinkButton, { text: button.text, version: button?.version, ...button })) : null] }));
32
+ });
33
+ const handleSelectSell = (calcState, setCalcState, currencyRatesSell) => (value) => {
34
+ setCalcState({ selectSell: value });
35
+ callbackCurrencySelect({
36
+ value,
37
+ oppositeValue: calcState.selectBuy,
38
+ handleConvert: (currencyFrom = calcState.selectSell, currencyTo = calcState.selectBuy) => {
39
+ handleInputSell(setCalcState, currencyRatesSell)(calcState.inputSell, currencyFrom, currencyTo);
40
+ },
41
+ });
42
+ };
43
+ const handleSelectBuy = (calcState, setCalcState, currencyRatesBuy) => (value) => {
44
+ setCalcState({ selectBuy: value });
45
+ callbackCurrencySelect({
46
+ value,
47
+ oppositeValue: calcState.selectSell,
48
+ handleConvert: (currencyTo = calcState.selectBuy, currencyFrom = calcState.selectSell) => handleInputBuy(setCalcState, currencyRatesBuy)(calcState.inputBuy, currencyTo, currencyFrom),
49
+ });
50
+ };
51
+ const handleInputSell = (setCalcState, currencyRatesSell) => (value, currencyFrom, currencyTo) => {
52
+ setCalcState({ inputSell: formatValue(value), selectBuy: currencyTo });
53
+ const rate = currencyRatesSell.find((_) => _.currency?.currency === currencyTo)?.buyExchangeRate ||
54
+ currencyRatesSell.find((_) => _.currency?.currency === currencyFrom)?.buyExchangeRate;
55
+ if (rate) {
56
+ setCalcState({
57
+ inputBuy: String(calculateResult(value, rate, currencyFrom === Currency.RUB) || ''),
58
+ });
59
+ }
60
+ };
61
+ const handleInputBuy = (setCalcState, currencyRatesBuy) => (value, currencyTo, currencyFrom) => {
62
+ setCalcState({ inputBuy: formatValue(value), selectSell: currencyFrom });
63
+ const rate = currencyRatesBuy.find((_) => _.currency?.currency === currencyFrom)?.saleExchangeRate ||
64
+ currencyRatesBuy.find((_) => _.currency?.currency === currencyTo)?.saleExchangeRate;
65
+ if (rate) {
66
+ setCalcState({
67
+ inputSell: String(calculateResult(value, rate, currencyTo === Currency.RUB) || ''),
68
+ });
69
+ }
70
+ };
71
+ //# sourceMappingURL=ExchangeCurrencyCalculator.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ExchangeCurrencyCalculator.js","sourceRoot":"","sources":["../../../src/components/ExchangeRateTile/ExchangeC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,EAAE,eAAe,CAAC;IACxF,IAAI,IAAI,EAAE;QACR,YAAY,CAAC;YACX,QAAQ,EAAE,MAAM,CAAC,eAAe,CAAC,KAAK,EAAE,IAAI,EAAE,YAAY,KAAK,QAAQ,CAAC,GAAG,CAAC,IAAI,EAAE,CAAC;SACpF,CAAC,CAAC;KACJ;AACH,CAAC,CAAC;AAEJ,MAAM,cAAc,GAClB,CAAC,YAAiD,EAAE,gBAAwC,EAAE,EAAE,CAChG,CAAC,KAAa,EAAE,UAAoB,EAAE,YAAsB,EAAE,EAAE;IAC9D,YAAY,CAAC,EAAE,QAAQ,EAAE,WAAW,CAAC,KAAK,CAAC,EAAE,UAAU,EAAE,YAAY,EAAE,CAAC,CAAC;IACzE,MAAM,IAAI,GACR,gBAAgB,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,QAAQ,EAAE,QAAQ,KAAK,YAAY,CAAC,EAAE,gBAAgB;QACrF,gBAAgB,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,QAAQ,EAAE,QAAQ,KAAK,UAAU,CAAC,EAAE,gBAAgB,CAAC;IACtF,IAAI,IAAI,EAAE;QACR,YAAY,CAAC;YACX,SAAS,EAAE,MAAM,CAAC,eAAe,CAAC,KAAK,EAAE,IAAI,EAAE,UAAU,KAAK,QAAQ,CAAC,GAAG,CAAC,IAAI,EAAE,CAAC;SACnF,CAAC,CAAC;KACJ;AACH,CAAC,CAAC"}
@@ -0,0 +1,5 @@
1
+ import { type UniBlockProps } from '../../UniBlock/UniBlockProps';
2
+ import { type ExchangeRateTileContent } from './ExchangeRateTileContent';
3
+ export interface ExchangeRateTileProps extends ExchangeRateTileContent, UniBlockProps {
4
+ }
5
+ export declare const ExchangeRateTile: import("@redneckz/uni-jsx").UNIComponent<ExchangeRateTileProps, any, any>;
@@ -0,0 +1,5 @@
1
+ import '../../setup-fixture';
2
+ declare const _default: {
3
+ default: any;
4
+ };
5
+ export default _default;
@@ -0,0 +1,5 @@
1
+ import '../../setup-fixture';
2
+ declare const _default: {
3
+ default: any;
4
+ };
5
+ export default _default;
@@ -0,0 +1,24 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "@redneckz/uni-jsx/jsx-runtime";
2
+ import { JSX } from '@redneckz/uni-jsx';
3
+ import { useLocation } from '../../hooks/useLocation.js';
4
+ import { BaseTile } from '../../ui-kit/BaseTile/BaseTile.js';
5
+ import { BlockWrapper } from '../../ui-kit/BlockWrapper.js';
6
+ import { Heading } from '../../ui-kit/Heading/Heading.js';
7
+ import { style } from '../../utils/style.js';
8
+ import { Currency } from './CurrencyProps.js';
9
+ import { CurrencyTable } from './CurrencyTable.js';
10
+ import { CurrentLocation } from './CurrentLocation.js';
11
+ import { ExchangeCurrencyCalculator, } from './ExchangeCurrencyCalculator.js';
12
+ import { useFetchExchangeRateData } from './useFetchExchangeRateData.js';
13
+ export const ExchangeRateTile = JSX(({ className = '', title = 'Курсы обмена валют', button, ...rest }) => {
14
+ const currentLocation = useLocation();
15
+ const exchangeRates = useFetchExchangeRateData(currentLocation);
16
+ const currencyRates = getCurrencyRates(exchangeRates?.exchangeRate?.currencies);
17
+ const currencyRatesBuy = currencyRates.filter((_) => _.buyExchangeRate);
18
+ currencyRatesBuy.unshift({ currency: { currency: Currency.RUB } });
19
+ const currencyRatesSell = currencyRates.filter((_) => _.saleExchangeRate);
20
+ currencyRatesSell.push({ currency: { currency: Currency.RUB } });
21
+ return (_jsx(BlockWrapper, { className: style('box-border min-h-80', className), ...rest, children: _jsx(BaseTile, { className: "h-full", title: _jsx(Heading, { headingType: "h4", title: title, className: "whitespace-pre-wrap" }), children: _jsxs("div", { className: "flex w-full gap-6xl flex-wrap @lg:flex-nowrap", children: [_jsxs("div", { className: "w-full @2xl:w-auto @5xl:w-1/2", children: [currencyRates ? (_jsx(CurrencyTable, { className: "mb-xl", exchangeCurrencyItems: currencyRates })) : null, _jsx(CurrentLocation, { address: exchangeRates?.address })] }), _jsx(ExchangeCurrencyCalculator, { className: "grow w-1/2", currencyRatesBuy: currencyRatesBuy, currencyRatesSell: currencyRatesSell, button: button })] }) }) }));
22
+ });
23
+ const getCurrencyRates = (currencies) => currencies?.filter((_) => [1, 2, 3].includes(_?.currency?.id)) || [];
24
+ //# sourceMappingURL=ExchangeRateTile.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ExchangeRateTile.js","sourceRoot":"","sources":["../../../src/components/ExchangeRateTile/ExchangeRateTile.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,GAAG,EAAE,MAAM,mBAAmB,CAAC;AACxC,OAAO,EAAE,WAAW,EAAE,MAAM,yBAAyB,CAAC;AACtD,OAAO,EAAE,QAAQ,EAAE,MAAM,gCAAgC,CAAC;AAC1D,OAAO,EAAE,YAAY,EAAE,MAAM,2BAA2B,CAAC;AACzD,OAAO,EAAE,OAAO,EAAE,MAAM,8BAA8B,CAAC;AAEvD,OAAO,EAAE,KAAK,EAAE,MAAM,mBAAmB,CAAC;AAC1C,OAAO,EAAE,QAAQ,EAAE,MAAM,iBAAiB,CAAC;AAC3C,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAChD,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AACpD,OAAO,EACL,0BAA0B,GAE3B,MAAM,8BAA8B,CAAC;AAEtC,OAAO,EAAE,wBAAwB,EAAE,MAAM,4BAA4B,CAAC;AAItE,MAAM,CAAC,MAAM,gBAAgB,GAAG,GAAG,CACjC,CAAC,EAAE,SAAS,GAAG,EAAE,EAAE,KAAK,GAAG,oBAAoB,EAAE,MAAM,EAAE,GAAG,IAAI,EAAE,EAAE,EAAE;IACpE,MAAM,eAAe,GAAG,WAAW,EAAE,CAAC;IACtC,MAAM,aAAa,GAAG,wBAAwB,CAAC,eAAe,CAAC,CAAC;IAEhE,MAAM,aAAa,GAAG,gBAAgB,CAAC,aAAa,EAAE,YAAY,EAAE,UAAU,CAAC,CAAC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M,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,EAAE,QAAQ,EAAE,EAAY,CAAC,CAAC,IAAI,EAAE,CAAC"}
@@ -0,0 +1,9 @@
1
+ import { type TitleProps } from '../../model/HeadlineType';
2
+ import { type LinkButtonContent } from '../../ui-kit/LinkButton/LinkButtonContent';
3
+ import { type UniBlockContent } from '../../UniBlock/UniBlockProps';
4
+ /**
5
+ * @title Курсы обмена валют
6
+ */
7
+ export declare type ExchangeRateTileContent = UniBlockContent & TitleProps & {
8
+ button?: LinkButtonContent;
9
+ };
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=ExchangeRateTileContent.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ExchangeRateTileContent.js","sourceRoot":"","sources":["../../../src/components/ExchangeRateTile/ExchangeRateTileContent.ts"],"names":[],"mappings":""}
@@ -0,0 +1,2 @@
1
+ export declare const calculateResult: (value: string, rate: number, precision: boolean) => number;
2
+ export declare const formatValue: (value: string) => string;
@@ -0,0 +1,7 @@
1
+ import { roundTo } from '../../utils/roundTo.js';
2
+ export const calculateResult = (value, rate, precision) => {
3
+ const result = Number(formatValue(value)) * Math.pow(rate, precision ? -1 : 1);
4
+ return Number.isInteger(result) ? result : roundTo(result);
5
+ };
6
+ export const formatValue = (value) => value.replace(/[^\d.,]/g, '').replace(',', '.');
7
+ //# sourceMappingURL=calculateResult.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"calculateResult.js","sourceRoot":"","sources":["../../../src/components/ExchangeRateTile/calculateResult.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,qBAAqB,CAAC;AAE9C,MAAM,CAAC,MAAM,eAAe,GAAG,CAAC,KAAa,EAAE,IAAY,EAAE,SAAkB,EAAE,EAAE;IACjF,MAAM,MAAM,GAAG,MAAM,CAAC,WAAW,CAAC,KAAK,CAAC,CAAC,GAAG,IAAI,CAAC,GAAG,CAAC,IAAI,EAAE,SAAS,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;IAE/E,OAAO,MAAM,CAAC,SAAS,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC;AAC7D,CAAC,CAAC;AAEF,MAAM,CAAC,MAAM,WAAW,GAAG,CAAC,KAAa,EAAE,EAAE,CAAC,KAAK,CAAC,OAAO,CAAC,UAAU,EAAE,EAAE,CAAC,CAAC,OAAO,CAAC,GAAG,EAAE,GAAG,CAAC,CAAC"}
@@ -0,0 +1,8 @@
1
+ import { Currency } from './CurrencyProps';
2
+ interface TableFuncProps {
3
+ value: Currency;
4
+ oppositeValue: Currency;
5
+ handleConvert: (currencyFrom?: Currency, currencyTo?: Currency) => void;
6
+ }
7
+ export declare const callbackCurrencySelect: (props: TableFuncProps) => void;
8
+ export {};
@@ -0,0 +1,18 @@
1
+ import { tableFunc } from '../../utils/tableFunc.js';
2
+ import { Currency } from './CurrencyProps.js';
3
+ export const callbackCurrencySelect = (props) => tableFunc([
4
+ [
5
+ (_) => _.value !== Currency.RUB && _.oppositeValue !== Currency.RUB,
6
+ () => props.handleConvert(props.value, Currency.RUB),
7
+ ],
8
+ [
9
+ (_) => _.value === Currency.RUB && _.oppositeValue === Currency.RUB,
10
+ () => props.handleConvert(props.value, Currency.USD),
11
+ ],
12
+ [
13
+ (_) => _.value === Currency.RUB && _.oppositeValue === Currency.RUB,
14
+ () => props.handleConvert(props.value, Currency.CNY),
15
+ ],
16
+ [() => true, () => props.handleConvert(props.value)],
17
+ ])(props)?.();
18
+ //# sourceMappingURL=callbackCurrencySelect.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"callbackCurrencySelect.js","sourceRoot":"","sources":["../../../src/components/ExchangeRateTile/callbackCurrencySelect.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,uBAAuB,CAAC;AAClD,OAAO,EAAE,QAAQ,EAAE,MAAM,iBAAiB,CAAC;AAQ3C,MAAM,CAAC,MAAM,sBAAsB,GAAG,CAAC,KAAqB,EAAE,EAAE,CAC9D,SAAS,CAA6B;IACpC;QACE,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,KAAK,KAAK,QAAQ,CAAC,GAAG,IAAI,CAAC,CAAC,aAAa,KAAK,QAAQ,CAAC,GAAG;QACnE,GAAG,EAAE,CAAC,KAAK,CAAC,aAAa,CAAC,KAAK,CAAC,KAAK,EAAE,QAAQ,CAAC,GAAG,CAAC;KACrD;IACD;QACE,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,KAAK,KAAK,QAAQ,CAAC,GAAG,IAAI,CAAC,CAAC,aAAa,KAAK,QAAQ,CAAC,GAAG;QACnE,GAAG,EAAE,CAAC,KAAK,CAAC,aAAa,CAAC,KAAK,CAAC,KAAK,EAAE,QAAQ,CAAC,GAAG,CAAC;KACrD;IACD;QACE,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,KAAK,KAAK,QAAQ,CAAC,GAAG,IAAI,CAAC,CAAC,aAAa,KAAK,QAAQ,CAAC,GAAG;QACnE,GAAG,EAAE,CAAC,KAAK,CAAC,aAAa,CAAC,KAAK,CAAC,KAAK,EAAE,QAAQ,CAAC,GAAG,CAAC;KACrD;IACD,CAAC,GAAG,EAAE,CAAC,IAAI,EAAE,GAAG,EAAE,CAAC,KAAK,CAAC,aAAa,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;CACrD,CAAC,CAAC,KAAK,CAAC,EAAE,EAAE,CAAC"}
@@ -0,0 +1 @@
1
+ export declare const formatCurrency: (value?: number) => string;
@@ -0,0 +1,7 @@
1
+ import { Currency } from './CurrencyProps.js';
2
+ const currencyNumberFormat = new Intl.NumberFormat('ru', {
3
+ style: 'currency',
4
+ currency: Currency.RUB,
5
+ });
6
+ export const formatCurrency = (value) => (value ? currencyNumberFormat.format(value) : '');
7
+ //# sourceMappingURL=formatCurrency.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"formatCurrency.js","sourceRoot":"","sources":["../../../src/components/ExchangeRateTile/formatCurrency.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,iBAAiB,CAAC;AAE3C,MAAM,oBAAoB,GAAG,IAAI,IAAI,CAAC,YAAY,CAAC,IAAI,EAAE;IACvD,KAAK,EAAE,UAAU;IACjB,QAAQ,EAAE,QAAQ,CAAC,GAAG;CACvB,CAAC,CAAC;AAEH,MAAM,CAAC,MAAM,cAAc,GAAG,CAAC,KAAc,EAAE,EAAE,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,oBAAoB,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC"}
@@ -0,0 +1,11 @@
1
+ import { type ControlProps } from '../../model/ControlProps';
2
+ import { type PlaceholderProps } from '../../model/PlaceholderProps';
3
+ import { type Currency } from './CurrencyProps';
4
+ import { type ExchangeCurrencyItem } from './ExchangeCurrencyCalculator';
5
+ interface InputProps extends PlaceholderProps, ControlProps<string> {
6
+ rates: ExchangeCurrencyItem[];
7
+ selected: string;
8
+ setSelected: (value: Currency) => void;
9
+ }
10
+ export declare function renderInput(props: InputProps): any;
11
+ export {};
@@ -0,0 +1,13 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "@redneckz/uni-jsx/jsx-runtime";
2
+ import { Input } from '../../ui-kit/Input/Input.js';
3
+ import { Select } from '../../ui-kit/Select/Select.js';
4
+ export function renderInput(props) {
5
+ const { placeholder, rates, selected, value, onChange, setSelected } = props;
6
+ const ratesOptions = rates.map((_) => ({
7
+ key: _?.currency?.currency ?? '',
8
+ text: _?.currency?.currency ?? '',
9
+ }));
10
+ const selectedValue = { key: selected, text: selected };
11
+ return (_jsxs("div", { className: "relative flex", children: [_jsx(Input, { className: "shrink-0 text-l w-full appearance-none -mr-20", placeholder: placeholder, type: "text", value: value, onChange: onChange }), ratesOptions.length ? (_jsx(Select, { className: "absolute right-0", isBorder: false, onChange: (_) => setSelected(_.key), options: ratesOptions, value: selectedValue })) : null] }));
12
+ }
13
+ //# sourceMappingURL=renderInput.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"renderInput.js","sourceRoot":"","sources":["../../../src/components/ExchangeRateTile/renderInput.tsx"],"names":[],"mappings":";AAEA,OAAO,EAAE,KAAK,EAAE,MAAM,0BAA0B,CAAC;AAEjD,OAAO,EAAE,MAAM,EAAE,MAAM,4BAA4B,CAAC;AAUpD,MAAM,UAAU,WAAW,CAAC,KAAiB;IAC3C,MAAM,EAAE,WAAW,EAAE,KAAK,EAAE,QAAQ,EAAE,KAAK,EAAE,QAAQ,EAAE,WAAW,EAAE,GAAG,KAAK,CAAC;IAC7E,MAAM,YAAY,GAAa,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC;QAC/C,GAAG,EAAE,CAAC,EAAE,QAAQ,EAAE,QAAQ,IAAI,EAAE;QAChC,IAAI,EAAE,CAAC,EAAE,QAAQ,EAAE,QAAQ,IAAI,EAAE;KAClC,CAAC,CAAC,CAAC;IACJ,MAAM,aAAa,GAAW,EAAE,GAAG,EAAE,QAAQ,EAAE,IAAI,EAAE,QAAQ,EAAE,CAAC;IAEhE,OAAO,CACL,eAAK,SAAS,EAAC,eAAe,aAC5B,KAAC,KAAK,IACJ,SAAS,EAAC,+CAA+C,EACzD,WAAW,EAAE,WAAW,EACxB,IAAI,EAAC,MAAM,EACX,KAAK,EAAE,KAAK,EACZ,QAAQ,EAAE,QAAQ,GAClB,EACD,YAAY,CAAC,MAAM,CAAC,CAAC,CAAC,CACrB,KAAC,MAAM,IACL,SAAS,EAAC,kBAAkB,EAC5B,QAAQ,EAAE,KAAK,EACf,QAAQ,EAAE,CAAC,CAAC,EAAE,EAAE,CAAC,WAAW,CAAC,CAAC,CAAC,GAAe,CAAC,EAC/C,OAAO,EAAE,YAAY,EACrB,KAAK,EAAE,aAAa,GACpB,CACH,CAAC,CAAC,CAAC,IAAI,IACJ,CACP,CAAC;AACJ,CAAC"}
@@ -0,0 +1,9 @@
1
+ import { type ExchangeCurrencyItem } from '../../components/ExchangeRateTile/ExchangeCurrencyCalculator';
2
+ import { type Region } from '../../hooks/useRegions';
3
+ export interface ExchangeData {
4
+ exchangeRate?: {
5
+ currencies?: ExchangeCurrencyItem[];
6
+ };
7
+ address?: string;
8
+ }
9
+ export declare function useFetchExchangeRateData(currentRegion: Region): ExchangeData;
@@ -0,0 +1,10 @@
1
+ import { useAsyncData } from '@redneckz/uni-jsx/lib/hooks/useAsyncData';
2
+ import { API_BASE_URI } from '../../api/apiBaseUrl.js';
3
+ import { fetchJSONUnsafe } from '../../utils/fetchJSON.js';
4
+ const EXCHANGE_RATES_URL = `${API_BASE_URI}/exchangerates`;
5
+ export function useFetchExchangeRateData(currentRegion) {
6
+ const regionCode = currentRegion?.code || '000';
7
+ const { data } = useAsyncData(EXCHANGE_RATES_URL + `?regionCode=${regionCode}`, fetchJSONUnsafe);
8
+ return data || {};
9
+ }
10
+ //# sourceMappingURL=useFetchExchangeRateData.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useFetchExchangeRateData.js","sourceRoot":"","sources":["../../../src/components/ExchangeRateTile/useFetchExchangeRateData.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,0CAA0C,CAAC;AACxE,OAAO,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAC;AAGpD,OAAO,EAAE,eAAe,EAA4B,MAAM,uBAAuB,CAAC;AASlF,MAAM,kBAAkB,GAAG,GAAG,YAAY,gBAAgB,CAAC;AAE3D,MAAM,UAAU,wBAAwB,CAAC,aAAqB;IAC5D,MAAM,UAAU,GAAG,aAAa,EAAE,IAAI,IAAI,KAAK,CAAC;IAEhD,MAAM,EAAE,IAAI,EAAE,GAAG,YAAY,CAC3B,kBAAkB,GAAG,eAAe,UAAU,EAAE,EAChD,eAAoD,CACrD,CAAC;IAEF,OAAO,IAAI,IAAI,EAAE,CAAC;AACpB,CAAC"}
@@ -763,10 +763,10 @@
763
763
  const and = (a, b) => (...args) => a(...args) && b(...args);
764
764
 
765
765
  const table = (...table) => (...input) => {
766
- const [, unit] = assertNonEmpty(table.find(([predicate]) => predicate(...input)));
766
+ const [, unit] = assertNonEmpty$1(table.find(([predicate]) => predicate(...input)));
767
767
  return unit(...input);
768
768
  };
769
- function assertNonEmpty(value) {
769
+ function assertNonEmpty$1(value) {
770
770
  if (!value) {
771
771
  throw new Error('Value should be fulfilled');
772
772
  }
@@ -3396,7 +3396,7 @@
3396
3396
  docId: 1,
3397
3397
  },
3398
3398
  consentPfrFlg: {
3399
- text: 'Согласие на запрос в ПФР',
3399
+ text: 'Согласие на запрос в CФР',
3400
3400
  docId: 3,
3401
3401
  },
3402
3402
  };
@@ -6639,7 +6639,7 @@
6639
6639
  }, []);
6640
6640
  useEffect(() => {
6641
6641
  leadFormStore.productType = productType;
6642
- const { code, state, referalCode, refererCode, productId, marketingInfo } = getLeadQueryParams(queryFromStorage, sessionStore);
6642
+ const { referalCode, refererCode, productId, marketingInfo } = getLeadQueryParams(queryFromStorage, sessionStore);
6643
6643
  if (referalCode) {
6644
6644
  sessionStore.referalData = {
6645
6645
  refererCode,
@@ -6648,6 +6648,11 @@
6648
6648
  };
6649
6649
  }
6650
6650
  sessionStore.marketingInfo = marketingInfo;
6651
+ }, [queryFromStorage]);
6652
+ useEffect(() => {
6653
+ const params = new URLSearchParams(decodeURIComponent(globalThis.location?.search));
6654
+ const code = params.get('code');
6655
+ const state = params.get('state');
6651
6656
  if (code && state) {
6652
6657
  requestEsiaProfile(code, state);
6653
6658
  }
@@ -6655,16 +6660,14 @@
6655
6660
  sessionStorage.removeItem('accessToken');
6656
6661
  sessionStorage.removeItem('refreshToken');
6657
6662
  }
6658
- }, [queryFromStorage]);
6663
+ }, []);
6659
6664
  return initialFormState;
6660
6665
  };
6661
6666
  const getLeadQueryParams = (queryFromStorage, sessionStore) => {
6662
6667
  const referalData = sessionStore.referalData;
6663
6668
  const marketingInfoFromStorage = sessionStore.marketingInfo;
6664
6669
  const queryStorage = new URLSearchParams(decodeURIComponent(queryFromStorage || ''));
6665
- const params = new URLSearchParams(decodeURIComponent(globalThis.location?.search));
6666
- const code = params.get('code');
6667
- const state = params.get('state');
6670
+ const code = queryStorage.get('code');
6668
6671
  const referalCode = code ? referalData?.referalCode : queryStorage.get('referalCode');
6669
6672
  const refererCode = code ? referalData?.refererCode : queryStorage.get('refererCode');
6670
6673
  const productId = code ? referalData?.productId : queryStorage.get('productId');
@@ -6680,8 +6683,6 @@
6680
6683
  userId: queryStorage.get('userId'),
6681
6684
  };
6682
6685
  return {
6683
- code,
6684
- state,
6685
6686
  referalCode,
6686
6687
  refererCode,
6687
6688
  productId,
@@ -10143,6 +10144,214 @@
10143
10144
  };
10144
10145
  const ErrorBlock = JSX(({ className = '', title, description, error, button, ...rest }) => (jsxs(BlockWrapper, { className: style('flex flex-col justify-center items-center', className), defaultPadding: style('p-6xl'), version: "transparent", ...rest, children: [jsx("div", { className: "flex justify-center", children: renderErrorContent(error) }), jsx(Headline, { title: title, description: description, headlineVersion: "XL", isEmbedded: true, className: "mb-2xl last:mb-0" }), button?.text ? (jsx(LinkButton, { version: button?.version, text: button?.text, ...button })) : null] })));
10145
10146
 
10147
+ const REGION_URL = `${API_BASE_URI$1}/region`;
10148
+ function useLocation(defaultLocation = 'Москва') {
10149
+ const locationStore = useLocalStore();
10150
+ return locationStore.location ?? { name: defaultLocation };
10151
+ }
10152
+ function useDefaultLocation(defaultLocation = 'Москва') {
10153
+ const locationStore = useLocalStore();
10154
+ const preselectLocation = useCallback(async () => {
10155
+ if (!locationStore.location) {
10156
+ const region = await fetchJSON(REGION_URL);
10157
+ locationStore.location = region ?? { name: defaultLocation };
10158
+ }
10159
+ }, [locationStore, defaultLocation]);
10160
+ useAsyncData(REGION_URL, preselectLocation);
10161
+ return locationStore;
10162
+ }
10163
+
10164
+ var Currency;
10165
+ (function (Currency) {
10166
+ Currency["RUB"] = "RUB";
10167
+ Currency["EUR"] = "EUR";
10168
+ Currency["USD"] = "USD";
10169
+ Currency["CNY"] = "CNY";
10170
+ })(Currency || (Currency = {}));
10171
+
10172
+ const currencyNumberFormat = new Intl.NumberFormat('ru', {
10173
+ style: 'currency',
10174
+ currency: Currency.RUB,
10175
+ });
10176
+ const formatCurrency = (value) => (value ? currencyNumberFormat.format(value) : '');
10177
+
10178
+ const TABLE_STYLE_BASE = 'text-m font-light text-secondary-text ';
10179
+ const TABLE_HEAD_STYLE = `${TABLE_STYLE_BASE} text-left`;
10180
+ const TABLE_HEAD_STYLE_CENTER = `${TABLE_STYLE_BASE} pl-5xl text-center`;
10181
+ const TABLE_HEAD_STYLE_RIGHT = `${TABLE_STYLE_BASE} pl-5xl text-right`;
10182
+ const CURRENCY_ICONS_MAP = {
10183
+ USD: 'DollarIcon',
10184
+ EUR: 'EuroIcon',
10185
+ CNY: 'ChineseYuanRenminbiIcon',
10186
+ };
10187
+ const CurrencyTable = JSX(({ className, exchangeCurrencyItems }) => (jsxs("table", { className: style('h-fit w-full', className), children: [jsx("thead", { children: jsxs("tr", { children: [jsx("th", { className: TABLE_HEAD_STYLE, children: jsx(Text, { size: "text-m", children: "\u0412\u0430\u043B\u044E\u0442\u0430" }) }), jsx("th", { className: TABLE_HEAD_STYLE_CENTER, children: jsx(Text, { size: "text-m", children: "\u041A\u0443\u043F\u0438\u0442\u044C" }) }), jsx("th", { className: TABLE_HEAD_STYLE_RIGHT, children: jsx(Text, { size: "text-m", children: "\u041F\u0440\u043E\u0434\u0430\u0442\u044C" }) })] }) }), jsx("tbody", { children: exchangeCurrencyItems.map(renderCurrencyRow) })] })));
10188
+ const renderCurrencyRow = (exchangeCurrencyItem) => {
10189
+ const currency = exchangeCurrencyItem?.currency?.currency;
10190
+ return (jsxs("tr", { className: "pb-2xs text-h6", children: [jsx("td", { className: "pt-m m-auto flex text-left", children: jsxs("div", { className: "flex items-center gap-xs", children: [currency ? (jsx(Img, { image: { icon: CURRENCY_ICONS_MAP[currency] }, width: "24", height: "24" })) : null, jsx(Text, { size: "text-h6", children: currency })] }) }), jsx("td", { className: "pt-m pl-5xl text-center", children: jsx(Text, { size: "text-h6", children: formatCurrency(exchangeCurrencyItem?.saleExchangeRate) }) }), jsx("td", { className: "pt-m pl-5xl text-right", children: jsx(Text, { size: "text-h6", children: formatCurrency(exchangeCurrencyItem?.buyExchangeRate) }) })] }, currency));
10191
+ };
10192
+
10193
+ const icon = { icon: 'GpsIcon' };
10194
+ const CurrentLocation = JSX(({ className = '', address }) => (jsxs("div", { className: style('flex gap-s w-full justify-between @sm:justify-center', className), children: [jsx(RoundedIcon, { ...icon, iconBgVersion: "primary", className: "shrink-0" }), jsxs("div", { className: "space-y-2xs whitespace-pre-wrap", children: [address ? (jsx(Paragraph, { size: "text-l", color: "text-primary-main", children: address })) : null, jsx(Paragraph, { size: "text-m", color: "text-secondary-text", children: "\u041A\u0443\u0440\u0441 \u0443\u043A\u0430\u0437\u0430\u043D \u0434\u043B\u044F \u0437\u0430\u0434\u0430\u043D\u043D\u043E\u0433\u043E \u043E\u0444\u0438\u0441\u0430" })] })] })));
10195
+
10196
+ const roundTo = (value, precision = 2) => {
10197
+ const factor = 10 ** precision;
10198
+ return Math.round(parseFloat(String(value)) * factor) / factor;
10199
+ };
10200
+
10201
+ const calculateResult = (value, rate, precision) => {
10202
+ const result = Number(formatValue(value)) * Math.pow(rate, precision ? -1 : 1);
10203
+ return Number.isInteger(result) ? result : roundTo(result);
10204
+ };
10205
+ const formatValue = (value) => value.replace(/[^\d.,]/g, '').replace(',', '.');
10206
+
10207
+ function assertNonEmpty(value) {
10208
+ if (!value) {
10209
+ throw new Error('Value should be fulfilled');
10210
+ }
10211
+ return value;
10212
+ }
10213
+
10214
+ const baseTableFunc = (table) => (input) => {
10215
+ const [, unit] = assertNonEmpty(table.find(([predicate]) => predicate(input)));
10216
+ return unit(input);
10217
+ };
10218
+ const tableFunc = (table) => baseTableFunc(table.map(([p, o]) => [p, () => o]));
10219
+ tableFunc.if = (predicate) => new TableFuncBuilder(undefined, predicate);
10220
+ class TableFuncBuilder {
10221
+ parent;
10222
+ predicate;
10223
+ unit;
10224
+ get entry() {
10225
+ return [assertNonEmpty(this.predicate), assertNonEmpty(this.unit)];
10226
+ }
10227
+ constructor(parent, predicate, unit) {
10228
+ this.parent = parent;
10229
+ this.predicate = predicate;
10230
+ this.unit = unit;
10231
+ }
10232
+ if(predicate) {
10233
+ return new TableFuncBuilder(this, predicate);
10234
+ }
10235
+ then(unit) {
10236
+ return new TableFuncBuilder(this.parent, this.predicate, unit);
10237
+ }
10238
+ else(unit) {
10239
+ return baseTableFunc([...buildTable(this), [() => true, unit]]);
10240
+ }
10241
+ }
10242
+ const buildTable = (builder) => [
10243
+ ...(builder?.parent ? buildTable(builder.parent) : []),
10244
+ builder.entry,
10245
+ ];
10246
+
10247
+ const callbackCurrencySelect = (props) => tableFunc([
10248
+ [
10249
+ (_) => _.value !== Currency.RUB && _.oppositeValue !== Currency.RUB,
10250
+ () => props.handleConvert(props.value, Currency.RUB),
10251
+ ],
10252
+ [
10253
+ (_) => _.value === Currency.RUB && _.oppositeValue === Currency.RUB,
10254
+ () => props.handleConvert(props.value, Currency.USD),
10255
+ ],
10256
+ [
10257
+ (_) => _.value === Currency.RUB && _.oppositeValue === Currency.RUB,
10258
+ () => props.handleConvert(props.value, Currency.CNY),
10259
+ ],
10260
+ [() => true, () => props.handleConvert(props.value)],
10261
+ ])(props)?.();
10262
+
10263
+ function renderInput(props) {
10264
+ const { placeholder, rates, selected, value, onChange, setSelected } = props;
10265
+ const ratesOptions = rates.map((_) => ({
10266
+ key: _?.currency?.currency ?? '',
10267
+ text: _?.currency?.currency ?? '',
10268
+ }));
10269
+ const selectedValue = { key: selected, text: selected };
10270
+ return (jsxs("div", { className: "relative flex", children: [jsx(Input, { className: "shrink-0 text-l w-full appearance-none -mr-20", placeholder: placeholder, type: "text", value: value, onChange: onChange }), ratesOptions.length ? (jsx(Select, { className: "absolute right-0", isBorder: false, onChange: (_) => setSelected(_.key), options: ratesOptions, value: selectedValue })) : null] }));
10271
+ }
10272
+
10273
+ const ExchangeCurrencyCalculator = JSX(({ className = '', currencyRatesBuy, currencyRatesSell, button }) => {
10274
+ const [calcState, setCalcState] = useState({
10275
+ inputSell: '',
10276
+ inputBuy: '',
10277
+ selectSell: currencyRatesBuy?.[0]?.currency?.currency || Currency.RUB,
10278
+ selectBuy: currencyRatesSell?.[0]?.currency?.currency || Currency.USD,
10279
+ });
10280
+ const handleSetCalcState = useCallback((newState) => setCalcState((oldState) => ({ ...oldState, ...newState })), []);
10281
+ return (jsxs("div", { className: `flex flex-col gap-m pt-2xl ${className}`, children: [currencyRatesBuy && currencyRatesSell ? (jsxs("div", { className: "grid gap-m", children: [renderInput({
10282
+ placeholder: 'Хочу продать',
10283
+ rates: currencyRatesSell,
10284
+ selected: calcState.selectSell,
10285
+ setSelected: handleSelectSell(calcState, handleSetCalcState, currencyRatesSell),
10286
+ value: calcState.inputSell,
10287
+ onChange: (value) => handleInputSell(handleSetCalcState, currencyRatesSell)(value, calcState.selectSell, calcState.selectBuy),
10288
+ }), renderInput({
10289
+ placeholder: 'Получу',
10290
+ rates: currencyRatesBuy,
10291
+ selected: calcState.selectBuy,
10292
+ setSelected: handleSelectBuy(calcState, handleSetCalcState, currencyRatesBuy),
10293
+ value: calcState.inputBuy,
10294
+ onChange: (value) => handleInputBuy(handleSetCalcState, currencyRatesBuy)(value, calcState.selectBuy, calcState.selectSell),
10295
+ })] })) : null, button?.text ? (jsx(LinkButton, { text: button.text, version: button?.version, ...button })) : null] }));
10296
+ });
10297
+ const handleSelectSell = (calcState, setCalcState, currencyRatesSell) => (value) => {
10298
+ setCalcState({ selectSell: value });
10299
+ callbackCurrencySelect({
10300
+ value,
10301
+ oppositeValue: calcState.selectBuy,
10302
+ handleConvert: (currencyFrom = calcState.selectSell, currencyTo = calcState.selectBuy) => {
10303
+ handleInputSell(setCalcState, currencyRatesSell)(calcState.inputSell, currencyFrom, currencyTo);
10304
+ },
10305
+ });
10306
+ };
10307
+ const handleSelectBuy = (calcState, setCalcState, currencyRatesBuy) => (value) => {
10308
+ setCalcState({ selectBuy: value });
10309
+ callbackCurrencySelect({
10310
+ value,
10311
+ oppositeValue: calcState.selectSell,
10312
+ handleConvert: (currencyTo = calcState.selectBuy, currencyFrom = calcState.selectSell) => handleInputBuy(setCalcState, currencyRatesBuy)(calcState.inputBuy, currencyTo, currencyFrom),
10313
+ });
10314
+ };
10315
+ const handleInputSell = (setCalcState, currencyRatesSell) => (value, currencyFrom, currencyTo) => {
10316
+ setCalcState({ inputSell: formatValue(value), selectBuy: currencyTo });
10317
+ const rate = currencyRatesSell.find((_) => _.currency?.currency === currencyTo)?.buyExchangeRate ||
10318
+ currencyRatesSell.find((_) => _.currency?.currency === currencyFrom)?.buyExchangeRate;
10319
+ if (rate) {
10320
+ setCalcState({
10321
+ inputBuy: String(calculateResult(value, rate, currencyFrom === Currency.RUB) || ''),
10322
+ });
10323
+ }
10324
+ };
10325
+ const handleInputBuy = (setCalcState, currencyRatesBuy) => (value, currencyTo, currencyFrom) => {
10326
+ setCalcState({ inputBuy: formatValue(value), selectSell: currencyFrom });
10327
+ const rate = currencyRatesBuy.find((_) => _.currency?.currency === currencyFrom)?.saleExchangeRate ||
10328
+ currencyRatesBuy.find((_) => _.currency?.currency === currencyTo)?.saleExchangeRate;
10329
+ if (rate) {
10330
+ setCalcState({
10331
+ inputSell: String(calculateResult(value, rate, currencyTo === Currency.RUB) || ''),
10332
+ });
10333
+ }
10334
+ };
10335
+
10336
+ const EXCHANGE_RATES_URL = `${API_BASE_URI$1}/exchangerates`;
10337
+ function useFetchExchangeRateData(currentRegion) {
10338
+ const regionCode = currentRegion?.code || '000';
10339
+ const { data } = useAsyncData(EXCHANGE_RATES_URL + `?regionCode=${regionCode}`, fetchJSONUnsafe);
10340
+ return data || {};
10341
+ }
10342
+
10343
+ const ExchangeRateTile = JSX(({ className = '', title = 'Курсы обмена валют', button, ...rest }) => {
10344
+ const currentLocation = useLocation();
10345
+ const exchangeRates = useFetchExchangeRateData(currentLocation);
10346
+ const currencyRates = getCurrencyRates(exchangeRates?.exchangeRate?.currencies);
10347
+ const currencyRatesBuy = currencyRates.filter((_) => _.buyExchangeRate);
10348
+ currencyRatesBuy.unshift({ currency: { currency: Currency.RUB } });
10349
+ const currencyRatesSell = currencyRates.filter((_) => _.saleExchangeRate);
10350
+ currencyRatesSell.push({ currency: { currency: Currency.RUB } });
10351
+ return (jsx(BlockWrapper, { className: style('box-border min-h-80', className), ...rest, children: jsx(BaseTile, { className: "h-full", title: jsx(Heading, { headingType: "h4", title: title, className: "whitespace-pre-wrap" }), children: jsxs("div", { className: "flex w-full gap-6xl flex-wrap @lg:flex-nowrap", children: [jsxs("div", { className: "w-full @2xl:w-auto @5xl:w-1/2", children: [currencyRates ? (jsx(CurrencyTable, { className: "mb-xl", exchangeCurrencyItems: currencyRates })) : null, jsx(CurrentLocation, { address: exchangeRates?.address })] }), jsx(ExchangeCurrencyCalculator, { className: "grow w-1/2", currencyRatesBuy: currencyRatesBuy, currencyRatesSell: currencyRatesSell, button: button })] }) }) }));
10352
+ });
10353
+ const getCurrencyRates = (currencies) => currencies?.filter((_) => [1, 2, 3].includes(_?.currency?.id)) || [];
10354
+
10146
10355
  const LinkList = JSX(({ className = '', items }) => {
10147
10356
  const link = useLink();
10148
10357
  return (jsx("ul", { className: style('flex flex-col gap-s w-full', className), children: items?.map(renderLinkListItem(link)) }));
@@ -10489,23 +10698,6 @@
10489
10698
  return (jsx(BlockWrapper, { className: style('min-h-80', className), padding: "p-0", version: version, ...rest, children: jsxs(BaseTile, { className: "h-full", padding: padding, defaultPadding: "p-6xl", title: jsx(Heading, { headingType: headingType, title: title, className: style('whitespace-pre-wrap', align) }), rightImage: img, buttons: renderButtonsSection(buttons, { className: 'flex-wrap' }), children: [description ? (jsx(Text, { size: "text-xl", "font-weight": "font-light", children: description })) : null, jsxs("div", { className: style('gap-m', 'flex flex-1 flex-col', 'flex-col items-start @xl:flex-row @xl:items-center'), children: [__html ? jsx(RichText, { __html: __html, itemSize: "list-m" }) : null, jsx(Text, { size: "text-m", "font-weight": "font-light", color: "text-secondary-text", children: additionalDescription }), qr?.src ? (jsx("div", { className: style('flex justify-center bg-white rounded-md @xl:-order-1', containerStyle), children: jsx(Img, { className: "w-fit", image: qr }) })) : null, image?.src ? jsx(Img, { className: "lg:hidden", image: image }) : null] })] }) }));
10490
10699
  });
10491
10700
 
10492
- const REGION_URL = `${API_BASE_URI$1}/region`;
10493
- function useLocation(defaultLocation = 'Москва') {
10494
- const locationStore = useLocalStore();
10495
- return locationStore.location ?? { name: defaultLocation };
10496
- }
10497
- function useDefaultLocation(defaultLocation = 'Москва') {
10498
- const locationStore = useLocalStore();
10499
- const preselectLocation = useCallback(async () => {
10500
- if (!locationStore.location) {
10501
- const region = await fetchJSON(REGION_URL);
10502
- locationStore.location = region ?? { name: defaultLocation };
10503
- }
10504
- }, [locationStore, defaultLocation]);
10505
- useAsyncData(REGION_URL, preselectLocation);
10506
- return locationStore;
10507
- }
10508
-
10509
10701
  const COMMON_FILTERS_STYLES = 'flex flex-col sm:flex-row sm:flex-wrap gap-3xl pb-2xl';
10510
10702
  const VISIBLE_FILTERS = [
10511
10703
  'workingSaturday',
@@ -11355,6 +11547,7 @@
11355
11547
  CarouselTariffsCard,
11356
11548
  DepositFiltration,
11357
11549
  ErrorBlock,
11550
+ ExchangeRateTile,
11358
11551
  Footer,
11359
11552
  GalleryLayout,
11360
11553
  GrantSupport,
@@ -11499,7 +11692,7 @@
11499
11692
  slots: () => [HEADER_SLOT, FOOTER_SLOT, STICKY_FOOTER_SLOT],
11500
11693
  });
11501
11694
 
11502
- const packageVersion = "0.14.898";
11695
+ const packageVersion = "0.14.900";
11503
11696
 
11504
11697
  exports.Blocks = Blocks;
11505
11698
  exports.ContentPage = ContentPage;