@megafon/ui-shared 5.2.4 → 5.4.0

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.
package/CHANGELOG.md CHANGED
@@ -3,6 +3,33 @@
3
3
  All notable changes to this project will be documented in this file.
4
4
  See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
5
5
 
6
+ # [5.4.0](https://hq-gitlab.megafon.ru/site-portal/services/megafon-ui/compare/@megafon/ui-shared@5.3.0...@megafon/ui-shared@5.4.0) (2024-01-09)
7
+
8
+
9
+ ### Features
10
+
11
+ * **benefitspictures:** add imgAlign and textAlign props, add ReactNode type to item text ([ebb2f3f](https://hq-gitlab.megafon.ru/site-portal/services/megafon-ui/commit/ebb2f3f0509f436e456a60c01fa362ecf92371e8))
12
+
13
+
14
+
15
+
16
+
17
+ # [5.3.0](https://hq-gitlab.megafon.ru/site-portal/services/megafon-ui/compare/@megafon/ui-shared@5.2.4...@megafon/ui-shared@5.3.0) (2023-12-14)
18
+
19
+
20
+ ### Bug Fixes
21
+
22
+ * **steps:** added classes props ([e9f1732](https://hq-gitlab.megafon.ru/site-portal/services/megafon-ui/commit/e9f17329e675ec31efdd74904dcfb2861af90c79))
23
+
24
+
25
+ ### Features
26
+
27
+ * **benefitspictures:** add minor fixes ([b6203da](https://hq-gitlab.megafon.ru/site-portal/services/megafon-ui/commit/b6203dafbb3a8761ae5bfa0ad6ef54c789a01df9))
28
+
29
+
30
+
31
+
32
+
6
33
  ## [5.2.4](https://hq-gitlab.megafon.ru/site-portal/services/megafon-ui/compare/@megafon/ui-shared@5.2.3...@megafon/ui-shared@5.2.4) (2023-11-27)
7
34
 
8
35
  **Note:** Version bump only for package @megafon/ui-shared
@@ -7,8 +7,12 @@ export interface IBenefitsPicturesProps {
7
7
  rootRef?: React.Ref<HTMLDivElement>;
8
8
  /** Данные для бенефитов */
9
9
  items: IBenefit[];
10
- /** Горизонтальное выравнивание */
10
+ /** Горизонтальное выравнивание бенефитов */
11
11
  align?: 'left' | 'center';
12
+ /** Горизонтальное выравнивание текста */
13
+ textAlign?: 'left' | 'center' | 'auto';
14
+ /** Горизонтальное выравнивание изображения */
15
+ imgAlign?: 'left' | 'center' | 'auto';
12
16
  /** Расстояние между бенефитами */
13
17
  gridGap?: GridGutterSize;
14
18
  /** Дополнительный css класс для корневого элемента */
@@ -19,6 +19,10 @@ var BenefitsPictures = function BenefitsPictures(_ref) {
19
19
  var items = _ref.items,
20
20
  _ref$align = _ref.align,
21
21
  align = _ref$align === void 0 ? 'left' : _ref$align,
22
+ _ref$textAlign = _ref.textAlign,
23
+ textAlign = _ref$textAlign === void 0 ? 'auto' : _ref$textAlign,
24
+ _ref$imgAlign = _ref.imgAlign,
25
+ imgAlign = _ref$imgAlign === void 0 ? 'auto' : _ref$imgAlign,
22
26
  _ref$gridGap = _ref.gridGap,
23
27
  gridGap = _ref$gridGap === void 0 ? 'large' : _ref$gridGap,
24
28
  rootRef = _ref.rootRef,
@@ -44,6 +48,21 @@ var BenefitsPictures = function BenefitsPictures(_ref) {
44
48
  setCurrentGutter('large');
45
49
  }
46
50
  }, [isLargeGutter]);
51
+
52
+ var renderText = function renderText(text) {
53
+ if (typeof text === 'string') {
54
+ return /*#__PURE__*/React.createElement(Paragraph, {
55
+ dataAttrs: {
56
+ root: {
57
+ 'data-testid': "".concat(testIdPrefix, "-paragraph")
58
+ }
59
+ }
60
+ }, convert(text));
61
+ }
62
+
63
+ return text;
64
+ };
65
+
47
66
  React.useEffect(function () {
48
67
  var throttledResizeHandler = throttle(resizeHandler, throttleTime.resize);
49
68
  resizeHandler();
@@ -55,6 +74,8 @@ var BenefitsPictures = function BenefitsPictures(_ref) {
55
74
  return /*#__PURE__*/React.createElement("div", {
56
75
  className: cn([className, classes.root]),
57
76
  ref: rootRef
77
+ }, /*#__PURE__*/React.createElement("div", {
78
+ className: cn('inner')
58
79
  }, /*#__PURE__*/React.createElement(Grid, {
59
80
  guttersLeft: currentGutter,
60
81
  hAlign: isGridCenterAlign ? 'center' : 'left',
@@ -75,18 +96,26 @@ var BenefitsPictures = function BenefitsPictures(_ref) {
75
96
  "data-testid": "".concat(testIdPrefix, "-item")
76
97
  }, /*#__PURE__*/React.createElement("img", {
77
98
  className: cn('img', {
78
- 'h-align': align
99
+ 'h-align': imgAlign === 'auto' ? align : imgAlign
79
100
  }),
80
101
  src: img,
81
- alt: alt
82
- }), /*#__PURE__*/React.createElement(Header, {
102
+ alt: alt,
103
+ "data-testid": "".concat(testIdPrefix, "-img")
104
+ }), /*#__PURE__*/React.createElement("div", {
105
+ className: cn('content', {
106
+ 'h-align': textAlign === 'auto' ? align : textAlign
107
+ }),
108
+ "data-testid": "".concat(testIdPrefix, "-content")
109
+ }, !!title && /*#__PURE__*/React.createElement(Header, {
83
110
  className: cn('title'),
84
- align: align,
85
- as: "h3"
86
- }, convert(title)), /*#__PURE__*/React.createElement(Paragraph, {
87
- align: align
88
- }, convert(text))));
89
- })));
111
+ as: "h3",
112
+ dataAttrs: {
113
+ root: {
114
+ 'data-testid': "".concat(testIdPrefix, "-title")
115
+ }
116
+ }
117
+ }, convert(title)), !!text && renderText(text))));
118
+ }))));
90
119
  };
91
120
 
92
121
  BenefitsPictures.propTypes = {
@@ -94,12 +123,14 @@ BenefitsPictures.propTypes = {
94
123
  current: PropTypes.elementType
95
124
  }), PropTypes.any])]),
96
125
  items: PropTypes.arrayOf(PropTypes.shape({
97
- title: PropTypes.string.isRequired,
98
- text: PropTypes.string.isRequired,
126
+ title: PropTypes.string,
127
+ text: PropTypes.oneOfType([PropTypes.string, PropTypes.node, PropTypes.arrayOf(PropTypes.node)]),
99
128
  img: PropTypes.string.isRequired,
100
129
  alt: PropTypes.string
101
130
  }).isRequired).isRequired,
102
131
  align: PropTypes.oneOf(['left', 'center']),
132
+ textAlign: PropTypes.oneOf(['left', 'center', 'auto']),
133
+ imgAlign: PropTypes.oneOf(['left', 'center', 'auto']),
103
134
  gridGap: PropTypes.oneOf(['medium', 'large']),
104
135
  className: PropTypes.string,
105
136
  classes: PropTypes.shape({
@@ -5,9 +5,33 @@ h4,
5
5
  h5 {
6
6
  margin: 0;
7
7
  }
8
+ .mfui-benefits-pictures {
9
+ overflow: hidden;
10
+ }
11
+ .mfui-benefits-pictures__inner {
12
+ margin-bottom: -40px;
13
+ }
14
+ @media screen and (min-width: 768px) {
15
+ .mfui-benefits-pictures__inner {
16
+ margin-bottom: -48px;
17
+ }
18
+ }
19
+ .mfui-benefits-pictures__item {
20
+ margin-bottom: 40px;
21
+ }
22
+ @media screen and (min-width: 768px) {
23
+ .mfui-benefits-pictures__item {
24
+ margin-bottom: 48px;
25
+ }
26
+ }
27
+ .mfui-benefits-pictures__content_h-align_center {
28
+ text-align: center;
29
+ }
8
30
  .mfui-benefits-pictures__img {
9
31
  max-width: 100%;
10
32
  margin-bottom: 32px;
33
+ border-radius: 12px;
34
+ vertical-align: top;
11
35
  }
12
36
  .mfui-benefits-pictures__img_h-align_center {
13
37
  display: block;
@@ -1,8 +1,9 @@
1
+ /// <reference types="react" />
1
2
  export interface IBenefit {
2
3
  /** Заголовок бенефита */
3
- title: string;
4
+ title?: string;
4
5
  /** Основной текст в бенефите */
5
- text: string;
6
+ text?: string | React.ReactNode | React.ReactNode[];
6
7
  /** Изображение */
7
8
  img: string;
8
9
  /** Значение тега alt для изображения */
@@ -3,10 +3,16 @@ import './Steps.less';
3
3
  export interface ISteps {
4
4
  /** Дополнительный класс корневого элемента */
5
5
  className?: string;
6
+ /** Дополнительные классы для корневого и внутренних элементов */
7
+ classes?: {
8
+ title?: string;
9
+ list?: string;
10
+ item?: string;
11
+ };
6
12
  /** Ссылка на корневой элемент */
7
13
  rootRef?: React.Ref<HTMLDivElement>;
8
14
  /** Заголовок */
9
- title: string;
15
+ title?: string;
10
16
  }
11
17
  declare const Steps: React.FC<ISteps>;
12
18
  export default Steps;
@@ -8,30 +8,36 @@ var cn = cnCreate('mfui-steps');
8
8
 
9
9
  var Steps = function Steps(_ref) {
10
10
  var className = _ref.className,
11
+ classes = _ref.classes,
11
12
  title = _ref.title,
12
13
  rootRef = _ref.rootRef,
13
14
  children = _ref.children;
14
15
  return /*#__PURE__*/React.createElement("div", {
15
16
  className: cn([className]),
16
17
  ref: rootRef
17
- }, /*#__PURE__*/React.createElement(Header, {
18
+ }, !!title && /*#__PURE__*/React.createElement(Header, {
18
19
  as: "h2",
19
20
  align: "center",
20
- className: cn('title')
21
+ className: cn('title', [classes === null || classes === void 0 ? void 0 : classes.title])
21
22
  }, convert(title, titleConvertConfig)), /*#__PURE__*/React.createElement("ul", {
22
- className: cn('list')
23
+ className: cn('list', [classes === null || classes === void 0 ? void 0 : classes.list])
23
24
  }, React.Children.map(children, function (child) {
24
25
  return /*#__PURE__*/React.createElement("li", {
25
- className: cn('item')
26
+ className: cn('item', [classes === null || classes === void 0 ? void 0 : classes.item])
26
27
  }, child);
27
28
  })));
28
29
  };
29
30
 
30
31
  Steps.propTypes = {
31
32
  className: PropTypes.string,
33
+ classes: PropTypes.shape({
34
+ title: PropTypes.string,
35
+ list: PropTypes.string,
36
+ item: PropTypes.string
37
+ }),
32
38
  rootRef: PropTypes.oneOfType([PropTypes.func, PropTypes.oneOfType([PropTypes.shape({
33
39
  current: PropTypes.elementType
34
40
  }), PropTypes.any])]),
35
- title: PropTypes.string.isRequired
41
+ title: PropTypes.string
36
42
  };
37
43
  export default Steps;
@@ -1,2 +1,2 @@
1
1
  import React from 'react';
2
- export declare const getColumnConfig: (isFullWidth: boolean) => Pick<React.PropsWithChildren<import("@megafon/ui-core/dist/lib/components/Grid/GridColumn").IGridColumn>, "all" | "wide" | "mobile" | "desktop" | "tablet">;
2
+ export declare const getColumnConfig: (isFullWidth: boolean) => Pick<React.PropsWithChildren<import("../../../ui-core/dist/lib/components/Grid/GridColumn").IGridColumn>, "all" | "wide" | "mobile" | "desktop" | "tablet">;
@@ -7,8 +7,12 @@ export interface IBenefitsPicturesProps {
7
7
  rootRef?: React.Ref<HTMLDivElement>;
8
8
  /** Данные для бенефитов */
9
9
  items: IBenefit[];
10
- /** Горизонтальное выравнивание */
10
+ /** Горизонтальное выравнивание бенефитов */
11
11
  align?: 'left' | 'center';
12
+ /** Горизонтальное выравнивание текста */
13
+ textAlign?: 'left' | 'center' | 'auto';
14
+ /** Горизонтальное выравнивание изображения */
15
+ imgAlign?: 'left' | 'center' | 'auto';
12
16
  /** Расстояние между бенефитами */
13
17
  gridGap?: GridGutterSize;
14
18
  /** Дополнительный css класс для корневого элемента */
@@ -44,6 +44,10 @@ var BenefitsPictures = function BenefitsPictures(_ref) {
44
44
  var items = _ref.items,
45
45
  _ref$align = _ref.align,
46
46
  align = _ref$align === void 0 ? 'left' : _ref$align,
47
+ _ref$textAlign = _ref.textAlign,
48
+ textAlign = _ref$textAlign === void 0 ? 'auto' : _ref$textAlign,
49
+ _ref$imgAlign = _ref.imgAlign,
50
+ imgAlign = _ref$imgAlign === void 0 ? 'auto' : _ref$imgAlign,
47
51
  _ref$gridGap = _ref.gridGap,
48
52
  gridGap = _ref$gridGap === void 0 ? 'large' : _ref$gridGap,
49
53
  rootRef = _ref.rootRef,
@@ -69,6 +73,21 @@ var BenefitsPictures = function BenefitsPictures(_ref) {
69
73
  setCurrentGutter('large');
70
74
  }
71
75
  }, [isLargeGutter]);
76
+
77
+ var renderText = function renderText(text) {
78
+ if (typeof text === 'string') {
79
+ return /*#__PURE__*/React.createElement(_uiCore.Paragraph, {
80
+ dataAttrs: {
81
+ root: {
82
+ 'data-testid': "".concat(testIdPrefix, "-paragraph")
83
+ }
84
+ }
85
+ }, (0, _htmr["default"])(text));
86
+ }
87
+
88
+ return text;
89
+ };
90
+
72
91
  React.useEffect(function () {
73
92
  var throttledResizeHandler = (0, _lodash["default"])(resizeHandler, _throttleTime["default"].resize);
74
93
  resizeHandler();
@@ -80,6 +99,8 @@ var BenefitsPictures = function BenefitsPictures(_ref) {
80
99
  return /*#__PURE__*/React.createElement("div", {
81
100
  className: cn([className, classes.root]),
82
101
  ref: rootRef
102
+ }, /*#__PURE__*/React.createElement("div", {
103
+ className: cn('inner')
83
104
  }, /*#__PURE__*/React.createElement(_uiCore.Grid, {
84
105
  guttersLeft: currentGutter,
85
106
  hAlign: isGridCenterAlign ? 'center' : 'left',
@@ -100,18 +121,26 @@ var BenefitsPictures = function BenefitsPictures(_ref) {
100
121
  "data-testid": "".concat(testIdPrefix, "-item")
101
122
  }, /*#__PURE__*/React.createElement("img", {
102
123
  className: cn('img', {
103
- 'h-align': align
124
+ 'h-align': imgAlign === 'auto' ? align : imgAlign
104
125
  }),
105
126
  src: img,
106
- alt: alt
107
- }), /*#__PURE__*/React.createElement(_uiCore.Header, {
127
+ alt: alt,
128
+ "data-testid": "".concat(testIdPrefix, "-img")
129
+ }), /*#__PURE__*/React.createElement("div", {
130
+ className: cn('content', {
131
+ 'h-align': textAlign === 'auto' ? align : textAlign
132
+ }),
133
+ "data-testid": "".concat(testIdPrefix, "-content")
134
+ }, !!title && /*#__PURE__*/React.createElement(_uiCore.Header, {
108
135
  className: cn('title'),
109
- align: align,
110
- as: "h3"
111
- }, (0, _htmr["default"])(title)), /*#__PURE__*/React.createElement(_uiCore.Paragraph, {
112
- align: align
113
- }, (0, _htmr["default"])(text))));
114
- })));
136
+ as: "h3",
137
+ dataAttrs: {
138
+ root: {
139
+ 'data-testid': "".concat(testIdPrefix, "-title")
140
+ }
141
+ }
142
+ }, (0, _htmr["default"])(title)), !!text && renderText(text))));
143
+ }))));
115
144
  };
116
145
 
117
146
  BenefitsPictures.propTypes = {
@@ -119,12 +148,14 @@ BenefitsPictures.propTypes = {
119
148
  current: _propTypes["default"].elementType
120
149
  }), _propTypes["default"].any])]),
121
150
  items: _propTypes["default"].arrayOf(_propTypes["default"].shape({
122
- title: _propTypes["default"].string.isRequired,
123
- text: _propTypes["default"].string.isRequired,
151
+ title: _propTypes["default"].string,
152
+ text: _propTypes["default"].oneOfType([_propTypes["default"].string, _propTypes["default"].node, _propTypes["default"].arrayOf(_propTypes["default"].node)]),
124
153
  img: _propTypes["default"].string.isRequired,
125
154
  alt: _propTypes["default"].string
126
155
  }).isRequired).isRequired,
127
156
  align: _propTypes["default"].oneOf(['left', 'center']),
157
+ textAlign: _propTypes["default"].oneOf(['left', 'center', 'auto']),
158
+ imgAlign: _propTypes["default"].oneOf(['left', 'center', 'auto']),
128
159
  gridGap: _propTypes["default"].oneOf(['medium', 'large']),
129
160
  className: _propTypes["default"].string,
130
161
  classes: _propTypes["default"].shape({
@@ -5,9 +5,33 @@ h4,
5
5
  h5 {
6
6
  margin: 0;
7
7
  }
8
+ .mfui-benefits-pictures {
9
+ overflow: hidden;
10
+ }
11
+ .mfui-benefits-pictures__inner {
12
+ margin-bottom: -40px;
13
+ }
14
+ @media screen and (min-width: 768px) {
15
+ .mfui-benefits-pictures__inner {
16
+ margin-bottom: -48px;
17
+ }
18
+ }
19
+ .mfui-benefits-pictures__item {
20
+ margin-bottom: 40px;
21
+ }
22
+ @media screen and (min-width: 768px) {
23
+ .mfui-benefits-pictures__item {
24
+ margin-bottom: 48px;
25
+ }
26
+ }
27
+ .mfui-benefits-pictures__content_h-align_center {
28
+ text-align: center;
29
+ }
8
30
  .mfui-benefits-pictures__img {
9
31
  max-width: 100%;
10
32
  margin-bottom: 32px;
33
+ border-radius: 12px;
34
+ vertical-align: top;
11
35
  }
12
36
  .mfui-benefits-pictures__img_h-align_center {
13
37
  display: block;
@@ -1,8 +1,9 @@
1
+ /// <reference types="react" />
1
2
  export interface IBenefit {
2
3
  /** Заголовок бенефита */
3
- title: string;
4
+ title?: string;
4
5
  /** Основной текст в бенефите */
5
- text: string;
6
+ text?: string | React.ReactNode | React.ReactNode[];
6
7
  /** Изображение */
7
8
  img: string;
8
9
  /** Значение тега alt для изображения */
@@ -3,10 +3,16 @@ import './Steps.less';
3
3
  export interface ISteps {
4
4
  /** Дополнительный класс корневого элемента */
5
5
  className?: string;
6
+ /** Дополнительные классы для корневого и внутренних элементов */
7
+ classes?: {
8
+ title?: string;
9
+ list?: string;
10
+ item?: string;
11
+ };
6
12
  /** Ссылка на корневой элемент */
7
13
  rootRef?: React.Ref<HTMLDivElement>;
8
14
  /** Заголовок */
9
- title: string;
15
+ title?: string;
10
16
  }
11
17
  declare const Steps: React.FC<ISteps>;
12
18
  export default Steps;
@@ -27,31 +27,37 @@ var cn = (0, _uiHelpers.cnCreate)('mfui-steps');
27
27
 
28
28
  var Steps = function Steps(_ref) {
29
29
  var className = _ref.className,
30
+ classes = _ref.classes,
30
31
  title = _ref.title,
31
32
  rootRef = _ref.rootRef,
32
33
  children = _ref.children;
33
34
  return /*#__PURE__*/React.createElement("div", {
34
35
  className: cn([className]),
35
36
  ref: rootRef
36
- }, /*#__PURE__*/React.createElement(_uiCore.Header, {
37
+ }, !!title && /*#__PURE__*/React.createElement(_uiCore.Header, {
37
38
  as: "h2",
38
39
  align: "center",
39
- className: cn('title')
40
+ className: cn('title', [classes === null || classes === void 0 ? void 0 : classes.title])
40
41
  }, (0, _uiHelpers.convert)(title, _uiHelpers.titleConvertConfig)), /*#__PURE__*/React.createElement("ul", {
41
- className: cn('list')
42
+ className: cn('list', [classes === null || classes === void 0 ? void 0 : classes.list])
42
43
  }, React.Children.map(children, function (child) {
43
44
  return /*#__PURE__*/React.createElement("li", {
44
- className: cn('item')
45
+ className: cn('item', [classes === null || classes === void 0 ? void 0 : classes.item])
45
46
  }, child);
46
47
  })));
47
48
  };
48
49
 
49
50
  Steps.propTypes = {
50
51
  className: _propTypes["default"].string,
52
+ classes: _propTypes["default"].shape({
53
+ title: _propTypes["default"].string,
54
+ list: _propTypes["default"].string,
55
+ item: _propTypes["default"].string
56
+ }),
51
57
  rootRef: _propTypes["default"].oneOfType([_propTypes["default"].func, _propTypes["default"].oneOfType([_propTypes["default"].shape({
52
58
  current: _propTypes["default"].elementType
53
59
  }), _propTypes["default"].any])]),
54
- title: _propTypes["default"].string.isRequired
60
+ title: _propTypes["default"].string
55
61
  };
56
62
  var _default = Steps;
57
63
  exports["default"] = _default;
@@ -1,2 +1,2 @@
1
1
  import React from 'react';
2
- export declare const getColumnConfig: (isFullWidth: boolean) => Pick<React.PropsWithChildren<import("@megafon/ui-core/dist/lib/components/Grid/GridColumn").IGridColumn>, "all" | "wide" | "mobile" | "desktop" | "tablet">;
2
+ export declare const getColumnConfig: (isFullWidth: boolean) => Pick<React.PropsWithChildren<import("../../../ui-core/dist/lib/components/Grid/GridColumn").IGridColumn>, "all" | "wide" | "mobile" | "desktop" | "tablet">;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@megafon/ui-shared",
3
- "version": "5.2.4",
3
+ "version": "5.4.0",
4
4
  "files": [
5
5
  "dist"
6
6
  ],
@@ -48,7 +48,7 @@
48
48
  "@babel/preset-env": "^7.8.6",
49
49
  "@babel/preset-react": "^7.8.3",
50
50
  "@babel/preset-typescript": "^7.8.3",
51
- "@megafon/ui-icons": "^2.15.0",
51
+ "@megafon/ui-icons": "^2.17.0",
52
52
  "@svgr/core": "^2.4.1",
53
53
  "@testing-library/jest-dom": "5.16.2",
54
54
  "@testing-library/react": "12.1.2",
@@ -82,13 +82,13 @@
82
82
  },
83
83
  "dependencies": {
84
84
  "@babel/runtime": "^7.8.4",
85
- "@megafon/ui-core": "^5.4.1",
86
- "@megafon/ui-helpers": "^2.5.3",
85
+ "@megafon/ui-core": "^5.4.3",
86
+ "@megafon/ui-helpers": "^2.5.4",
87
87
  "core-js": "^3.6.4",
88
88
  "htmr": "^0.9.2",
89
89
  "lodash.throttle": "^4.1.1",
90
90
  "prop-types": "^15.7.2",
91
91
  "swiper": "^6.5.6"
92
92
  },
93
- "gitHead": "d65bc4cd4de9180971e4285c2d0b5beec27d0542"
93
+ "gitHead": "1120ea0f847f81f7a9218cba42ee13a24f09912a"
94
94
  }