@redneckz/wildless-cms-uni-blocks 0.7.7 → 0.7.8

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 (55) hide show
  1. package/bin/migration-scripts/0.7.8.js +29 -0
  2. package/bundle/blocks.schema.json +1 -1
  3. package/bundle/bundle.umd.js +29 -12
  4. package/bundle/bundle.umd.min.js +1 -1
  5. package/bundle/components/PictureText/renderBenefit.d.ts +4 -0
  6. package/bundle/ui-kit/BenefitItem/BenefitItemProps.d.ts +26 -3
  7. package/dist/components/PictureText/PictureText.js +2 -3
  8. package/dist/components/PictureText/PictureText.js.map +1 -1
  9. package/dist/components/PictureText/renderBenefit.d.ts +4 -0
  10. package/dist/components/PictureText/renderBenefit.js +25 -0
  11. package/dist/components/PictureText/renderBenefit.js.map +1 -0
  12. package/dist/components/ProductTile/renderBenefit.js +1 -1
  13. package/dist/components/ProductTile/renderBenefit.js.map +1 -1
  14. package/dist/ui-kit/BenefitItem/BenefitItemProps.d.ts +26 -3
  15. package/lib/components/PictureText/PictureText.fixture.d.ts +2 -0
  16. package/lib/components/PictureText/PictureText.js +1 -2
  17. package/lib/components/PictureText/PictureText.js.map +1 -1
  18. package/lib/components/PictureText/renderBenefit.d.ts +4 -0
  19. package/lib/components/PictureText/renderBenefit.js +22 -0
  20. package/lib/components/PictureText/renderBenefit.js.map +1 -0
  21. package/lib/components/ProductTile/renderBenefit.js +1 -1
  22. package/lib/components/ProductTile/renderBenefit.js.map +1 -1
  23. package/lib/ui-kit/BenefitItem/BenefitItemProps.d.ts +26 -3
  24. package/mobile/bundle/bundle.umd.js +1 -1
  25. package/mobile/bundle/bundle.umd.min.js +1 -1
  26. package/mobile/bundle/components/PictureText/renderBenefit.d.ts +4 -0
  27. package/mobile/bundle/ui-kit/BenefitItem/BenefitItemProps.d.ts +26 -3
  28. package/mobile/dist/components/PictureText/PictureText.js +2 -3
  29. package/mobile/dist/components/PictureText/PictureText.js.map +1 -1
  30. package/mobile/dist/components/PictureText/renderBenefit.d.ts +4 -0
  31. package/mobile/dist/components/PictureText/renderBenefit.js +25 -0
  32. package/mobile/dist/components/PictureText/renderBenefit.js.map +1 -0
  33. package/mobile/dist/components/ProductTile/renderBenefit.js +1 -1
  34. package/mobile/dist/components/ProductTile/renderBenefit.js.map +1 -1
  35. package/mobile/dist/ui-kit/BenefitItem/BenefitItemProps.d.ts +26 -3
  36. package/mobile/lib/components/PictureText/PictureText.js +1 -2
  37. package/mobile/lib/components/PictureText/PictureText.js.map +1 -1
  38. package/mobile/lib/components/PictureText/renderBenefit.d.ts +4 -0
  39. package/mobile/lib/components/PictureText/renderBenefit.js +22 -0
  40. package/mobile/lib/components/PictureText/renderBenefit.js.map +1 -0
  41. package/mobile/lib/components/ProductTile/renderBenefit.js +1 -1
  42. package/mobile/lib/components/ProductTile/renderBenefit.js.map +1 -1
  43. package/mobile/lib/ui-kit/BenefitItem/BenefitItemProps.d.ts +26 -3
  44. package/mobile/src/components/PictureText/PictureText.tsx +1 -14
  45. package/mobile/src/components/PictureText/PictureText.ui.json +10 -0
  46. package/mobile/src/components/PictureText/renderBenefit.tsx +33 -0
  47. package/mobile/src/components/ProductTile/renderBenefit.tsx +5 -1
  48. package/mobile/src/ui-kit/BenefitItem/BenefitItemProps.ts +28 -3
  49. package/package.json +1 -1
  50. package/src/components/PictureText/PictureText.fixture.tsx +37 -0
  51. package/src/components/PictureText/PictureText.tsx +1 -14
  52. package/src/components/PictureText/PictureText.ui.json +10 -0
  53. package/src/components/PictureText/renderBenefit.tsx +33 -0
  54. package/src/components/ProductTile/renderBenefit.tsx +5 -1
  55. package/src/ui-kit/BenefitItem/BenefitItemProps.ts +28 -3
@@ -1,7 +1,8 @@
1
- import type { IconProps } from '../../model/Picture';
2
1
  import type { BlockVersion } from '../../model/BlockVersion';
3
- import type { IconVersion } from '../../model/IconVersion';
4
2
  import type { DescriptionProps, LabelProps } from '../../model/HeadlineType';
3
+ import type { IconVersion } from '../../model/IconVersion';
4
+ import type { IconProps } from '../../model/Picture';
5
+ import { RichTextProps } from '../RichText/RichTextProps';
5
6
  export interface BenefitItemCommonProps {
6
7
  /** @hidden */
7
8
  benefitsVersion?: IconVersion;
@@ -11,10 +12,32 @@ export interface BenefitItemCommonProps {
11
12
  className?: string;
12
13
  }
13
14
  export declare type BenefitItemProps = DescriptionProps & LabelProps & IconProps;
15
+ /**
16
+ * @title Стандартный бенефит
17
+ */
18
+ declare type DefaultBenefit = BenefitItemProps & {
19
+ /** @default default */
20
+ type: 'default';
21
+ };
22
+ /**
23
+ * @title Форматированный текст
24
+ */
25
+ declare type RichText = RichTextProps & {
26
+ /** @default rte */
27
+ type: 'rte';
28
+ };
29
+ /**
30
+ * @title Преимущество
31
+ * @default{
32
+ * "type": "default"
33
+ * }
34
+ */
35
+ export declare type ComplexBenefitProps = DefaultBenefit | RichText;
14
36
  /**
15
37
  * @title Преимущество
16
38
  */
17
39
  export declare type BenefitsProps = BenefitItemCommonProps & {
18
40
  /** @title Список преимуществ */
19
- benefits?: BenefitItemProps[];
41
+ benefits?: ComplexBenefitProps[];
20
42
  };
43
+ export {};
@@ -1,13 +1,11 @@
1
1
  import { JSX } from '@redneckz/uni-jsx';
2
- import type { BlockVersion } from '../../model/BlockVersion';
3
2
  import type { UniBlockProps } from '../../model/JSXBlock';
4
- import { BenefitItem } from '../../ui-kit/BenefitItem/BenefitItem';
5
- import type { BenefitItemProps } from '../../ui-kit/BenefitItem/BenefitItemProps';
6
3
  import { BlockWrapper } from '../../ui-kit/BlockWrapper';
7
4
  import { Img } from '../../ui-kit/Img/Img';
8
5
  import { addSpacesBetweenNumbers } from '../../utils/addSpacesBetweenNumbers';
9
6
  import { Headline } from '../Headline/Headline';
10
7
  import type { PictureTextContent } from './PictureTextContent';
8
+ import { renderBenefit } from './renderBenefit';
11
9
 
12
10
  export interface PictureTextProps extends PictureTextContent, UniBlockProps {}
13
11
 
@@ -39,17 +37,6 @@ export const PictureText = JSX<PictureTextProps>(
39
37
  ),
40
38
  );
41
39
 
42
- const renderBenefit = (version: BlockVersion) => (benefit: BenefitItemProps, i: number) =>
43
- (
44
- <BenefitItem
45
- key={String(i)}
46
- icon={benefit.icon}
47
- label={benefit.label}
48
- description={benefit.description}
49
- version={version}
50
- />
51
- );
52
-
53
40
  function renderInsuranceSumMonth(sum?: number, monthLimit?: number) {
54
41
  return sum || monthLimit ? (
55
42
  <div className="bg-main-divider rounded-md flex mt-7 gap-6 px-5 py-4">
@@ -5,6 +5,16 @@
5
5
  },
6
6
  "monthLimit": {
7
7
  "ui:field": "number"
8
+ },
9
+ "benefits": {
10
+ "items": {
11
+ "__html": {
12
+ "ui:widget": "html"
13
+ },
14
+ "type": {
15
+ "ui:widget": "hidden"
16
+ }
17
+ }
8
18
  }
9
19
  }
10
20
  }
@@ -0,0 +1,33 @@
1
+ import { BlockVersion } from '../../model/BlockVersion';
2
+ import { BenefitItem } from '../../ui-kit/BenefitItem/BenefitItem';
3
+ import type { ComplexBenefitProps } from '../../ui-kit/BenefitItem/BenefitItemProps';
4
+ import { RichText } from '../../ui-kit/RichText/RichText';
5
+ import { assertUnreachable } from '../../utils/assertUnreachable';
6
+
7
+ export const renderBenefit =
8
+ // Linter doesn't understand that switch processes all cases
9
+ // eslint-disable-next-line consistent-return
10
+ (version: BlockVersion) => (benefit: ComplexBenefitProps, i: number) => {
11
+ const { type } = benefit;
12
+
13
+ if (!(type === 'default' || type === 'rte')) {
14
+ return null;
15
+ }
16
+
17
+ switch (type) {
18
+ case 'default':
19
+ return (
20
+ <BenefitItem
21
+ key={String(i)}
22
+ icon={benefit.icon}
23
+ label={benefit.label}
24
+ description={benefit.description}
25
+ version={version}
26
+ />
27
+ );
28
+ case 'rte':
29
+ return <RichText __html={benefit.__html} />;
30
+ default:
31
+ assertUnreachable(benefit);
32
+ }
33
+ };
@@ -29,7 +29,11 @@ export const renderBenefit =
29
29
  </Text>,
30
30
  ];
31
31
  case 'rte':
32
- return <RichText __html={benefit.__html} />;
32
+ return (
33
+ <div className="col-span-2">
34
+ <RichText __html={benefit.__html} />
35
+ </div>
36
+ );
33
37
  default:
34
38
  assertUnreachable(benefit);
35
39
  }
@@ -1,7 +1,8 @@
1
- import type { IconProps } from '../../model/Picture';
2
1
  import type { BlockVersion } from '../../model/BlockVersion';
3
- import type { IconVersion } from '../../model/IconVersion';
4
2
  import type { DescriptionProps, LabelProps } from '../../model/HeadlineType';
3
+ import type { IconVersion } from '../../model/IconVersion';
4
+ import type { IconProps } from '../../model/Picture';
5
+ import { RichTextProps } from '../RichText/RichTextProps';
5
6
 
6
7
  export interface BenefitItemCommonProps {
7
8
  /** @hidden */
@@ -14,10 +15,34 @@ export interface BenefitItemCommonProps {
14
15
 
15
16
  export type BenefitItemProps = DescriptionProps & LabelProps & IconProps;
16
17
 
18
+ /**
19
+ * @title Стандартный бенефит
20
+ */
21
+ type DefaultBenefit = BenefitItemProps & {
22
+ /** @default default */
23
+ type: 'default';
24
+ };
25
+
26
+ /**
27
+ * @title Форматированный текст
28
+ */
29
+ type RichText = RichTextProps & {
30
+ /** @default rte */
31
+ type: 'rte';
32
+ };
33
+
34
+ /**
35
+ * @title Преимущество
36
+ * @default{
37
+ * "type": "default"
38
+ * }
39
+ */
40
+ export type ComplexBenefitProps = DefaultBenefit | RichText;
41
+
17
42
  /**
18
43
  * @title Преимущество
19
44
  */
20
45
  export type BenefitsProps = BenefitItemCommonProps & {
21
46
  /** @title Список преимуществ */
22
- benefits?: BenefitItemProps[];
47
+ benefits?: ComplexBenefitProps[];
23
48
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@redneckz/wildless-cms-uni-blocks",
3
- "version": "0.7.7",
3
+ "version": "0.7.8",
4
4
  "private": false,
5
5
  "license": "MIT",
6
6
  "author": "ЦК",
@@ -29,6 +29,14 @@ const imageInsurance: Picture = {
29
29
  ],
30
30
  };
31
31
 
32
+ const imageMonitor: Picture = {
33
+ src: 'monitor.png',
34
+ format: 'webp',
35
+ alt: 'Управление несколькими счетами',
36
+ size: {
37
+ width: 420,
38
+ },
39
+ };
32
40
  export const PICTURE_TEXT: PictureTextContent = {
33
41
  title: 'Обменивайте бонусы на путешествия',
34
42
  description:
@@ -36,11 +44,13 @@ export const PICTURE_TEXT: PictureTextContent = {
36
44
  'бонусные баллы на авиа и ж/д билеты, бронирование отелей и прокат автомобилей.',
37
45
  benefits: [
38
46
  {
47
+ type: 'default',
39
48
  label: 'Кредит по одному документу',
40
49
  description: 'До 300 тыс ₽ по упрощённой процедуре получения кредита',
41
50
  icon: { icon: 'DocumentTextIcon' },
42
51
  },
43
52
  {
53
+ type: 'default',
44
54
  label: 'Кредит на общих условиях',
45
55
  description: 'До 5 млн ₽ на общих условиях получения кредита',
46
56
  icon: { icon: 'DocumentTextIcon' },
@@ -54,19 +64,23 @@ export const INSURANCE_TEXT: PictureTextContent = {
54
64
  description: 'Покрываемые риски программы «Защита вас и ваших близких»',
55
65
  benefits: [
56
66
  {
67
+ type: 'default',
57
68
  label: 'Телесное повреждение',
58
69
  icon: { icon: 'ShieldTickIcon' },
59
70
  },
60
71
  {
72
+ type: 'default',
61
73
  label: 'Госпитализация застрахованного',
62
74
  description: 'Описание',
63
75
  icon: { icon: 'ShieldTickIcon' },
64
76
  },
65
77
  {
78
+ type: 'default',
66
79
  label: 'Сокращение численности работников организации и другой текст для теста длинны текста',
67
80
  icon: { icon: 'ShieldTickIcon' },
68
81
  },
69
82
  {
83
+ type: 'default',
70
84
  label: 'Смерть застрахованного',
71
85
  icon: { icon: 'ShieldTickIcon' },
72
86
  },
@@ -75,6 +89,24 @@ export const INSURANCE_TEXT: PictureTextContent = {
75
89
  sum: 500000,
76
90
  };
77
91
 
92
+ export const BENEFITS_HTML_TEXT: PictureTextContent = {
93
+ title: '',
94
+ benefits: [
95
+ {
96
+ type: 'rte',
97
+ __html:
98
+ '<p class="h3">Управление несколькими счетами</p><p>Контролируйте баланс, пересылайте реквизиты контрагентам и установите любимый счёт для регулярных платежей</p>',
99
+ },
100
+ {
101
+ type: 'rte',
102
+ __html:
103
+ '<p class="h3">Управление несколькими счетами</p><p>Контролируйте баланс, пересылайте реквизиты контрагентам и установите любимый счёт для регулярных платежей</p>',
104
+ },
105
+ ],
106
+
107
+ image: imageMonitor,
108
+ };
109
+
78
110
  export default {
79
111
  default: (
80
112
  <div className="container grid grid-cols-12">
@@ -96,4 +128,9 @@ export default {
96
128
  <PictureText className="col-span-12" {...INSURANCE_TEXT} monthLimit={25000} />
97
129
  </div>
98
130
  ),
131
+ 'benefits as html': (
132
+ <div className="container grid grid-cols-12">
133
+ <PictureText className="col-span-12" {...BENEFITS_HTML_TEXT} />
134
+ </div>
135
+ ),
99
136
  };
@@ -1,13 +1,11 @@
1
1
  import { JSX } from '@redneckz/uni-jsx';
2
- import type { BlockVersion } from '../../model/BlockVersion';
3
2
  import type { UniBlockProps } from '../../model/JSXBlock';
4
- import { BenefitItem } from '../../ui-kit/BenefitItem/BenefitItem';
5
- import type { BenefitItemProps } from '../../ui-kit/BenefitItem/BenefitItemProps';
6
3
  import { BlockWrapper } from '../../ui-kit/BlockWrapper';
7
4
  import { Img } from '../../ui-kit/Img/Img';
8
5
  import { addSpacesBetweenNumbers } from '../../utils/addSpacesBetweenNumbers';
9
6
  import { Headline } from '../Headline/Headline';
10
7
  import type { PictureTextContent } from './PictureTextContent';
8
+ import { renderBenefit } from './renderBenefit';
11
9
 
12
10
  export interface PictureTextProps extends PictureTextContent, UniBlockProps {}
13
11
 
@@ -39,17 +37,6 @@ export const PictureText = JSX<PictureTextProps>(
39
37
  ),
40
38
  );
41
39
 
42
- const renderBenefit = (version: BlockVersion) => (benefit: BenefitItemProps, i: number) =>
43
- (
44
- <BenefitItem
45
- key={String(i)}
46
- icon={benefit.icon}
47
- label={benefit.label}
48
- description={benefit.description}
49
- version={version}
50
- />
51
- );
52
-
53
40
  function renderInsuranceSumMonth(sum?: number, monthLimit?: number) {
54
41
  return sum || monthLimit ? (
55
42
  <div className="bg-main-divider rounded-md flex mt-7 gap-6 px-5 py-4">
@@ -5,6 +5,16 @@
5
5
  },
6
6
  "monthLimit": {
7
7
  "ui:field": "number"
8
+ },
9
+ "benefits": {
10
+ "items": {
11
+ "__html": {
12
+ "ui:widget": "html"
13
+ },
14
+ "type": {
15
+ "ui:widget": "hidden"
16
+ }
17
+ }
8
18
  }
9
19
  }
10
20
  }
@@ -0,0 +1,33 @@
1
+ import { BlockVersion } from '../../model/BlockVersion';
2
+ import { BenefitItem } from '../../ui-kit/BenefitItem/BenefitItem';
3
+ import type { ComplexBenefitProps } from '../../ui-kit/BenefitItem/BenefitItemProps';
4
+ import { RichText } from '../../ui-kit/RichText/RichText';
5
+ import { assertUnreachable } from '../../utils/assertUnreachable';
6
+
7
+ export const renderBenefit =
8
+ // Linter doesn't understand that switch processes all cases
9
+ // eslint-disable-next-line consistent-return
10
+ (version: BlockVersion) => (benefit: ComplexBenefitProps, i: number) => {
11
+ const { type } = benefit;
12
+
13
+ if (!(type === 'default' || type === 'rte')) {
14
+ return null;
15
+ }
16
+
17
+ switch (type) {
18
+ case 'default':
19
+ return (
20
+ <BenefitItem
21
+ key={String(i)}
22
+ icon={benefit.icon}
23
+ label={benefit.label}
24
+ description={benefit.description}
25
+ version={version}
26
+ />
27
+ );
28
+ case 'rte':
29
+ return <RichText __html={benefit.__html} />;
30
+ default:
31
+ assertUnreachable(benefit);
32
+ }
33
+ };
@@ -29,7 +29,11 @@ export const renderBenefit =
29
29
  </Text>,
30
30
  ];
31
31
  case 'rte':
32
- return <RichText __html={benefit.__html} />;
32
+ return (
33
+ <div className="col-span-2">
34
+ <RichText __html={benefit.__html} />
35
+ </div>
36
+ );
33
37
  default:
34
38
  assertUnreachable(benefit);
35
39
  }
@@ -1,7 +1,8 @@
1
- import type { IconProps } from '../../model/Picture';
2
1
  import type { BlockVersion } from '../../model/BlockVersion';
3
- import type { IconVersion } from '../../model/IconVersion';
4
2
  import type { DescriptionProps, LabelProps } from '../../model/HeadlineType';
3
+ import type { IconVersion } from '../../model/IconVersion';
4
+ import type { IconProps } from '../../model/Picture';
5
+ import { RichTextProps } from '../RichText/RichTextProps';
5
6
 
6
7
  export interface BenefitItemCommonProps {
7
8
  /** @hidden */
@@ -14,10 +15,34 @@ export interface BenefitItemCommonProps {
14
15
 
15
16
  export type BenefitItemProps = DescriptionProps & LabelProps & IconProps;
16
17
 
18
+ /**
19
+ * @title Стандартный бенефит
20
+ */
21
+ type DefaultBenefit = BenefitItemProps & {
22
+ /** @default default */
23
+ type: 'default';
24
+ };
25
+
26
+ /**
27
+ * @title Форматированный текст
28
+ */
29
+ type RichText = RichTextProps & {
30
+ /** @default rte */
31
+ type: 'rte';
32
+ };
33
+
34
+ /**
35
+ * @title Преимущество
36
+ * @default{
37
+ * "type": "default"
38
+ * }
39
+ */
40
+ export type ComplexBenefitProps = DefaultBenefit | RichText;
41
+
17
42
  /**
18
43
  * @title Преимущество
19
44
  */
20
45
  export type BenefitsProps = BenefitItemCommonProps & {
21
46
  /** @title Список преимуществ */
22
- benefits?: BenefitItemProps[];
47
+ benefits?: ComplexBenefitProps[];
23
48
  };