@megafon/ui-shared 5.0.1 → 5.2.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 +29 -0
- package/dist/es/components/BenefitsIcons/BenefitsIcons.js +19 -116
- package/dist/es/components/BenefitsIcons/BenefitsIconsTile.js +3 -1
- package/dist/es/components/BenefitsIcons/helpers.d.ts +8 -0
- package/dist/es/components/BenefitsIcons/helpers.js +116 -0
- package/dist/es/components/BenefitsPictures/BenefitsPictures.d.ts +1 -0
- package/dist/es/components/BenefitsPictures/BenefitsPictures.js +12 -102
- package/dist/es/components/BenefitsPictures/helpers.d.ts +11 -0
- package/dist/es/components/BenefitsPictures/helpers.js +99 -0
- package/dist/es/components/Card/Card.css +5 -1
- package/dist/es/components/Card/Card.d.ts +9 -1
- package/dist/es/components/Card/Card.js +15 -4
- package/dist/es/components/Property/Property.js +2 -2
- package/dist/es/components/Property/types.d.ts +1 -1
- package/dist/es/components/Table/Table.css +10 -1
- package/dist/es/components/Table/Table.d.ts +2 -0
- package/dist/es/components/Table/Table.js +17 -6
- package/dist/es/components/Table/TableRow.d.ts +2 -0
- package/dist/es/components/Table/TableRow.js +2 -0
- package/dist/es/index.d.ts +0 -1
- package/dist/es/index.js +0 -1
- package/dist/lib/components/BenefitsIcons/BenefitsIcons.js +21 -116
- package/dist/lib/components/BenefitsIcons/BenefitsIconsTile.js +3 -1
- package/dist/lib/components/BenefitsIcons/helpers.d.ts +8 -0
- package/dist/lib/components/BenefitsIcons/helpers.js +135 -0
- package/dist/lib/components/BenefitsPictures/BenefitsPictures.d.ts +1 -0
- package/dist/lib/components/BenefitsPictures/BenefitsPictures.js +16 -104
- package/dist/lib/components/BenefitsPictures/helpers.d.ts +11 -0
- package/dist/lib/components/BenefitsPictures/helpers.js +122 -0
- package/dist/lib/components/Card/Card.css +5 -1
- package/dist/lib/components/Card/Card.d.ts +9 -1
- package/dist/lib/components/Card/Card.js +15 -4
- package/dist/lib/components/Property/Property.js +2 -2
- package/dist/lib/components/Property/types.d.ts +1 -1
- package/dist/lib/components/Table/Table.css +10 -1
- package/dist/lib/components/Table/Table.d.ts +2 -0
- package/dist/lib/components/Table/Table.js +17 -6
- package/dist/lib/components/Table/TableRow.d.ts +2 -0
- package/dist/lib/components/Table/TableRow.js +2 -0
- package/dist/lib/index.d.ts +0 -1
- package/dist/lib/index.js +0 -8
- package/package.json +5 -5
@@ -98,7 +98,7 @@ var Property = function Property(_ref) {
|
|
98
98
|
"data-testid": "".concat(testIdPrefix, "-value")
|
99
99
|
}, /*#__PURE__*/React.createElement("div", {
|
100
100
|
className: cn('value')
|
101
|
-
}, convert(value, {})), valueUnit && /*#__PURE__*/React.createElement(Caption, {
|
101
|
+
}, typeof value === 'string' ? convert(value, {}) : value), valueUnit && /*#__PURE__*/React.createElement(Caption, {
|
102
102
|
className: cn('value-unit'),
|
103
103
|
hasMargin: false
|
104
104
|
}, convert(valueUnit, {})));
|
@@ -157,7 +157,7 @@ Property.propTypes = {
|
|
157
157
|
value: PropTypes.oneOfType([PropTypes.string, PropTypes.arrayOf(PropTypes.node)]).isRequired,
|
158
158
|
isCollapsible: PropTypes.bool
|
159
159
|
})),
|
160
|
-
value: PropTypes.string,
|
160
|
+
value: PropTypes.oneOfType([PropTypes.string, PropTypes.node]),
|
161
161
|
titleSize: PropTypes.oneOf(['default', 'big']),
|
162
162
|
valueUnit: PropTypes.string,
|
163
163
|
valueFrameColor: PropTypes.oneOf(['none', 'default', 'gray'])
|
@@ -14,7 +14,7 @@ export declare type Item = {
|
|
14
14
|
title?: string[] | React.ReactNode[];
|
15
15
|
titleSize?: 'default' | 'big';
|
16
16
|
description?: Desc[];
|
17
|
-
value?: string;
|
17
|
+
value?: string | React.ReactNode;
|
18
18
|
valueUnit?: string;
|
19
19
|
valueFrameColor?: 'none' | 'default' | 'gray';
|
20
20
|
};
|
@@ -40,7 +40,7 @@ h5 {
|
|
40
40
|
overflow: auto;
|
41
41
|
}
|
42
42
|
@media screen and (min-width: 1024px) {
|
43
|
-
.mfui-
|
43
|
+
.mfui-table__scroll_limit {
|
44
44
|
max-height: 500px;
|
45
45
|
}
|
46
46
|
}
|
@@ -131,6 +131,15 @@ h5 {
|
|
131
131
|
.mfui-table__row:not(:last-child) .mfui-table__cell {
|
132
132
|
border-bottom: 1px solid var(--spbSky2);
|
133
133
|
}
|
134
|
+
.mfui-table__row_align_bottom .mfui-table__cell {
|
135
|
+
vertical-align: bottom;
|
136
|
+
}
|
137
|
+
.mfui-table__row_align_top .mfui-table__cell {
|
138
|
+
vertical-align: top;
|
139
|
+
}
|
140
|
+
.mfui-table__row_align_top.mfui-table__row_head .mfui-table__cell {
|
141
|
+
padding-top: 12px;
|
142
|
+
}
|
134
143
|
.mfui-table_min-cell-size_small .mfui-table__cell:not(:first-child) {
|
135
144
|
min-width: 72px;
|
136
145
|
}
|
@@ -8,6 +8,8 @@ export interface ITable {
|
|
8
8
|
fixColumn?: boolean;
|
9
9
|
/** Минимальный размер ячеек */
|
10
10
|
minCellSize?: 'small' | 'large';
|
11
|
+
/** Отключить ограничение по высоте при разрешении больше 1024px */
|
12
|
+
disableHeightLimit?: boolean;
|
11
13
|
children: Array<React.ReactElement<ITableRow>>;
|
12
14
|
}
|
13
15
|
declare const Table: React.FC<ITable>;
|
@@ -14,6 +14,8 @@ var Table = function Table(_ref) {
|
|
14
14
|
fixColumn = _ref$fixColumn === void 0 ? true : _ref$fixColumn,
|
15
15
|
_ref$minCellSize = _ref.minCellSize,
|
16
16
|
minCellSize = _ref$minCellSize === void 0 ? 'large' : _ref$minCellSize,
|
17
|
+
_ref$disableHeightLim = _ref.disableHeightLimit,
|
18
|
+
disableHeightLimit = _ref$disableHeightLim === void 0 ? false : _ref$disableHeightLim,
|
17
19
|
children = _ref.children;
|
18
20
|
var scrollRef = React.useRef(null);
|
19
21
|
|
@@ -75,17 +77,23 @@ var Table = function Table(_ref) {
|
|
75
77
|
}, []);
|
76
78
|
|
77
79
|
var renderRows = function renderRows() {
|
78
|
-
return React.Children.map(children, function (_ref2) {
|
80
|
+
return React.Children.map(children, function (_ref2, index) {
|
79
81
|
var _ref2$props = _ref2.props,
|
80
82
|
cells = _ref2$props.children,
|
81
|
-
head = _ref2$props.head
|
83
|
+
head = _ref2$props.head,
|
84
|
+
_ref2$props$vAlign = _ref2$props.vAlign,
|
85
|
+
vAlign = _ref2$props$vAlign === void 0 ? 'default' : _ref2$props$vAlign;
|
82
86
|
return /*#__PURE__*/React.createElement("tr", {
|
87
|
+
key: index,
|
83
88
|
className: cn('row', {
|
84
|
-
head: head
|
85
|
-
|
86
|
-
|
89
|
+
head: head,
|
90
|
+
align: vAlign
|
91
|
+
}),
|
92
|
+
"data-testid": "Table-row"
|
93
|
+
}, React.Children.map(cells, function (_ref3, cellIndex) {
|
87
94
|
var cell = _ref3.props.children;
|
88
95
|
return /*#__PURE__*/React.createElement("td", {
|
96
|
+
key: cellIndex,
|
89
97
|
className: cn('cell')
|
90
98
|
}, typeof cell === 'string' ? convert(cell) : cell);
|
91
99
|
}));
|
@@ -99,7 +107,9 @@ var Table = function Table(_ref) {
|
|
99
107
|
touch: isTouchDevice
|
100
108
|
}, [className])
|
101
109
|
}, /*#__PURE__*/React.createElement("div", {
|
102
|
-
className: cn('scroll'
|
110
|
+
className: cn('scroll', {
|
111
|
+
limit: !disableHeightLimit
|
112
|
+
}),
|
103
113
|
ref: scrollRef,
|
104
114
|
onScroll: handleTableScroll
|
105
115
|
}, isTopShadow && /*#__PURE__*/React.createElement("div", {
|
@@ -119,6 +129,7 @@ Table.propTypes = {
|
|
119
129
|
className: PropTypes.string,
|
120
130
|
fixColumn: PropTypes.bool,
|
121
131
|
minCellSize: PropTypes.oneOf(['small', 'large']),
|
132
|
+
disableHeightLimit: PropTypes.bool,
|
122
133
|
children: PropTypes.arrayOf(PropTypes.element.isRequired).isRequired
|
123
134
|
};
|
124
135
|
export default Table;
|
@@ -3,6 +3,8 @@ import { ITableCell } from './TableCell';
|
|
3
3
|
export interface ITableRow {
|
4
4
|
/** Ряд таблицы как заголовок */
|
5
5
|
head?: boolean;
|
6
|
+
/** Выравнивание по вертикали в ячейках таблицы */
|
7
|
+
vAlign?: 'default' | 'bottom' | 'top';
|
6
8
|
children: Array<React.ReactElement<ITableCell>>;
|
7
9
|
}
|
8
10
|
declare const TableRow: React.FC<ITableRow>;
|
@@ -9,6 +9,8 @@ var TableRow = function TableRow(_ref) {
|
|
9
9
|
TableRow.propTypes = {
|
10
10
|
// eslint-disable-next-line react/no-unused-prop-types
|
11
11
|
head: PropTypes.bool,
|
12
|
+
// eslint-disable-next-line react/no-unused-prop-types
|
13
|
+
vAlign: PropTypes.oneOf(['default', 'bottom', 'top']),
|
12
14
|
children: PropTypes.arrayOf(PropTypes.element.isRequired).isRequired
|
13
15
|
};
|
14
16
|
export default TableRow;
|
package/dist/es/index.d.ts
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';
|
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";
|
@@ -7,10 +7,10 @@ Object.defineProperty(exports, "__esModule", {
|
|
7
7
|
});
|
8
8
|
exports["default"] = void 0;
|
9
9
|
|
10
|
-
var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
|
11
|
-
|
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
|
require("core-js/modules/es.object.values.js");
|
@@ -29,6 +29,8 @@ var _throttleTime = _interopRequireDefault(require("../../constants/throttleTime
|
|
29
29
|
|
30
30
|
var _BenefitsIconsTile = _interopRequireDefault(require("./BenefitsIconsTile"));
|
31
31
|
|
32
|
+
var _helpers = _interopRequireWildcard(require("./helpers"));
|
33
|
+
|
32
34
|
var _types = require("./types");
|
33
35
|
|
34
36
|
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); }
|
@@ -37,117 +39,7 @@ function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj &&
|
|
37
39
|
|
38
40
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
|
39
41
|
|
40
|
-
var
|
41
|
-
var everySecondWithoutOffset = index % 2 ? '1' : undefined;
|
42
|
-
var columnSize = {
|
43
|
-
wide: '4',
|
44
|
-
desktop: '5',
|
45
|
-
tablet: '10'
|
46
|
-
};
|
47
|
-
|
48
|
-
switch (count) {
|
49
|
-
case 2:
|
50
|
-
case 4:
|
51
|
-
return (0, _extends2["default"])((0, _extends2["default"])({}, columnSize), {
|
52
|
-
leftOffsetWide: everySecondWithoutOffset,
|
53
|
-
leftOffsetDesktop: everySecondWithoutOffset
|
54
|
-
});
|
55
|
-
|
56
|
-
default:
|
57
|
-
return (0, _extends2["default"])((0, _extends2["default"])({}, columnSize), {
|
58
|
-
leftOffsetDesktop: everySecondWithoutOffset
|
59
|
-
});
|
60
|
-
}
|
61
|
-
}; // left-aligned column with left-aligned icon on top
|
62
|
-
|
63
|
-
|
64
|
-
var getLeftTopConfig = function getLeftTopConfig(count, index) {
|
65
|
-
var everySecondWithoutOffset = index % 2 ? '1' : undefined;
|
66
|
-
var everyThirdWithoutOffset = index % 3 ? '1' : undefined;
|
67
|
-
|
68
|
-
switch (count) {
|
69
|
-
case 2:
|
70
|
-
return {
|
71
|
-
wide: '4',
|
72
|
-
desktop: '4',
|
73
|
-
tablet: '5',
|
74
|
-
leftOffsetWide: everySecondWithoutOffset,
|
75
|
-
leftOffsetDesktop: everySecondWithoutOffset,
|
76
|
-
leftOffsetTablet: everySecondWithoutOffset
|
77
|
-
};
|
78
|
-
|
79
|
-
case 4:
|
80
|
-
return {
|
81
|
-
wide: '3',
|
82
|
-
desktop: '4',
|
83
|
-
tablet: '5',
|
84
|
-
leftOffsetDesktop: everySecondWithoutOffset,
|
85
|
-
leftOffsetTablet: everySecondWithoutOffset
|
86
|
-
};
|
87
|
-
|
88
|
-
default:
|
89
|
-
return {
|
90
|
-
wide: '3',
|
91
|
-
desktop: '4',
|
92
|
-
tablet: '5',
|
93
|
-
leftOffsetWide: everyThirdWithoutOffset,
|
94
|
-
leftOffsetTablet: everySecondWithoutOffset
|
95
|
-
};
|
96
|
-
}
|
97
|
-
}; // center-aligned column with center-aligned icon on top
|
98
|
-
|
99
|
-
|
100
|
-
var getCenterTopConfig = function getCenterTopConfig(count, index) {
|
101
|
-
var isEvenIndex = !(index % 2);
|
102
|
-
var everyEvenWithLeftOffset = isEvenIndex ? '1' : undefined;
|
103
|
-
var everyOddWithRightOffset = isEvenIndex ? undefined : '1';
|
104
|
-
|
105
|
-
switch (count) {
|
106
|
-
case 4:
|
107
|
-
return {
|
108
|
-
wide: '3',
|
109
|
-
desktop: '5',
|
110
|
-
tablet: '5',
|
111
|
-
leftOffsetDesktop: everyEvenWithLeftOffset,
|
112
|
-
leftOffsetTablet: everyEvenWithLeftOffset,
|
113
|
-
rightOffsetTablet: everyOddWithRightOffset,
|
114
|
-
rightOffsetDesktop: everyOddWithRightOffset
|
115
|
-
};
|
116
|
-
|
117
|
-
default:
|
118
|
-
return {
|
119
|
-
wide: '4',
|
120
|
-
desktop: '4',
|
121
|
-
tablet: '4'
|
122
|
-
};
|
123
|
-
}
|
124
|
-
};
|
125
|
-
|
126
|
-
var getOneColumnConfig = function getOneColumnConfig(iconPosition) {
|
127
|
-
return iconPosition !== _types.IconPositionEnum.CENTER_TOP ? {
|
128
|
-
wide: '10',
|
129
|
-
desktop: '10',
|
130
|
-
tablet: '10'
|
131
|
-
} : {
|
132
|
-
wide: '12',
|
133
|
-
desktop: '12',
|
134
|
-
tablet: '12'
|
135
|
-
};
|
136
|
-
};
|
137
|
-
|
138
|
-
var getMultiColumnConfig = function getMultiColumnConfig(iconPosition, count, index) {
|
139
|
-
switch (iconPosition) {
|
140
|
-
case _types.IconPositionEnum.LEFT_TOP:
|
141
|
-
return getLeftTopConfig(count, index);
|
142
|
-
|
143
|
-
case _types.IconPositionEnum.CENTER_TOP:
|
144
|
-
return getCenterTopConfig(count, index);
|
145
|
-
|
146
|
-
default:
|
147
|
-
return getLeftSideConfig(count, index);
|
148
|
-
}
|
149
|
-
};
|
150
|
-
|
42
|
+
var testIdPrefix = 'BenefitsIcons';
|
151
43
|
var cn = (0, _uiHelpers.cnCreate)('mfui-benefits-icons');
|
152
44
|
|
153
45
|
var BenefitsIcons = function BenefitsIcons(_ref) {
|
@@ -202,15 +94,28 @@ var BenefitsIcons = function BenefitsIcons(_ref) {
|
|
202
94
|
}, /*#__PURE__*/React.createElement(_uiCore.Grid, {
|
203
95
|
className: classes.grid,
|
204
96
|
guttersLeft: "medium",
|
205
|
-
hAlign: itemsAlign
|
97
|
+
hAlign: itemsAlign,
|
98
|
+
dataAttrs: {
|
99
|
+
root: {
|
100
|
+
'data-testid': "".concat(testIdPrefix, "-grid-root")
|
101
|
+
},
|
102
|
+
container: {
|
103
|
+
'data-testid': "".concat(testIdPrefix, "-grid-container")
|
104
|
+
}
|
105
|
+
}
|
206
106
|
}, items.map(function (_ref2, i) {
|
207
107
|
var title = _ref2.title,
|
208
108
|
text = _ref2.text,
|
209
109
|
icon = _ref2.icon;
|
210
|
-
var columnConfig = inOneColumn ? getOneColumnConfig(iconPosition) :
|
110
|
+
var columnConfig = inOneColumn ? (0, _helpers.getOneColumnConfig)(iconPosition) : (0, _helpers["default"])(iconPosition, items.length, i);
|
211
111
|
return /*#__PURE__*/React.createElement(_uiCore.GridColumn, (0, _extends2["default"])({
|
212
112
|
className: classes.gridColumn,
|
213
|
-
key: i
|
113
|
+
key: i,
|
114
|
+
dataAttrs: {
|
115
|
+
root: {
|
116
|
+
'data-testid': "".concat(testIdPrefix, "-grid-column")
|
117
|
+
}
|
118
|
+
}
|
214
119
|
}, columnConfig), /*#__PURE__*/React.createElement(_BenefitsIconsTile["default"], {
|
215
120
|
className: cn('tile', [classes.item]),
|
216
121
|
title: title,
|
@@ -25,6 +25,7 @@ function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "functio
|
|
25
25
|
|
26
26
|
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; }
|
27
27
|
|
28
|
+
var testIdPrefix = 'BenefitsIconsTile';
|
28
29
|
var cn = (0, _uiHelpers.cnCreate)('mfui-benefits-icons-tile');
|
29
30
|
|
30
31
|
var BenefitsIconsTile = function BenefitsIconsTile(_ref) {
|
@@ -37,7 +38,8 @@ var BenefitsIconsTile = function BenefitsIconsTile(_ref) {
|
|
37
38
|
return /*#__PURE__*/React.createElement("div", {
|
38
39
|
className: cn({
|
39
40
|
'icon-position': iconPosition
|
40
|
-
}, [className])
|
41
|
+
}, [className]),
|
42
|
+
"data-testid": "".concat(testIdPrefix, "-root")
|
41
43
|
}, /*#__PURE__*/React.createElement("div", {
|
42
44
|
className: cn('svg-icon')
|
43
45
|
}, icon), /*#__PURE__*/React.createElement("div", {
|
@@ -0,0 +1,8 @@
|
|
1
|
+
import { GridConfig } from './types';
|
2
|
+
declare const getLeftSideConfig: (count: number, index: number) => GridConfig;
|
3
|
+
declare const getLeftTopConfig: (count: number, index: number) => GridConfig;
|
4
|
+
declare const getCenterTopConfig: (count: number, index: number) => GridConfig;
|
5
|
+
declare const getOneColumnConfig: (iconPosition: "left-top" | "center-top" | "left-side") => GridConfig;
|
6
|
+
declare const getMultiColumnConfig: (iconPosition: "left-top" | "center-top" | "left-side", count: number, index: number) => GridConfig;
|
7
|
+
export default getMultiColumnConfig;
|
8
|
+
export { getLeftSideConfig, getLeftTopConfig, getCenterTopConfig, getOneColumnConfig };
|
@@ -0,0 +1,135 @@
|
|
1
|
+
"use strict";
|
2
|
+
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
4
|
+
value: true
|
5
|
+
});
|
6
|
+
exports.getOneColumnConfig = exports.getCenterTopConfig = exports.getLeftTopConfig = exports.getLeftSideConfig = exports["default"] = void 0;
|
7
|
+
|
8
|
+
var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
|
9
|
+
|
10
|
+
var _types = require("./types");
|
11
|
+
|
12
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
|
13
|
+
|
14
|
+
// left-aligned column with left side icon
|
15
|
+
var getLeftSideConfig = function getLeftSideConfig(count, index) {
|
16
|
+
var everySecondWithoutOffset = index % 2 ? '1' : undefined;
|
17
|
+
var columnSize = {
|
18
|
+
wide: '4',
|
19
|
+
desktop: '5',
|
20
|
+
tablet: '10'
|
21
|
+
};
|
22
|
+
|
23
|
+
switch (count) {
|
24
|
+
case 2:
|
25
|
+
case 4:
|
26
|
+
return (0, _extends2["default"])((0, _extends2["default"])({}, columnSize), {
|
27
|
+
leftOffsetWide: everySecondWithoutOffset,
|
28
|
+
leftOffsetDesktop: everySecondWithoutOffset
|
29
|
+
});
|
30
|
+
|
31
|
+
default:
|
32
|
+
return (0, _extends2["default"])((0, _extends2["default"])({}, columnSize), {
|
33
|
+
leftOffsetDesktop: everySecondWithoutOffset
|
34
|
+
});
|
35
|
+
}
|
36
|
+
}; // left-aligned column with left-aligned icon on top
|
37
|
+
|
38
|
+
|
39
|
+
exports.getLeftSideConfig = getLeftSideConfig;
|
40
|
+
|
41
|
+
var getLeftTopConfig = function getLeftTopConfig(count, index) {
|
42
|
+
var everySecondWithoutOffset = index % 2 ? '1' : undefined;
|
43
|
+
var everyThirdWithoutOffset = index % 3 ? '1' : undefined;
|
44
|
+
|
45
|
+
switch (count) {
|
46
|
+
case 2:
|
47
|
+
return {
|
48
|
+
wide: '4',
|
49
|
+
desktop: '4',
|
50
|
+
tablet: '5',
|
51
|
+
leftOffsetWide: everySecondWithoutOffset,
|
52
|
+
leftOffsetDesktop: everySecondWithoutOffset,
|
53
|
+
leftOffsetTablet: everySecondWithoutOffset
|
54
|
+
};
|
55
|
+
|
56
|
+
case 4:
|
57
|
+
return {
|
58
|
+
wide: '3',
|
59
|
+
desktop: '4',
|
60
|
+
tablet: '5',
|
61
|
+
leftOffsetDesktop: everySecondWithoutOffset,
|
62
|
+
leftOffsetTablet: everySecondWithoutOffset
|
63
|
+
};
|
64
|
+
|
65
|
+
default:
|
66
|
+
return {
|
67
|
+
wide: '3',
|
68
|
+
desktop: '4',
|
69
|
+
tablet: '5',
|
70
|
+
leftOffsetWide: everyThirdWithoutOffset,
|
71
|
+
leftOffsetTablet: everySecondWithoutOffset
|
72
|
+
};
|
73
|
+
}
|
74
|
+
}; // center-aligned column with center-aligned icon on top
|
75
|
+
|
76
|
+
|
77
|
+
exports.getLeftTopConfig = getLeftTopConfig;
|
78
|
+
|
79
|
+
var getCenterTopConfig = function getCenterTopConfig(count, index) {
|
80
|
+
var isEvenIndex = !(index % 2);
|
81
|
+
var everyEvenWithLeftOffset = isEvenIndex ? '1' : undefined;
|
82
|
+
var everyOddWithRightOffset = isEvenIndex ? undefined : '1';
|
83
|
+
|
84
|
+
switch (count) {
|
85
|
+
case 4:
|
86
|
+
return {
|
87
|
+
wide: '3',
|
88
|
+
desktop: '5',
|
89
|
+
tablet: '5',
|
90
|
+
leftOffsetDesktop: everyEvenWithLeftOffset,
|
91
|
+
leftOffsetTablet: everyEvenWithLeftOffset,
|
92
|
+
rightOffsetTablet: everyOddWithRightOffset,
|
93
|
+
rightOffsetDesktop: everyOddWithRightOffset
|
94
|
+
};
|
95
|
+
|
96
|
+
default:
|
97
|
+
return {
|
98
|
+
wide: '4',
|
99
|
+
desktop: '4',
|
100
|
+
tablet: '4'
|
101
|
+
};
|
102
|
+
}
|
103
|
+
};
|
104
|
+
|
105
|
+
exports.getCenterTopConfig = getCenterTopConfig;
|
106
|
+
|
107
|
+
var getOneColumnConfig = function getOneColumnConfig(iconPosition) {
|
108
|
+
return iconPosition !== _types.IconPositionEnum.CENTER_TOP ? {
|
109
|
+
wide: '10',
|
110
|
+
desktop: '10',
|
111
|
+
tablet: '10'
|
112
|
+
} : {
|
113
|
+
wide: '12',
|
114
|
+
desktop: '12',
|
115
|
+
tablet: '12'
|
116
|
+
};
|
117
|
+
};
|
118
|
+
|
119
|
+
exports.getOneColumnConfig = getOneColumnConfig;
|
120
|
+
|
121
|
+
var getMultiColumnConfig = function getMultiColumnConfig(iconPosition, count, index) {
|
122
|
+
switch (iconPosition) {
|
123
|
+
case _types.IconPositionEnum.LEFT_TOP:
|
124
|
+
return getLeftTopConfig(count, index);
|
125
|
+
|
126
|
+
case _types.IconPositionEnum.CENTER_TOP:
|
127
|
+
return getCenterTopConfig(count, index);
|
128
|
+
|
129
|
+
default:
|
130
|
+
return getLeftSideConfig(count, index);
|
131
|
+
}
|
132
|
+
};
|
133
|
+
|
134
|
+
var _default = getMultiColumnConfig;
|
135
|
+
exports["default"] = _default;
|
@@ -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
|
-
|
38
|
-
|
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) :
|
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, };
|