@redneckz/wildless-cms-uni-blocks 0.14.1026 → 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 (187) hide show
  1. package/bundle/blocks.schema.json +1 -1
  2. package/bundle/bundle.umd.js +353 -244
  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/model/LinkProps.d.ts +2 -0
  12. package/bundle/ui-kit/LinkButton/LinkButtonContent.d.ts +11 -0
  13. package/bundle/ui-kit/Rate/Rate.d.ts +12 -0
  14. package/dist/components/Blocks.js +2 -0
  15. package/dist/components/Blocks.js.map +1 -1
  16. package/dist/components/Blocks.mobile.js +2 -0
  17. package/dist/components/Blocks.mobile.js.map +1 -1
  18. package/dist/components/RatesTable/RatesTable.d.ts +6 -0
  19. package/dist/components/RatesTable/RatesTable.js +17 -0
  20. package/dist/components/RatesTable/RatesTable.js.map +1 -0
  21. package/dist/components/RatesTable/RatesTableContent.d.ts +12 -0
  22. package/dist/components/RatesTable/RatesTableContent.js +2 -0
  23. package/dist/components/RatesTable/RatesTableContent.js.map +1 -0
  24. package/dist/components/RatesTable/RatesTableItem.d.ts +9 -0
  25. package/dist/components/RatesTable/RatesTableItem.js +16 -0
  26. package/dist/components/RatesTable/RatesTableItem.js.map +1 -0
  27. package/dist/components/RatesTable/renderDataPickForm.d.ts +1 -0
  28. package/dist/components/RatesTable/renderDataPickForm.js +8 -0
  29. package/dist/components/RatesTable/renderDataPickForm.js.map +1 -0
  30. package/dist/components/RatesTable/renderDate.d.ts +6 -0
  31. package/dist/components/RatesTable/renderDate.js +24 -0
  32. package/dist/components/RatesTable/renderDate.js.map +1 -0
  33. package/dist/components/RatesTable/renderLink.d.ts +1 -0
  34. package/dist/components/RatesTable/renderLink.js +8 -0
  35. package/dist/components/RatesTable/renderLink.js.map +1 -0
  36. package/dist/hooks/useRates.d.ts +4 -0
  37. package/dist/hooks/useRates.js +42 -0
  38. package/dist/hooks/useRates.js.map +1 -0
  39. package/dist/model/LinkProps.d.ts +2 -0
  40. package/dist/ui-kit/LinkButton/LinkButton.js +36 -2
  41. package/dist/ui-kit/LinkButton/LinkButton.js.map +1 -1
  42. package/dist/ui-kit/LinkButton/LinkButtonContent.d.ts +11 -0
  43. package/dist/ui-kit/Rate/Rate.d.ts +12 -0
  44. package/dist/ui-kit/Rate/Rate.js +11 -0
  45. package/dist/ui-kit/Rate/Rate.js.map +1 -0
  46. package/lib/common.css +1 -1
  47. package/lib/components/Blocks.js +2 -0
  48. package/lib/components/Blocks.js.map +1 -1
  49. package/lib/components/Blocks.mobile.js +2 -0
  50. package/lib/components/Blocks.mobile.js.map +1 -1
  51. package/lib/components/ButtonsBlock/ButtonsBlock.fixture.d.ts +1 -0
  52. package/lib/components/RatesTable/RatesTable.d.ts +6 -0
  53. package/lib/components/RatesTable/RatesTable.fixture.d.ts +6 -0
  54. package/lib/components/RatesTable/RatesTable.fixture.mobile.d.ts +6 -0
  55. package/lib/components/RatesTable/RatesTable.js +15 -0
  56. package/lib/components/RatesTable/RatesTable.js.map +1 -0
  57. package/lib/components/RatesTable/RatesTableContent.d.ts +12 -0
  58. package/lib/components/RatesTable/RatesTableContent.js +2 -0
  59. package/lib/components/RatesTable/RatesTableContent.js.map +1 -0
  60. package/lib/components/RatesTable/RatesTableItem.d.ts +9 -0
  61. package/lib/components/RatesTable/RatesTableItem.js +14 -0
  62. package/lib/components/RatesTable/RatesTableItem.js.map +1 -0
  63. package/lib/components/RatesTable/renderDataPickForm.d.ts +1 -0
  64. package/lib/components/RatesTable/renderDataPickForm.js +5 -0
  65. package/lib/components/RatesTable/renderDataPickForm.js.map +1 -0
  66. package/lib/components/RatesTable/renderDate.d.ts +6 -0
  67. package/lib/components/RatesTable/renderDate.js +21 -0
  68. package/lib/components/RatesTable/renderDate.js.map +1 -0
  69. package/lib/components/RatesTable/renderLink.d.ts +1 -0
  70. package/lib/components/RatesTable/renderLink.js +5 -0
  71. package/lib/components/RatesTable/renderLink.js.map +1 -0
  72. package/lib/hooks/useRates.d.ts +4 -0
  73. package/lib/hooks/useRates.js +39 -0
  74. package/lib/hooks/useRates.js.map +1 -0
  75. package/lib/model/LinkProps.d.ts +2 -0
  76. package/lib/ui-kit/LinkButton/LinkButton.js +36 -2
  77. package/lib/ui-kit/LinkButton/LinkButton.js.map +1 -1
  78. package/lib/ui-kit/LinkButton/LinkButtonContent.d.ts +11 -0
  79. package/lib/ui-kit/Rate/Rate.d.ts +12 -0
  80. package/lib/ui-kit/Rate/Rate.js +9 -0
  81. package/lib/ui-kit/Rate/Rate.js.map +1 -0
  82. package/mobile/bundle/bundle.umd.js +318 -209
  83. package/mobile/bundle/bundle.umd.min.js +1 -1
  84. package/mobile/bundle/components/RatesTable/RatesTable.d.ts +6 -0
  85. package/mobile/bundle/components/RatesTable/RatesTableContent.d.ts +12 -0
  86. package/mobile/bundle/components/RatesTable/RatesTableItem.d.ts +9 -0
  87. package/mobile/bundle/components/RatesTable/renderDataPickForm.d.ts +1 -0
  88. package/mobile/bundle/components/RatesTable/renderDate.d.ts +6 -0
  89. package/mobile/bundle/components/RatesTable/renderLink.d.ts +1 -0
  90. package/mobile/bundle/hooks/useRates.d.ts +4 -0
  91. package/mobile/bundle/model/LinkProps.d.ts +2 -0
  92. package/mobile/bundle/ui-kit/LinkButton/LinkButtonContent.d.ts +11 -0
  93. package/mobile/bundle/ui-kit/Rate/Rate.d.ts +12 -0
  94. package/mobile/dist/components/Blocks.js +2 -0
  95. package/mobile/dist/components/Blocks.js.map +1 -1
  96. package/mobile/dist/components/RatesTable/RatesTable.d.ts +6 -0
  97. package/mobile/dist/components/RatesTable/RatesTable.js +17 -0
  98. package/mobile/dist/components/RatesTable/RatesTable.js.map +1 -0
  99. package/mobile/dist/components/RatesTable/RatesTableContent.d.ts +12 -0
  100. package/mobile/dist/components/RatesTable/RatesTableContent.js +2 -0
  101. package/mobile/dist/components/RatesTable/RatesTableContent.js.map +1 -0
  102. package/mobile/dist/components/RatesTable/RatesTableItem.d.ts +9 -0
  103. package/mobile/dist/components/RatesTable/RatesTableItem.js +16 -0
  104. package/mobile/dist/components/RatesTable/RatesTableItem.js.map +1 -0
  105. package/mobile/dist/components/RatesTable/renderDataPickForm.d.ts +1 -0
  106. package/mobile/dist/components/RatesTable/renderDataPickForm.js +8 -0
  107. package/mobile/dist/components/RatesTable/renderDataPickForm.js.map +1 -0
  108. package/mobile/dist/components/RatesTable/renderDate.d.ts +6 -0
  109. package/mobile/dist/components/RatesTable/renderDate.js +24 -0
  110. package/mobile/dist/components/RatesTable/renderDate.js.map +1 -0
  111. package/mobile/dist/components/RatesTable/renderLink.d.ts +1 -0
  112. package/mobile/dist/components/RatesTable/renderLink.js +8 -0
  113. package/mobile/dist/components/RatesTable/renderLink.js.map +1 -0
  114. package/mobile/dist/hooks/useRates.d.ts +4 -0
  115. package/mobile/dist/hooks/useRates.js +42 -0
  116. package/mobile/dist/hooks/useRates.js.map +1 -0
  117. package/mobile/dist/model/LinkProps.d.ts +2 -0
  118. package/mobile/dist/ui-kit/LinkButton/LinkButton.js +36 -2
  119. package/mobile/dist/ui-kit/LinkButton/LinkButton.js.map +1 -1
  120. package/mobile/dist/ui-kit/LinkButton/LinkButtonContent.d.ts +11 -0
  121. package/mobile/dist/ui-kit/Rate/Rate.d.ts +12 -0
  122. package/mobile/dist/ui-kit/Rate/Rate.js +11 -0
  123. package/mobile/dist/ui-kit/Rate/Rate.js.map +1 -0
  124. package/mobile/lib/common.css +1 -1
  125. package/mobile/lib/components/Blocks.js +2 -0
  126. package/mobile/lib/components/Blocks.js.map +1 -1
  127. package/mobile/lib/components/RatesTable/RatesTable.d.ts +6 -0
  128. package/mobile/lib/components/RatesTable/RatesTable.js +15 -0
  129. package/mobile/lib/components/RatesTable/RatesTable.js.map +1 -0
  130. package/mobile/lib/components/RatesTable/RatesTableContent.d.ts +12 -0
  131. package/mobile/lib/components/RatesTable/RatesTableContent.js +2 -0
  132. package/mobile/lib/components/RatesTable/RatesTableContent.js.map +1 -0
  133. package/mobile/lib/components/RatesTable/RatesTableItem.d.ts +9 -0
  134. package/mobile/lib/components/RatesTable/RatesTableItem.js +14 -0
  135. package/mobile/lib/components/RatesTable/RatesTableItem.js.map +1 -0
  136. package/mobile/lib/components/RatesTable/renderDataPickForm.d.ts +1 -0
  137. package/mobile/lib/components/RatesTable/renderDataPickForm.js +5 -0
  138. package/mobile/lib/components/RatesTable/renderDataPickForm.js.map +1 -0
  139. package/mobile/lib/components/RatesTable/renderDate.d.ts +6 -0
  140. package/mobile/lib/components/RatesTable/renderDate.js +21 -0
  141. package/mobile/lib/components/RatesTable/renderDate.js.map +1 -0
  142. package/mobile/lib/components/RatesTable/renderLink.d.ts +1 -0
  143. package/mobile/lib/components/RatesTable/renderLink.js +5 -0
  144. package/mobile/lib/components/RatesTable/renderLink.js.map +1 -0
  145. package/mobile/lib/hooks/useRates.d.ts +4 -0
  146. package/mobile/lib/hooks/useRates.js +39 -0
  147. package/mobile/lib/hooks/useRates.js.map +1 -0
  148. package/mobile/lib/model/LinkProps.d.ts +2 -0
  149. package/mobile/lib/ui-kit/LinkButton/LinkButton.js +36 -2
  150. package/mobile/lib/ui-kit/LinkButton/LinkButton.js.map +1 -1
  151. package/mobile/lib/ui-kit/LinkButton/LinkButtonContent.d.ts +11 -0
  152. package/mobile/lib/ui-kit/Rate/Rate.d.ts +12 -0
  153. package/mobile/lib/ui-kit/Rate/Rate.js +9 -0
  154. package/mobile/lib/ui-kit/Rate/Rate.js.map +1 -0
  155. package/mobile/src/components/Blocks.ts +2 -0
  156. package/mobile/src/components/RatesTable/RatesTable.example.json +7 -0
  157. package/mobile/src/components/RatesTable/RatesTable.tsx +38 -0
  158. package/mobile/src/components/RatesTable/RatesTable.ui.json +7 -0
  159. package/mobile/src/components/RatesTable/RatesTableContent.ts +13 -0
  160. package/mobile/src/components/RatesTable/RatesTableItem.tsx +39 -0
  161. package/mobile/src/components/RatesTable/renderDataPickForm.tsx +9 -0
  162. package/mobile/src/components/RatesTable/renderDate.tsx +42 -0
  163. package/mobile/src/components/RatesTable/renderLink.tsx +8 -0
  164. package/mobile/src/hooks/useRates.ts +65 -0
  165. package/mobile/src/model/LinkProps.ts +2 -0
  166. package/mobile/src/ui-kit/LinkButton/LinkButton.tsx +54 -2
  167. package/mobile/src/ui-kit/LinkButton/LinkButtonContent.ts +12 -0
  168. package/mobile/src/ui-kit/Rate/Rate.tsx +27 -0
  169. package/package.json +1 -1
  170. package/src/components/Blocks.mobile.ts +2 -0
  171. package/src/components/Blocks.ts +2 -0
  172. package/src/components/ButtonsBlock/ButtonsBlock.fixture.tsx +21 -0
  173. package/src/components/RatesTable/RatesTable.example.json +7 -0
  174. package/src/components/RatesTable/RatesTable.fixture.mobile.tsx +26 -0
  175. package/src/components/RatesTable/RatesTable.fixture.tsx +26 -0
  176. package/src/components/RatesTable/RatesTable.tsx +38 -0
  177. package/src/components/RatesTable/RatesTable.ui.json +7 -0
  178. package/src/components/RatesTable/RatesTableContent.ts +13 -0
  179. package/src/components/RatesTable/RatesTableItem.tsx +39 -0
  180. package/src/components/RatesTable/renderDataPickForm.tsx +9 -0
  181. package/src/components/RatesTable/renderDate.tsx +42 -0
  182. package/src/components/RatesTable/renderLink.tsx +8 -0
  183. package/src/hooks/useRates.ts +65 -0
  184. package/src/model/LinkProps.ts +2 -0
  185. package/src/ui-kit/LinkButton/LinkButton.tsx +54 -2
  186. package/src/ui-kit/LinkButton/LinkButtonContent.ts +12 -0
  187. package/src/ui-kit/Rate/Rate.tsx +27 -0
@@ -400,24 +400,28 @@
400
400
  className,
401
401
  ].join(' ');
402
402
 
403
- /* eslint-disable @typescript-eslint/ban-types */
404
- const handlerDecorator = (handler) => {
405
- return handlerDecorator._impl(handler);
406
- };
407
- handlerDecorator._impl = (handler) => handler;
408
- handlerDecorator.setup = (impl) => {
409
- handlerDecorator._impl = impl;
410
- };
403
+ function copy(source, target) {
404
+ for (const [k, v] of source.entries()) {
405
+ if (v !== null && v !== undefined) {
406
+ target.setItem(k, v);
407
+ }
408
+ else {
409
+ target.removeItem(k);
410
+ }
411
+ }
412
+ }
411
413
 
412
- function useEmitterWithActions(eventBus, type) {
413
- const cache = useRef({});
414
- return useMemo(() => new Proxy({}, {
415
- get(_, actionType) {
416
- cache.current ||= {};
417
- cache.current[actionType] ||= action => eventBus.fire(type, { ...(action ?? {}), type: actionType });
418
- return cache.current[actionType];
414
+ function replicate(primary, secondary) {
415
+ copy(primary, secondary);
416
+ copy(secondary, primary);
417
+ return primary.bus.watch(({ type, event }) => {
418
+ if (event !== null && event !== undefined) {
419
+ secondary.setItem(type, event);
419
420
  }
420
- }), [eventBus, type]);
421
+ else {
422
+ secondary.removeItem(type);
423
+ }
424
+ });
421
425
  }
422
426
 
423
427
  class EventBus {
@@ -469,6 +473,146 @@
469
473
  }
470
474
  }
471
475
 
476
+ class StorageAdapter {
477
+ storage;
478
+ bus;
479
+ get size() {
480
+ return this.storage?.length ?? 0;
481
+ }
482
+ constructor(storage, bus = new EventBus()) {
483
+ this.storage = storage;
484
+ this.bus = bus;
485
+ }
486
+ hasItem(key) {
487
+ return Boolean(this.storage?.getItem(String(key)));
488
+ }
489
+ getItem(key) {
490
+ const _ = this.storage?.getItem(String(key)) ?? null;
491
+ try {
492
+ return JSON.parse(String(_));
493
+ }
494
+ catch (ex) {
495
+ return null;
496
+ }
497
+ }
498
+ entries() {
499
+ return Array.from({ length: this.size }, (_, i) => {
500
+ const k = String(this.storage?.key(i));
501
+ return [k, this.getItem(k)];
502
+ });
503
+ }
504
+ setItem(key, value) {
505
+ if (value !== null) {
506
+ this.storage?.setItem(String(key), JSON.stringify(value));
507
+ }
508
+ else {
509
+ this.storage?.removeItem(String(key));
510
+ }
511
+ this.bus?.subject(key, value);
512
+ }
513
+ removeItem(key) {
514
+ this.storage?.removeItem(String(key));
515
+ this.bus?.subject(key, null);
516
+ }
517
+ }
518
+
519
+ class Store {
520
+ bus;
521
+ store = new Map();
522
+ get size() {
523
+ return this.store.size;
524
+ }
525
+ constructor(bus = new EventBus()) {
526
+ this.bus = bus;
527
+ }
528
+ hasItem(key) {
529
+ return this.store.has(key);
530
+ }
531
+ getItem(key) {
532
+ return this.store.get(key);
533
+ }
534
+ entries() {
535
+ return this.store.entries();
536
+ }
537
+ setItem(key, value) {
538
+ this.store.set(key, value);
539
+ this.bus.subject(key, value);
540
+ }
541
+ removeItem(key) {
542
+ this.store.delete(key);
543
+ this.bus.subject(key, null);
544
+ }
545
+ }
546
+
547
+ function useRerender() {
548
+ const [, setCount] = useState(0);
549
+ return useCallback(() => setCount(_ => (_ + 1) % (1 << 16)), []);
550
+ }
551
+
552
+ const DEFAULT_METHODS = {};
553
+ /**
554
+ * MobX like reactivity (simplified).
555
+ * Can be used to migrate from Redux/MobX or something else
556
+ *
557
+ * @param store
558
+ * @returns reactive proxy backed by store
559
+ */
560
+ function useStore(store, methods = DEFAULT_METHODS) {
561
+ const deps = useRef(null);
562
+ const render = useRerender();
563
+ useEffect(() => store.bus.watch(ev => {
564
+ if (deps.current?.has(String(ev.type))) {
565
+ render();
566
+ }
567
+ }), [store, render]);
568
+ return useMemo(() => new Proxy(methods, {
569
+ get(_, key) {
570
+ deps.current ||= new Set();
571
+ deps.current.add(key);
572
+ return store.getItem(key);
573
+ },
574
+ has(_, key) {
575
+ deps.current ||= new Set();
576
+ deps.current.add(key);
577
+ return store.hasItem(key);
578
+ },
579
+ set(_, key, value) {
580
+ store.setItem(key, value);
581
+ return true;
582
+ },
583
+ deleteProperty(_, key) {
584
+ store.removeItem(key);
585
+ return true;
586
+ }
587
+ }), [store]);
588
+ }
589
+
590
+ const localStore = new Store(); // localStorage cache
591
+ replicate(localStore, new StorageAdapter(globalThis?.localStorage));
592
+ function useLocalStore(methods) {
593
+ return useStore(localStore, methods);
594
+ }
595
+
596
+ /* eslint-disable @typescript-eslint/ban-types */
597
+ const handlerDecorator = (handler) => {
598
+ return handlerDecorator._impl(handler);
599
+ };
600
+ handlerDecorator._impl = (handler) => handler;
601
+ handlerDecorator.setup = (impl) => {
602
+ handlerDecorator._impl = impl;
603
+ };
604
+
605
+ function useEmitterWithActions(eventBus, type) {
606
+ const cache = useRef({});
607
+ return useMemo(() => new Proxy({}, {
608
+ get(_, actionType) {
609
+ cache.current ||= {};
610
+ cache.current[actionType] ||= action => eventBus.fire(type, { ...(action ?? {}), type: actionType });
611
+ return cache.current[actionType];
612
+ }
613
+ }), [eventBus, type]);
614
+ }
615
+
472
616
  const defaultEventBus = new EventBus();
473
617
 
474
618
  const useDialogManager = () => useEmitterWithActions(defaultEventBus.emitter, 'dialog');
@@ -562,15 +706,48 @@
562
706
  }, [method, href]);
563
707
 
564
708
  /** @deprecated */
565
- const LinkButton = JSX(({ disabled, children, method = 'LINK', href, ...rest }) => {
709
+ const LinkButton = JSX(({ disabled, children, method = 'LINK', href, id, additionalHrefs, ...rest }) => {
566
710
  const handleFormSubmit = useFormSubmit({ method, href });
711
+ const linksStore = useLocalStore();
712
+ saveLinksToStore({ linksStore, href, id, additionalHrefs });
713
+ const adjustedHref = additionalHrefs
714
+ ? (linksStore.links || []).find((store) => store.id === id)?.lastLink
715
+ : href;
567
716
  const link = useLink();
568
- const adjustedProps = link({ onClick: handleFormSubmit, href, ...rest });
717
+ const adjustedProps = link({ onClick: handleFormSubmit, href: adjustedHref, ...rest });
569
718
  const buttonInner = children ?? jsx(ButtonInner, { ...adjustedProps });
570
719
  return disabled ? (jsx(DisabledButton, { ...adjustedProps, children: buttonInner })) : (jsx(RegularButton, { ...adjustedProps, children: buttonInner }));
571
720
  });
572
721
  const RegularButton = JSX(({ className = '', href, rel, target, ariaLabel, version, rounded, onClick, type, data, children, text, }) => (jsx("a", { className: getRegularButtonClasses({ className, version, rounded }), href: href, rel: rel, target: target, "aria-label": ariaLabel || `Ссылка на ${text}`, role: href ? 'link' : 'button', onClick: onClick, type: type, ...getAspectsAttributes(data), children: children })));
573
722
  const DisabledButton = JSX(({ className, ariaLabel, version, rounded, children }) => (jsx("button", { type: "button", "aria-disabled": "true", "aria-label": ariaLabel, tabIndex: -1, className: getDisabledButtonClasses({ className, rounded, version }), children: children })));
723
+ const getRandomHref = (href = '', additionalHrefs = []) => {
724
+ const hrefs = [href, ...additionalHrefs];
725
+ return hrefs[Math.floor(Math.random() * hrefs.length)];
726
+ };
727
+ // Отсчитываем 7 длей с текущей даты
728
+ const getTimeAfter7days = () => Date.now() + 7 * 24 * 60 * 60 * 1000;
729
+ // Сохраняем или заменяем рандомную ссылку в localStorage
730
+ const saveLinksToStore = ({ linksStore, id, href, additionalHrefs }) => {
731
+ const buttonLinkStore = (linksStore.links || []).find((store) => store.id === id);
732
+ // Если хранилища вообще нет
733
+ if (!linksStore.links) {
734
+ linksStore.links = [];
735
+ }
736
+ if ((!buttonLinkStore || buttonLinkStore.nextDueAt <= Date.now()) && additionalHrefs) {
737
+ // Получаем рандомную ссылку
738
+ const randomHref = getRandomHref(href, additionalHrefs);
739
+ // При наличии ссылки для этой кнопки в хранилище удаляем этот элемент из массива ссылок
740
+ const updatedLinks = linksStore.links?.filter((item) => item.id !== id);
741
+ // Добавляем новый элемент
742
+ updatedLinks.push({
743
+ id: id ?? '',
744
+ lastLink: randomHref,
745
+ nextDueAt: getTimeAfter7days(),
746
+ });
747
+ // Добавляем это все в хранилище
748
+ linksStore.links = updatedLinks;
749
+ }
750
+ };
574
751
 
575
752
  // TODO Заменить LinkButton на Button и применить RoundedIcon
576
753
  function renderBackwardButton({ version, handleClick, text = 'Вернуться назад', alwaysVisible = false, }) {
@@ -1376,150 +1553,6 @@
1376
1553
  return (jsx(Dialog, { maxWidth: "lg", onClose: onClose, children: jsxs("div", { className: "flex flex-col gap-lg items-center rounded-md space-x-m", children: [jsx(Img, { image: { icon: statusIcon, iconVersion: 'normal' }, width: "136", height: "136" }), jsx(Headline, { className: "w-full", title: ok ? 'Ваша заявка отправлена' : 'Не удалось отправить заявку', description: ok ? responseOKDescription : responseFailDescription, headlineVersion: "XS", isEmbedded: true }), jsx(Button, { type: "button", onClick: onClose, children: "\u0425\u043E\u0440\u043E\u0448\u043E" })] }) }));
1377
1554
  });
1378
1555
 
1379
- function copy(source, target) {
1380
- for (const [k, v] of source.entries()) {
1381
- if (v !== null && v !== undefined) {
1382
- target.setItem(k, v);
1383
- }
1384
- else {
1385
- target.removeItem(k);
1386
- }
1387
- }
1388
- }
1389
-
1390
- function replicate(primary, secondary) {
1391
- copy(primary, secondary);
1392
- copy(secondary, primary);
1393
- return primary.bus.watch(({ type, event }) => {
1394
- if (event !== null && event !== undefined) {
1395
- secondary.setItem(type, event);
1396
- }
1397
- else {
1398
- secondary.removeItem(type);
1399
- }
1400
- });
1401
- }
1402
-
1403
- class StorageAdapter {
1404
- storage;
1405
- bus;
1406
- get size() {
1407
- return this.storage?.length ?? 0;
1408
- }
1409
- constructor(storage, bus = new EventBus()) {
1410
- this.storage = storage;
1411
- this.bus = bus;
1412
- }
1413
- hasItem(key) {
1414
- return Boolean(this.storage?.getItem(String(key)));
1415
- }
1416
- getItem(key) {
1417
- const _ = this.storage?.getItem(String(key)) ?? null;
1418
- try {
1419
- return JSON.parse(String(_));
1420
- }
1421
- catch (ex) {
1422
- return null;
1423
- }
1424
- }
1425
- entries() {
1426
- return Array.from({ length: this.size }, (_, i) => {
1427
- const k = String(this.storage?.key(i));
1428
- return [k, this.getItem(k)];
1429
- });
1430
- }
1431
- setItem(key, value) {
1432
- if (value !== null) {
1433
- this.storage?.setItem(String(key), JSON.stringify(value));
1434
- }
1435
- else {
1436
- this.storage?.removeItem(String(key));
1437
- }
1438
- this.bus?.subject(key, value);
1439
- }
1440
- removeItem(key) {
1441
- this.storage?.removeItem(String(key));
1442
- this.bus?.subject(key, null);
1443
- }
1444
- }
1445
-
1446
- class Store {
1447
- bus;
1448
- store = new Map();
1449
- get size() {
1450
- return this.store.size;
1451
- }
1452
- constructor(bus = new EventBus()) {
1453
- this.bus = bus;
1454
- }
1455
- hasItem(key) {
1456
- return this.store.has(key);
1457
- }
1458
- getItem(key) {
1459
- return this.store.get(key);
1460
- }
1461
- entries() {
1462
- return this.store.entries();
1463
- }
1464
- setItem(key, value) {
1465
- this.store.set(key, value);
1466
- this.bus.subject(key, value);
1467
- }
1468
- removeItem(key) {
1469
- this.store.delete(key);
1470
- this.bus.subject(key, null);
1471
- }
1472
- }
1473
-
1474
- function useRerender() {
1475
- const [, setCount] = useState(0);
1476
- return useCallback(() => setCount(_ => (_ + 1) % (1 << 16)), []);
1477
- }
1478
-
1479
- const DEFAULT_METHODS = {};
1480
- /**
1481
- * MobX like reactivity (simplified).
1482
- * Can be used to migrate from Redux/MobX or something else
1483
- *
1484
- * @param store
1485
- * @returns reactive proxy backed by store
1486
- */
1487
- function useStore(store, methods = DEFAULT_METHODS) {
1488
- const deps = useRef(null);
1489
- const render = useRerender();
1490
- useEffect(() => store.bus.watch(ev => {
1491
- if (deps.current?.has(String(ev.type))) {
1492
- render();
1493
- }
1494
- }), [store, render]);
1495
- return useMemo(() => new Proxy(methods, {
1496
- get(_, key) {
1497
- deps.current ||= new Set();
1498
- deps.current.add(key);
1499
- return store.getItem(key);
1500
- },
1501
- has(_, key) {
1502
- deps.current ||= new Set();
1503
- deps.current.add(key);
1504
- return store.hasItem(key);
1505
- },
1506
- set(_, key, value) {
1507
- store.setItem(key, value);
1508
- return true;
1509
- },
1510
- deleteProperty(_, key) {
1511
- store.removeItem(key);
1512
- return true;
1513
- }
1514
- }), [store]);
1515
- }
1516
-
1517
- const localStore = new Store(); // localStorage cache
1518
- replicate(localStore, new StorageAdapter(globalThis?.localStorage));
1519
- function useLocalStore(methods) {
1520
- return useStore(localStore, methods);
1521
- }
1522
-
1523
1556
  const sessionStore = new Store(); // sessionStorage cache
1524
1557
  replicate(sessionStore, new StorageAdapter(globalThis?.sessionStorage));
1525
1558
  function useSessionStore() {
@@ -8759,11 +8792,11 @@
8759
8792
  return (jsx(BlockWrapper, { className: style('!bg-transparent', alignStyle, className), defaultPadding: "p-0", ...rest, children: renderButtonsSection(buttons) }));
8760
8793
  });
8761
8794
 
8762
- 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] })] })));
8763
8796
 
8764
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" }) })] })));
8765
8798
 
8766
- 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 }));
8767
8800
 
8768
8801
  const DEFAULT_BONUS_CALCULATOR_PARAMS$1 = {
8769
8802
  minSumTravel: 6000,
@@ -13763,6 +13796,160 @@
13763
13796
  return (jsx(BlockWrapper, { version: "transparent", className: style(className), defaultPadding: "p-0", ...rest, children: dataType === 'offices' ? jsx(OfficesMap, {}) : jsx(AtmsMap, { descriptionData: data }) }));
13764
13797
  });
13765
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
+
13766
13953
  const RichTextBlock = UniBlock((props) => {
13767
13954
  const { __html, dynamicQueryParamText = {}, dynamicTextSource, richVersion = '', ...rest } = props;
13768
13955
  const formatText = getFormatDynamicText(dynamicQueryParamText, dynamicTextSource?.list, __html);
@@ -14056,85 +14243,6 @@
14056
14243
  : null }));
14057
14244
  });
14058
14245
 
14059
- const useCarouselControls = (props, initialIndex = 0) => {
14060
- const { itemCount, visibleItemCount } = props;
14061
- const [activeIndex, setActiveIndex] = useState(initialIndex);
14062
- const inc = useCallback(() => setActiveIndex((_) => Math.min(_ + 1, itemCount - 1)), [itemCount]);
14063
- const dec = useCallback(() => setActiveIndex((_) => Math.max(_ - 1, 0)), [itemCount]);
14064
- const canInc = visibleItemCount
14065
- ? itemCount > visibleItemCount && activeIndex < itemCount - visibleItemCount
14066
- : activeIndex < itemCount - 1;
14067
- const canDec = activeIndex > 0;
14068
- const isScrollAvailable = canDec || canInc;
14069
- return [
14070
- activeIndex,
14071
- {
14072
- inc,
14073
- dec,
14074
- canInc,
14075
- canDec,
14076
- isScrollAvailable,
14077
- },
14078
- ];
14079
- };
14080
-
14081
- /** @deprecated */
14082
- 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;
14083
-
14084
- const COLUMN_WIDTH = 140;
14085
- const getHorizontalShift = (columns, activeColumnIndex) => sum(columns.slice(0, activeColumnIndex).map((_) => _?.cols?.length ?? 1)) * COLUMN_WIDTH;
14086
-
14087
- const renderInnerTableRow = (activeColumnIndex) => (rowData, rowIdx) => {
14088
- if (!rowData?.length) {
14089
- return null;
14090
- }
14091
- const [headerColumn, ...columns] = rowData;
14092
- const columnsStyle = style('flex duration-1000 text-center', rowIdx !== 0 ? 'font-normal' : 'font-light');
14093
- 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: {
14094
- transform: `translateX(-${getHorizontalShift(columns, activeColumnIndex)}px)`,
14095
- }, 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)));
14096
- };
14097
- 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;
14098
-
14099
- const InnerTableBodyItem = JSX(({ rows }) => {
14100
- const rowsLength = rows?.[0]?.length ?? 0;
14101
- const CARD_VIEW_COUNT = 5;
14102
- const [activeIndex, controls] = useCarouselControls({
14103
- itemCount: rowsLength,
14104
- visibleItemCount: CARD_VIEW_COUNT,
14105
- });
14106
- return (jsxs("div", { children: [rows?.map(renderInnerTableRow(activeIndex)), renderArrows({
14107
- ...controls,
14108
- btnClass: ['left-3 top-20', 'right-3 top-20'],
14109
- className: '',
14110
- })] }));
14111
- });
14112
-
14113
- const InnerTableBody = JSX(({ activeTabIndex, items }) => (jsx("div", { children: items.map((_, tableIdx) => {
14114
- const key = `activeTabIdx:${activeTabIndex}-tableIdx:${tableIdx}`;
14115
- 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));
14116
- }) })));
14117
-
14118
- const linkButtonVersion = 'secondary';
14119
-
14120
- const TableColor = (isEqual = false) => `${isEqual ? 'text-white' : 'text-secondary-text'}`;
14121
- 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', {
14122
- 'bg-primary-main': idx === activeTabIndex,
14123
- }), 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] })));
14124
-
14125
- const EMPTY_DATA$1 = 'Данных нет';
14126
- const InnerTable = UniBlock(({ tableSource }) => {
14127
- const tableData = tableSource?.tableData;
14128
- const [activeTabIndex, setActiveTabIndex] = useState(0);
14129
- const handleActiveTabIndex = useCallback((_) => setActiveTabIndex(_), []);
14130
- const items = tableData?.[activeTabIndex]?.items ?? [];
14131
- const currencies = tableData?.map((item) => item.currency ?? '');
14132
- 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 }) }));
14133
- });
14134
-
14135
- const DIVIDER_STYLE = 'border-main-divider lg:border-b w-full py-s lg:py-xl';
14136
- 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] })));
14137
-
14138
14246
  const TariffsTableRow = JSX(({ row: { header, data = [] }, ...rest }) => {
14139
14247
  const [tableInner, setTableInner] = useState(undefined);
14140
14248
  const handleSetTableInner = useCallback((_) => {
@@ -14236,6 +14344,7 @@
14236
14344
  CashbackCalculator,
14237
14345
  CalculatorRko,
14238
14346
  RkoTariffCardsTable,
14347
+ RatesTable,
14239
14348
  };
14240
14349
 
14241
14350
  const applyAspects = (aspects) => (ev) => {
@@ -14380,7 +14489,7 @@
14380
14489
  slots: () => [HEADER_SLOT, FOOTER_SLOT, STICKY_FOOTER_SLOT],
14381
14490
  });
14382
14491
 
14383
- const packageVersion = "0.14.1025";
14492
+ const packageVersion = "0.14.1027";
14384
14493
 
14385
14494
  exports.Blocks = Blocks;
14386
14495
  exports.ContentPage = ContentPage;