@redneckz/wildless-cms-uni-blocks 0.8.23 → 0.8.24

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 (158) hide show
  1. package/bin/migration-scripts/0.8.17.js +27 -0
  2. package/bundle/blocks.schema.json +1 -1
  3. package/bundle/bundle.umd.js +59 -28
  4. package/bundle/bundle.umd.min.js +1 -1
  5. package/bundle/components/BonusBenefitsBlock/BonusBenefitsBlockContent.d.ts +6 -2
  6. package/bundle/components/Tabs/LinkTab.d.ts +1 -0
  7. package/bundle/hooks/useBranches.d.ts +20 -0
  8. package/bundle/ui-kit/TopItem/TopItem.d.ts +2 -1
  9. package/dist/components/ApplicationForm/ApplicationFormAcquiring.js +1 -1
  10. package/dist/components/ApplicationForm/ApplicationFormAcquiring.js.map +1 -1
  11. package/dist/components/ApplicationForm/ApplicationFormBusinessCard.js +2 -2
  12. package/dist/components/ApplicationForm/ApplicationFormBusinessCard.js.map +1 -1
  13. package/dist/components/ApplicationForm/ApplicationFormCredit.js +5 -5
  14. package/dist/components/ApplicationForm/ApplicationFormCredit.js.map +1 -1
  15. package/dist/components/ApplicationForm/renderBankOffices.js.map +1 -1
  16. package/dist/components/BonusBenefitsBlock/BonusBenefitsBlock.js +2 -2
  17. package/dist/components/BonusBenefitsBlock/BonusBenefitsBlock.js.map +1 -1
  18. package/dist/components/BonusBenefitsBlock/BonusBenefitsBlockContent.d.ts +6 -2
  19. package/dist/components/Calculator/getMonthlyPayment.js +4 -1
  20. package/dist/components/Calculator/getMonthlyPayment.js.map +1 -1
  21. package/dist/components/Header/HeaderSecondaryMenu.js +7 -2
  22. package/dist/components/Header/HeaderSecondaryMenu.js.map +1 -1
  23. package/dist/components/Tabs/LinkTab.d.ts +1 -0
  24. package/dist/components/Tabs/LinkTab.js +6 -2
  25. package/dist/components/Tabs/LinkTab.js.map +1 -1
  26. package/dist/components/Tabs/Tabs.js +15 -3
  27. package/dist/components/Tabs/Tabs.js.map +1 -1
  28. package/dist/components/Tabs/renderTab.js +1 -1
  29. package/dist/components/Tabs/renderTab.js.map +1 -1
  30. package/dist/hooks/useBranches.d.ts +20 -0
  31. package/dist/hooks/useBranches.js +16 -0
  32. package/dist/hooks/useBranches.js.map +1 -0
  33. package/dist/ui-kit/BlockWrapper.js +1 -4
  34. package/dist/ui-kit/BlockWrapper.js.map +1 -1
  35. package/dist/ui-kit/TopItem/TopItem.d.ts +2 -1
  36. package/dist/ui-kit/TopItem/TopItem.js.map +1 -1
  37. package/lib/components/ApplicationForm/ApplicationFormAcquiring.js +1 -1
  38. package/lib/components/ApplicationForm/ApplicationFormAcquiring.js.map +1 -1
  39. package/lib/components/ApplicationForm/ApplicationFormBusinessCard.js +2 -2
  40. package/lib/components/ApplicationForm/ApplicationFormBusinessCard.js.map +1 -1
  41. package/lib/components/ApplicationForm/ApplicationFormCredit.js +5 -5
  42. package/lib/components/ApplicationForm/ApplicationFormCredit.js.map +1 -1
  43. package/lib/components/ApplicationForm/renderBankOffices.js.map +1 -1
  44. package/lib/components/BonusBenefitsBlock/BonusBenefitsBlock.js +2 -2
  45. package/lib/components/BonusBenefitsBlock/BonusBenefitsBlock.js.map +1 -1
  46. package/lib/components/BonusBenefitsBlock/BonusBenefitsBlockContent.d.ts +6 -2
  47. package/lib/components/Calculator/getMonthlyPayment.js +4 -1
  48. package/lib/components/Calculator/getMonthlyPayment.js.map +1 -1
  49. package/lib/components/Header/HeaderSecondaryMenu.js +7 -2
  50. package/lib/components/Header/HeaderSecondaryMenu.js.map +1 -1
  51. package/lib/components/Tabs/LinkTab.d.ts +1 -0
  52. package/lib/components/Tabs/LinkTab.js +6 -2
  53. package/lib/components/Tabs/LinkTab.js.map +1 -1
  54. package/lib/components/Tabs/Tabs.js +15 -3
  55. package/lib/components/Tabs/Tabs.js.map +1 -1
  56. package/lib/components/Tabs/renderTab.js +1 -1
  57. package/lib/components/Tabs/renderTab.js.map +1 -1
  58. package/lib/hooks/useBranches.d.ts +20 -0
  59. package/lib/hooks/useBranches.js +13 -0
  60. package/lib/hooks/useBranches.js.map +1 -0
  61. package/lib/ui-kit/BlockWrapper.js +1 -4
  62. package/lib/ui-kit/BlockWrapper.js.map +1 -1
  63. package/lib/ui-kit/TopItem/TopItem.d.ts +2 -1
  64. package/lib/ui-kit/TopItem/TopItem.js.map +1 -1
  65. package/mobile/bundle/bundle.umd.js +2 -5
  66. package/mobile/bundle/bundle.umd.min.js +1 -1
  67. package/mobile/bundle/components/BonusBenefitsBlock/BonusBenefitsBlockContent.d.ts +6 -2
  68. package/mobile/bundle/components/Tabs/LinkTab.d.ts +1 -0
  69. package/mobile/bundle/hooks/useBranches.d.ts +20 -0
  70. package/mobile/bundle/ui-kit/TopItem/TopItem.d.ts +2 -1
  71. package/mobile/dist/components/ApplicationForm/ApplicationFormAcquiring.js +1 -1
  72. package/mobile/dist/components/ApplicationForm/ApplicationFormAcquiring.js.map +1 -1
  73. package/mobile/dist/components/ApplicationForm/ApplicationFormBusinessCard.js +2 -2
  74. package/mobile/dist/components/ApplicationForm/ApplicationFormBusinessCard.js.map +1 -1
  75. package/mobile/dist/components/ApplicationForm/ApplicationFormCredit.js +5 -5
  76. package/mobile/dist/components/ApplicationForm/ApplicationFormCredit.js.map +1 -1
  77. package/mobile/dist/components/ApplicationForm/renderBankOffices.js.map +1 -1
  78. package/mobile/dist/components/BonusBenefitsBlock/BonusBenefitsBlock.js +2 -2
  79. package/mobile/dist/components/BonusBenefitsBlock/BonusBenefitsBlock.js.map +1 -1
  80. package/mobile/dist/components/BonusBenefitsBlock/BonusBenefitsBlockContent.d.ts +6 -2
  81. package/mobile/dist/components/Calculator/getMonthlyPayment.js +4 -1
  82. package/mobile/dist/components/Calculator/getMonthlyPayment.js.map +1 -1
  83. package/mobile/dist/components/Header/HeaderSecondaryMenu.js +7 -2
  84. package/mobile/dist/components/Header/HeaderSecondaryMenu.js.map +1 -1
  85. package/mobile/dist/components/Tabs/LinkTab.d.ts +1 -0
  86. package/mobile/dist/components/Tabs/LinkTab.js +6 -2
  87. package/mobile/dist/components/Tabs/LinkTab.js.map +1 -1
  88. package/mobile/dist/components/Tabs/Tabs.js +15 -3
  89. package/mobile/dist/components/Tabs/Tabs.js.map +1 -1
  90. package/mobile/dist/components/Tabs/renderTab.js +1 -1
  91. package/mobile/dist/components/Tabs/renderTab.js.map +1 -1
  92. package/mobile/dist/hooks/useBranches.d.ts +20 -0
  93. package/mobile/dist/hooks/useBranches.js +16 -0
  94. package/mobile/dist/hooks/useBranches.js.map +1 -0
  95. package/mobile/dist/ui-kit/BlockWrapper.js +1 -4
  96. package/mobile/dist/ui-kit/BlockWrapper.js.map +1 -1
  97. package/mobile/dist/ui-kit/TopItem/TopItem.d.ts +2 -1
  98. package/mobile/dist/ui-kit/TopItem/TopItem.js.map +1 -1
  99. package/mobile/lib/components/ApplicationForm/ApplicationFormAcquiring.js +1 -1
  100. package/mobile/lib/components/ApplicationForm/ApplicationFormAcquiring.js.map +1 -1
  101. package/mobile/lib/components/ApplicationForm/ApplicationFormBusinessCard.js +2 -2
  102. package/mobile/lib/components/ApplicationForm/ApplicationFormBusinessCard.js.map +1 -1
  103. package/mobile/lib/components/ApplicationForm/ApplicationFormCredit.js +5 -5
  104. package/mobile/lib/components/ApplicationForm/ApplicationFormCredit.js.map +1 -1
  105. package/mobile/lib/components/ApplicationForm/renderBankOffices.js.map +1 -1
  106. package/mobile/lib/components/BonusBenefitsBlock/BonusBenefitsBlock.js +2 -2
  107. package/mobile/lib/components/BonusBenefitsBlock/BonusBenefitsBlock.js.map +1 -1
  108. package/mobile/lib/components/BonusBenefitsBlock/BonusBenefitsBlockContent.d.ts +6 -2
  109. package/mobile/lib/components/Calculator/getMonthlyPayment.js +4 -1
  110. package/mobile/lib/components/Calculator/getMonthlyPayment.js.map +1 -1
  111. package/mobile/lib/components/Header/HeaderSecondaryMenu.js +7 -2
  112. package/mobile/lib/components/Header/HeaderSecondaryMenu.js.map +1 -1
  113. package/mobile/lib/components/Tabs/LinkTab.d.ts +1 -0
  114. package/mobile/lib/components/Tabs/LinkTab.js +6 -2
  115. package/mobile/lib/components/Tabs/LinkTab.js.map +1 -1
  116. package/mobile/lib/components/Tabs/Tabs.js +15 -3
  117. package/mobile/lib/components/Tabs/Tabs.js.map +1 -1
  118. package/mobile/lib/components/Tabs/renderTab.js +1 -1
  119. package/mobile/lib/components/Tabs/renderTab.js.map +1 -1
  120. package/mobile/lib/hooks/useBranches.d.ts +20 -0
  121. package/mobile/lib/hooks/useBranches.js +13 -0
  122. package/mobile/lib/hooks/useBranches.js.map +1 -0
  123. package/mobile/lib/ui-kit/BlockWrapper.js +1 -4
  124. package/mobile/lib/ui-kit/BlockWrapper.js.map +1 -1
  125. package/mobile/lib/ui-kit/TopItem/TopItem.d.ts +2 -1
  126. package/mobile/lib/ui-kit/TopItem/TopItem.js.map +1 -1
  127. package/mobile/src/components/ApplicationForm/ApplicationFormAcquiring.tsx +1 -1
  128. package/mobile/src/components/ApplicationForm/ApplicationFormBusinessCard.tsx +2 -2
  129. package/mobile/src/components/ApplicationForm/ApplicationFormCredit.tsx +5 -5
  130. package/mobile/src/components/ApplicationForm/renderBankOffices.tsx +1 -1
  131. package/mobile/src/components/BonusBenefitsBlock/BonusBenefitsBlock.example.json +16 -8
  132. package/mobile/src/components/BonusBenefitsBlock/BonusBenefitsBlock.tsx +3 -3
  133. package/mobile/src/components/BonusBenefitsBlock/BonusBenefitsBlockContent.ts +6 -2
  134. package/mobile/src/components/Calculator/getMonthlyPayment.ts +3 -1
  135. package/mobile/src/components/Header/HeaderSecondaryMenu.tsx +9 -2
  136. package/mobile/src/components/Tabs/LinkTab.tsx +8 -2
  137. package/mobile/src/components/Tabs/Tabs.tsx +18 -3
  138. package/mobile/src/components/Tabs/renderTab.tsx +7 -1
  139. package/mobile/src/hooks/useBranches.ts +43 -0
  140. package/mobile/src/ui-kit/BlockWrapper.tsx +1 -6
  141. package/mobile/src/ui-kit/TopItem/TopItem.tsx +2 -1
  142. package/package.json +1 -1
  143. package/src/components/ApplicationForm/ApplicationFormAcquiring.tsx +1 -1
  144. package/src/components/ApplicationForm/ApplicationFormBusinessCard.tsx +2 -2
  145. package/src/components/ApplicationForm/ApplicationFormCredit.tsx +5 -5
  146. package/src/components/ApplicationForm/renderBankOffices.tsx +1 -1
  147. package/src/components/BonusBenefitsBlock/BonusBenefitsBlock.example.json +16 -8
  148. package/src/components/BonusBenefitsBlock/BonusBenefitsBlock.fixture.tsx +8 -8
  149. package/src/components/BonusBenefitsBlock/BonusBenefitsBlock.tsx +3 -3
  150. package/src/components/BonusBenefitsBlock/BonusBenefitsBlockContent.ts +6 -2
  151. package/src/components/Calculator/getMonthlyPayment.ts +3 -1
  152. package/src/components/Header/HeaderSecondaryMenu.tsx +9 -2
  153. package/src/components/Tabs/LinkTab.tsx +8 -2
  154. package/src/components/Tabs/Tabs.tsx +18 -3
  155. package/src/components/Tabs/renderTab.tsx +7 -1
  156. package/src/hooks/useBranches.ts +43 -0
  157. package/src/ui-kit/BlockWrapper.tsx +1 -6
  158. package/src/ui-kit/TopItem/TopItem.tsx +2 -1
@@ -1,5 +1,5 @@
1
1
  import type { AlignType } from '../../model/AlignType';
2
- import type { DescriptionProps, LabelProps, TitleProps } from '../../model/HeadlineType';
2
+ import type { DescriptionProps, TitleProps } from '../../model/HeadlineType';
3
3
  import type { UniBlockContent } from '../../model/JSXBlock';
4
4
  import type { IconProps } from '../../model/Picture';
5
5
 
@@ -15,8 +15,12 @@ export type ColumnsCount = '3' | '4' | '5';
15
15
 
16
16
  /**
17
17
  * @title Бонус и преимущество
18
+ * @default {
19
+ * "title": "Верхний заголовок",
20
+ * "description": "Нижний заголовок",
21
+ * }
18
22
  */
19
- export type BonusBenefit = LabelProps & IconProps & DescriptionProps;
23
+ export type BonusBenefit = TitleProps & IconProps & DescriptionProps;
20
24
 
21
25
  /**
22
26
  * @title Блок бонусов и преимуществ
@@ -9,7 +9,9 @@ import type { CreditCalculatorUserInputParams } from './useCreditCalculatorParam
9
9
  export const getMonthlyPayment = (rate: number, params: CreditCalculatorUserInputParams) => {
10
10
  const { isAnnuity, moneyValue, monthsValue } = params;
11
11
 
12
- if (isAnnuity) {
12
+ if (rate === 0) {
13
+ return 0;
14
+ } else if (isAnnuity) {
13
15
  const i = rate / MONTHLY_INTEREST_RATE; // Используется значение ставки в процентах
14
16
 
15
17
  return moneyValue * (i + i / (Math.pow(1 + i, monthsValue) - 1));
@@ -1,14 +1,16 @@
1
1
  import { JSX } from '@redneckz/uni-jsx';
2
+ import { useCallback } from '@redneckz/uni-jsx/lib/hooks';
2
3
  import { useBool } from '../../hooks/useBool';
3
4
  import { useLocation } from '../../hooks/useLocation';
4
5
  import type { BlockVersion } from '../../model/BlockVersion';
5
6
  import type { IconVersion } from '../../model/IconVersion';
7
+ import type { PreventableEvent } from '../../model/PreventableEvent';
8
+ import { projectSettings } from '../../ProjectSettings';
6
9
  import type { ForeignOffice } from '../../services/sitemap/SitemapProps';
7
10
  import { Location } from '../../ui-kit/Location/Location';
8
11
  import { TopItem } from '../../ui-kit/TopItem/TopItem';
9
12
  import { style } from '../../utils/style';
10
13
  import { HeaderChatBotButton } from './HeaderChatBotButton';
11
- import { projectSettings } from '../../ProjectSettings';
12
14
 
13
15
  interface HeaderSecondaryMenuContent {
14
16
  version?: BlockVersion;
@@ -30,6 +32,11 @@ export const HeaderSecondaryMenu = JSX<HeaderSecondaryMenuProps>(
30
32
 
31
33
  const iconVersion: IconVersion = version === 'transparent' ? 'white' : 'black';
32
34
 
35
+ const handleShowLocationModal = useCallback((ev?: PreventableEvent) => {
36
+ ev?.preventDefault();
37
+ showLocationModal();
38
+ }, []);
39
+
33
40
  return (
34
41
  <div className={style('flex items-center', className)}>
35
42
  <TopItem
@@ -37,7 +44,7 @@ export const HeaderSecondaryMenu = JSX<HeaderSecondaryMenuProps>(
37
44
  flat={true}
38
45
  href="#"
39
46
  text={location.name}
40
- onClick={showLocationModal}
47
+ onClick={handleShowLocationModal}
41
48
  />
42
49
  {officesLink ? (
43
50
  <TopItem className="mr-7" flat={true} href={officesLink} text="Офисы и банкоматы" />
@@ -7,22 +7,28 @@ interface LinkTabProps {
7
7
  tab: LinkTabData;
8
8
  currentTab?: TabData;
9
9
  isScrollable?: boolean;
10
+ onClick: (tab: TabData) => void;
10
11
  }
11
12
 
12
13
  export const LinkTab = JSX<LinkTabProps>((props) => {
13
- const { tab, currentTab, isScrollable = false } = props;
14
+ const { tab, currentTab, onClick, isScrollable = false } = props;
14
15
  const active = currentTab?.type === 'link' && currentTab.href === tab.href;
15
16
 
16
17
  const link = useLink();
17
18
  const adjustedProps = link(tab);
18
19
 
20
+ const handleClick = (ev?: { preventDefault: () => void }) => {
21
+ adjustedProps.onClick(ev);
22
+ onClick(tab);
23
+ };
24
+
19
25
  return (
20
26
  <a
21
27
  role="tab"
22
28
  className={getLinkTabClassName('link', active, isScrollable)}
23
29
  target={tab.target}
24
30
  href={adjustedProps.href}
25
- onClick={adjustedProps.onClick}
31
+ onClick={handleClick}
26
32
  >
27
33
  <span className={getLinkTabClassName('text', active, isScrollable)}>{tab.text}</span>
28
34
  </a>
@@ -19,6 +19,14 @@ export const Tabs = JSX<TabsBlockProps>((props) => {
19
19
 
20
20
  const [currentTab, setCurrentTab] = useState(tabs ? tabs[0] : undefined);
21
21
 
22
+ useEffect(() => {
23
+ if (!tabs || !tabs[0]) {
24
+ return;
25
+ }
26
+
27
+ fireTabEvent(tabs[0]);
28
+ }, []);
29
+
22
30
  useEffect(() => {
23
31
  if (currentTab?.type === 'group') {
24
32
  defaultEventBus.subject('tab', { type: currentTab.type, label: currentTab.ref });
@@ -26,9 +34,7 @@ export const Tabs = JSX<TabsBlockProps>((props) => {
26
34
  }, [currentTab]);
27
35
 
28
36
  const handleClick = useCallback((selectedTab: TabData) => {
29
- if (selectedTab?.type === 'group') {
30
- defaultEventBus.fire('tab', { type: selectedTab.type, label: selectedTab.ref });
31
- }
37
+ fireTabEvent(selectedTab);
32
38
  setCurrentTab(selectedTab);
33
39
  }, []);
34
40
 
@@ -61,3 +67,12 @@ export const Tabs = JSX<TabsBlockProps>((props) => {
61
67
  </BlockWrapper>
62
68
  );
63
69
  });
70
+
71
+ const fireTabEvent = (tab: TabData) => {
72
+ if (tab.type === 'group') {
73
+ defaultEventBus.fire('tab', { type: tab.type, label: tab.ref });
74
+ }
75
+ if (tab.type === 'link') {
76
+ defaultEventBus.fire('tab', { type: tab.type, label: tab.href });
77
+ }
78
+ };
@@ -26,7 +26,13 @@ export const renderTab =
26
26
  return renderGroupTab({ page, currentTab, showCounter, onClick, isScrollable })(tab, i);
27
27
  case 'link': {
28
28
  return (
29
- <LinkTab key={String(i)} tab={tab} currentTab={currentTab} isScrollable={isScrollable} />
29
+ <LinkTab
30
+ key={String(i)}
31
+ tab={tab}
32
+ currentTab={currentTab}
33
+ isScrollable={isScrollable}
34
+ onClick={onClick}
35
+ />
30
36
  );
31
37
  }
32
38
  default:
@@ -0,0 +1,43 @@
1
+ import { useAsyncData } from '@redneckz/uni-jsx/lib/hooks/useAsyncData';
2
+ import { fetchJSON } from '../utils/fetchJSON';
3
+
4
+ export interface Tariff {
5
+ tariffType?: string;
6
+ tariffValue?: number;
7
+ }
8
+
9
+ export interface SafeBoxCase {
10
+ safeBoxCasesSize?: string;
11
+ tariffs?: Tariff[];
12
+ }
13
+
14
+ export interface SafeBoxCaseVolume {
15
+ volume?: string;
16
+ safeBoxCases?: SafeBoxCase[];
17
+ }
18
+
19
+ export interface Branch {
20
+ branchCode?: string;
21
+ address?: string;
22
+ gpsLatitude?: number;
23
+ gpsLongitude?: number;
24
+ safeBoxCaseVolumes?: SafeBoxCaseVolume[];
25
+ }
26
+
27
+ const BRANCHES_URL = '/api/v1/branches';
28
+ const EMPTY_VALUE = [];
29
+
30
+ export function useBranches(regionCode?: string): Branch[] {
31
+ const { data } = useAsyncData<Branch[], any, string | null>(
32
+ regionCode ? `${BRANCHES_URL}?regionCode=${regionCode}` : null,
33
+ fetchSafeBoxes,
34
+ );
35
+
36
+ return data || EMPTY_VALUE;
37
+ }
38
+
39
+ const fetchSafeBoxes = async (url: string): Promise<Branch[]> => {
40
+ const result = await fetchJSON<Branch[]>(url, { method: 'GET' });
41
+
42
+ return result || EMPTY_VALUE;
43
+ };
@@ -38,12 +38,7 @@ export const BlockWrapper = JSX<BlockWrapperProps>(
38
38
  () =>
39
39
  defaultEventBus.subscribe('tab', (event) => {
40
40
  setHidden(
41
- Boolean(
42
- event.type === 'group' &&
43
- event.label &&
44
- block?.labels?.length &&
45
- !block.labels.includes(event.label),
46
- ),
41
+ Boolean(event.label && block?.labels?.length && !block.labels.includes(event.label)),
47
42
  );
48
43
  }),
49
44
  [block],
@@ -1,6 +1,7 @@
1
1
  import { JSX } from '@redneckz/uni-jsx';
2
2
  import { useLink } from '../../hooks/useLink';
3
3
  import type { LinkProps } from '../../model/LinkProps';
4
+ import type { PreventableEvent } from '../../model/PreventableEvent';
4
5
  import { style } from '../../utils/style';
5
6
 
6
7
  export interface TopItemContent extends LinkProps {
@@ -11,7 +12,7 @@ export interface TopItemProps extends TopItemContent {
11
12
  className?: string;
12
13
  flat?: boolean;
13
14
  dataItemName?: string;
14
- onClick?: () => void;
15
+ onClick?: (ev?: PreventableEvent) => void;
15
16
  }
16
17
 
17
18
  export const TopItem = JSX<TopItemProps>(({ className = '', active, flat, children, ...rest }) => {