@megafon/ui-shared 5.0.1 → 5.1.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,23 @@
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.1.0](https://hq-gitlab.megafon.ru/site-portal/services/megafon-ui/compare/@megafon/ui-shared@5.0.1...@megafon/ui-shared@5.1.0) (2023-09-14)
7
+
8
+
9
+ ### Bug Fixes
10
+
11
+ * **benefitpictures:** rename helpers ([282fcfe](https://hq-gitlab.megafon.ru/site-portal/services/megafon-ui/commit/282fcfec6f6fc8f0bec325c52f7ec5ada955e4ff))
12
+ * **dulpfile:** fix ignore rule ([525138b](https://hq-gitlab.megafon.ru/site-portal/services/megafon-ui/commit/525138bafeaa3836fa37997691da544419efd7fa))
13
+
14
+
15
+ ### Features
16
+
17
+ * **card:** add minor features ([e80582c](https://hq-gitlab.megafon.ru/site-portal/services/megafon-ui/commit/e80582c863f7baeaf17effe7566531f2f9a2c695))
18
+
19
+
20
+
21
+
22
+
6
23
  ## [5.0.1](https://hq-gitlab.megafon.ru/site-portal/libraries/javascript/megafon-ui/compare/@megafon/ui-shared@5.0.0...@megafon/ui-shared@5.0.1) (2023-08-31)
7
24
 
8
25
 
@@ -1,6 +1,7 @@
1
1
  import * as React from 'react';
2
2
  import { IBenefit, GridGutterSize } from './types';
3
3
  import './BenfitsPictures.less';
4
+ export declare const ONLY_LEFT_ALIGN_ITEMS_COUNT = 3;
4
5
  export interface IBenefitsPicturesProps {
5
6
  /** Ссылка на корневой элемент */
6
7
  rootRef?: React.Ref<HTMLDivElement>;
@@ -1,5 +1,5 @@
1
- import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
2
1
  import _extends from "@babel/runtime/helpers/extends";
2
+ import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
3
3
  import "core-js/modules/es.array.map.js";
4
4
  import * as React from 'react';
5
5
  import { useCallback } from 'react';
@@ -9,106 +9,10 @@ import convert from 'htmr';
9
9
  import throttle from 'lodash.throttle';
10
10
  import PropTypes from 'prop-types';
11
11
  import throttleTime from "../../constants/throttleTime";
12
+ import getCenterConfig, { getLeftConfig } from "./helpers";
12
13
  import "./BenfitsPictures.css";
13
- var ONLY_LEFT_ALIGN_ITEMS_COUNT = 3;
14
- var columnSize = {
15
- wide: '4',
16
- desktop: '4',
17
- tablet: '5'
18
- };
19
-
20
- var isEvenIndex = function isEvenIndex(index) {
21
- return !((index + 1) % 2);
22
- };
23
-
24
- var getEvenOffset = function getEvenOffset(index) {
25
- return isEvenIndex(index) ? '1' : undefined;
26
- };
27
-
28
- var getOddOffset = function getOddOffset(index) {
29
- return isEvenIndex(index) ? undefined : '1';
30
- };
31
-
32
- var getLeftConfig = function getLeftConfig(count, index) {
33
- switch (count) {
34
- case 2:
35
- case 4:
36
- return _extends(_extends({}, columnSize), {
37
- leftOffsetWide: getEvenOffset(index),
38
- leftOffsetDesktop: getEvenOffset(index),
39
- leftOffsetTablet: getEvenOffset(index)
40
- });
41
-
42
- default:
43
- return _extends(_extends({}, columnSize), {
44
- leftOffsetTablet: getEvenOffset(index)
45
- });
46
- }
47
- };
48
-
49
- var getCenterMediumConfig = function getCenterMediumConfig(count, index) {
50
- switch (count) {
51
- case 3:
52
- return _extends(_extends({}, columnSize), {
53
- leftOffsetTablet: getOddOffset(index)
54
- });
55
-
56
- case 4:
57
- return _extends(_extends({}, columnSize), {
58
- rightOffsetWide: getOddOffset(index),
59
- leftOffsetWide: getEvenOffset(index),
60
- rightOffsetDesktop: getEvenOffset(index),
61
- leftOffsetDesktop: getOddOffset(index),
62
- rightOffsetTablet: getEvenOffset(index),
63
- leftOffsetTablet: getOddOffset(index)
64
- });
65
-
66
- default:
67
- return _extends(_extends({}, columnSize), {
68
- rightOffsetWide: getOddOffset(index),
69
- leftOffsetWide: getEvenOffset(index)
70
- });
71
- }
72
- };
73
-
74
- var getCenterLargeConfig = function getCenterLargeConfig(count, index) {
75
- switch (count) {
76
- case 4:
77
- return _extends(_extends({}, columnSize), {
78
- leftOffsetWide: getOddOffset(index),
79
- rightOffsetWide: getEvenOffset(index),
80
- leftOffsetDesktop: getOddOffset(index),
81
- rightOffsetDesktop: getEvenOffset(index),
82
- leftOffsetTablet: getOddOffset(index),
83
- rightOffsetTablet: getEvenOffset(index)
84
- });
85
-
86
- case 3:
87
- {
88
- return _extends(_extends({}, columnSize), {
89
- leftOffsetTablet: getOddOffset(index)
90
- });
91
- }
92
-
93
- default:
94
- return _extends({}, columnSize);
95
- }
96
- };
97
-
98
- var getCenterConfig = function getCenterConfig(count, index, gutterSize) {
99
- switch (gutterSize) {
100
- case 'medium':
101
- {
102
- return getCenterMediumConfig(count, index);
103
- }
104
-
105
- default:
106
- {
107
- return getCenterLargeConfig(count, index);
108
- }
109
- }
110
- };
111
-
14
+ export var ONLY_LEFT_ALIGN_ITEMS_COUNT = 3;
15
+ var testIdPrefix = 'BenefitsPictures';
112
16
  var cn = cnCreate('mfui-benefits-pictures');
113
17
 
114
18
  var BenefitsPictures = function BenefitsPictures(_ref) {
@@ -153,7 +57,12 @@ var BenefitsPictures = function BenefitsPictures(_ref) {
153
57
  ref: rootRef
154
58
  }, /*#__PURE__*/React.createElement(Grid, {
155
59
  guttersLeft: currentGutter,
156
- hAlign: isGridCenterAlign ? 'center' : 'left'
60
+ hAlign: isGridCenterAlign ? 'center' : 'left',
61
+ dataAttrs: {
62
+ container: {
63
+ 'data-testid': "".concat(testIdPrefix, "-grid-container")
64
+ }
65
+ }
157
66
  }, items.map(function (_ref2, index) {
158
67
  var img = _ref2.img,
159
68
  title = _ref2.title,
@@ -162,7 +71,8 @@ var BenefitsPictures = function BenefitsPictures(_ref) {
162
71
  return /*#__PURE__*/React.createElement(GridColumn, _extends({}, align === 'left' ? getLeftConfig(items.length, index) : getCenterConfig(items.length, index, gridGap), {
163
72
  key: index
164
73
  }), /*#__PURE__*/React.createElement("div", {
165
- className: cn('item', [classes.item])
74
+ className: cn('item', [classes.item]),
75
+ "data-testid": "".concat(testIdPrefix, "-item")
166
76
  }, /*#__PURE__*/React.createElement("img", {
167
77
  className: cn('img', {
168
78
  'h-align': align
@@ -0,0 +1,11 @@
1
+ import { GridConfig } from './types';
2
+ declare const columnSize: GridConfig;
3
+ declare const isOddIndex: (index: number) => boolean;
4
+ declare const getEvenOffset: (index: number) => "1" | undefined;
5
+ declare const getOddOffset: (index: number) => "1" | undefined;
6
+ declare const getLeftConfig: (count: number, index: number) => GridConfig;
7
+ declare const getCenterMediumConfig: (count: number, index: number) => GridConfig;
8
+ declare const getCenterLargeConfig: (count: number, index: number) => GridConfig;
9
+ declare const getCenterConfig: (count: number, index: number, gutterSize: string) => GridConfig;
10
+ export default getCenterConfig;
11
+ export { columnSize, isOddIndex, getEvenOffset, getOddOffset, getLeftConfig, getCenterMediumConfig, getCenterLargeConfig, };
@@ -0,0 +1,99 @@
1
+ import _extends from "@babel/runtime/helpers/extends";
2
+ var columnSize = {
3
+ wide: '4',
4
+ desktop: '4',
5
+ tablet: '5'
6
+ };
7
+
8
+ var isOddIndex = function isOddIndex(index) {
9
+ return !((index + 1) % 2);
10
+ };
11
+
12
+ var getEvenOffset = function getEvenOffset(index) {
13
+ return isOddIndex(index) ? '1' : undefined;
14
+ };
15
+
16
+ var getOddOffset = function getOddOffset(index) {
17
+ return isOddIndex(index) ? undefined : '1';
18
+ };
19
+
20
+ var getLeftConfig = function getLeftConfig(count, index) {
21
+ switch (count) {
22
+ case 2:
23
+ case 4:
24
+ return _extends(_extends({}, columnSize), {
25
+ leftOffsetWide: getEvenOffset(index),
26
+ leftOffsetDesktop: getEvenOffset(index),
27
+ leftOffsetTablet: getEvenOffset(index)
28
+ });
29
+
30
+ default:
31
+ return _extends(_extends({}, columnSize), {
32
+ leftOffsetTablet: getEvenOffset(index)
33
+ });
34
+ }
35
+ };
36
+
37
+ var getCenterMediumConfig = function getCenterMediumConfig(count, index) {
38
+ switch (count) {
39
+ case 3:
40
+ return _extends(_extends({}, columnSize), {
41
+ leftOffsetTablet: getOddOffset(index)
42
+ });
43
+
44
+ case 4:
45
+ return _extends(_extends({}, columnSize), {
46
+ rightOffsetWide: getOddOffset(index),
47
+ leftOffsetWide: getEvenOffset(index),
48
+ rightOffsetDesktop: getEvenOffset(index),
49
+ leftOffsetDesktop: getOddOffset(index),
50
+ rightOffsetTablet: getEvenOffset(index),
51
+ leftOffsetTablet: getOddOffset(index)
52
+ });
53
+
54
+ default:
55
+ return _extends(_extends({}, columnSize), {
56
+ rightOffsetWide: getOddOffset(index),
57
+ leftOffsetWide: getEvenOffset(index)
58
+ });
59
+ }
60
+ };
61
+
62
+ var getCenterLargeConfig = function getCenterLargeConfig(count, index) {
63
+ switch (count) {
64
+ case 4:
65
+ return _extends(_extends({}, columnSize), {
66
+ leftOffsetWide: getOddOffset(index),
67
+ rightOffsetWide: getEvenOffset(index),
68
+ leftOffsetDesktop: getOddOffset(index),
69
+ rightOffsetDesktop: getEvenOffset(index),
70
+ leftOffsetTablet: getOddOffset(index),
71
+ rightOffsetTablet: getEvenOffset(index)
72
+ });
73
+
74
+ case 3:
75
+ return _extends(_extends({}, columnSize), {
76
+ leftOffsetTablet: getOddOffset(index)
77
+ });
78
+
79
+ default:
80
+ return _extends({}, columnSize);
81
+ }
82
+ };
83
+
84
+ var getCenterConfig = function getCenterConfig(count, index, gutterSize) {
85
+ switch (gutterSize) {
86
+ case 'medium':
87
+ {
88
+ return getCenterMediumConfig(count, index);
89
+ }
90
+
91
+ default:
92
+ {
93
+ return getCenterLargeConfig(count, index);
94
+ }
95
+ }
96
+ };
97
+
98
+ export default getCenterConfig;
99
+ export { columnSize, isOddIndex, getEvenOffset, getOddOffset, getLeftConfig, getCenterMediumConfig, getCenterLargeConfig };
@@ -20,8 +20,12 @@ h5 {
20
20
  padding: 16px 16px 24px;
21
21
  border-radius: 12px;
22
22
  color: var(--content);
23
- text-decoration: none;
23
+ text-decoration: none !important;
24
24
  background-color: var(--base);
25
+ -webkit-transition: background-color 0.3s, 0.3s, -webkit-box-shadow;
26
+ transition: background-color 0.3s, 0.3s, -webkit-box-shadow;
27
+ transition: background-color 0.3s, box-shadow, 0.3s;
28
+ transition: background-color 0.3s, box-shadow, 0.3s, -webkit-box-shadow;
25
29
  }
26
30
  @media screen and (min-width: 1280px) {
27
31
  .mfui-card {
@@ -1,4 +1,4 @@
1
- import React from 'react';
1
+ import React, { Ref } from 'react';
2
2
  import './Card.less';
3
3
  import { ButtonType, FeaturesList, IconsList, Image, Link, Price, TextsList, Title } from './types';
4
4
  export interface ICard {
@@ -12,6 +12,14 @@ export interface ICard {
12
12
  };
13
13
  /** Дополнительный класс для компонента */
14
14
  className?: string;
15
+ /** Дополнительные классы для внутренних элементов */
16
+ classes?: {
17
+ root?: string;
18
+ button?: string;
19
+ extraButton?: string;
20
+ };
21
+ /** Ссылка на корневой элемент */
22
+ rootRef?: Ref<HTMLDivElement | HTMLAnchorElement>;
15
23
  isFullHeight?: boolean;
16
24
  /** Вид */
17
25
  view?: 'shadow' | 'background';
@@ -37,6 +37,8 @@ var cn = cnCreate('mfui-card');
37
37
  var Card = function Card(_ref5) {
38
38
  var dataAttrs = _ref5.dataAttrs,
39
39
  className = _ref5.className,
40
+ classes = _ref5.classes,
41
+ rootRef = _ref5.rootRef,
40
42
  _ref5$isFullHeight = _ref5.isFullHeight,
41
43
  isFullHeight = _ref5$isFullHeight === void 0 ? false : _ref5$isFullHeight,
42
44
  link = _ref5.link,
@@ -169,7 +171,7 @@ var Card = function Card(_ref5) {
169
171
  dataAttrs: {
170
172
  root: dataAttrs === null || dataAttrs === void 0 ? void 0 : dataAttrs.button
171
173
  },
172
- className: cn('button'),
174
+ className: cn('button', [classes === null || classes === void 0 ? void 0 : classes.button]),
173
175
  href: button.href,
174
176
  target: button.target,
175
177
  onClick: button === null || button === void 0 ? void 0 : button.onClick
@@ -177,7 +179,7 @@ var Card = function Card(_ref5) {
177
179
  dataAttrs: {
178
180
  root: dataAttrs === null || dataAttrs === void 0 ? void 0 : dataAttrs.extraButton
179
181
  },
180
- className: cn('button'),
182
+ className: cn('button', [classes === null || classes === void 0 ? void 0 : classes.extraButton]),
181
183
  href: extraButton.href,
182
184
  target: extraButton.target,
183
185
  type: "outline",
@@ -201,10 +203,11 @@ var Card = function Card(_ref5) {
201
203
  view: view,
202
204
  link: isLink,
203
205
  'full-height': isFullHeight
204
- }, [className]),
206
+ }, [className, classes === null || classes === void 0 ? void 0 : classes.root]),
205
207
  href: isLink ? link === null || link === void 0 ? void 0 : link.href : undefined,
206
208
  target: isLink ? link === null || link === void 0 ? void 0 : link.target : undefined,
207
- onClick: isLink ? onClick : undefined
209
+ onClick: isLink ? onClick : undefined,
210
+ ref: rootRef
208
211
  }), renderIcon(), !isBottomImage && renderImage(), /*#__PURE__*/React.createElement(Header, {
209
212
  className: cn('title'),
210
213
  as: "h3",
@@ -221,6 +224,14 @@ Card.propTypes = {
221
224
  extraButton: PropTypes.objectOf(PropTypes.string.isRequired)
222
225
  }),
223
226
  className: PropTypes.string,
227
+ classes: PropTypes.shape({
228
+ root: PropTypes.string,
229
+ button: PropTypes.string,
230
+ extraButton: PropTypes.string
231
+ }),
232
+ rootRef: PropTypes.oneOfType([PropTypes.func, PropTypes.oneOfType([PropTypes.shape({
233
+ current: PropTypes.elementType
234
+ }), PropTypes.any])]),
224
235
  view: PropTypes.oneOf(['shadow', 'background']),
225
236
  link: PropTypes.shape({
226
237
  href: PropTypes.string,
@@ -18,7 +18,6 @@ export { default as Container } from './components/Container/Container';
18
18
  export { default as DownloadLink } from './components/DownloadLinks/DownloadLink';
19
19
  export { default as DownloadLinks } from './components/DownloadLinks/DownloadLinks';
20
20
  export { default as FaqWrapper } from './components/FaqWrapper/FaqWrapper';
21
- export { default as helpers } from './components/CardsBox/helpers';
22
21
  export { default as Instructions } from './components/Instructions/Instructions';
23
22
  export { default as NotificationBox } from './components/NotificationBox/NotificationBox';
24
23
  export { default as PageTitle } from './components/PageTitle/PageTitle';
package/dist/es/index.js CHANGED
@@ -18,7 +18,6 @@ export { default as Container } from "./components/Container/Container";
18
18
  export { default as DownloadLink } from "./components/DownloadLinks/DownloadLink";
19
19
  export { default as DownloadLinks } from "./components/DownloadLinks/DownloadLinks";
20
20
  export { default as FaqWrapper } from "./components/FaqWrapper/FaqWrapper";
21
- export { default as helpers } from "./components/CardsBox/helpers";
22
21
  export { default as Instructions } from "./components/Instructions/Instructions";
23
22
  export { default as NotificationBox } from "./components/NotificationBox/NotificationBox";
24
23
  export { default as PageTitle } from "./components/PageTitle/PageTitle";
@@ -1,6 +1,7 @@
1
1
  import * as React from 'react';
2
2
  import { IBenefit, GridGutterSize } from './types';
3
3
  import './BenfitsPictures.less';
4
+ export declare const ONLY_LEFT_ALIGN_ITEMS_COUNT = 3;
4
5
  export interface IBenefitsPicturesProps {
5
6
  /** Ссылка на корневой элемент */
6
7
  rootRef?: React.Ref<HTMLDivElement>;
@@ -5,12 +5,12 @@ function _typeof(obj) { "@babel/helpers - typeof"; if (typeof Symbol === "functi
5
5
  Object.defineProperty(exports, "__esModule", {
6
6
  value: true
7
7
  });
8
- exports["default"] = void 0;
9
-
10
- var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
8
+ exports["default"] = exports.ONLY_LEFT_ALIGN_ITEMS_COUNT = void 0;
11
9
 
12
10
  var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
13
11
 
12
+ var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
13
+
14
14
  require("core-js/modules/es.array.map.js");
15
15
 
16
16
  var React = _interopRequireWildcard(require("react"));
@@ -27,6 +27,8 @@ var _propTypes = _interopRequireDefault(require("prop-types"));
27
27
 
28
28
  var _throttleTime = _interopRequireDefault(require("../../constants/throttleTime"));
29
29
 
30
+ var _helpers = _interopRequireWildcard(require("./helpers"));
31
+
30
32
  function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
31
33
 
32
34
  function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { "default": obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj["default"] = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
@@ -34,104 +36,8 @@ function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj &&
34
36
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
35
37
 
36
38
  var ONLY_LEFT_ALIGN_ITEMS_COUNT = 3;
37
- var columnSize = {
38
- wide: '4',
39
- desktop: '4',
40
- tablet: '5'
41
- };
42
-
43
- var isEvenIndex = function isEvenIndex(index) {
44
- return !((index + 1) % 2);
45
- };
46
-
47
- var getEvenOffset = function getEvenOffset(index) {
48
- return isEvenIndex(index) ? '1' : undefined;
49
- };
50
-
51
- var getOddOffset = function getOddOffset(index) {
52
- return isEvenIndex(index) ? undefined : '1';
53
- };
54
-
55
- var getLeftConfig = function getLeftConfig(count, index) {
56
- switch (count) {
57
- case 2:
58
- case 4:
59
- return (0, _extends2["default"])((0, _extends2["default"])({}, columnSize), {
60
- leftOffsetWide: getEvenOffset(index),
61
- leftOffsetDesktop: getEvenOffset(index),
62
- leftOffsetTablet: getEvenOffset(index)
63
- });
64
-
65
- default:
66
- return (0, _extends2["default"])((0, _extends2["default"])({}, columnSize), {
67
- leftOffsetTablet: getEvenOffset(index)
68
- });
69
- }
70
- };
71
-
72
- var getCenterMediumConfig = function getCenterMediumConfig(count, index) {
73
- switch (count) {
74
- case 3:
75
- return (0, _extends2["default"])((0, _extends2["default"])({}, columnSize), {
76
- leftOffsetTablet: getOddOffset(index)
77
- });
78
-
79
- case 4:
80
- return (0, _extends2["default"])((0, _extends2["default"])({}, columnSize), {
81
- rightOffsetWide: getOddOffset(index),
82
- leftOffsetWide: getEvenOffset(index),
83
- rightOffsetDesktop: getEvenOffset(index),
84
- leftOffsetDesktop: getOddOffset(index),
85
- rightOffsetTablet: getEvenOffset(index),
86
- leftOffsetTablet: getOddOffset(index)
87
- });
88
-
89
- default:
90
- return (0, _extends2["default"])((0, _extends2["default"])({}, columnSize), {
91
- rightOffsetWide: getOddOffset(index),
92
- leftOffsetWide: getEvenOffset(index)
93
- });
94
- }
95
- };
96
-
97
- var getCenterLargeConfig = function getCenterLargeConfig(count, index) {
98
- switch (count) {
99
- case 4:
100
- return (0, _extends2["default"])((0, _extends2["default"])({}, columnSize), {
101
- leftOffsetWide: getOddOffset(index),
102
- rightOffsetWide: getEvenOffset(index),
103
- leftOffsetDesktop: getOddOffset(index),
104
- rightOffsetDesktop: getEvenOffset(index),
105
- leftOffsetTablet: getOddOffset(index),
106
- rightOffsetTablet: getEvenOffset(index)
107
- });
108
-
109
- case 3:
110
- {
111
- return (0, _extends2["default"])((0, _extends2["default"])({}, columnSize), {
112
- leftOffsetTablet: getOddOffset(index)
113
- });
114
- }
115
-
116
- default:
117
- return (0, _extends2["default"])({}, columnSize);
118
- }
119
- };
120
-
121
- var getCenterConfig = function getCenterConfig(count, index, gutterSize) {
122
- switch (gutterSize) {
123
- case 'medium':
124
- {
125
- return getCenterMediumConfig(count, index);
126
- }
127
-
128
- default:
129
- {
130
- return getCenterLargeConfig(count, index);
131
- }
132
- }
133
- };
134
-
39
+ exports.ONLY_LEFT_ALIGN_ITEMS_COUNT = ONLY_LEFT_ALIGN_ITEMS_COUNT;
40
+ var testIdPrefix = 'BenefitsPictures';
135
41
  var cn = (0, _uiHelpers.cnCreate)('mfui-benefits-pictures');
136
42
 
137
43
  var BenefitsPictures = function BenefitsPictures(_ref) {
@@ -176,16 +82,22 @@ var BenefitsPictures = function BenefitsPictures(_ref) {
176
82
  ref: rootRef
177
83
  }, /*#__PURE__*/React.createElement(_uiCore.Grid, {
178
84
  guttersLeft: currentGutter,
179
- hAlign: isGridCenterAlign ? 'center' : 'left'
85
+ hAlign: isGridCenterAlign ? 'center' : 'left',
86
+ dataAttrs: {
87
+ container: {
88
+ 'data-testid': "".concat(testIdPrefix, "-grid-container")
89
+ }
90
+ }
180
91
  }, items.map(function (_ref2, index) {
181
92
  var img = _ref2.img,
182
93
  title = _ref2.title,
183
94
  text = _ref2.text,
184
95
  alt = _ref2.alt;
185
- return /*#__PURE__*/React.createElement(_uiCore.GridColumn, (0, _extends2["default"])({}, align === 'left' ? getLeftConfig(items.length, index) : getCenterConfig(items.length, index, gridGap), {
96
+ return /*#__PURE__*/React.createElement(_uiCore.GridColumn, (0, _extends2["default"])({}, align === 'left' ? (0, _helpers.getLeftConfig)(items.length, index) : (0, _helpers["default"])(items.length, index, gridGap), {
186
97
  key: index
187
98
  }), /*#__PURE__*/React.createElement("div", {
188
- className: cn('item', [classes.item])
99
+ className: cn('item', [classes.item]),
100
+ "data-testid": "".concat(testIdPrefix, "-item")
189
101
  }, /*#__PURE__*/React.createElement("img", {
190
102
  className: cn('img', {
191
103
  'h-align': align
@@ -0,0 +1,11 @@
1
+ import { GridConfig } from './types';
2
+ declare const columnSize: GridConfig;
3
+ declare const isOddIndex: (index: number) => boolean;
4
+ declare const getEvenOffset: (index: number) => "1" | undefined;
5
+ declare const getOddOffset: (index: number) => "1" | undefined;
6
+ declare const getLeftConfig: (count: number, index: number) => GridConfig;
7
+ declare const getCenterMediumConfig: (count: number, index: number) => GridConfig;
8
+ declare const getCenterLargeConfig: (count: number, index: number) => GridConfig;
9
+ declare const getCenterConfig: (count: number, index: number, gutterSize: string) => GridConfig;
10
+ export default getCenterConfig;
11
+ export { columnSize, isOddIndex, getEvenOffset, getOddOffset, getLeftConfig, getCenterMediumConfig, getCenterLargeConfig, };
@@ -0,0 +1,122 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.getCenterLargeConfig = exports.getCenterMediumConfig = exports.getLeftConfig = exports.getOddOffset = exports.getEvenOffset = exports.isOddIndex = exports.columnSize = exports["default"] = void 0;
7
+
8
+ var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
9
+
10
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
11
+
12
+ var columnSize = {
13
+ wide: '4',
14
+ desktop: '4',
15
+ tablet: '5'
16
+ };
17
+ exports.columnSize = columnSize;
18
+
19
+ var isOddIndex = function isOddIndex(index) {
20
+ return !((index + 1) % 2);
21
+ };
22
+
23
+ exports.isOddIndex = isOddIndex;
24
+
25
+ var getEvenOffset = function getEvenOffset(index) {
26
+ return isOddIndex(index) ? '1' : undefined;
27
+ };
28
+
29
+ exports.getEvenOffset = getEvenOffset;
30
+
31
+ var getOddOffset = function getOddOffset(index) {
32
+ return isOddIndex(index) ? undefined : '1';
33
+ };
34
+
35
+ exports.getOddOffset = getOddOffset;
36
+
37
+ var getLeftConfig = function getLeftConfig(count, index) {
38
+ switch (count) {
39
+ case 2:
40
+ case 4:
41
+ return (0, _extends2["default"])((0, _extends2["default"])({}, columnSize), {
42
+ leftOffsetWide: getEvenOffset(index),
43
+ leftOffsetDesktop: getEvenOffset(index),
44
+ leftOffsetTablet: getEvenOffset(index)
45
+ });
46
+
47
+ default:
48
+ return (0, _extends2["default"])((0, _extends2["default"])({}, columnSize), {
49
+ leftOffsetTablet: getEvenOffset(index)
50
+ });
51
+ }
52
+ };
53
+
54
+ exports.getLeftConfig = getLeftConfig;
55
+
56
+ var getCenterMediumConfig = function getCenterMediumConfig(count, index) {
57
+ switch (count) {
58
+ case 3:
59
+ return (0, _extends2["default"])((0, _extends2["default"])({}, columnSize), {
60
+ leftOffsetTablet: getOddOffset(index)
61
+ });
62
+
63
+ case 4:
64
+ return (0, _extends2["default"])((0, _extends2["default"])({}, columnSize), {
65
+ rightOffsetWide: getOddOffset(index),
66
+ leftOffsetWide: getEvenOffset(index),
67
+ rightOffsetDesktop: getEvenOffset(index),
68
+ leftOffsetDesktop: getOddOffset(index),
69
+ rightOffsetTablet: getEvenOffset(index),
70
+ leftOffsetTablet: getOddOffset(index)
71
+ });
72
+
73
+ default:
74
+ return (0, _extends2["default"])((0, _extends2["default"])({}, columnSize), {
75
+ rightOffsetWide: getOddOffset(index),
76
+ leftOffsetWide: getEvenOffset(index)
77
+ });
78
+ }
79
+ };
80
+
81
+ exports.getCenterMediumConfig = getCenterMediumConfig;
82
+
83
+ var getCenterLargeConfig = function getCenterLargeConfig(count, index) {
84
+ switch (count) {
85
+ case 4:
86
+ return (0, _extends2["default"])((0, _extends2["default"])({}, columnSize), {
87
+ leftOffsetWide: getOddOffset(index),
88
+ rightOffsetWide: getEvenOffset(index),
89
+ leftOffsetDesktop: getOddOffset(index),
90
+ rightOffsetDesktop: getEvenOffset(index),
91
+ leftOffsetTablet: getOddOffset(index),
92
+ rightOffsetTablet: getEvenOffset(index)
93
+ });
94
+
95
+ case 3:
96
+ return (0, _extends2["default"])((0, _extends2["default"])({}, columnSize), {
97
+ leftOffsetTablet: getOddOffset(index)
98
+ });
99
+
100
+ default:
101
+ return (0, _extends2["default"])({}, columnSize);
102
+ }
103
+ };
104
+
105
+ exports.getCenterLargeConfig = getCenterLargeConfig;
106
+
107
+ var getCenterConfig = function getCenterConfig(count, index, gutterSize) {
108
+ switch (gutterSize) {
109
+ case 'medium':
110
+ {
111
+ return getCenterMediumConfig(count, index);
112
+ }
113
+
114
+ default:
115
+ {
116
+ return getCenterLargeConfig(count, index);
117
+ }
118
+ }
119
+ };
120
+
121
+ var _default = getCenterConfig;
122
+ exports["default"] = _default;
@@ -20,8 +20,12 @@ h5 {
20
20
  padding: 16px 16px 24px;
21
21
  border-radius: 12px;
22
22
  color: var(--content);
23
- text-decoration: none;
23
+ text-decoration: none !important;
24
24
  background-color: var(--base);
25
+ -webkit-transition: background-color 0.3s, 0.3s, -webkit-box-shadow;
26
+ transition: background-color 0.3s, 0.3s, -webkit-box-shadow;
27
+ transition: background-color 0.3s, box-shadow, 0.3s;
28
+ transition: background-color 0.3s, box-shadow, 0.3s, -webkit-box-shadow;
25
29
  }
26
30
  @media screen and (min-width: 1280px) {
27
31
  .mfui-card {
@@ -1,4 +1,4 @@
1
- import React from 'react';
1
+ import React, { Ref } from 'react';
2
2
  import './Card.less';
3
3
  import { ButtonType, FeaturesList, IconsList, Image, Link, Price, TextsList, Title } from './types';
4
4
  export interface ICard {
@@ -12,6 +12,14 @@ export interface ICard {
12
12
  };
13
13
  /** Дополнительный класс для компонента */
14
14
  className?: string;
15
+ /** Дополнительные классы для внутренних элементов */
16
+ classes?: {
17
+ root?: string;
18
+ button?: string;
19
+ extraButton?: string;
20
+ };
21
+ /** Ссылка на корневой элемент */
22
+ rootRef?: Ref<HTMLDivElement | HTMLAnchorElement>;
15
23
  isFullHeight?: boolean;
16
24
  /** Вид */
17
25
  view?: 'shadow' | 'background';
@@ -52,6 +52,8 @@ var cn = (0, _uiHelpers.cnCreate)('mfui-card');
52
52
  var Card = function Card(_ref5) {
53
53
  var dataAttrs = _ref5.dataAttrs,
54
54
  className = _ref5.className,
55
+ classes = _ref5.classes,
56
+ rootRef = _ref5.rootRef,
55
57
  _ref5$isFullHeight = _ref5.isFullHeight,
56
58
  isFullHeight = _ref5$isFullHeight === void 0 ? false : _ref5$isFullHeight,
57
59
  link = _ref5.link,
@@ -184,7 +186,7 @@ var Card = function Card(_ref5) {
184
186
  dataAttrs: {
185
187
  root: dataAttrs === null || dataAttrs === void 0 ? void 0 : dataAttrs.button
186
188
  },
187
- className: cn('button'),
189
+ className: cn('button', [classes === null || classes === void 0 ? void 0 : classes.button]),
188
190
  href: button.href,
189
191
  target: button.target,
190
192
  onClick: button === null || button === void 0 ? void 0 : button.onClick
@@ -192,7 +194,7 @@ var Card = function Card(_ref5) {
192
194
  dataAttrs: {
193
195
  root: dataAttrs === null || dataAttrs === void 0 ? void 0 : dataAttrs.extraButton
194
196
  },
195
- className: cn('button'),
197
+ className: cn('button', [classes === null || classes === void 0 ? void 0 : classes.extraButton]),
196
198
  href: extraButton.href,
197
199
  target: extraButton.target,
198
200
  type: "outline",
@@ -216,10 +218,11 @@ var Card = function Card(_ref5) {
216
218
  view: view,
217
219
  link: isLink,
218
220
  'full-height': isFullHeight
219
- }, [className]),
221
+ }, [className, classes === null || classes === void 0 ? void 0 : classes.root]),
220
222
  href: isLink ? link === null || link === void 0 ? void 0 : link.href : undefined,
221
223
  target: isLink ? link === null || link === void 0 ? void 0 : link.target : undefined,
222
- onClick: isLink ? onClick : undefined
224
+ onClick: isLink ? onClick : undefined,
225
+ ref: rootRef
223
226
  }), renderIcon(), !isBottomImage && renderImage(), /*#__PURE__*/_react["default"].createElement(_uiCore.Header, {
224
227
  className: cn('title'),
225
228
  as: "h3",
@@ -236,6 +239,14 @@ Card.propTypes = {
236
239
  extraButton: _propTypes["default"].objectOf(_propTypes["default"].string.isRequired)
237
240
  }),
238
241
  className: _propTypes["default"].string,
242
+ classes: _propTypes["default"].shape({
243
+ root: _propTypes["default"].string,
244
+ button: _propTypes["default"].string,
245
+ extraButton: _propTypes["default"].string
246
+ }),
247
+ rootRef: _propTypes["default"].oneOfType([_propTypes["default"].func, _propTypes["default"].oneOfType([_propTypes["default"].shape({
248
+ current: _propTypes["default"].elementType
249
+ }), _propTypes["default"].any])]),
239
250
  view: _propTypes["default"].oneOf(['shadow', 'background']),
240
251
  link: _propTypes["default"].shape({
241
252
  href: _propTypes["default"].string,
@@ -18,7 +18,6 @@ export { default as Container } from './components/Container/Container';
18
18
  export { default as DownloadLink } from './components/DownloadLinks/DownloadLink';
19
19
  export { default as DownloadLinks } from './components/DownloadLinks/DownloadLinks';
20
20
  export { default as FaqWrapper } from './components/FaqWrapper/FaqWrapper';
21
- export { default as helpers } from './components/CardsBox/helpers';
22
21
  export { default as Instructions } from './components/Instructions/Instructions';
23
22
  export { default as NotificationBox } from './components/NotificationBox/NotificationBox';
24
23
  export { default as PageTitle } from './components/PageTitle/PageTitle';
package/dist/lib/index.js CHANGED
@@ -123,12 +123,6 @@ Object.defineProperty(exports, "FaqWrapper", {
123
123
  return _FaqWrapper["default"];
124
124
  }
125
125
  });
126
- Object.defineProperty(exports, "helpers", {
127
- enumerable: true,
128
- get: function get() {
129
- return _helpers["default"];
130
- }
131
- });
132
126
  Object.defineProperty(exports, "Instructions", {
133
127
  enumerable: true,
134
128
  get: function get() {
@@ -320,8 +314,6 @@ var _DownloadLinks = _interopRequireDefault(require("./components/DownloadLinks/
320
314
 
321
315
  var _FaqWrapper = _interopRequireDefault(require("./components/FaqWrapper/FaqWrapper"));
322
316
 
323
- var _helpers = _interopRequireDefault(require("./components/CardsBox/helpers"));
324
-
325
317
  var _Instructions = _interopRequireDefault(require("./components/Instructions/Instructions"));
326
318
 
327
319
  var _NotificationBox = _interopRequireDefault(require("./components/NotificationBox/NotificationBox"));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@megafon/ui-shared",
3
- "version": "5.0.1",
3
+ "version": "5.1.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.14.0",
51
+ "@megafon/ui-icons": "^2.14.1",
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.2.1",
86
- "@megafon/ui-helpers": "^2.5.2",
85
+ "@megafon/ui-core": "^5.2.2",
86
+ "@megafon/ui-helpers": "^2.5.3",
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": "c69a92daeb0568c343f3ca3b0dc4b2ca6de338d7"
93
+ "gitHead": "67d1595c72454846b31ebcd4acc8f7550a5f0df3"
94
94
  }