@redneckz/wildless-cms-uni-blocks 0.14.1027 → 0.14.1028

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 (159) hide show
  1. package/bundle/blocks.schema.json +1 -1
  2. package/bundle/bundle.umd.js +158 -82
  3. package/bundle/bundle.umd.min.js +1 -1
  4. package/bundle/components/RatesTable/RatesTable.d.ts +6 -0
  5. package/bundle/components/RatesTable/RatesTableContent.d.ts +12 -0
  6. package/bundle/components/RatesTable/RatesTableItem.d.ts +9 -0
  7. package/bundle/components/RatesTable/renderDataPickForm.d.ts +1 -0
  8. package/bundle/components/RatesTable/renderDate.d.ts +6 -0
  9. package/bundle/components/RatesTable/renderLink.d.ts +1 -0
  10. package/bundle/hooks/useRates.d.ts +4 -0
  11. package/bundle/ui-kit/Rate/Rate.d.ts +12 -0
  12. package/dist/components/Blocks.js +2 -0
  13. package/dist/components/Blocks.js.map +1 -1
  14. package/dist/components/Blocks.mobile.js +2 -0
  15. package/dist/components/Blocks.mobile.js.map +1 -1
  16. package/dist/components/RatesTable/RatesTable.d.ts +6 -0
  17. package/dist/components/RatesTable/RatesTable.js +17 -0
  18. package/dist/components/RatesTable/RatesTable.js.map +1 -0
  19. package/dist/components/RatesTable/RatesTableContent.d.ts +12 -0
  20. package/dist/components/RatesTable/RatesTableContent.js +2 -0
  21. package/dist/components/RatesTable/RatesTableContent.js.map +1 -0
  22. package/dist/components/RatesTable/RatesTableItem.d.ts +9 -0
  23. package/dist/components/RatesTable/RatesTableItem.js +16 -0
  24. package/dist/components/RatesTable/RatesTableItem.js.map +1 -0
  25. package/dist/components/RatesTable/renderDataPickForm.d.ts +1 -0
  26. package/dist/components/RatesTable/renderDataPickForm.js +8 -0
  27. package/dist/components/RatesTable/renderDataPickForm.js.map +1 -0
  28. package/dist/components/RatesTable/renderDate.d.ts +6 -0
  29. package/dist/components/RatesTable/renderDate.js +24 -0
  30. package/dist/components/RatesTable/renderDate.js.map +1 -0
  31. package/dist/components/RatesTable/renderLink.d.ts +1 -0
  32. package/dist/components/RatesTable/renderLink.js +8 -0
  33. package/dist/components/RatesTable/renderLink.js.map +1 -0
  34. package/dist/hooks/useRates.d.ts +4 -0
  35. package/dist/hooks/useRates.js +42 -0
  36. package/dist/hooks/useRates.js.map +1 -0
  37. package/dist/ui-kit/Rate/Rate.d.ts +12 -0
  38. package/dist/ui-kit/Rate/Rate.js +11 -0
  39. package/dist/ui-kit/Rate/Rate.js.map +1 -0
  40. package/lib/common.css +1 -1
  41. package/lib/components/Blocks.js +2 -0
  42. package/lib/components/Blocks.js.map +1 -1
  43. package/lib/components/Blocks.mobile.js +2 -0
  44. package/lib/components/Blocks.mobile.js.map +1 -1
  45. package/lib/components/RatesTable/RatesTable.d.ts +6 -0
  46. package/lib/components/RatesTable/RatesTable.fixture.d.ts +6 -0
  47. package/lib/components/RatesTable/RatesTable.fixture.mobile.d.ts +6 -0
  48. package/lib/components/RatesTable/RatesTable.js +15 -0
  49. package/lib/components/RatesTable/RatesTable.js.map +1 -0
  50. package/lib/components/RatesTable/RatesTableContent.d.ts +12 -0
  51. package/lib/components/RatesTable/RatesTableContent.js +2 -0
  52. package/lib/components/RatesTable/RatesTableContent.js.map +1 -0
  53. package/lib/components/RatesTable/RatesTableItem.d.ts +9 -0
  54. package/lib/components/RatesTable/RatesTableItem.js +14 -0
  55. package/lib/components/RatesTable/RatesTableItem.js.map +1 -0
  56. package/lib/components/RatesTable/renderDataPickForm.d.ts +1 -0
  57. package/lib/components/RatesTable/renderDataPickForm.js +5 -0
  58. package/lib/components/RatesTable/renderDataPickForm.js.map +1 -0
  59. package/lib/components/RatesTable/renderDate.d.ts +6 -0
  60. package/lib/components/RatesTable/renderDate.js +21 -0
  61. package/lib/components/RatesTable/renderDate.js.map +1 -0
  62. package/lib/components/RatesTable/renderLink.d.ts +1 -0
  63. package/lib/components/RatesTable/renderLink.js +5 -0
  64. package/lib/components/RatesTable/renderLink.js.map +1 -0
  65. package/lib/hooks/useRates.d.ts +4 -0
  66. package/lib/hooks/useRates.js +39 -0
  67. package/lib/hooks/useRates.js.map +1 -0
  68. package/lib/ui-kit/Rate/Rate.d.ts +12 -0
  69. package/lib/ui-kit/Rate/Rate.js +9 -0
  70. package/lib/ui-kit/Rate/Rate.js.map +1 -0
  71. package/mobile/bundle/bundle.umd.js +123 -47
  72. package/mobile/bundle/bundle.umd.min.js +1 -1
  73. package/mobile/bundle/components/RatesTable/RatesTable.d.ts +6 -0
  74. package/mobile/bundle/components/RatesTable/RatesTableContent.d.ts +12 -0
  75. package/mobile/bundle/components/RatesTable/RatesTableItem.d.ts +9 -0
  76. package/mobile/bundle/components/RatesTable/renderDataPickForm.d.ts +1 -0
  77. package/mobile/bundle/components/RatesTable/renderDate.d.ts +6 -0
  78. package/mobile/bundle/components/RatesTable/renderLink.d.ts +1 -0
  79. package/mobile/bundle/hooks/useRates.d.ts +4 -0
  80. package/mobile/bundle/ui-kit/Rate/Rate.d.ts +12 -0
  81. package/mobile/dist/components/Blocks.js +2 -0
  82. package/mobile/dist/components/Blocks.js.map +1 -1
  83. package/mobile/dist/components/RatesTable/RatesTable.d.ts +6 -0
  84. package/mobile/dist/components/RatesTable/RatesTable.js +17 -0
  85. package/mobile/dist/components/RatesTable/RatesTable.js.map +1 -0
  86. package/mobile/dist/components/RatesTable/RatesTableContent.d.ts +12 -0
  87. package/mobile/dist/components/RatesTable/RatesTableContent.js +2 -0
  88. package/mobile/dist/components/RatesTable/RatesTableContent.js.map +1 -0
  89. package/mobile/dist/components/RatesTable/RatesTableItem.d.ts +9 -0
  90. package/mobile/dist/components/RatesTable/RatesTableItem.js +16 -0
  91. package/mobile/dist/components/RatesTable/RatesTableItem.js.map +1 -0
  92. package/mobile/dist/components/RatesTable/renderDataPickForm.d.ts +1 -0
  93. package/mobile/dist/components/RatesTable/renderDataPickForm.js +8 -0
  94. package/mobile/dist/components/RatesTable/renderDataPickForm.js.map +1 -0
  95. package/mobile/dist/components/RatesTable/renderDate.d.ts +6 -0
  96. package/mobile/dist/components/RatesTable/renderDate.js +24 -0
  97. package/mobile/dist/components/RatesTable/renderDate.js.map +1 -0
  98. package/mobile/dist/components/RatesTable/renderLink.d.ts +1 -0
  99. package/mobile/dist/components/RatesTable/renderLink.js +8 -0
  100. package/mobile/dist/components/RatesTable/renderLink.js.map +1 -0
  101. package/mobile/dist/hooks/useRates.d.ts +4 -0
  102. package/mobile/dist/hooks/useRates.js +42 -0
  103. package/mobile/dist/hooks/useRates.js.map +1 -0
  104. package/mobile/dist/ui-kit/Rate/Rate.d.ts +12 -0
  105. package/mobile/dist/ui-kit/Rate/Rate.js +11 -0
  106. package/mobile/dist/ui-kit/Rate/Rate.js.map +1 -0
  107. package/mobile/lib/common.css +1 -1
  108. package/mobile/lib/components/Blocks.js +2 -0
  109. package/mobile/lib/components/Blocks.js.map +1 -1
  110. package/mobile/lib/components/RatesTable/RatesTable.d.ts +6 -0
  111. package/mobile/lib/components/RatesTable/RatesTable.js +15 -0
  112. package/mobile/lib/components/RatesTable/RatesTable.js.map +1 -0
  113. package/mobile/lib/components/RatesTable/RatesTableContent.d.ts +12 -0
  114. package/mobile/lib/components/RatesTable/RatesTableContent.js +2 -0
  115. package/mobile/lib/components/RatesTable/RatesTableContent.js.map +1 -0
  116. package/mobile/lib/components/RatesTable/RatesTableItem.d.ts +9 -0
  117. package/mobile/lib/components/RatesTable/RatesTableItem.js +14 -0
  118. package/mobile/lib/components/RatesTable/RatesTableItem.js.map +1 -0
  119. package/mobile/lib/components/RatesTable/renderDataPickForm.d.ts +1 -0
  120. package/mobile/lib/components/RatesTable/renderDataPickForm.js +5 -0
  121. package/mobile/lib/components/RatesTable/renderDataPickForm.js.map +1 -0
  122. package/mobile/lib/components/RatesTable/renderDate.d.ts +6 -0
  123. package/mobile/lib/components/RatesTable/renderDate.js +21 -0
  124. package/mobile/lib/components/RatesTable/renderDate.js.map +1 -0
  125. package/mobile/lib/components/RatesTable/renderLink.d.ts +1 -0
  126. package/mobile/lib/components/RatesTable/renderLink.js +5 -0
  127. package/mobile/lib/components/RatesTable/renderLink.js.map +1 -0
  128. package/mobile/lib/hooks/useRates.d.ts +4 -0
  129. package/mobile/lib/hooks/useRates.js +39 -0
  130. package/mobile/lib/hooks/useRates.js.map +1 -0
  131. package/mobile/lib/ui-kit/Rate/Rate.d.ts +12 -0
  132. package/mobile/lib/ui-kit/Rate/Rate.js +9 -0
  133. package/mobile/lib/ui-kit/Rate/Rate.js.map +1 -0
  134. package/mobile/src/components/Blocks.ts +2 -0
  135. package/mobile/src/components/RatesTable/RatesTable.example.json +7 -0
  136. package/mobile/src/components/RatesTable/RatesTable.tsx +38 -0
  137. package/mobile/src/components/RatesTable/RatesTable.ui.json +7 -0
  138. package/mobile/src/components/RatesTable/RatesTableContent.ts +13 -0
  139. package/mobile/src/components/RatesTable/RatesTableItem.tsx +39 -0
  140. package/mobile/src/components/RatesTable/renderDataPickForm.tsx +9 -0
  141. package/mobile/src/components/RatesTable/renderDate.tsx +42 -0
  142. package/mobile/src/components/RatesTable/renderLink.tsx +8 -0
  143. package/mobile/src/hooks/useRates.ts +65 -0
  144. package/mobile/src/ui-kit/Rate/Rate.tsx +27 -0
  145. package/package.json +1 -1
  146. package/src/components/Blocks.mobile.ts +2 -0
  147. package/src/components/Blocks.ts +2 -0
  148. package/src/components/RatesTable/RatesTable.example.json +7 -0
  149. package/src/components/RatesTable/RatesTable.fixture.mobile.tsx +26 -0
  150. package/src/components/RatesTable/RatesTable.fixture.tsx +26 -0
  151. package/src/components/RatesTable/RatesTable.tsx +38 -0
  152. package/src/components/RatesTable/RatesTable.ui.json +7 -0
  153. package/src/components/RatesTable/RatesTableContent.ts +13 -0
  154. package/src/components/RatesTable/RatesTableItem.tsx +39 -0
  155. package/src/components/RatesTable/renderDataPickForm.tsx +9 -0
  156. package/src/components/RatesTable/renderDate.tsx +42 -0
  157. package/src/components/RatesTable/renderLink.tsx +8 -0
  158. package/src/hooks/useRates.ts +65 -0
  159. package/src/ui-kit/Rate/Rate.tsx +27 -0
@@ -8792,11 +8792,11 @@
8792
8792
  return (jsx(BlockWrapper, { className: style('!bg-transparent', alignStyle, className), defaultPadding: "p-0", ...rest, children: renderButtonsSection(buttons) }));
8793
8793
  });
8794
8794
 
8795
- const Rate = JSX(({ rate = 0, title = 'Ставка', unit, fractionDigits = 2, depositeName, isShowDepositeName, color = 'text-secondary-text', }) => (jsxs("div", { children: [jsx(Text, { size: "text-l", font: "font-light", color: color, children: title }), jsxs("div", { className: "relative", children: [jsxs("div", { className: "flex @xl:justify-center gradient-color-text gap-xs", children: [jsx("span", { className: "font-mohave text-title-huge -mt-m tracking-[-15px]", children: toLocalNumberFormat(fractionDigits, { fixed: true })(rate) }), unit ? jsx("span", { className: "text-7xl mt-5", children: unit }) : null] }), depositeName && isShowDepositeName ? (jsx("div", { className: "absolute bottom-2 w-full text-left whitespace-nowrap", children: depositeName })) : null] })] })));
8795
+ const Rate$1 = JSX(({ rate = 0, title = 'Ставка', unit, fractionDigits = 2, depositeName, isShowDepositeName, color = 'text-secondary-text', }) => (jsxs("div", { children: [jsx(Text, { size: "text-l", font: "font-light", color: color, children: title }), jsxs("div", { className: "relative", children: [jsxs("div", { className: "flex @xl:justify-center gradient-color-text gap-xs", children: [jsx("span", { className: "font-mohave text-title-huge -mt-m tracking-[-15px]", children: toLocalNumberFormat(fractionDigits, { fixed: true })(rate) }), unit ? jsx("span", { className: "text-7xl mt-5", children: unit }) : null] }), depositeName && isShowDepositeName ? (jsx("div", { className: "absolute bottom-2 w-full text-left whitespace-nowrap", children: depositeName })) : null] })] })));
8796
8796
 
8797
8797
  const UnknownRate = JSX(({ title = 'Ставка' }) => (jsxs("div", { className: "space-y-s lg:min-w-96", children: [jsx(Text, { size: "text-l", font: "font-light", color: "text-secondary-text", children: title }), jsx(Icon, { className: "w-10 h-auto lg:w-40", name: "PercentIcon" }), jsx("div", { className: "w-64", children: jsx(Paragraph, { size: "text-xl", font: "font-light", color: "text-primary-text", children: "\u041F\u0440\u043E\u0446\u0435\u043D\u0442\u043D\u0430\u044F \u0441\u0442\u0430\u0432\u043A\u0430 \u043D\u0435 \u043D\u0430\u0439\u0434\u0435\u043D\u0430, \u0432\u044B\u0431\u0435\u0440\u0438\u0442\u0435 \u0434\u0440\u0443\u0433\u0438\u0435 \u043F\u0430\u0440\u0430\u043C\u0435\u0442\u0440\u044B" }) })] })));
8798
8798
 
8799
- const renderRate = ({ title = 'Ставка', rate = 0, unit = '%', fractionDigits = 2, color = 'text-secondary-text', children, ...rest }) => rate ? (jsxs("div", { className: "flex flex-col", children: [jsx("div", { className: "hidden lg:block min-w-96", children: jsx(Rate, { title: title, rate: rate, unit: unit, fractionDigits: fractionDigits, color: color, ...rest }) }), jsx(CalculatorValue, { className: "lg:hidden", title: title, value: rate, postfix: unit, fractionDigits: fractionDigits, fixed: true, color: color, ...rest }), children] })) : (jsx(UnknownRate, { title: title, ...rest }));
8799
+ const renderRate = ({ title = 'Ставка', rate = 0, unit = '%', fractionDigits = 2, color = 'text-secondary-text', children, ...rest }) => rate ? (jsxs("div", { className: "flex flex-col", children: [jsx("div", { className: "hidden lg:block min-w-96", children: jsx(Rate$1, { title: title, rate: rate, unit: unit, fractionDigits: fractionDigits, color: color, ...rest }) }), jsx(CalculatorValue, { className: "lg:hidden", title: title, value: rate, postfix: unit, fractionDigits: fractionDigits, fixed: true, color: color, ...rest }), children] })) : (jsx(UnknownRate, { title: title, ...rest }));
8800
8800
 
8801
8801
  const DEFAULT_BONUS_CALCULATOR_PARAMS$1 = {
8802
8802
  minSumTravel: 6000,
@@ -13796,6 +13796,160 @@
13796
13796
  return (jsx(BlockWrapper, { version: "transparent", className: style(className), defaultPadding: "p-0", ...rest, children: dataType === 'offices' ? jsx(OfficesMap, {}) : jsx(AtmsMap, { descriptionData: data }) }));
13797
13797
  });
13798
13798
 
13799
+ const RATES_URL = `${API_BASE_URI}/rates`;
13800
+ const ARCHIVE_RATES_URL = `${API_BASE_URI}/historyrates`;
13801
+ const EMPTY_RATES = [
13802
+ [
13803
+ {
13804
+ currencyPair: 'Валютная пара',
13805
+ buyRate: 0,
13806
+ sellRate: 0,
13807
+ },
13808
+ ],
13809
+ ];
13810
+ function useRates(isArchive) {
13811
+ const url = isArchive ? ARCHIVE_RATES_URL : RATES_URL;
13812
+ const rateKey = isArchive ? 'archiveRates' : 'rates';
13813
+ const ratesStore = useLocalStore();
13814
+ // проверяем, надо ли обновлять значения ставок
13815
+ const shouldUpdate = getShouldUpdate(isArchive, ratesStore);
13816
+ // костыль, не отправлять запрос на бэк, если уже был запрос менее 15 мин назад
13817
+ const { data } = useAsyncData(shouldUpdate ? url : '', fetchJSONUnsafe);
13818
+ // если есть data и значение надо обновить, то обновляем локалсторадж
13819
+ if (shouldUpdate && data) {
13820
+ const nextUpdate = getTimeAfter15Minutes();
13821
+ ratesStore[rateKey] = { rate: data, nextUpdate };
13822
+ }
13823
+ // берем данные из локалсторадж
13824
+ const rates = ratesStore[rateKey]?.rate;
13825
+ // возвращаем данные из локалсторадж или заглушку
13826
+ return Array.isArray(rates) ? rates : EMPTY_RATES;
13827
+ }
13828
+ // Отсчитываем 15 минут с текущего момента
13829
+ const getTimeAfter15Minutes = () => Date.now() + 15 * 60 * 1000;
13830
+ const getShouldUpdate = (isArchive, ratesStore) => isArchive
13831
+ ? !ratesStore?.archiveRates || ratesStore?.archiveRates.nextUpdate <= Date.now()
13832
+ : !ratesStore?.rates || ratesStore?.rates.nextUpdate <= Date.now();
13833
+
13834
+ const useCarouselControls = (props, initialIndex = 0) => {
13835
+ const { itemCount, visibleItemCount } = props;
13836
+ const [activeIndex, setActiveIndex] = useState(initialIndex);
13837
+ const inc = useCallback(() => setActiveIndex((_) => Math.min(_ + 1, itemCount - 1)), [itemCount]);
13838
+ const dec = useCallback(() => setActiveIndex((_) => Math.max(_ - 1, 0)), [itemCount]);
13839
+ const canInc = visibleItemCount
13840
+ ? itemCount > visibleItemCount && activeIndex < itemCount - visibleItemCount
13841
+ : activeIndex < itemCount - 1;
13842
+ const canDec = activeIndex > 0;
13843
+ const isScrollAvailable = canDec || canInc;
13844
+ return [
13845
+ activeIndex,
13846
+ {
13847
+ inc,
13848
+ dec,
13849
+ canInc,
13850
+ canDec,
13851
+ isScrollAvailable,
13852
+ },
13853
+ ];
13854
+ };
13855
+
13856
+ /** @deprecated */
13857
+ const renderArrows = ({ className, btnClass, canDec, canInc, dec, inc, }) => canDec || canInc ? (jsxs("div", { children: [canDec ? (jsx(ArrowLeftButton, { wcmsIgnore: true, className: style('absolute z-40', btnClass[0], className), onClick: dec })) : null, canInc ? (jsx(ArrowRightButton, { wcmsIgnore: true, className: style('absolute z-40', btnClass[1], className), onClick: inc })) : null] })) : null;
13858
+
13859
+ const COLUMN_WIDTH = 140;
13860
+ const getHorizontalShift = (columns, activeColumnIndex) => sum(columns.slice(0, activeColumnIndex).map((_) => _?.cols?.length ?? 1)) * COLUMN_WIDTH;
13861
+
13862
+ const renderInnerTableRow = (activeColumnIndex) => (rowData, rowIdx) => {
13863
+ if (!rowData?.length) {
13864
+ return null;
13865
+ }
13866
+ const [headerColumn, ...columns] = rowData;
13867
+ const columnsStyle = style('flex duration-1000 text-center', rowIdx !== 0 ? 'font-normal' : 'font-light');
13868
+ return (jsxs("div", { className: "flex border-main-divider border-b border-solid h-full", children: [headerColumn?.data ? (jsx("div", { className: "whitespace-pre-wrap sm:whitespace-normal w-48 min-w-48 sm:w-56 sm:min-w-56 py-lg pr-lg sm:pr-0", children: jsx(Text, { size: "text-xl", font: "font-light", children: headerColumn.data }) })) : null, jsx("div", { className: "flex flex-grow overflow-hidden", children: jsx("div", { className: columnsStyle, style: {
13869
+ transform: `translateX(-${getHorizontalShift(columns, activeColumnIndex)}px)`,
13870
+ }, children: columns?.map((_, i) => (jsxs("div", { className: "flex flex-col flex-grow gap-s justify-center py-xl odd:bg-main-divider", children: [_?.data ? jsx(Text, { size: "text-xl", children: _.data }) : null, _?.cols ? renderCols(_.cols, activeColumnIndex) : null] }, `row${i}`))) }) })] }, String(rowIdx)));
13871
+ };
13872
+ const renderCols = (cols, rowIndex) => cols?.length > 0 ? (jsx("div", { className: style('flex', { 'text-secondary-text': rowIndex === 0 }), children: cols.map((data, i) => (jsx("div", { className: "w-20 mx-lg", children: jsx(Text, { size: "text-h6", font: "font-light", children: data }) }, String(i)))) })) : null;
13873
+
13874
+ const InnerTableBodyItem = JSX(({ rows }) => {
13875
+ const rowsLength = rows?.[0]?.length ?? 0;
13876
+ const CARD_VIEW_COUNT = 5;
13877
+ const [activeIndex, controls] = useCarouselControls({
13878
+ itemCount: rowsLength,
13879
+ visibleItemCount: CARD_VIEW_COUNT,
13880
+ });
13881
+ return (jsxs("div", { children: [rows?.map(renderInnerTableRow(activeIndex)), renderArrows({
13882
+ ...controls,
13883
+ btnClass: ['left-3 top-20', 'right-3 top-20'],
13884
+ className: '',
13885
+ })] }));
13886
+ });
13887
+
13888
+ const InnerTableBody = JSX(({ activeTabIndex, items }) => (jsx("div", { children: items.map((_, tableIdx) => {
13889
+ const key = `activeTabIdx:${activeTabIndex}-tableIdx:${tableIdx}`;
13890
+ return (jsxs("div", { className: "w-full @container", children: [jsx("div", { className: "flex py-m px-m bg-white @4xl:bg-gray relative", children: jsx(Text, { size: "text-xl", align: "text-left", children: _.title }) }), jsx("div", { className: "w-full sm:pl-xs overflow-hidden transition-height duration-500 ease-in-out", children: jsx("div", { className: "relative", children: jsx(InnerTableBodyItem, { rows: _.rowsData }) }) })] }, key));
13891
+ }) })));
13892
+
13893
+ const linkButtonVersion = 'secondary';
13894
+
13895
+ const TableColor = (isEqual = false) => `${isEqual ? 'text-white' : 'text-secondary-text'}`;
13896
+ const InnerTableHeader = JSX(({ currencies, linkToPDF, activeTabIndex, setActiveTabIndex }) => (jsxs("div", { className: "flex justify-between items-center w-full py-lg", children: [currencies && currencies.length > 1 ? (jsx("div", { className: "flex bg-secondary-light p-2xs rounded-md", children: currencies.map((currency, idx) => (jsx("div", { className: style('rounded-md px-4 py-3 cursor-pointer', {
13897
+ 'bg-primary-main': idx === activeTabIndex,
13898
+ }), onClick: () => setActiveTabIndex(idx), children: jsx(Text, { size: "text-xl", font: "font-light", color: TableColor(idx === activeTabIndex), children: currency || idx + 1 }) }, currency))) })) : null, linkToPDF ? (jsx(LinkButton, { className: "text-primary-main", href: linkToPDF, version: linkButtonVersion, target: "_blank", appendLeft: jsx(Icon, { name: "DocDownloadIcon", iconVersion: "color", className: "mr-3xs", width: "20", height: "20" }), text: "\u0421\u043A\u0430\u0447\u0430\u0442\u044C \u0432 PDF" })) : null] })));
13899
+
13900
+ const EMPTY_DATA$1 = 'Данных нет';
13901
+ const InnerTable = UniBlock(({ tableSource }) => {
13902
+ const tableData = tableSource?.tableData;
13903
+ const [activeTabIndex, setActiveTabIndex] = useState(0);
13904
+ const handleActiveTabIndex = useCallback((_) => setActiveTabIndex(_), []);
13905
+ const items = tableData?.[activeTabIndex]?.items ?? [];
13906
+ const currencies = tableData?.map((item) => item.currency ?? '');
13907
+ return tableData ? (jsxs("div", { className: "bg-white z-10", children: [jsx(InnerTableHeader, { currencies: currencies, activeTabIndex: activeTabIndex, setActiveTabIndex: handleActiveTabIndex }), jsx(InnerTableBody, { activeTabIndex: activeTabIndex, items: items })] })) : (jsx("div", { className: "space-y-m text-center", children: jsx(Text, { size: "text-h6", children: EMPTY_DATA$1 }) }));
13908
+ });
13909
+
13910
+ const DIVIDER_STYLE = 'border-main-divider lg:border-b w-full py-s lg:py-xl';
13911
+ const TariffsTableRowContainer = JSX(({ children, tableInner, onClick }) => (jsxs("div", { className: style('self-start flex flex-col gap-xl', DIVIDER_STYLE), role: "row", children: [jsx("div", { className: style('flex flex-col lg:flex-row gap-x-5xl gap-y-xs'), children: children }), tableInner ? (jsx("div", { className: "origin-top animate-expansion", children: jsx(InnerTable, { ...tableInner, onClick: onClick }) })) : null] })));
13912
+
13913
+ const RATES_COLUMN_STYLE = `grid grid-cols-3 gap-s`;
13914
+ const Rate = UniBlock(({ currencyPair = '', buyRate = 0, sellRate = 0 }) => (jsxs("div", { className: style('mb-s', RATES_COLUMN_STYLE, DIVIDER_STYLE), children: [jsx("div", { children: formatCurrencyPair(currencyPair) }), jsx("div", { children: formatRate(buyRate) }), jsx("div", { children: formatRate(sellRate) })] })));
13915
+ const formatCurrencyPair = (currency) => currency.replace('_TOD', '');
13916
+ const formatRate = (rate) => rate.toFixed(4);
13917
+
13918
+ const TIMEZONE = 'МСК';
13919
+ const renderDate = ({ dateString, isArchive = false }) => {
13920
+ const date = new Date(String(dateString));
13921
+ const formatTime = date.toLocaleTimeString('ru-RU', {
13922
+ timeZone: 'Europe/Moscow',
13923
+ hour: '2-digit',
13924
+ minute: '2-digit',
13925
+ hour12: false,
13926
+ });
13927
+ const formatDate = date.toLocaleDateString('ru-RU', {
13928
+ timeZone: 'Europe/Moscow',
13929
+ day: 'numeric',
13930
+ month: 'long',
13931
+ year: 'numeric',
13932
+ });
13933
+ return isArchive ? (jsxs("div", { children: [jsx(Paragraph, { color: "text-secondary-text", font: "font-medium", children: formatDate }), jsxs(Paragraph, { color: "text-secondary-text", children: [formatTime, " (", TIMEZONE, ")"] })] })) : (jsxs(Text, { color: "text-secondary-text", children: ["\u041A\u0443\u0440\u0441\u044B \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u0442\u0435\u043B\u044C\u043D\u044B \u043D\u0430 ", formatTime, " (", TIMEZONE, "), ", formatDate] }));
13934
+ };
13935
+
13936
+ const RatesTableItem = JSX(({ isArchive = false, isRatesValid, list = [], infoMessage }) => {
13937
+ const maxDate = isRatesValid
13938
+ ? list.map((item) => item.lastUpdatedAt).reduce((a, b) => (String(a) > String(b) ? a : b))
13939
+ : '';
13940
+ return (jsxs("div", { className: "space-y-xl mb-3xl", children: [maxDate && renderDate({ dateString: maxDate, isArchive }), jsxs("div", { className: style(RATES_COLUMN_STYLE), children: [jsx(Text, { font: "font-medium", children: "\u0412\u0430\u043B\u044E\u0442\u0430" }), jsx(Text, { font: "font-medium", children: "\u041F\u043E\u043A\u0443\u043F\u043A\u0430" }), jsx(Text, { font: "font-medium", children: "\u041F\u0440\u043E\u0434\u0430\u0436\u0430" })] }), list.length > 0 ? (list.map((rate, i) => jsx(Rate, { ...rate }, String(i)))) : (jsx(Paragraph, { children: "\u041E\u0448\u0438\u0431\u043A\u0430 \u043F\u043E\u043B\u0443\u0447\u0435\u043D\u0438\u044F \u0434\u0430\u043D\u043D\u044B\u0445" })), jsx(Paragraph, { color: "text-secondary-text", children: infoMessage })] }));
13941
+ });
13942
+
13943
+ const renderDataPickForm = () => (jsxs("div", { className: "flex justify-start items-end space-x-xl", children: [jsx(DatePicker, { label: "\u0412\u044B\u0431\u0435\u0440\u0438\u0442\u0435 \u0434\u0435\u043D\u044C", maxDate: new Date() }), jsx(SubmitButton$1, { className: "h-fit", children: "\u041F\u043E\u043A\u0430\u0437\u0430\u0442\u044C" })] }));
13944
+
13945
+ const renderLink = (href) => (jsxs(Paragraph, { children: ["\u041F\u043E\u043B\u043D\u044B\u0439 \u0430\u0440\u0445\u0438\u0432 \u0432\u044B \u043C\u043E\u0436\u0435\u0442\u0435 \u043F\u043E\u0441\u043C\u043E\u0442\u0440\u0435\u0442\u044C ", jsx(Link, { href: href, children: "\u0437\u0434\u0435\u0441\u044C" })] }));
13946
+
13947
+ const RatesTable = JSX(({ href, className = '', infoMessage, title, isArchive = false, ...rest }) => {
13948
+ const ratesList = useRates(isArchive);
13949
+ const isRatesValid = ratesList[0].length > 0;
13950
+ return (jsxs(BlockWrapper, { className: style('p-6xl space-y-xl', className), defaultPadding: "p-0", ...rest, children: [jsx(Heading, { className: "mb-xl", children: title }), isArchive ? renderDataPickForm() : null, ratesList.map((list, i) => (jsx(RatesTableItem, { list: list, isRatesValid: isRatesValid, isArchive: isArchive, infoMessage: infoMessage }, String(i)))), href ? renderLink(href) : null] }));
13951
+ });
13952
+
13799
13953
  const RichTextBlock = UniBlock((props) => {
13800
13954
  const { __html, dynamicQueryParamText = {}, dynamicTextSource, richVersion = '', ...rest } = props;
13801
13955
  const formatText = getFormatDynamicText(dynamicQueryParamText, dynamicTextSource?.list, __html);
@@ -14089,85 +14243,6 @@
14089
14243
  : null }));
14090
14244
  });
14091
14245
 
14092
- const useCarouselControls = (props, initialIndex = 0) => {
14093
- const { itemCount, visibleItemCount } = props;
14094
- const [activeIndex, setActiveIndex] = useState(initialIndex);
14095
- const inc = useCallback(() => setActiveIndex((_) => Math.min(_ + 1, itemCount - 1)), [itemCount]);
14096
- const dec = useCallback(() => setActiveIndex((_) => Math.max(_ - 1, 0)), [itemCount]);
14097
- const canInc = visibleItemCount
14098
- ? itemCount > visibleItemCount && activeIndex < itemCount - visibleItemCount
14099
- : activeIndex < itemCount - 1;
14100
- const canDec = activeIndex > 0;
14101
- const isScrollAvailable = canDec || canInc;
14102
- return [
14103
- activeIndex,
14104
- {
14105
- inc,
14106
- dec,
14107
- canInc,
14108
- canDec,
14109
- isScrollAvailable,
14110
- },
14111
- ];
14112
- };
14113
-
14114
- /** @deprecated */
14115
- const renderArrows = ({ className, btnClass, canDec, canInc, dec, inc, }) => canDec || canInc ? (jsxs("div", { children: [canDec ? (jsx(ArrowLeftButton, { wcmsIgnore: true, className: style('absolute z-40', btnClass[0], className), onClick: dec })) : null, canInc ? (jsx(ArrowRightButton, { wcmsIgnore: true, className: style('absolute z-40', btnClass[1], className), onClick: inc })) : null] })) : null;
14116
-
14117
- const COLUMN_WIDTH = 140;
14118
- const getHorizontalShift = (columns, activeColumnIndex) => sum(columns.slice(0, activeColumnIndex).map((_) => _?.cols?.length ?? 1)) * COLUMN_WIDTH;
14119
-
14120
- const renderInnerTableRow = (activeColumnIndex) => (rowData, rowIdx) => {
14121
- if (!rowData?.length) {
14122
- return null;
14123
- }
14124
- const [headerColumn, ...columns] = rowData;
14125
- const columnsStyle = style('flex duration-1000 text-center', rowIdx !== 0 ? 'font-normal' : 'font-light');
14126
- return (jsxs("div", { className: "flex border-main-divider border-b border-solid h-full", children: [headerColumn?.data ? (jsx("div", { className: "whitespace-pre-wrap sm:whitespace-normal w-48 min-w-48 sm:w-56 sm:min-w-56 py-lg pr-lg sm:pr-0", children: jsx(Text, { size: "text-xl", font: "font-light", children: headerColumn.data }) })) : null, jsx("div", { className: "flex flex-grow overflow-hidden", children: jsx("div", { className: columnsStyle, style: {
14127
- transform: `translateX(-${getHorizontalShift(columns, activeColumnIndex)}px)`,
14128
- }, children: columns?.map((_, i) => (jsxs("div", { className: "flex flex-col flex-grow gap-s justify-center py-xl odd:bg-main-divider", children: [_?.data ? jsx(Text, { size: "text-xl", children: _.data }) : null, _?.cols ? renderCols(_.cols, activeColumnIndex) : null] }, `row${i}`))) }) })] }, String(rowIdx)));
14129
- };
14130
- const renderCols = (cols, rowIndex) => cols?.length > 0 ? (jsx("div", { className: style('flex', { 'text-secondary-text': rowIndex === 0 }), children: cols.map((data, i) => (jsx("div", { className: "w-20 mx-lg", children: jsx(Text, { size: "text-h6", font: "font-light", children: data }) }, String(i)))) })) : null;
14131
-
14132
- const InnerTableBodyItem = JSX(({ rows }) => {
14133
- const rowsLength = rows?.[0]?.length ?? 0;
14134
- const CARD_VIEW_COUNT = 5;
14135
- const [activeIndex, controls] = useCarouselControls({
14136
- itemCount: rowsLength,
14137
- visibleItemCount: CARD_VIEW_COUNT,
14138
- });
14139
- return (jsxs("div", { children: [rows?.map(renderInnerTableRow(activeIndex)), renderArrows({
14140
- ...controls,
14141
- btnClass: ['left-3 top-20', 'right-3 top-20'],
14142
- className: '',
14143
- })] }));
14144
- });
14145
-
14146
- const InnerTableBody = JSX(({ activeTabIndex, items }) => (jsx("div", { children: items.map((_, tableIdx) => {
14147
- const key = `activeTabIdx:${activeTabIndex}-tableIdx:${tableIdx}`;
14148
- return (jsxs("div", { className: "w-full @container", children: [jsx("div", { className: "flex py-m px-m bg-white @4xl:bg-gray relative", children: jsx(Text, { size: "text-xl", align: "text-left", children: _.title }) }), jsx("div", { className: "w-full sm:pl-xs overflow-hidden transition-height duration-500 ease-in-out", children: jsx("div", { className: "relative", children: jsx(InnerTableBodyItem, { rows: _.rowsData }) }) })] }, key));
14149
- }) })));
14150
-
14151
- const linkButtonVersion = 'secondary';
14152
-
14153
- const TableColor = (isEqual = false) => `${isEqual ? 'text-white' : 'text-secondary-text'}`;
14154
- const InnerTableHeader = JSX(({ currencies, linkToPDF, activeTabIndex, setActiveTabIndex }) => (jsxs("div", { className: "flex justify-between items-center w-full py-lg", children: [currencies && currencies.length > 1 ? (jsx("div", { className: "flex bg-secondary-light p-2xs rounded-md", children: currencies.map((currency, idx) => (jsx("div", { className: style('rounded-md px-4 py-3 cursor-pointer', {
14155
- 'bg-primary-main': idx === activeTabIndex,
14156
- }), onClick: () => setActiveTabIndex(idx), children: jsx(Text, { size: "text-xl", font: "font-light", color: TableColor(idx === activeTabIndex), children: currency || idx + 1 }) }, currency))) })) : null, linkToPDF ? (jsx(LinkButton, { className: "text-primary-main", href: linkToPDF, version: linkButtonVersion, target: "_blank", appendLeft: jsx(Icon, { name: "DocDownloadIcon", iconVersion: "color", className: "mr-3xs", width: "20", height: "20" }), text: "\u0421\u043A\u0430\u0447\u0430\u0442\u044C \u0432 PDF" })) : null] })));
14157
-
14158
- const EMPTY_DATA$1 = 'Данных нет';
14159
- const InnerTable = UniBlock(({ tableSource }) => {
14160
- const tableData = tableSource?.tableData;
14161
- const [activeTabIndex, setActiveTabIndex] = useState(0);
14162
- const handleActiveTabIndex = useCallback((_) => setActiveTabIndex(_), []);
14163
- const items = tableData?.[activeTabIndex]?.items ?? [];
14164
- const currencies = tableData?.map((item) => item.currency ?? '');
14165
- return tableData ? (jsxs("div", { className: "bg-white z-10", children: [jsx(InnerTableHeader, { currencies: currencies, activeTabIndex: activeTabIndex, setActiveTabIndex: handleActiveTabIndex }), jsx(InnerTableBody, { activeTabIndex: activeTabIndex, items: items })] })) : (jsx("div", { className: "space-y-m text-center", children: jsx(Text, { size: "text-h6", children: EMPTY_DATA$1 }) }));
14166
- });
14167
-
14168
- const DIVIDER_STYLE = 'border-main-divider lg:border-b w-full py-s lg:py-xl';
14169
- const TariffsTableRowContainer = JSX(({ children, tableInner, onClick }) => (jsxs("div", { className: style('self-start flex flex-col gap-xl', DIVIDER_STYLE), role: "row", children: [jsx("div", { className: style('flex flex-col lg:flex-row gap-x-5xl gap-y-xs'), children: children }), tableInner ? (jsx("div", { className: "origin-top animate-expansion", children: jsx(InnerTable, { ...tableInner, onClick: onClick }) })) : null] })));
14170
-
14171
14246
  const TariffsTableRow = JSX(({ row: { header, data = [] }, ...rest }) => {
14172
14247
  const [tableInner, setTableInner] = useState(undefined);
14173
14248
  const handleSetTableInner = useCallback((_) => {
@@ -14269,6 +14344,7 @@
14269
14344
  CashbackCalculator,
14270
14345
  CalculatorRko,
14271
14346
  RkoTariffCardsTable,
14347
+ RatesTable,
14272
14348
  };
14273
14349
 
14274
14350
  const applyAspects = (aspects) => (ev) => {
@@ -14413,7 +14489,7 @@
14413
14489
  slots: () => [HEADER_SLOT, FOOTER_SLOT, STICKY_FOOTER_SLOT],
14414
14490
  });
14415
14491
 
14416
- const packageVersion = "0.14.1026";
14492
+ const packageVersion = "0.14.1027";
14417
14493
 
14418
14494
  exports.Blocks = Blocks;
14419
14495
  exports.ContentPage = ContentPage;