@redneckz/wildless-cms-uni-blocks 0.8.9 → 0.8.10

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 (213) hide show
  1. package/bin/migration-scripts/0.8.10.js +31 -0
  2. package/bundle/blocks.schema.json +1 -1
  3. package/bundle/bundle.umd.js +82 -48
  4. package/bundle/bundle.umd.min.js +1 -1
  5. package/bundle/components/Calculator/rangeHelpers.d.ts +4 -0
  6. package/bundle/components/StepsBlock/StepsBlockContent.d.ts +11 -1
  7. package/bundle/components/StepsBlock/checkCanRenderIcon.d.ts +2 -0
  8. package/bundle/components/StepsBlock/{renderStepContent.d.ts → renderStep.d.ts} +5 -5
  9. package/bundle/components/Tile/TileContent.d.ts +2 -2
  10. package/dist/components/Calculator/Rate.js +1 -1
  11. package/dist/components/Calculator/Rate.js.map +1 -1
  12. package/dist/components/Calculator/constants.js +2 -2
  13. package/dist/components/Calculator/constants.js.map +1 -1
  14. package/dist/components/Calculator/rangeHelpers.d.ts +4 -0
  15. package/dist/components/Calculator/rangeHelpers.js +12 -0
  16. package/dist/components/Calculator/rangeHelpers.js.map +1 -0
  17. package/dist/components/Calculator/useBusinessDepositCalculatorParams.js +10 -3
  18. package/dist/components/Calculator/useBusinessDepositCalculatorParams.js.map +1 -1
  19. package/dist/components/Calculator/useCreditCalculatorParams.js +8 -2
  20. package/dist/components/Calculator/useCreditCalculatorParams.js.map +1 -1
  21. package/dist/components/Calculator/useDepositCalculatorParams.js +14 -4
  22. package/dist/components/Calculator/useDepositCalculatorParams.js.map +1 -1
  23. package/dist/components/Carousel/Carousel.js +6 -4
  24. package/dist/components/Carousel/Carousel.js.map +1 -1
  25. package/dist/components/PictureText/renderBenefit.js +1 -0
  26. package/dist/components/PictureText/renderBenefit.js.map +1 -1
  27. package/dist/components/ProductTile/renderBenefit.js +1 -0
  28. package/dist/components/ProductTile/renderBenefit.js.map +1 -1
  29. package/dist/components/StepsBlock/StepsBlock.js +7 -13
  30. package/dist/components/StepsBlock/StepsBlock.js.map +1 -1
  31. package/dist/components/StepsBlock/StepsBlock.mobile.js +24 -4
  32. package/dist/components/StepsBlock/StepsBlock.mobile.js.map +1 -1
  33. package/dist/components/StepsBlock/StepsBlockContent.d.ts +11 -1
  34. package/dist/components/StepsBlock/checkCanRenderIcon.d.ts +2 -0
  35. package/dist/components/StepsBlock/checkCanRenderIcon.js +5 -0
  36. package/dist/components/StepsBlock/checkCanRenderIcon.js.map +1 -0
  37. package/{lib/components/StepsBlock/renderStepContent.d.ts → dist/components/StepsBlock/renderStep.d.ts} +5 -5
  38. package/dist/components/StepsBlock/renderStep.js +34 -0
  39. package/dist/components/StepsBlock/renderStep.js.map +1 -0
  40. package/dist/components/Tile/Tile.js +3 -3
  41. package/dist/components/Tile/Tile.js.map +1 -1
  42. package/dist/components/Tile/TileContent.d.ts +2 -2
  43. package/lib/components/Calculator/Rate.js +1 -1
  44. package/lib/components/Calculator/Rate.js.map +1 -1
  45. package/lib/components/Calculator/constants.js +2 -2
  46. package/lib/components/Calculator/constants.js.map +1 -1
  47. package/lib/components/Calculator/rangeHelpers.d.ts +4 -0
  48. package/lib/components/Calculator/rangeHelpers.js +8 -0
  49. package/lib/components/Calculator/rangeHelpers.js.map +1 -0
  50. package/lib/components/Calculator/useBusinessDepositCalculatorParams.js +10 -3
  51. package/lib/components/Calculator/useBusinessDepositCalculatorParams.js.map +1 -1
  52. package/lib/components/Calculator/useCreditCalculatorParams.js +8 -2
  53. package/lib/components/Calculator/useCreditCalculatorParams.js.map +1 -1
  54. package/lib/components/Calculator/useDepositCalculatorParams.js +14 -4
  55. package/lib/components/Calculator/useDepositCalculatorParams.js.map +1 -1
  56. package/lib/components/Carousel/Carousel.js +6 -4
  57. package/lib/components/Carousel/Carousel.js.map +1 -1
  58. package/lib/components/PictureText/renderBenefit.js +1 -0
  59. package/lib/components/PictureText/renderBenefit.js.map +1 -1
  60. package/lib/components/ProductTile/renderBenefit.js +1 -0
  61. package/lib/components/ProductTile/renderBenefit.js.map +1 -1
  62. package/lib/components/StepsBlock/StepsBlock.js +7 -13
  63. package/lib/components/StepsBlock/StepsBlock.js.map +1 -1
  64. package/lib/components/StepsBlock/StepsBlock.mobile.js +24 -4
  65. package/lib/components/StepsBlock/StepsBlock.mobile.js.map +1 -1
  66. package/lib/components/StepsBlock/StepsBlockContent.d.ts +11 -1
  67. package/lib/components/StepsBlock/checkCanRenderIcon.d.ts +2 -0
  68. package/lib/components/StepsBlock/checkCanRenderIcon.js +2 -0
  69. package/lib/components/StepsBlock/checkCanRenderIcon.js.map +1 -0
  70. package/{dist/components/StepsBlock/renderStepContent.d.ts → lib/components/StepsBlock/renderStep.d.ts} +5 -5
  71. package/lib/components/StepsBlock/renderStep.js +31 -0
  72. package/lib/components/StepsBlock/renderStep.js.map +1 -0
  73. package/lib/components/Tile/Tile.js +3 -3
  74. package/lib/components/Tile/Tile.js.map +1 -1
  75. package/lib/components/Tile/TileContent.d.ts +2 -2
  76. package/mobile/bundle/bundle.umd.js +32 -5
  77. package/mobile/bundle/bundle.umd.min.js +1 -1
  78. package/mobile/bundle/components/Calculator/rangeHelpers.d.ts +4 -0
  79. package/mobile/bundle/components/StepsBlock/StepsBlockContent.d.ts +11 -1
  80. package/mobile/bundle/components/StepsBlock/checkCanRenderIcon.d.ts +2 -0
  81. package/mobile/bundle/components/StepsBlock/{renderStepContent.d.ts → renderStep.d.ts} +5 -5
  82. package/mobile/bundle/components/Tile/TileContent.d.ts +2 -2
  83. package/mobile/dist/components/Calculator/Rate.js +1 -1
  84. package/mobile/dist/components/Calculator/Rate.js.map +1 -1
  85. package/mobile/dist/components/Calculator/constants.js +2 -2
  86. package/mobile/dist/components/Calculator/constants.js.map +1 -1
  87. package/mobile/dist/components/Calculator/rangeHelpers.d.ts +4 -0
  88. package/mobile/dist/components/Calculator/rangeHelpers.js +12 -0
  89. package/mobile/dist/components/Calculator/rangeHelpers.js.map +1 -0
  90. package/mobile/dist/components/Calculator/useBusinessDepositCalculatorParams.js +10 -3
  91. package/mobile/dist/components/Calculator/useBusinessDepositCalculatorParams.js.map +1 -1
  92. package/mobile/dist/components/Calculator/useCreditCalculatorParams.js +8 -2
  93. package/mobile/dist/components/Calculator/useCreditCalculatorParams.js.map +1 -1
  94. package/mobile/dist/components/Calculator/useDepositCalculatorParams.js +14 -4
  95. package/mobile/dist/components/Calculator/useDepositCalculatorParams.js.map +1 -1
  96. package/mobile/dist/components/Carousel/Carousel.js +6 -4
  97. package/mobile/dist/components/Carousel/Carousel.js.map +1 -1
  98. package/mobile/dist/components/PictureText/renderBenefit.js +1 -0
  99. package/mobile/dist/components/PictureText/renderBenefit.js.map +1 -1
  100. package/mobile/dist/components/ProductTile/renderBenefit.js +1 -0
  101. package/mobile/dist/components/ProductTile/renderBenefit.js.map +1 -1
  102. package/mobile/dist/components/StepsBlock/StepsBlock.js +24 -4
  103. package/mobile/dist/components/StepsBlock/StepsBlock.js.map +1 -1
  104. package/mobile/dist/components/StepsBlock/StepsBlockContent.d.ts +11 -1
  105. package/mobile/dist/components/StepsBlock/checkCanRenderIcon.d.ts +2 -0
  106. package/mobile/dist/components/StepsBlock/checkCanRenderIcon.js +5 -0
  107. package/mobile/dist/components/StepsBlock/checkCanRenderIcon.js.map +1 -0
  108. package/mobile/dist/components/StepsBlock/renderStep.d.ts +11 -0
  109. package/mobile/dist/components/StepsBlock/renderStep.js +34 -0
  110. package/mobile/dist/components/StepsBlock/renderStep.js.map +1 -0
  111. package/mobile/dist/components/Tile/Tile.js +3 -3
  112. package/mobile/dist/components/Tile/Tile.js.map +1 -1
  113. package/mobile/dist/components/Tile/TileContent.d.ts +2 -2
  114. package/mobile/lib/components/Calculator/Rate.js +1 -1
  115. package/mobile/lib/components/Calculator/Rate.js.map +1 -1
  116. package/mobile/lib/components/Calculator/constants.js +2 -2
  117. package/mobile/lib/components/Calculator/constants.js.map +1 -1
  118. package/mobile/lib/components/Calculator/rangeHelpers.d.ts +4 -0
  119. package/mobile/lib/components/Calculator/rangeHelpers.js +8 -0
  120. package/mobile/lib/components/Calculator/rangeHelpers.js.map +1 -0
  121. package/mobile/lib/components/Calculator/useBusinessDepositCalculatorParams.js +10 -3
  122. package/mobile/lib/components/Calculator/useBusinessDepositCalculatorParams.js.map +1 -1
  123. package/mobile/lib/components/Calculator/useCreditCalculatorParams.js +8 -2
  124. package/mobile/lib/components/Calculator/useCreditCalculatorParams.js.map +1 -1
  125. package/mobile/lib/components/Calculator/useDepositCalculatorParams.js +14 -4
  126. package/mobile/lib/components/Calculator/useDepositCalculatorParams.js.map +1 -1
  127. package/mobile/lib/components/Carousel/Carousel.js +6 -4
  128. package/mobile/lib/components/Carousel/Carousel.js.map +1 -1
  129. package/mobile/lib/components/PictureText/renderBenefit.js +1 -0
  130. package/mobile/lib/components/PictureText/renderBenefit.js.map +1 -1
  131. package/mobile/lib/components/ProductTile/renderBenefit.js +1 -0
  132. package/mobile/lib/components/ProductTile/renderBenefit.js.map +1 -1
  133. package/mobile/lib/components/StepsBlock/StepsBlock.js +24 -4
  134. package/mobile/lib/components/StepsBlock/StepsBlock.js.map +1 -1
  135. package/mobile/lib/components/StepsBlock/StepsBlockContent.d.ts +11 -1
  136. package/mobile/lib/components/StepsBlock/checkCanRenderIcon.d.ts +2 -0
  137. package/mobile/lib/components/StepsBlock/checkCanRenderIcon.js +2 -0
  138. package/mobile/lib/components/StepsBlock/checkCanRenderIcon.js.map +1 -0
  139. package/mobile/lib/components/StepsBlock/renderStep.d.ts +11 -0
  140. package/mobile/lib/components/StepsBlock/renderStep.js +31 -0
  141. package/mobile/lib/components/StepsBlock/renderStep.js.map +1 -0
  142. package/mobile/lib/components/Tile/Tile.js +3 -3
  143. package/mobile/lib/components/Tile/Tile.js.map +1 -1
  144. package/mobile/lib/components/Tile/TileContent.d.ts +2 -2
  145. package/mobile/src/components/Calculator/Rate.tsx +1 -1
  146. package/mobile/src/components/Calculator/constants.ts +2 -2
  147. package/mobile/src/components/Calculator/rangeHelpers.ts +24 -0
  148. package/mobile/src/components/Calculator/useBusinessDepositCalculatorParams.ts +15 -3
  149. package/mobile/src/components/Calculator/useCreditCalculatorParams.ts +8 -2
  150. package/mobile/src/components/Calculator/useDepositCalculatorParams.ts +18 -4
  151. package/mobile/src/components/Carousel/Carousel.tsx +6 -4
  152. package/mobile/src/components/PictureText/renderBenefit.tsx +1 -0
  153. package/mobile/src/components/ProductTile/renderBenefit.tsx +1 -0
  154. package/mobile/src/components/StepsBlock/StepsBlock.tsx +29 -5
  155. package/mobile/src/components/StepsBlock/StepsBlock.ui.json +6 -0
  156. package/mobile/src/components/StepsBlock/StepsBlockContent.ts +13 -1
  157. package/mobile/src/components/StepsBlock/checkCanRenderIcon.ts +3 -0
  158. package/mobile/src/components/StepsBlock/renderStep.tsx +83 -0
  159. package/mobile/src/components/Tile/Tile.example.json +1 -1
  160. package/mobile/src/components/Tile/Tile.tsx +4 -4
  161. package/mobile/src/components/Tile/Tile.ui.json +7 -1
  162. package/mobile/src/components/Tile/TileContent.ts +2 -2
  163. package/package.json +1 -1
  164. package/src/components/Calculator/Rate.tsx +1 -1
  165. package/src/components/Calculator/constants.ts +2 -2
  166. package/src/components/Calculator/rangeHelpers.ts +24 -0
  167. package/src/components/Calculator/useBusinessDepositCalculatorParams.ts +15 -3
  168. package/src/components/Calculator/useCreditCalculatorParams.ts +8 -2
  169. package/src/components/Calculator/useDepositCalculatorParams.ts +18 -4
  170. package/src/components/Carousel/Carousel.tsx +6 -4
  171. package/src/components/PictureText/renderBenefit.tsx +1 -0
  172. package/src/components/ProductTile/renderBenefit.tsx +1 -0
  173. package/src/components/StepsBlock/StepsBlock.fixture.mobile.tsx +19 -1
  174. package/src/components/StepsBlock/StepsBlock.fixture.tsx +10 -3
  175. package/src/components/StepsBlock/StepsBlock.mobile.tsx +29 -5
  176. package/src/components/StepsBlock/StepsBlock.tsx +28 -16
  177. package/src/components/StepsBlock/StepsBlock.ui.json +6 -0
  178. package/src/components/StepsBlock/StepsBlockContent.ts +13 -1
  179. package/src/components/StepsBlock/checkCanRenderIcon.ts +3 -0
  180. package/src/components/StepsBlock/renderStep.tsx +83 -0
  181. package/src/components/Tile/Tile.example.json +1 -1
  182. package/src/components/Tile/Tile.fixture.tsx +2 -2
  183. package/src/components/Tile/Tile.tsx +4 -4
  184. package/src/components/Tile/Tile.ui.json +7 -1
  185. package/src/components/Tile/TileContent.ts +2 -2
  186. package/bundle/utils/checkIsIconRenderable.d.ts +0 -2
  187. package/dist/components/StepsBlock/renderStepContent.js +0 -19
  188. package/dist/components/StepsBlock/renderStepContent.js.map +0 -1
  189. package/dist/utils/checkIsIconRenderable.d.ts +0 -2
  190. package/dist/utils/checkIsIconRenderable.js +0 -5
  191. package/dist/utils/checkIsIconRenderable.js.map +0 -1
  192. package/lib/components/StepsBlock/renderStepContent.js +0 -16
  193. package/lib/components/StepsBlock/renderStepContent.js.map +0 -1
  194. package/lib/utils/checkIsIconRenderable.d.ts +0 -2
  195. package/lib/utils/checkIsIconRenderable.js +0 -2
  196. package/lib/utils/checkIsIconRenderable.js.map +0 -1
  197. package/mobile/bundle/utils/checkIsIconRenderable.d.ts +0 -2
  198. package/mobile/dist/components/StepsBlock/renderStepContent.d.ts +0 -11
  199. package/mobile/dist/components/StepsBlock/renderStepContent.js +0 -19
  200. package/mobile/dist/components/StepsBlock/renderStepContent.js.map +0 -1
  201. package/mobile/dist/utils/checkIsIconRenderable.d.ts +0 -2
  202. package/mobile/dist/utils/checkIsIconRenderable.js +0 -5
  203. package/mobile/dist/utils/checkIsIconRenderable.js.map +0 -1
  204. package/mobile/lib/components/StepsBlock/renderStepContent.d.ts +0 -11
  205. package/mobile/lib/components/StepsBlock/renderStepContent.js +0 -16
  206. package/mobile/lib/components/StepsBlock/renderStepContent.js.map +0 -1
  207. package/mobile/lib/utils/checkIsIconRenderable.d.ts +0 -2
  208. package/mobile/lib/utils/checkIsIconRenderable.js +0 -2
  209. package/mobile/lib/utils/checkIsIconRenderable.js.map +0 -1
  210. package/mobile/src/components/StepsBlock/renderStepContent.tsx +0 -83
  211. package/mobile/src/utils/checkIsIconRenderable.tsx +0 -3
  212. package/src/components/StepsBlock/renderStepContent.tsx +0 -83
  213. package/src/utils/checkIsIconRenderable.tsx +0 -3
@@ -1,6 +1,8 @@
1
1
  import type { BlockVersion } from '../../model/BlockVersion';
2
+ import type { DefaultListItemType } from '../../model/DefaultListItemType';
2
3
  import type { DescriptionProps, HeadlineCommonProps, LabelProps } from '../../model/HeadlineType';
3
4
  import type { IconProps } from '../../model/Picture';
5
+ import type { RichTextItem } from '../../model/RichTextItem';
4
6
  import type { SizeVersion } from '../../model/SizeVersion';
5
7
  import type { ButtonWithIconProps } from '../../ui-kit/Button/ButtonProps';
6
8
 
@@ -16,10 +18,20 @@ type StepCommonProps = IconProps & {
16
18
  items?: string[];
17
19
  };
18
20
 
21
+ /**
22
+ * @title Стандартный
23
+ */
24
+ export type DefaultStep = DescriptionProps & LabelProps & StepCommonProps & DefaultListItemType;
25
+
26
+ /**
27
+ * @title Форматированный текст
28
+ */
29
+ type RichTextStep = RichTextItem & IconProps;
30
+
19
31
  /**
20
32
  * @title Шаг
21
33
  */
22
- export type Step = DescriptionProps & LabelProps & StepCommonProps;
34
+ export type Step = DefaultStep | RichTextStep;
23
35
 
24
36
  /**
25
37
  * @title Блок шаги
@@ -0,0 +1,3 @@
1
+ import type { Picture } from '../../model/Picture';
2
+
3
+ export const checkCanRenderIcon = (icon?: Picture) => Boolean(icon?.icon || icon?.src);
@@ -0,0 +1,83 @@
1
+ import type { BlockVersion } from '../../model/BlockVersion';
2
+ import type { ButtonVersion } from '../../model/ButtonVersion';
3
+ import type { VNode } from '../../model/VNode';
4
+ import { Button } from '../../ui-kit/Button/Button';
5
+ import { List } from '../../ui-kit/List/List';
6
+ import { RichText } from '../../ui-kit/RichText/RichText';
7
+ import { Text } from '../../ui-kit/Text/Text';
8
+ import { assertUnreachable } from '../../utils/assertUnreachable';
9
+ import { style } from '../../utils/style';
10
+ import type { DefaultStep, Step } from './StepsBlockContent';
11
+ import type { StyleType } from './StepsBlockStyleMaps';
12
+
13
+ interface RenderStepProps {
14
+ styleMap: StyleType;
15
+ isMainButton: boolean;
16
+ version?: BlockVersion;
17
+ }
18
+
19
+ // TODO: Create universal function for this case
20
+ export const renderStep =
21
+ (props: RenderStepProps) =>
22
+ // Linter doesn't understand that switch processes all cases
23
+ // eslint-disable-next-line consistent-return
24
+ (step: Step, i: number, arr: Step[]): VNode => {
25
+ const { type } = step;
26
+
27
+ if (!(type === 'default' || type === 'rte')) {
28
+ return null;
29
+ }
30
+
31
+ switch (type) {
32
+ case 'default':
33
+ return renderDefaultStep(props)(step, i, arr);
34
+ case 'rte':
35
+ return <RichText __html={step.__html} />;
36
+ default:
37
+ assertUnreachable(step);
38
+ }
39
+ };
40
+
41
+ const renderDefaultStep =
42
+ ({ styleMap, isMainButton, version }: RenderStepProps) =>
43
+ (step: DefaultStep, i: number, arr: Step[]) => {
44
+ const { label, description, button, items, isDotted } = step;
45
+
46
+ return (
47
+ <div
48
+ key={String(i)}
49
+ className={style(
50
+ 'relative flex flex-col items-center text-center whitespace-pre-line overflow-hidden',
51
+ getContainerWidth(arr.length),
52
+ )}
53
+ >
54
+ <div className={style(button?.text ? 'mb-8' : '', 'text-center')}>
55
+ {label ? (
56
+ <div className="mb-2">
57
+ <Text size="text-h6">{label}</Text>
58
+ </div>
59
+ ) : null}
60
+ <div className="flex flex-col items-center">
61
+ {description ? <div className={styleMap.description}>{description}</div> : null}
62
+ <List
63
+ className={style(description ? `${styleMap.description} mt-0.5` : 'text-h6')}
64
+ items={items}
65
+ listItemSize="M"
66
+ isDotted={isDotted}
67
+ />
68
+ </div>
69
+ </div>
70
+ {button?.text && !isMainButton ? (
71
+ <Button
72
+ className="box-border py-3 h-12 w-full max-w-[240px] mt-auto"
73
+ version={version as ButtonVersion}
74
+ {...button}
75
+ >
76
+ {button?.text}
77
+ </Button>
78
+ ) : null}
79
+ </div>
80
+ );
81
+ };
82
+
83
+ const getContainerWidth = (length: number): string => (length < 5 ? 'w-[276px]' : 'w-[210px]');
@@ -2,7 +2,7 @@
2
2
  "content": {
3
3
  "title": "Плитка",
4
4
  "headingType": "h3",
5
- "description": "Описание",
5
+ "__html": "<p>Описание</p>",
6
6
  "image": {
7
7
  "format": "webp",
8
8
  "size": {
@@ -5,7 +5,7 @@ import { renderButtonsSection } from '../../ui-kit/Button/renderButtonsSection';
5
5
  import { Heading } from '../../ui-kit/Heading/Heading';
6
6
  import { Img } from '../../ui-kit/Img/Img';
7
7
  import { List } from '../../ui-kit/List/List';
8
- import { Paragraph } from '../../ui-kit/Paragraph/Paragraph';
8
+ import { RichText } from '../../ui-kit/RichText/RichText';
9
9
  import { Tags } from '../../ui-kit/Tags/Tags';
10
10
  import { BaseTile } from '../BaseTile/BaseTile';
11
11
  import { getTileMinHeight } from '../BaseTile/getTileMinHeight';
@@ -18,7 +18,7 @@ export const Tile = JSX<TileProps>(
18
18
  ({
19
19
  title,
20
20
  headingType = 'h3',
21
- description,
21
+ __html,
22
22
  items,
23
23
  buttons,
24
24
  image,
@@ -52,9 +52,9 @@ export const Tile = JSX<TileProps>(
52
52
  })}
53
53
  image={image?.src ? <Img className="mt-auto ml-7" image={image} /> : null}
54
54
  >
55
- {description ? (
55
+ {__html ? (
56
56
  <div className="max-w-[600px] mt-2.5">
57
- <Paragraph size="text-xl-light">{description}</Paragraph>
57
+ <RichText __html={__html} />
58
58
  </div>
59
59
  ) : null}
60
60
  {children}
@@ -1 +1,7 @@
1
- {}
1
+ {
2
+ "content": {
3
+ "__html": {
4
+ "ui:widget": "html"
5
+ }
6
+ }
7
+ }
@@ -1,17 +1,17 @@
1
1
  import type { BlockVersion } from '../../model/BlockVersion';
2
- import type { DescriptionProps } from '../../model/HeadlineType';
3
2
  import type { Picture } from '../../model/Picture';
4
3
  import type { ButtonContent } from '../../ui-kit/Button/ButtonProps';
5
4
  import type { HeadingCommonProps } from '../../ui-kit/Heading/HeadingProps';
6
5
  import type { ListContent } from '../../ui-kit/List/ListContent';
7
6
  import type { ListItemSize } from '../../ui-kit/List/ListProps';
7
+ import type { RichTextProps } from '../../ui-kit/RichText/RichTextProps';
8
8
  import type { TagsContent } from '../../ui-kit/Tags/TagsContent';
9
9
 
10
10
  /**
11
11
  * @title Плитка
12
12
  */
13
13
  export type TileContent = HeadingCommonProps &
14
- DescriptionProps &
14
+ RichTextProps &
15
15
  ListContent &
16
16
  ButtonContent &
17
17
  TagsContent & {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@redneckz/wildless-cms-uni-blocks",
3
- "version": "0.8.9",
3
+ "version": "0.8.10",
4
4
  "private": false,
5
5
  "license": "MIT",
6
6
  "author": "ЦК",
@@ -25,7 +25,7 @@ export const Rate = JSX<RateProps>(
25
25
  rateBlockClassName,
26
26
  )}
27
27
  >
28
- {String(rate).replace('.', ',')}
28
+ {String(rate.toFixed(2)).replace('.', ',')}
29
29
  </span>
30
30
  {unit ? (
31
31
  <span className="gradient-color-text text-[65px] leading-[75px]">{unit}</span>
@@ -54,7 +54,7 @@ export const DEFAULT_DEPOSIT_CALCULATOR_PARAMS: DepositCalculatorSourceBookParam
54
54
  maxSum: 5000000,
55
55
  minMonths: 2,
56
56
  maxMonths: 120,
57
- rate: 5.9,
57
+ rate: 7,
58
58
  isMonthlyInterestPayment: true,
59
59
  };
60
60
 
@@ -64,7 +64,7 @@ export const DEFAULT_BUSINESS_DEPOSIT_CALCULATOR_PARAMS: BusinessDepositCalculat
64
64
  maxSum: 500000,
65
65
  minDays: BUSINESS_MIN_DAYS,
66
66
  maxDays: BUSINESS_MAX_DAYS,
67
- rate: 5.9,
67
+ rate: 6.6,
68
68
  isMonthlyInterestPayment: true,
69
69
  isReplenished: false,
70
70
  isPartialWithdrawal: false,
@@ -0,0 +1,24 @@
1
+ import { maxBy } from '../../utils/maxBy';
2
+ import { minBy } from '../../utils/minBy';
3
+
4
+ export const getRangeByKeys = <
5
+ MinKey extends string,
6
+ MaxKey extends string,
7
+ T extends Record<MinKey | MaxKey, number>,
8
+ >(
9
+ [minKey, maxKey]: [MinKey, MaxKey],
10
+ rows: T[] = [],
11
+ ) => ({
12
+ [minKey]: rows.length ? minBy()(rows.map((row) => row[minKey])) : 0,
13
+ [maxKey]: rows.length ? maxBy()(rows.map((row) => row[maxKey])) : 0,
14
+ });
15
+
16
+ export const checkRangeByKeys = <
17
+ MinKey extends string,
18
+ MaxKey extends string,
19
+ T extends Record<MinKey | MaxKey, number>,
20
+ >(
21
+ value: number,
22
+ [minKey, maxKey]: [MinKey, MaxKey],
23
+ sourceBookRow: T,
24
+ ): boolean => value >= sourceBookRow[minKey] && value < sourceBookRow[maxKey];
@@ -5,6 +5,7 @@ import {
5
5
  BUSINESS_RATE_MIN_DAYS,
6
6
  DEFAULT_BUSINESS_DEPOSIT_CALCULATOR_PARAMS,
7
7
  } from './constants';
8
+ import { checkRangeByKeys, getRangeByKeys } from './rangeHelpers';
8
9
  import { useCalculatorParams } from './useCalculatorParams';
9
10
  import type { CommonDepositParams } from './useDepositCalculatorParams';
10
11
 
@@ -72,9 +73,9 @@ export const useBusinessDepositCalculatorParams = (
72
73
  return (
73
74
  isMonthlyInterestPayment === _.isMonthlyInterestPayment &&
74
75
  isSmallBusiness === _.isSmallBusiness &&
75
- (isOperatingDeposit
76
- ? _.isReplenished && _.isPartialWithdrawal
77
- : !_.isReplenished && !_.isPartialWithdrawal)
76
+ checkIsOperatingDeposit(isOperatingDeposit, _) &&
77
+ checkRangeByKeys(moneyValue, ['minSum', 'maxSum'], _) &&
78
+ checkRangeByKeys(daysValue, ['minDays', 'maxDays'], _)
78
79
  );
79
80
  }) || DEFAULT_BUSINESS_DEPOSIT_CALCULATOR_PARAMS;
80
81
 
@@ -82,9 +83,12 @@ export const useBusinessDepositCalculatorParams = (
82
83
 
83
84
  const income = getDepositIncome(rate, userInputParams);
84
85
  const finalSum = moneyValue + income;
86
+ const sourceBookRows = data?.rows || [DEFAULT_BUSINESS_DEPOSIT_CALCULATOR_PARAMS];
85
87
 
86
88
  return {
87
89
  ...businessDepositCalculatorSourceBookParams,
90
+ ...getRangeByKeys(['minSum', 'maxSum'], sourceBookRows),
91
+ ...getRangeByKeys(['minDays', 'maxDays'], sourceBookRows),
88
92
  ...userInputParams,
89
93
  isDisabledOperatingDeposit,
90
94
  income,
@@ -92,6 +96,14 @@ export const useBusinessDepositCalculatorParams = (
92
96
  };
93
97
  };
94
98
 
99
+ const checkIsOperatingDeposit = (
100
+ isOperatingDeposit: boolean,
101
+ sourceBookRow: BusinessDepositCalculatorSourceBookParams,
102
+ ) =>
103
+ isOperatingDeposit
104
+ ? sourceBookRow.isReplenished && sourceBookRow.isPartialWithdrawal
105
+ : !sourceBookRow.isReplenished && !sourceBookRow.isPartialWithdrawal;
106
+
95
107
  const getDepositIncome = (
96
108
  rate: number,
97
109
  userInputParams: BusinessDepositCalculatorUserInputParams,
@@ -1,5 +1,6 @@
1
1
  import { CREDIT_CALC_DEFAULT_DIR, DEFAULT_CREDIT_CALCULATOR_PARAMS } from './constants';
2
2
  import { getMonthlyPayment } from './getMonthlyPayment';
3
+ import { checkRangeByKeys, getRangeByKeys } from './rangeHelpers';
3
4
  import { useCalculatorParams } from './useCalculatorParams';
4
5
 
5
6
  export interface CommonCreditParams {
@@ -38,7 +39,7 @@ export const useCreditCalculatorParams = (
38
39
  userInputParams: CreditCalculatorUserInputParams,
39
40
  sourceBookDir?: string,
40
41
  ): CreditCalculatorParams => {
41
- const { isInsurance, isSalaryClient, isStateEmployee, moneyValue } = userInputParams;
42
+ const { isInsurance, isSalaryClient, isStateEmployee, moneyValue, monthsValue } = userInputParams;
42
43
 
43
44
  const data = useCalculatorParams<CreditCalculatorData>(sourceBookDir || CREDIT_CALC_DEFAULT_DIR);
44
45
  const creditCalculatorSourceBookParams =
@@ -46,16 +47,21 @@ export const useCreditCalculatorParams = (
46
47
  return (
47
48
  isInsurance === _.isInsurance &&
48
49
  isSalaryClient === _.isSalaryClient &&
49
- isStateEmployee === _.isStateEmployee
50
+ isStateEmployee === _.isStateEmployee &&
51
+ checkRangeByKeys(moneyValue, ['minSum', 'maxSum'], _) &&
52
+ checkRangeByKeys(monthsValue, ['minMonths', 'maxMonths'], _)
50
53
  );
51
54
  }) || DEFAULT_CREDIT_CALCULATOR_PARAMS;
52
55
 
53
56
  const { rateBottomRange, rateTopRange, sumBorder } = creditCalculatorSourceBookParams;
54
57
  const finalRate = moneyValue <= sumBorder ? rateBottomRange : rateTopRange;
55
58
  const monthlyPayment = getMonthlyPayment(finalRate, userInputParams);
59
+ const sourceBookRows = data?.rows || [DEFAULT_CREDIT_CALCULATOR_PARAMS];
56
60
 
57
61
  return {
58
62
  ...creditCalculatorSourceBookParams,
63
+ ...getRangeByKeys(['minSum', 'maxSum'], sourceBookRows),
64
+ ...getRangeByKeys(['minMonths', 'maxMonths'], sourceBookRows),
59
65
  ...userInputParams,
60
66
  finalRate,
61
67
  monthlyPayment,
@@ -1,9 +1,11 @@
1
1
  import { DEFAULT_DEPOSIT_CALCULATOR_PARAMS, DEPOSIT_CALC_DEFAULT_DIR } from './constants';
2
+ import { checkRangeByKeys, getRangeByKeys } from './rangeHelpers';
2
3
  import { useCalculatorParams } from './useCalculatorParams';
3
4
 
4
5
  export interface CommonDepositParams {
5
6
  isMonthlyInterestPayment: boolean;
6
7
  }
8
+
7
9
  export interface DepositCalculatorSourceBookParams extends CommonDepositParams {
8
10
  minSum: number;
9
11
  maxSum: number;
@@ -32,22 +34,34 @@ export const useDepositCalculatorParams = (
32
34
  userInputParams: DepositCalculatorUserInputParams,
33
35
  sourceBookDir?: string,
34
36
  ): DepositCalculatorParams => {
35
- const { isMonthlyInterestPayment, moneyValue } = userInputParams;
37
+ const { isMonthlyInterestPayment, moneyValue, monthsValue } = userInputParams;
36
38
 
37
39
  const data = useCalculatorParams<DepositCalculatorData>(
38
40
  sourceBookDir || DEPOSIT_CALC_DEFAULT_DIR,
39
41
  );
40
42
 
41
43
  const depositCalculatorSourceBookParams =
42
- data?.rows?.find((_) => isMonthlyInterestPayment === _.isMonthlyInterestPayment) ||
43
- DEFAULT_DEPOSIT_CALCULATOR_PARAMS;
44
+ data?.rows?.find(
45
+ (_) =>
46
+ isMonthlyInterestPayment === _.isMonthlyInterestPayment &&
47
+ checkRangeByKeys(moneyValue, ['minSum', 'maxSum'], _) &&
48
+ checkRangeByKeys(monthsValue, ['minMonths', 'maxMonths'], _),
49
+ ) || DEFAULT_DEPOSIT_CALCULATOR_PARAMS;
44
50
 
45
51
  const { rate } = depositCalculatorSourceBookParams;
46
52
 
47
53
  const income = getDepositIncome(rate, userInputParams);
48
54
  const finalSum = moneyValue + income;
55
+ const sourceBookRows = data?.rows || [DEFAULT_DEPOSIT_CALCULATOR_PARAMS];
49
56
 
50
- return { ...depositCalculatorSourceBookParams, ...userInputParams, income, finalSum };
57
+ return {
58
+ ...depositCalculatorSourceBookParams,
59
+ ...getRangeByKeys(['minSum', 'maxSum'], sourceBookRows),
60
+ ...getRangeByKeys(['minMonths', 'maxMonths'], sourceBookRows),
61
+ ...userInputParams,
62
+ income,
63
+ finalSum,
64
+ };
51
65
  };
52
66
 
53
67
  const getDepositIncome = (rate: number, userInputParams: DepositCalculatorUserInputParams) => {
@@ -52,10 +52,12 @@ export const Carousel: JSXBlock<CarouselProps> = JSX<CarouselProps>(
52
52
  gap={ITEMS_GAP}
53
53
  onVisibleIndicesChange={scroll.handleVisibleIndicesChange}
54
54
  >
55
- {renderChildren({
56
- ...rest,
57
- block: { ...rest.block, blocks: buildBlocks(childBlocks, activeIndex) },
58
- })}
55
+ {isBankHistoryCarousel
56
+ ? renderChildren({
57
+ ...rest,
58
+ block: { ...rest.block, blocks: buildBlocks(childBlocks, activeIndex) },
59
+ })
60
+ : renderChildren(rest)}
59
61
  </SwipeListContainer>
60
62
  <CarouselScrollButtons
61
63
  scroll={scroll}
@@ -4,6 +4,7 @@ import type { ComplexBenefitProps } from '../../ui-kit/BenefitItem/BenefitItemPr
4
4
  import { RichText } from '../../ui-kit/RichText/RichText';
5
5
  import { assertUnreachable } from '../../utils/assertUnreachable';
6
6
 
7
+ // TODO: Create universal function for this case
7
8
  export const renderBenefit =
8
9
  // Linter doesn't understand that switch processes all cases
9
10
  // eslint-disable-next-line consistent-return
@@ -3,6 +3,7 @@ import { Text } from '../../ui-kit/Text/Text';
3
3
  import { assertUnreachable } from '../../utils/assertUnreachable';
4
4
  import type { Benefit } from './ProductTileContent';
5
5
 
6
+ // TODO: Create universal function for this case
6
7
  export const renderBenefit =
7
8
  // Linter doesn't understand that switch processes all cases
8
9
  // eslint-disable-next-line consistent-return
@@ -1,16 +1,20 @@
1
1
  import '../../setup-fixture';
2
2
  import { StepsBlock } from './StepsBlock';
3
+ import type { Step } from './StepsBlockContent';
3
4
 
4
- const steps = [
5
+ const steps: Step[] = [
5
6
  {
7
+ type: 'default',
6
8
  label: 'Заявка на кредит',
7
9
  description: 'Оставьте онлайн-заявку на потребительский кредит',
8
10
  },
9
11
  {
12
+ type: 'default',
10
13
  label: 'В случае одобрения',
11
14
  description: 'Менеджер свяжется с вами и согласует встречу',
12
15
  },
13
16
  {
17
+ type: 'default',
14
18
  label: 'Получение наличных',
15
19
  description: 'Получите наличные в отделении банка',
16
20
  },
@@ -49,19 +53,23 @@ export default {
49
53
  size="small"
50
54
  steps={[
51
55
  {
56
+ type: 'default',
52
57
  description: 'Оставьте онлайн-заявку на потребительский кредит',
53
58
  icon: { icon: 'ClockIcon' },
54
59
  },
55
60
  {
61
+ type: 'default',
56
62
  label: 'В случае одобрения',
57
63
  icon: { icon: 'SignDocsIcon' },
58
64
  },
59
65
  {
66
+ type: 'default',
60
67
  label: 'Заявка на кредит',
61
68
  description: 'Оставьте онлайн-заявку на потребительский кредит',
62
69
  icon: { icon: 'ComfortableCompIcon' },
63
70
  },
64
71
  {
72
+ type: 'default',
65
73
  label: 'Получение наличных',
66
74
  icon: { icon: 'ClockIcon' },
67
75
  },
@@ -78,14 +86,17 @@ export default {
78
86
  size="small"
79
87
  steps={[
80
88
  {
89
+ type: 'default',
81
90
  label: 'Заявка на кредит',
82
91
  icon: { icon: 'EmptyWalletIcon' },
83
92
  },
84
93
  {
94
+ type: 'default',
85
95
  label: 'В случае одобрения',
86
96
  icon: { icon: 'PercentageSquareIcon' },
87
97
  },
88
98
  {
99
+ type: 'default',
89
100
  label: 'Получение наличных',
90
101
  icon: { icon: 'CalendarIcon' },
91
102
  },
@@ -128,19 +139,23 @@ export default {
128
139
  size="small"
129
140
  steps={[
130
141
  {
142
+ type: 'default',
131
143
  description: 'Оставьте онлайн-заявку на потребительский кредит',
132
144
  icon: { icon: 'ClockIcon', iconVersion: 'normal' },
133
145
  },
134
146
  {
147
+ type: 'default',
135
148
  label: 'В случае одобрения',
136
149
  icon: { icon: 'SignDocsIcon', iconVersion: 'normal' },
137
150
  },
138
151
  {
152
+ type: 'default',
139
153
  label: 'Заявка на кредит',
140
154
  description: 'Оставьте онлайн-заявку на потребительский кредит',
141
155
  icon: { icon: 'ComfortableCompIcon', iconVersion: 'normal' },
142
156
  },
143
157
  {
158
+ type: 'default',
144
159
  label: 'Получение наличных',
145
160
  icon: { icon: 'ClockIcon', iconVersion: 'normal' },
146
161
  },
@@ -158,14 +173,17 @@ export default {
158
173
  size="small"
159
174
  steps={[
160
175
  {
176
+ type: 'default',
161
177
  label: 'Заявка на кредит',
162
178
  icon: { icon: 'EmptyWalletIcon' },
163
179
  },
164
180
  {
181
+ type: 'default',
165
182
  label: 'В случае одобрения',
166
183
  icon: { icon: 'PercentageSquareIcon' },
167
184
  },
168
185
  {
186
+ type: 'default',
169
187
  label: 'Получение наличных',
170
188
  icon: { icon: 'CalendarIcon' },
171
189
  },
@@ -1,12 +1,12 @@
1
1
  import '../../setup-fixture';
2
2
  import type { StepsBlockProps } from './StepsBlock';
3
3
  import { StepsBlock } from './StepsBlock';
4
- import type { Step } from './StepsBlockContent';
4
+ import type { DefaultStep, Step } from './StepsBlockContent';
5
5
 
6
6
  const TITLE =
7
7
  'Рассчитайте условия на онлайн-калькуляторе и оставьте заявку на потребительский кредит';
8
8
 
9
- const ITEMS: Step['items'] = ['item1', 'item2', 'item3', 'item4', 'item5'];
9
+ const ITEMS: DefaultStep['items'] = ['item1', 'item2', 'item3', 'item4', 'item5'];
10
10
  const COMMON_PROPS: StepsBlockProps = {
11
11
  className: 'col-span-12',
12
12
  title: TITLE,
@@ -14,18 +14,22 @@ const COMMON_PROPS: StepsBlockProps = {
14
14
 
15
15
  const STEPS: Step[] = [
16
16
  {
17
+ type: 'default',
17
18
  label: 'Заявка на кредит',
18
19
  description: 'Оставьте онлайн-заявку на потребительский кредит',
19
20
  },
20
21
  {
22
+ type: 'default',
21
23
  label: 'В случае одобрения',
22
24
  description: 'Менеджер свяжется с вами и согласует встречу',
23
25
  },
24
26
  {
27
+ type: 'default',
25
28
  label: 'Получение наличных',
26
29
  description: 'Получите наличные в отделении банка',
27
30
  },
28
31
  {
32
+ type: 'default',
29
33
  label: 'Последний шаг!',
30
34
  description: 'Получите наличные в отделении банка',
31
35
  },
@@ -33,23 +37,26 @@ const STEPS: Step[] = [
33
37
 
34
38
  const STEPS_WITH_ICONS: Step[] = [
35
39
  {
40
+ type: 'default',
36
41
  label: 'В мобильном приложении или интернет-банке',
37
42
  description: 'Для всех клиентов Россельхозбанка',
38
43
  icon: { icon: 'SignDocsIcon', iconVersion: 'normal' },
39
44
  },
40
45
  {
46
+ type: 'default',
41
47
  label: 'Через Госуслуги',
42
48
  description: 'При наличии данных в Единой биометрической системе',
43
49
  icon: { icon: 'ClockIcon', iconVersion: 'normal' },
44
50
  },
45
51
  {
52
+ type: 'default',
46
53
  label: 'В офисах Россельхозбанка',
47
54
  description: 'Откройте вклад',
48
55
  icon: { icon: 'ComfortableCompIcon', iconVersion: 'normal' },
49
56
  },
50
57
  ];
51
58
 
52
- const BUTTONS: Step['button'][] = [
59
+ const BUTTONS: DefaultStep['button'][] = [
53
60
  { text: 'Войти в интернет-банк' },
54
61
  { text: 'Оформить' },
55
62
  { text: 'Офисы на карте' },
@@ -5,9 +5,11 @@ import type { SizeVersion } from '../../model/SizeVersion';
5
5
  import { BlockWrapper } from '../../ui-kit/BlockWrapper';
6
6
  import { Heading } from '../../ui-kit/Heading/Heading';
7
7
  import { Img } from '../../ui-kit/Img/Img';
8
- import { checkIsIconRenderable } from '../../utils/checkIsIconRenderable';
8
+ import { RichText } from '../../ui-kit/RichText/RichText';
9
+ import { assertUnreachable } from '../../utils/assertUnreachable';
9
10
  import { getIconWithVersion } from '../../utils/getIconWithVersion';
10
- import type { Step, StepsBlockContent } from './StepsBlockContent';
11
+ import { checkCanRenderIcon } from './checkCanRenderIcon';
12
+ import type { DefaultStep, Step, StepsBlockContent } from './StepsBlockContent';
11
13
  import { STEPS_BLOCK_STYLE_MAPS } from './StepsBlockStyleMaps';
12
14
 
13
15
  export interface StepsBlockProps extends StepsBlockContent, UniBlockProps {}
@@ -50,7 +52,7 @@ export const StepsBlock = JSX<StepsBlockProps>(
50
52
  {steps?.length ? (
51
53
  <div className={`box-border py-0.5 mb-0.5 mt-5`}>
52
54
  <div className="flex flex-col justify-between gap-x-[101px]">
53
- {steps.map(renderStepTitle(size, version, showLines))}
55
+ {steps.map(renderStep(size, version, showLines))}
54
56
  </div>
55
57
  </div>
56
58
  ) : null}
@@ -59,9 +61,31 @@ export const StepsBlock = JSX<StepsBlockProps>(
59
61
  },
60
62
  );
61
63
 
62
- const renderStepTitle =
64
+ // TODO: Create universal function for this case
65
+ const renderStep =
63
66
  (size: SizeVersion, version: BlockVersion, showLines: boolean) =>
67
+ // Linter doesn't understand that switch processes all cases
68
+ // eslint-disable-next-line consistent-return
64
69
  (step: Step, i: number, steps: Step[]) => {
70
+ const { type } = step;
71
+
72
+ if (!(type === 'default' || type === 'rte')) {
73
+ return null;
74
+ }
75
+
76
+ switch (type) {
77
+ case 'default':
78
+ return renderDefaultStep(size, version, showLines)(step, i, steps);
79
+ case 'rte':
80
+ return <RichText __html={step.__html} />;
81
+ default:
82
+ assertUnreachable(step);
83
+ }
84
+ };
85
+
86
+ const renderDefaultStep =
87
+ (size: SizeVersion, version: BlockVersion, showLines: boolean) =>
88
+ (step: DefaultStep, i: number, steps: Step[]) => {
65
89
  const isLastStep = steps.length - 1 === i;
66
90
  const margin = size === 'normal' ? 'ml-[34px]' : 'ml-6';
67
91
  const styleMap = STEPS_BLOCK_STYLE_MAPS[version];
@@ -106,7 +130,7 @@ const renderIconArea = (size: SizeVersion, version: BlockVersion) => (step: Step
106
130
  className={`${iconAreaSize} ${styleMap.iconBackground} rounded-full z-10 mr-3 flex justify-center content-center`}
107
131
  >
108
132
  <span className={`font-medium flex self-center ${iconTextSize}`}>
109
- {checkIsIconRenderable(step?.icon) ? (
133
+ {checkCanRenderIcon(step?.icon) ? (
110
134
  <Img
111
135
  image={getIconWithVersion({ ...step.icon }, version)}
112
136
  width={iconSize}