@megafon/ui-core 2.1.1 → 2.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 CHANGED
@@ -3,6 +3,51 @@
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
+ # [2.2.0](https://github.com/MegafonWebLab/megafon-ui/compare/@megafon/ui-core@2.1.4...@megafon/ui-core@2.2.0) (2021-12-29)
7
+
8
+
9
+ ### Features
10
+
11
+ * **radiobutton:** add dataAttrs prop ([3f8d0b4](https://github.com/MegafonWebLab/megafon-ui/commit/3f8d0b4c4ec4a6ca301ab44feed2842ec8e54f3a))
12
+
13
+
14
+
15
+
16
+
17
+ ## [2.1.4](https://github.com/MegafonWebLab/megafon-ui/compare/@megafon/ui-core@2.1.3...@megafon/ui-core@2.1.4) (2021-12-20)
18
+
19
+
20
+ ### Bug Fixes
21
+
22
+ * **colors:** add hover colors to system group ([634ac03](https://github.com/MegafonWebLab/megafon-ui/commit/634ac034445fdcd08b60ff056f75683025cb6d49))
23
+ * **tabs:** fix active tab underline width ([4499399](https://github.com/MegafonWebLab/megafon-ui/commit/449939942730143712a92930a279a8b6fc17a012))
24
+
25
+
26
+
27
+
28
+
29
+ ## [2.1.3](https://github.com/MegafonWebLab/megafon-ui/compare/@megafon/ui-core@2.1.2...@megafon/ui-core@2.1.3) (2021-12-14)
30
+
31
+
32
+ ### Bug Fixes
33
+
34
+ * **contentarea:** fix backgroundColor and innerBackgroundColor props values ([d6004a4](https://github.com/MegafonWebLab/megafon-ui/commit/d6004a493b623cced4c453d69b0fd16d3cfbef43))
35
+
36
+
37
+
38
+
39
+
40
+ ## [2.1.2](https://github.com/MegafonWebLab/megafon-ui/compare/@megafon/ui-core@2.1.1...@megafon/ui-core@2.1.2) (2021-12-14)
41
+
42
+
43
+ ### Bug Fixes
44
+
45
+ * **paragraph:** rollback deprecated color props clearWhite ([ee4e5a9](https://github.com/MegafonWebLab/megafon-ui/commit/ee4e5a9ce158a4df68e437d316e37ed6e87df664))
46
+
47
+
48
+
49
+
50
+
6
51
  ## [2.1.1](https://github.com/MegafonWebLab/megafon-ui/compare/@megafon/ui-core@2.1.0...@megafon/ui-core@2.1.1) (2021-12-13)
7
52
 
8
53
 
@@ -70,13 +70,13 @@ h5 {
70
70
  }
71
71
  }
72
72
  .colors__list {
73
+ -webkit-box-pack: space-evenly;
74
+ -ms-flex-pack: space-evenly;
75
+ justify-content: space-evenly;
73
76
  padding-bottom: 12px;
74
77
  }
75
78
  @media screen and (max-width: 1023px) {
76
79
  .colors__list {
77
- -webkit-box-pack: space-evenly;
78
- -ms-flex-pack: space-evenly;
79
- justify-content: space-evenly;
80
80
  -webkit-box-ordinal-group: 3;
81
81
  -ms-flex-order: 2;
82
82
  order: 2;
@@ -229,7 +229,7 @@ var Colors = function Colors() {
229
229
  mobile: "12",
230
230
  tablet: "12"
231
231
  }, renderColorBlock(secondary)), /*#__PURE__*/React.createElement(GridColumn, {
232
- all: "5",
232
+ all: "10",
233
233
  mobile: "12",
234
234
  tablet: "12"
235
235
  }, renderColorBlock(system))), /*#__PURE__*/React.createElement(Grid, null, /*#__PURE__*/React.createElement(GridColumn, {
@@ -238,7 +238,7 @@ var Colors = function Colors() {
238
238
  tablet: "12"
239
239
  }, renderColorBlock(gradientColors)), /*#__PURE__*/React.createElement(GridColumn, {
240
240
  all: "3",
241
- leftOffsetWide: "1",
241
+ leftOffsetWide: "2",
242
242
  leftOffsetTablet: "1",
243
243
  leftOffsetDesktop: "1",
244
244
  mobile: "12",
@@ -67,6 +67,15 @@ var colors = {
67
67
  }, {
68
68
  name: 'Background',
69
69
  code: '#FFFFFF'
70
+ }, {
71
+ name: 'Button Hov. G.',
72
+ code: '#10E272'
73
+ }, {
74
+ name: 'Button Hov. P.',
75
+ code: '#A500BF'
76
+ }, {
77
+ name: 'Button Down',
78
+ code: '#404D46'
70
79
  }]
71
80
  }
72
81
  },
@@ -5,6 +5,7 @@ h4,
5
5
  h5 {
6
6
  margin: 0;
7
7
  }
8
+ .mfui-content-area_color_base,
8
9
  .mfui-content-area_color_white {
9
10
  background-color: #FFFFFF;
10
11
  }
@@ -81,6 +82,7 @@ h5 {
81
82
  padding-right: 0;
82
83
  padding-left: 0;
83
84
  }
85
+ .mfui-content-area__inner_color_base,
84
86
  .mfui-content-area__inner_color_white {
85
87
  background-color: #FFFFFF;
86
88
  }
@@ -1,7 +1,7 @@
1
1
  import * as React from 'react';
2
2
  import './ContentArea.less';
3
3
  declare const BACKGROUND_COLORS: {
4
- readonly WHITE: "white";
4
+ readonly BASE: "base";
5
5
  readonly TRANSPARENT: "transparent";
6
6
  readonly GREEN: "green";
7
7
  readonly PURPLE: "purple";
@@ -11,6 +11,8 @@ declare const BACKGROUND_COLORS: {
11
11
  readonly CONTENT: "content";
12
12
  readonly FULL_BLACK: "fullBlack";
13
13
  /** @deprecated */
14
+ readonly WHITE: "white";
15
+ /** @deprecated */
14
16
  readonly FRESH_ASPHALT: "freshAsphalt";
15
17
  };
16
18
  export declare type BackgroundColorType = typeof BACKGROUND_COLORS[keyof typeof BACKGROUND_COLORS];
@@ -7,7 +7,7 @@ import { cnCreate } from '@megafon/ui-helpers';
7
7
  import * as PropTypes from 'prop-types';
8
8
  import "./ContentArea.css";
9
9
  var BACKGROUND_COLORS = {
10
- WHITE: 'white',
10
+ BASE: 'base',
11
11
  TRANSPARENT: 'transparent',
12
12
  GREEN: 'green',
13
13
  PURPLE: 'purple',
@@ -17,6 +17,9 @@ var BACKGROUND_COLORS = {
17
17
  CONTENT: 'content',
18
18
  FULL_BLACK: 'fullBlack',
19
19
 
20
+ /** @deprecated */
21
+ WHITE: 'white',
22
+
20
23
  /** @deprecated */
21
24
  FRESH_ASPHALT: 'freshAsphalt'
22
25
  };
@@ -48,15 +51,20 @@ var ContentArea = function ContentArea(_ref) {
48
51
  };
49
52
 
50
53
  var colorsCustomPropTypes = function colorsCustomPropTypes(props, propName, componentName) {
51
- var deprecatedValue = BACKGROUND_COLORS.FRESH_ASPHALT;
54
+ var deprecatedBlackValue = BACKGROUND_COLORS.FRESH_ASPHALT;
55
+ var deprecatedWhiteValue = BACKGROUND_COLORS.WHITE;
52
56
  var propValue = props[propName];
53
57
 
54
58
  if (propValue && !Object.values(BACKGROUND_COLORS).includes(propValue)) {
55
- return new Error("Failed prop type: Invalid prop '".concat(propName, "' of value '").concat(propValue, "' supplied to '").concat(componentName, "', \n expected one of [").concat(Object.values(BACKGROUND_COLORS), "]"));
59
+ return new Error("Failed prop type: Invalid prop '".concat(propName, "' of value '").concat(propValue, "' supplied to '").concat(componentName, "',\n expected one of [").concat(Object.values(BACKGROUND_COLORS), "]"));
60
+ }
61
+
62
+ if (propValue && propValue === deprecatedBlackValue) {
63
+ return new Error("Failed prop type: Invalid prop '".concat(propName, "' of value '").concat(propValue, "' supplied to '").concat(componentName, "',\n value '").concat(deprecatedBlackValue, "' is deprecated, please use value '").concat(BACKGROUND_COLORS.CONTENT, "'"));
56
64
  }
57
65
 
58
- if (propValue && propValue === BACKGROUND_COLORS.FRESH_ASPHALT) {
59
- return new Error("Failed prop type: Invalid prop '".concat(propName, "' of value '").concat(propValue, "' supplied to '").concat(componentName, "',\n value '").concat(deprecatedValue, "' is deprecated, please use value '").concat(BACKGROUND_COLORS.CONTENT, "'"));
66
+ if (propValue && propValue === deprecatedWhiteValue) {
67
+ return new Error("Failed prop type: Invalid prop '".concat(propName, "' of value '").concat(propValue, "' supplied to '").concat(componentName, "',\n value '").concat(deprecatedWhiteValue, "' is deprecated, please use value '").concat(BACKGROUND_COLORS.BASE, "'"));
60
68
  }
61
69
 
62
70
  return null;
@@ -36,7 +36,8 @@ h5 {
36
36
  .mfui-paragraph_color_purple {
37
37
  color: #731982;
38
38
  }
39
- .mfui-paragraph_color_base {
39
+ .mfui-paragraph_color_base,
40
+ .mfui-paragraph_color_clearWhite {
40
41
  color: #FFFFFF;
41
42
  }
42
43
  .mfui-paragraph_color_spbSky0 {
@@ -11,6 +11,8 @@ declare const COLORS: {
11
11
  FULL_BLACK: string;
12
12
  INHERIT: string;
13
13
  /** @deprecated */
14
+ CLEAR_WHITE: string;
15
+ /** @deprecated */
14
16
  FRESH_ASPHALT: string;
15
17
  };
16
18
  declare type ColorType = typeof COLORS[keyof typeof COLORS];
@@ -17,6 +17,9 @@ var COLORS = {
17
17
  FULL_BLACK: 'fullBlack',
18
18
  INHERIT: 'inherit',
19
19
 
20
+ /** @deprecated */
21
+ CLEAR_WHITE: 'clearWhite',
22
+
20
23
  /** @deprecated */
21
24
  FRESH_ASPHALT: 'freshAsphalt'
22
25
  };
@@ -27,7 +30,7 @@ var Paragraph = function Paragraph(_ref) {
27
30
  size = _ref$size === void 0 ? 'regular' : _ref$size,
28
31
  align = _ref.align,
29
32
  _ref$color = _ref.color,
30
- color = _ref$color === void 0 ? 'content' : _ref$color,
33
+ color = _ref$color === void 0 ? 'freshAsphalt' : _ref$color,
31
34
  className = _ref.className,
32
35
  _ref$hasMargin = _ref.hasMargin,
33
36
  hasMargin = _ref$hasMargin === void 0 ? true : _ref$hasMargin,
@@ -47,15 +50,20 @@ Paragraph.propTypes = {
47
50
  size: PropTypes.oneOf(['regular', 'small']),
48
51
  hasMargin: PropTypes.bool,
49
52
  color: function color(props, propName, componentName) {
50
- var deprecatedValue = COLORS.FRESH_ASPHALT;
53
+ var deprecatedBlackValue = COLORS.FRESH_ASPHALT;
54
+ var deprecatedWhiteValue = COLORS.CLEAR_WHITE;
51
55
  var propValue = props[propName];
52
56
 
53
57
  if (propValue && !Object.values(COLORS).includes(propValue)) {
54
58
  return new Error("Failed prop type: Invalid prop '".concat(propName, "' of value '").concat(propValue, "' supplied to '").concat(componentName, "', \n expected one of [").concat(Object.values(COLORS), "]"));
55
59
  }
56
60
 
57
- if (propValue && props[propName] === COLORS.FRESH_ASPHALT) {
58
- return new Error("Failed prop type: Invalid prop '".concat(propName, "' of value '").concat(propValue, "' supplied to '").concat(componentName, "',\n value '").concat(deprecatedValue, "' is deprecated, please use value '").concat(COLORS.CONTENT, "'"));
61
+ if (propValue && props[propName] === deprecatedBlackValue) {
62
+ return new Error("Failed prop type: Invalid prop '".concat(propName, "' of value '").concat(propValue, "' supplied to '").concat(componentName, "',\n value '").concat(deprecatedBlackValue, "' is deprecated, please use value '").concat(COLORS.CONTENT, "'"));
63
+ }
64
+
65
+ if (propValue && props[propName] === deprecatedWhiteValue) {
66
+ return new Error("Failed prop type: Invalid prop '".concat(propName, "' of value '").concat(propValue, "' supplied to '").concat(componentName, "',\n value '").concat(deprecatedWhiteValue, "' is deprecated, please use value '").concat(COLORS.BASE, "'"));
59
67
  }
60
68
 
61
69
  return null;
@@ -1,7 +1,8 @@
1
1
  import * as React from 'react';
2
+ import { IFilterDataAttrs } from '@megafon/ui-helpers';
2
3
  import * as PropTypes from 'prop-types';
3
4
  import './RadioButton.less';
4
- export interface IRadioButtonProps {
5
+ export interface IRadioButtonProps extends IFilterDataAttrs {
5
6
  /** Значение */
6
7
  value: string;
7
8
  /** Имя для тега form */
@@ -44,6 +45,9 @@ declare class RadioButton extends React.Component<IRadioButtonProps> {
44
45
  children: PropTypes.Requireable<PropTypes.ReactNodeLike>;
45
46
  onChange: PropTypes.Requireable<(...args: any[]) => any>;
46
47
  inputRef: PropTypes.Requireable<any>;
48
+ dataAttrs: PropTypes.Requireable<{
49
+ [x: string]: string;
50
+ }>;
47
51
  };
48
52
  static defaultProps: Partial<IRadioButtonProps>;
49
53
  handleChange: () => void;
@@ -18,7 +18,7 @@ function _createSuper(Derived) { return function () { var Super = _getPrototypeO
18
18
  function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Date.prototype.toString.call(Reflect.construct(Date, [], function () {})); return true; } catch (e) { return false; } }
19
19
 
20
20
  import * as React from 'react';
21
- import { cnCreate } from '@megafon/ui-helpers';
21
+ import { cnCreate, filterDataAttrs } from '@megafon/ui-helpers';
22
22
  import * as PropTypes from 'prop-types';
23
23
  import "./RadioButton.css";
24
24
  var cn = cnCreate('mfui-radio-button');
@@ -58,14 +58,15 @@ var RadioButton = /*#__PURE__*/function (_React$Component) {
58
58
  inputRef = _this$props2.inputRef,
59
59
  className = _this$props2.className,
60
60
  _this$props2$classes = _this$props2.classes,
61
- classes = _this$props2$classes === void 0 ? {} : _this$props2$classes;
61
+ classes = _this$props2$classes === void 0 ? {} : _this$props2$classes,
62
+ dataAttrs = _this$props2.dataAttrs;
62
63
  var checkedProp = isChecked !== undefined ? {
63
64
  checked: isChecked
64
65
  } : {};
65
66
  var rootClassNames = Array.isArray(className) ? [].concat(_toConsumableArray(className), [classes.root]) : [className, classes.root];
66
- return /*#__PURE__*/React.createElement("div", {
67
+ return /*#__PURE__*/React.createElement("div", _extends({
67
68
  className: cn(rootClassNames)
68
- }, /*#__PURE__*/React.createElement("label", {
69
+ }, filterDataAttrs(dataAttrs)), /*#__PURE__*/React.createElement("label", {
69
70
  className: cn('label', {
70
71
  disabled: disabled
71
72
  }, classes.label)
@@ -107,7 +108,8 @@ RadioButton.propTypes = {
107
108
  onChange: PropTypes.func,
108
109
  inputRef: PropTypes.oneOfType([PropTypes.func, PropTypes.oneOfType([PropTypes.shape({
109
110
  current: PropTypes.elementType
110
- }), PropTypes.any])])
111
+ }), PropTypes.any])]),
112
+ dataAttrs: PropTypes.objectOf(PropTypes.string.isRequired)
111
113
  };
112
114
  RadioButton.defaultProps = {
113
115
  textSize: 'medium',
@@ -96,36 +96,41 @@ var Tabs = function Tabs(_ref) {
96
96
 
97
97
  var _React$useState9 = React.useState(0),
98
98
  _React$useState10 = _slicedToArray(_React$useState9, 2),
99
- underlineWidth = _React$useState10[0],
100
- setUnderlineWidth = _React$useState10[1];
99
+ activeTabWidth = _React$useState10[0],
100
+ setActiveTabWidth = _React$useState10[1];
101
101
 
102
102
  var _React$useState11 = React.useState(0),
103
103
  _React$useState12 = _slicedToArray(_React$useState11, 2),
104
- underlineTranslate = _React$useState12[0],
105
- setUnderlineTranslate = _React$useState12[1];
104
+ underlineWidth = _React$useState12[0],
105
+ setUnderlineWidth = _React$useState12[1];
106
106
 
107
- var _React$useState13 = React.useState('none'),
107
+ var _React$useState13 = React.useState(0),
108
108
  _React$useState14 = _slicedToArray(_React$useState13, 2),
109
- underlineTransition = _React$useState14[0],
110
- setUnderlineTransition = _React$useState14[1];
109
+ underlineTranslate = _React$useState14[0],
110
+ setUnderlineTranslate = _React$useState14[1];
111
111
 
112
- var _React$useState15 = React.useState('auto'),
112
+ var _React$useState15 = React.useState('none'),
113
113
  _React$useState16 = _slicedToArray(_React$useState15, 2),
114
- tabListHeight = _React$useState16[0],
115
- setTabListHeight = _React$useState16[1];
114
+ underlineTransition = _React$useState16[0],
115
+ setUnderlineTransition = _React$useState16[1];
116
116
 
117
- var _React$useState17 = React.useState(false),
117
+ var _React$useState17 = React.useState('auto'),
118
118
  _React$useState18 = _slicedToArray(_React$useState17, 2),
119
- isSticky = _React$useState18[0],
120
- setSticky = _React$useState18[1];
119
+ tabListHeight = _React$useState18[0],
120
+ setTabListHeight = _React$useState18[1];
121
121
 
122
- var _React$useState19 = React.useState({
122
+ var _React$useState19 = React.useState(false),
123
+ _React$useState20 = _slicedToArray(_React$useState19, 2),
124
+ isSticky = _React$useState20[0],
125
+ setSticky = _React$useState20[1];
126
+
127
+ var _React$useState21 = React.useState({
123
128
  left: 0,
124
129
  right: 0
125
130
  }),
126
- _React$useState20 = _slicedToArray(_React$useState19, 2),
127
- stickyOffset = _React$useState20[0],
128
- setStickyOffset = _React$useState20[1];
131
+ _React$useState22 = _slicedToArray(_React$useState21, 2),
132
+ stickyOffset = _React$useState22[0],
133
+ setStickyOffset = _React$useState22[1];
129
134
 
130
135
  var setTabRef = React.useCallback(function (tab) {
131
136
  tab && tabsRef.current.push(tab);
@@ -135,12 +140,6 @@ var Tabs = function Tabs(_ref) {
135
140
  return;
136
141
  }
137
142
 
138
- var tabNodeChild = tabsRef.current[currentIndex].firstElementChild;
139
-
140
- var _ref2 = tabNodeChild || {},
141
- _ref2$clientWidth = _ref2.clientWidth,
142
- clientWidth = _ref2$clientWidth === void 0 ? 0 : _ref2$clientWidth;
143
-
144
143
  var translate = _toConsumableArray(tabsRef.current).splice(0, currentIndex).reduce(function (accWidth, node) {
145
144
  var _node$getBoundingClie = node.getBoundingClientRect(),
146
145
  width = _node$getBoundingClie.width;
@@ -148,9 +147,9 @@ var Tabs = function Tabs(_ref) {
148
147
  return accWidth + width;
149
148
  }, 0);
150
149
 
151
- setUnderlineWidth(clientWidth);
150
+ setUnderlineWidth(activeTabWidth);
152
151
  setUnderlineTranslate(translate);
153
- }, [currentIndex]);
152
+ }, [currentIndex, activeTabWidth]);
154
153
  var calculateSticky = React.useCallback(function () {
155
154
  if (!sticky || !rootRef.current || !tabListRef.current) {
156
155
  return;
@@ -247,12 +246,12 @@ var Tabs = function Tabs(_ref) {
247
246
  }, []);
248
247
  React.useEffect(function () {
249
248
  var observer = new IntersectionObserver(function (entries) {
250
- entries.forEach(function (_ref3) {
251
- var isIntersecting = _ref3.isIntersecting,
252
- _ref3$boundingClientR = _ref3.boundingClientRect,
253
- top = _ref3$boundingClientR.top,
254
- left = _ref3$boundingClientR.left,
255
- right = _ref3$boundingClientR.right;
249
+ entries.forEach(function (_ref2) {
250
+ var isIntersecting = _ref2.isIntersecting,
251
+ _ref2$boundingClientR = _ref2.boundingClientRect,
252
+ top = _ref2$boundingClientR.top,
253
+ left = _ref2$boundingClientR.left,
254
+ right = _ref2$boundingClientR.right;
256
255
 
257
256
  if (!sticky || !rootRef.current || !tabListRef.current) {
258
257
  return;
@@ -294,10 +293,20 @@ var Tabs = function Tabs(_ref) {
294
293
  }, [calculateSticky]);
295
294
  React.useEffect(function () {
296
295
  var handleResize = throttle(function () {
297
- calculateUnderline();
298
296
  calculateSticky();
299
297
  }, 300);
298
+ var activeTabNode = tabsRef.current[currentIndex];
299
+ var resizeObserver = new ResizeObserver(function (entries) {
300
+ if (!entries.length || !entries[0]) {
301
+ return;
302
+ }
303
+
304
+ var width = entries[0].contentRect.width;
305
+ setActiveTabWidth(width);
306
+ calculateUnderline();
307
+ });
300
308
  calculateUnderline();
309
+ resizeObserver.observe(activeTabNode);
301
310
  window.addEventListener('resize', handleResize);
302
311
  return function () {
303
312
  window.removeEventListener('resize', handleResize);
@@ -70,13 +70,13 @@ h5 {
70
70
  }
71
71
  }
72
72
  .colors__list {
73
+ -webkit-box-pack: space-evenly;
74
+ -ms-flex-pack: space-evenly;
75
+ justify-content: space-evenly;
73
76
  padding-bottom: 12px;
74
77
  }
75
78
  @media screen and (max-width: 1023px) {
76
79
  .colors__list {
77
- -webkit-box-pack: space-evenly;
78
- -ms-flex-pack: space-evenly;
79
- justify-content: space-evenly;
80
80
  -webkit-box-ordinal-group: 3;
81
81
  -ms-flex-order: 2;
82
82
  order: 2;
@@ -256,7 +256,7 @@ var Colors = function Colors() {
256
256
  mobile: "12",
257
257
  tablet: "12"
258
258
  }, renderColorBlock(secondary)), /*#__PURE__*/React.createElement(_GridColumn["default"], {
259
- all: "5",
259
+ all: "10",
260
260
  mobile: "12",
261
261
  tablet: "12"
262
262
  }, renderColorBlock(system))), /*#__PURE__*/React.createElement(_Grid["default"], null, /*#__PURE__*/React.createElement(_GridColumn["default"], {
@@ -265,7 +265,7 @@ var Colors = function Colors() {
265
265
  tablet: "12"
266
266
  }, renderColorBlock(gradientColors)), /*#__PURE__*/React.createElement(_GridColumn["default"], {
267
267
  all: "3",
268
- leftOffsetWide: "1",
268
+ leftOffsetWide: "2",
269
269
  leftOffsetTablet: "1",
270
270
  leftOffsetDesktop: "1",
271
271
  mobile: "12",
@@ -73,6 +73,15 @@ var colors = {
73
73
  }, {
74
74
  name: 'Background',
75
75
  code: '#FFFFFF'
76
+ }, {
77
+ name: 'Button Hov. G.',
78
+ code: '#10E272'
79
+ }, {
80
+ name: 'Button Hov. P.',
81
+ code: '#A500BF'
82
+ }, {
83
+ name: 'Button Down',
84
+ code: '#404D46'
76
85
  }]
77
86
  }
78
87
  },
@@ -5,6 +5,7 @@ h4,
5
5
  h5 {
6
6
  margin: 0;
7
7
  }
8
+ .mfui-content-area_color_base,
8
9
  .mfui-content-area_color_white {
9
10
  background-color: #FFFFFF;
10
11
  }
@@ -81,6 +82,7 @@ h5 {
81
82
  padding-right: 0;
82
83
  padding-left: 0;
83
84
  }
85
+ .mfui-content-area__inner_color_base,
84
86
  .mfui-content-area__inner_color_white {
85
87
  background-color: #FFFFFF;
86
88
  }
@@ -1,7 +1,7 @@
1
1
  import * as React from 'react';
2
2
  import './ContentArea.less';
3
3
  declare const BACKGROUND_COLORS: {
4
- readonly WHITE: "white";
4
+ readonly BASE: "base";
5
5
  readonly TRANSPARENT: "transparent";
6
6
  readonly GREEN: "green";
7
7
  readonly PURPLE: "purple";
@@ -11,6 +11,8 @@ declare const BACKGROUND_COLORS: {
11
11
  readonly CONTENT: "content";
12
12
  readonly FULL_BLACK: "fullBlack";
13
13
  /** @deprecated */
14
+ readonly WHITE: "white";
15
+ /** @deprecated */
14
16
  readonly FRESH_ASPHALT: "freshAsphalt";
15
17
  };
16
18
  export declare type BackgroundColorType = typeof BACKGROUND_COLORS[keyof typeof BACKGROUND_COLORS];
@@ -26,7 +26,7 @@ function _getRequireWildcardCache() { if (typeof WeakMap !== "function") return
26
26
  function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { "default": obj }; } var cache = _getRequireWildcardCache(); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (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
28
  var BACKGROUND_COLORS = {
29
- WHITE: 'white',
29
+ BASE: 'base',
30
30
  TRANSPARENT: 'transparent',
31
31
  GREEN: 'green',
32
32
  PURPLE: 'purple',
@@ -36,6 +36,9 @@ var BACKGROUND_COLORS = {
36
36
  CONTENT: 'content',
37
37
  FULL_BLACK: 'fullBlack',
38
38
 
39
+ /** @deprecated */
40
+ WHITE: 'white',
41
+
39
42
  /** @deprecated */
40
43
  FRESH_ASPHALT: 'freshAsphalt'
41
44
  };
@@ -67,15 +70,20 @@ var ContentArea = function ContentArea(_ref) {
67
70
  };
68
71
 
69
72
  var colorsCustomPropTypes = function colorsCustomPropTypes(props, propName, componentName) {
70
- var deprecatedValue = BACKGROUND_COLORS.FRESH_ASPHALT;
73
+ var deprecatedBlackValue = BACKGROUND_COLORS.FRESH_ASPHALT;
74
+ var deprecatedWhiteValue = BACKGROUND_COLORS.WHITE;
71
75
  var propValue = props[propName];
72
76
 
73
77
  if (propValue && !Object.values(BACKGROUND_COLORS).includes(propValue)) {
74
- return new Error("Failed prop type: Invalid prop '".concat(propName, "' of value '").concat(propValue, "' supplied to '").concat(componentName, "', \n expected one of [").concat(Object.values(BACKGROUND_COLORS), "]"));
78
+ return new Error("Failed prop type: Invalid prop '".concat(propName, "' of value '").concat(propValue, "' supplied to '").concat(componentName, "',\n expected one of [").concat(Object.values(BACKGROUND_COLORS), "]"));
79
+ }
80
+
81
+ if (propValue && propValue === deprecatedBlackValue) {
82
+ return new Error("Failed prop type: Invalid prop '".concat(propName, "' of value '").concat(propValue, "' supplied to '").concat(componentName, "',\n value '").concat(deprecatedBlackValue, "' is deprecated, please use value '").concat(BACKGROUND_COLORS.CONTENT, "'"));
75
83
  }
76
84
 
77
- if (propValue && propValue === BACKGROUND_COLORS.FRESH_ASPHALT) {
78
- return new Error("Failed prop type: Invalid prop '".concat(propName, "' of value '").concat(propValue, "' supplied to '").concat(componentName, "',\n value '").concat(deprecatedValue, "' is deprecated, please use value '").concat(BACKGROUND_COLORS.CONTENT, "'"));
85
+ if (propValue && propValue === deprecatedWhiteValue) {
86
+ return new Error("Failed prop type: Invalid prop '".concat(propName, "' of value '").concat(propValue, "' supplied to '").concat(componentName, "',\n value '").concat(deprecatedWhiteValue, "' is deprecated, please use value '").concat(BACKGROUND_COLORS.BASE, "'"));
79
87
  }
80
88
 
81
89
  return null;
@@ -36,7 +36,8 @@ h5 {
36
36
  .mfui-paragraph_color_purple {
37
37
  color: #731982;
38
38
  }
39
- .mfui-paragraph_color_base {
39
+ .mfui-paragraph_color_base,
40
+ .mfui-paragraph_color_clearWhite {
40
41
  color: #FFFFFF;
41
42
  }
42
43
  .mfui-paragraph_color_spbSky0 {
@@ -11,6 +11,8 @@ declare const COLORS: {
11
11
  FULL_BLACK: string;
12
12
  INHERIT: string;
13
13
  /** @deprecated */
14
+ CLEAR_WHITE: string;
15
+ /** @deprecated */
14
16
  FRESH_ASPHALT: string;
15
17
  };
16
18
  declare type ColorType = typeof COLORS[keyof typeof COLORS];
@@ -36,6 +36,9 @@ var COLORS = {
36
36
  FULL_BLACK: 'fullBlack',
37
37
  INHERIT: 'inherit',
38
38
 
39
+ /** @deprecated */
40
+ CLEAR_WHITE: 'clearWhite',
41
+
39
42
  /** @deprecated */
40
43
  FRESH_ASPHALT: 'freshAsphalt'
41
44
  };
@@ -46,7 +49,7 @@ var Paragraph = function Paragraph(_ref) {
46
49
  size = _ref$size === void 0 ? 'regular' : _ref$size,
47
50
  align = _ref.align,
48
51
  _ref$color = _ref.color,
49
- color = _ref$color === void 0 ? 'content' : _ref$color,
52
+ color = _ref$color === void 0 ? 'freshAsphalt' : _ref$color,
50
53
  className = _ref.className,
51
54
  _ref$hasMargin = _ref.hasMargin,
52
55
  hasMargin = _ref$hasMargin === void 0 ? true : _ref$hasMargin,
@@ -66,15 +69,20 @@ Paragraph.propTypes = {
66
69
  size: PropTypes.oneOf(['regular', 'small']),
67
70
  hasMargin: PropTypes.bool,
68
71
  color: function color(props, propName, componentName) {
69
- var deprecatedValue = COLORS.FRESH_ASPHALT;
72
+ var deprecatedBlackValue = COLORS.FRESH_ASPHALT;
73
+ var deprecatedWhiteValue = COLORS.CLEAR_WHITE;
70
74
  var propValue = props[propName];
71
75
 
72
76
  if (propValue && !Object.values(COLORS).includes(propValue)) {
73
77
  return new Error("Failed prop type: Invalid prop '".concat(propName, "' of value '").concat(propValue, "' supplied to '").concat(componentName, "', \n expected one of [").concat(Object.values(COLORS), "]"));
74
78
  }
75
79
 
76
- if (propValue && props[propName] === COLORS.FRESH_ASPHALT) {
77
- return new Error("Failed prop type: Invalid prop '".concat(propName, "' of value '").concat(propValue, "' supplied to '").concat(componentName, "',\n value '").concat(deprecatedValue, "' is deprecated, please use value '").concat(COLORS.CONTENT, "'"));
80
+ if (propValue && props[propName] === deprecatedBlackValue) {
81
+ return new Error("Failed prop type: Invalid prop '".concat(propName, "' of value '").concat(propValue, "' supplied to '").concat(componentName, "',\n value '").concat(deprecatedBlackValue, "' is deprecated, please use value '").concat(COLORS.CONTENT, "'"));
82
+ }
83
+
84
+ if (propValue && props[propName] === deprecatedWhiteValue) {
85
+ return new Error("Failed prop type: Invalid prop '".concat(propName, "' of value '").concat(propValue, "' supplied to '").concat(componentName, "',\n value '").concat(deprecatedWhiteValue, "' is deprecated, please use value '").concat(COLORS.BASE, "'"));
78
86
  }
79
87
 
80
88
  return null;
@@ -1,7 +1,8 @@
1
1
  import * as React from 'react';
2
+ import { IFilterDataAttrs } from '@megafon/ui-helpers';
2
3
  import * as PropTypes from 'prop-types';
3
4
  import './RadioButton.less';
4
- export interface IRadioButtonProps {
5
+ export interface IRadioButtonProps extends IFilterDataAttrs {
5
6
  /** Значение */
6
7
  value: string;
7
8
  /** Имя для тега form */
@@ -44,6 +45,9 @@ declare class RadioButton extends React.Component<IRadioButtonProps> {
44
45
  children: PropTypes.Requireable<PropTypes.ReactNodeLike>;
45
46
  onChange: PropTypes.Requireable<(...args: any[]) => any>;
46
47
  inputRef: PropTypes.Requireable<any>;
48
+ dataAttrs: PropTypes.Requireable<{
49
+ [x: string]: string;
50
+ }>;
47
51
  };
48
52
  static defaultProps: Partial<IRadioButtonProps>;
49
53
  handleChange: () => void;
@@ -112,14 +112,15 @@ var RadioButton = /*#__PURE__*/function (_React$Component) {
112
112
  inputRef = _this$props2.inputRef,
113
113
  className = _this$props2.className,
114
114
  _this$props2$classes = _this$props2.classes,
115
- classes = _this$props2$classes === void 0 ? {} : _this$props2$classes;
115
+ classes = _this$props2$classes === void 0 ? {} : _this$props2$classes,
116
+ dataAttrs = _this$props2.dataAttrs;
116
117
  var checkedProp = isChecked !== undefined ? {
117
118
  checked: isChecked
118
119
  } : {};
119
120
  var rootClassNames = Array.isArray(className) ? [].concat((0, _toConsumableArray2["default"])(className), [classes.root]) : [className, classes.root];
120
- return /*#__PURE__*/React.createElement("div", {
121
+ return /*#__PURE__*/React.createElement("div", (0, _extends2["default"])({
121
122
  className: cn(rootClassNames)
122
- }, /*#__PURE__*/React.createElement("label", {
123
+ }, (0, _uiHelpers.filterDataAttrs)(dataAttrs)), /*#__PURE__*/React.createElement("label", {
123
124
  className: cn('label', {
124
125
  disabled: disabled
125
126
  }, classes.label)
@@ -160,7 +161,8 @@ RadioButton.propTypes = {
160
161
  onChange: PropTypes.func,
161
162
  inputRef: PropTypes.oneOfType([PropTypes.func, PropTypes.oneOfType([PropTypes.shape({
162
163
  current: PropTypes.elementType
163
- }), PropTypes.any])])
164
+ }), PropTypes.any])]),
165
+ dataAttrs: PropTypes.objectOf(PropTypes.string.isRequired)
164
166
  };
165
167
  RadioButton.defaultProps = {
166
168
  textSize: 'medium',
@@ -126,36 +126,41 @@ var Tabs = function Tabs(_ref) {
126
126
 
127
127
  var _React$useState9 = React.useState(0),
128
128
  _React$useState10 = (0, _slicedToArray2["default"])(_React$useState9, 2),
129
- underlineWidth = _React$useState10[0],
130
- setUnderlineWidth = _React$useState10[1];
129
+ activeTabWidth = _React$useState10[0],
130
+ setActiveTabWidth = _React$useState10[1];
131
131
 
132
132
  var _React$useState11 = React.useState(0),
133
133
  _React$useState12 = (0, _slicedToArray2["default"])(_React$useState11, 2),
134
- underlineTranslate = _React$useState12[0],
135
- setUnderlineTranslate = _React$useState12[1];
134
+ underlineWidth = _React$useState12[0],
135
+ setUnderlineWidth = _React$useState12[1];
136
136
 
137
- var _React$useState13 = React.useState('none'),
137
+ var _React$useState13 = React.useState(0),
138
138
  _React$useState14 = (0, _slicedToArray2["default"])(_React$useState13, 2),
139
- underlineTransition = _React$useState14[0],
140
- setUnderlineTransition = _React$useState14[1];
139
+ underlineTranslate = _React$useState14[0],
140
+ setUnderlineTranslate = _React$useState14[1];
141
141
 
142
- var _React$useState15 = React.useState('auto'),
142
+ var _React$useState15 = React.useState('none'),
143
143
  _React$useState16 = (0, _slicedToArray2["default"])(_React$useState15, 2),
144
- tabListHeight = _React$useState16[0],
145
- setTabListHeight = _React$useState16[1];
144
+ underlineTransition = _React$useState16[0],
145
+ setUnderlineTransition = _React$useState16[1];
146
146
 
147
- var _React$useState17 = React.useState(false),
147
+ var _React$useState17 = React.useState('auto'),
148
148
  _React$useState18 = (0, _slicedToArray2["default"])(_React$useState17, 2),
149
- isSticky = _React$useState18[0],
150
- setSticky = _React$useState18[1];
149
+ tabListHeight = _React$useState18[0],
150
+ setTabListHeight = _React$useState18[1];
151
151
 
152
- var _React$useState19 = React.useState({
152
+ var _React$useState19 = React.useState(false),
153
+ _React$useState20 = (0, _slicedToArray2["default"])(_React$useState19, 2),
154
+ isSticky = _React$useState20[0],
155
+ setSticky = _React$useState20[1];
156
+
157
+ var _React$useState21 = React.useState({
153
158
  left: 0,
154
159
  right: 0
155
160
  }),
156
- _React$useState20 = (0, _slicedToArray2["default"])(_React$useState19, 2),
157
- stickyOffset = _React$useState20[0],
158
- setStickyOffset = _React$useState20[1];
161
+ _React$useState22 = (0, _slicedToArray2["default"])(_React$useState21, 2),
162
+ stickyOffset = _React$useState22[0],
163
+ setStickyOffset = _React$useState22[1];
159
164
 
160
165
  var setTabRef = React.useCallback(function (tab) {
161
166
  tab && tabsRef.current.push(tab);
@@ -165,21 +170,15 @@ var Tabs = function Tabs(_ref) {
165
170
  return;
166
171
  }
167
172
 
168
- var tabNodeChild = tabsRef.current[currentIndex].firstElementChild;
169
-
170
- var _ref2 = tabNodeChild || {},
171
- _ref2$clientWidth = _ref2.clientWidth,
172
- clientWidth = _ref2$clientWidth === void 0 ? 0 : _ref2$clientWidth;
173
-
174
173
  var translate = (0, _toConsumableArray2["default"])(tabsRef.current).splice(0, currentIndex).reduce(function (accWidth, node) {
175
174
  var _node$getBoundingClie = node.getBoundingClientRect(),
176
175
  width = _node$getBoundingClie.width;
177
176
 
178
177
  return accWidth + width;
179
178
  }, 0);
180
- setUnderlineWidth(clientWidth);
179
+ setUnderlineWidth(activeTabWidth);
181
180
  setUnderlineTranslate(translate);
182
- }, [currentIndex]);
181
+ }, [currentIndex, activeTabWidth]);
183
182
  var calculateSticky = React.useCallback(function () {
184
183
  if (!sticky || !rootRef.current || !tabListRef.current) {
185
184
  return;
@@ -276,12 +275,12 @@ var Tabs = function Tabs(_ref) {
276
275
  }, []);
277
276
  React.useEffect(function () {
278
277
  var observer = new IntersectionObserver(function (entries) {
279
- entries.forEach(function (_ref3) {
280
- var isIntersecting = _ref3.isIntersecting,
281
- _ref3$boundingClientR = _ref3.boundingClientRect,
282
- top = _ref3$boundingClientR.top,
283
- left = _ref3$boundingClientR.left,
284
- right = _ref3$boundingClientR.right;
278
+ entries.forEach(function (_ref2) {
279
+ var isIntersecting = _ref2.isIntersecting,
280
+ _ref2$boundingClientR = _ref2.boundingClientRect,
281
+ top = _ref2$boundingClientR.top,
282
+ left = _ref2$boundingClientR.left,
283
+ right = _ref2$boundingClientR.right;
285
284
 
286
285
  if (!sticky || !rootRef.current || !tabListRef.current) {
287
286
  return;
@@ -323,10 +322,20 @@ var Tabs = function Tabs(_ref) {
323
322
  }, [calculateSticky]);
324
323
  React.useEffect(function () {
325
324
  var handleResize = (0, _lodash["default"])(function () {
326
- calculateUnderline();
327
325
  calculateSticky();
328
326
  }, 300);
327
+ var activeTabNode = tabsRef.current[currentIndex];
328
+ var resizeObserver = new ResizeObserver(function (entries) {
329
+ if (!entries.length || !entries[0]) {
330
+ return;
331
+ }
332
+
333
+ var width = entries[0].contentRect.width;
334
+ setActiveTabWidth(width);
335
+ calculateUnderline();
336
+ });
329
337
  calculateUnderline();
338
+ resizeObserver.observe(activeTabNode);
330
339
  window.addEventListener('resize', handleResize);
331
340
  return function () {
332
341
  window.removeEventListener('resize', handleResize);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@megafon/ui-core",
3
- "version": "2.1.1",
3
+ "version": "2.2.0",
4
4
  "files": [
5
5
  "dist",
6
6
  "styles"
@@ -96,5 +96,5 @@
96
96
  "react-popper": "^2.2.3",
97
97
  "swiper": "^6.5.6"
98
98
  },
99
- "gitHead": "31bd33b5e87106ea511fbbdc8ad266f70457e3d3"
99
+ "gitHead": "26b2f120bd0f51992981718c28cb8cd8138e1870"
100
100
  }
package/styles/base.less CHANGED
@@ -19,6 +19,9 @@
19
19
  @fury: #F62434;
20
20
  @systemBlue: #34AAF2;
21
21
  @background: #FFFFFF;
22
+ @buttonHoverGreen: #10E272;
23
+ @buttonhoverPurple: #534455;
24
+ @buttonDown: #404D46;
22
25
 
23
26
  // Gradients
24
27
  @basic: linear-gradient(90deg, #01873F 0%, #00B956 74%, #14CD6A 100%);
@@ -56,11 +59,6 @@
56
59
  @fury80: #F8505D;
57
60
  @fury20: #FFC5C9;
58
61
 
59
- // old colors
60
- @buttonHoverGreen: #10E272;
61
- @buttonhoverPurple: #534455;
62
- @buttonDown: #404D46;
63
-
64
62
  // Notification Colors
65
63
  // TODO: будут отрефакторены после обновления дизайном Notification по новой палитре
66
64
  @error: #FFC4C9;