@megafon/ui-core 2.1.2 → 2.3.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.
Files changed (31) hide show
  1. package/CHANGELOG.md +51 -0
  2. package/dist/es/colors/Colors.css +3 -3
  3. package/dist/es/colors/Colors.js +2 -2
  4. package/dist/es/colors/colorsData.js +9 -0
  5. package/dist/es/components/Accordion/Accordion.d.ts +1 -0
  6. package/dist/es/components/Accordion/Accordion.js +3 -1
  7. package/dist/es/components/ContentArea/ContentArea.css +2 -0
  8. package/dist/es/components/ContentArea/ContentArea.d.ts +3 -1
  9. package/dist/es/components/ContentArea/ContentArea.js +13 -5
  10. package/dist/es/components/RadioButton/RadioButton.d.ts +5 -1
  11. package/dist/es/components/RadioButton/RadioButton.js +7 -5
  12. package/dist/es/components/Search/Search.js +1 -0
  13. package/dist/es/components/Tabs/Tabs.js +41 -32
  14. package/dist/es/components/TextField/TextField.d.ts +3 -1
  15. package/dist/es/components/TextField/TextField.js +5 -1
  16. package/dist/lib/colors/Colors.css +3 -3
  17. package/dist/lib/colors/Colors.js +2 -2
  18. package/dist/lib/colors/colorsData.js +9 -0
  19. package/dist/lib/components/Accordion/Accordion.d.ts +1 -0
  20. package/dist/lib/components/Accordion/Accordion.js +3 -1
  21. package/dist/lib/components/ContentArea/ContentArea.css +2 -0
  22. package/dist/lib/components/ContentArea/ContentArea.d.ts +3 -1
  23. package/dist/lib/components/ContentArea/ContentArea.js +13 -5
  24. package/dist/lib/components/RadioButton/RadioButton.d.ts +5 -1
  25. package/dist/lib/components/RadioButton/RadioButton.js +6 -4
  26. package/dist/lib/components/Search/Search.js +1 -0
  27. package/dist/lib/components/Tabs/Tabs.js +41 -32
  28. package/dist/lib/components/TextField/TextField.d.ts +3 -1
  29. package/dist/lib/components/TextField/TextField.js +5 -1
  30. package/package.json +2 -2
  31. package/styles/base.less +3 -5
package/CHANGELOG.md CHANGED
@@ -3,6 +3,57 @@
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.3.0](https://github.com/MegafonWebLab/megafon-ui/compare/@megafon/ui-core@2.2.0...@megafon/ui-core@2.3.0) (2022-01-24)
7
+
8
+
9
+ ### Bug Fixes
10
+
11
+ * **search:** prevents default action when a menu item is selected and the enter button is pressed ([054cbcf](https://github.com/MegafonWebLab/megafon-ui/commit/054cbcf3457ff779443a82b5ae6383fda57f9cc7))
12
+
13
+
14
+ ### Features
15
+
16
+ * **accordion:** props hasVerticalPaddings marked as deprecated ([4d6d4cc](https://github.com/MegafonWebLab/megafon-ui/commit/4d6d4cca2cf45a86441827f0bef625a88a2c44f8))
17
+ * **textfield:** add autocomplete prop ([f2cff94](https://github.com/MegafonWebLab/megafon-ui/commit/f2cff9403503de174b785ea02365ce470811369e))
18
+
19
+
20
+
21
+
22
+
23
+ # [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)
24
+
25
+
26
+ ### Features
27
+
28
+ * **radiobutton:** add dataAttrs prop ([3f8d0b4](https://github.com/MegafonWebLab/megafon-ui/commit/3f8d0b4c4ec4a6ca301ab44feed2842ec8e54f3a))
29
+
30
+
31
+
32
+
33
+
34
+ ## [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)
35
+
36
+
37
+ ### Bug Fixes
38
+
39
+ * **colors:** add hover colors to system group ([634ac03](https://github.com/MegafonWebLab/megafon-ui/commit/634ac034445fdcd08b60ff056f75683025cb6d49))
40
+ * **tabs:** fix active tab underline width ([4499399](https://github.com/MegafonWebLab/megafon-ui/commit/449939942730143712a92930a279a8b6fc17a012))
41
+
42
+
43
+
44
+
45
+
46
+ ## [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)
47
+
48
+
49
+ ### Bug Fixes
50
+
51
+ * **contentarea:** fix backgroundColor and innerBackgroundColor props values ([d6004a4](https://github.com/MegafonWebLab/megafon-ui/commit/d6004a493b623cced4c453d69b0fd16d3cfbef43))
52
+
53
+
54
+
55
+
56
+
6
57
  ## [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)
7
58
 
8
59
 
@@ -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
  },
@@ -9,6 +9,7 @@ export interface IAccordionProps extends IFilterDataAttrs {
9
9
  /** Состояние открытости */
10
10
  isOpened?: boolean;
11
11
  /** Вертикальные отступы */
12
+ /** @deprecated */
12
13
  hasVerticalPaddings?: boolean;
13
14
  /** Дополнительный класс для корневого элемента */
14
15
  className?: string;
@@ -87,7 +87,9 @@ Accordion.propTypes = {
87
87
  }), PropTypes.any])]),
88
88
  title: PropTypes.oneOfType([PropTypes.string, PropTypes.node, PropTypes.arrayOf(PropTypes.node)]).isRequired,
89
89
  isOpened: PropTypes.bool,
90
- hasVerticalPaddings: PropTypes.bool,
90
+ hasVerticalPaddings: function hasVerticalPaddings(props, propName) {
91
+ return props[propName] && new Error('Failed prop type: Prop "hasVerticalPaddings" is deprecated');
92
+ },
91
93
  className: PropTypes.string,
92
94
  classes: PropTypes.shape({
93
95
  openedClass: PropTypes.string,
@@ -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;
@@ -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',
@@ -125,6 +125,7 @@ var Search = function Search(_ref) {
125
125
  e.preventDefault();
126
126
  } else if (e.key === 'Enter' && activeIndex > -1) {
127
127
  handleItemSubmit(activeIndex);
128
+ e.preventDefault();
128
129
  } else if (e.key === 'Enter' && activeIndex === -1) {
129
130
  handleSearchSubmit();
130
131
  }
@@ -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);
@@ -62,8 +62,10 @@ export declare type TextFieldProps = {
62
62
  classes?: {
63
63
  input?: string;
64
64
  };
65
- /** Аргумент элемента input */
65
+ /** Атрибут элемента input */
66
66
  inputMode?: 'numeric' | 'tel' | 'decimal' | 'email' | 'url' | 'search' | 'none';
67
+ /** Атрибут элемента input. Не работает с textarea=true */
68
+ autoComplete?: string;
67
69
  /** Переводит компонент в контролируемое состояние */
68
70
  isControlled?: boolean;
69
71
  /** Обработчик изменения значения */
@@ -96,6 +96,7 @@ var TextField = function TextField(_ref) {
96
96
  noticeText = _ref.noticeText,
97
97
  inputRef = _ref.inputRef,
98
98
  inputMode = _ref.inputMode,
99
+ autoComplete = _ref.autoComplete,
99
100
  _ref$classes = _ref.classes;
100
101
  _ref$classes = _ref$classes === void 0 ? {} : _ref$classes;
101
102
  var input = _ref$classes.input;
@@ -232,7 +233,8 @@ var TextField = function TextField(_ref) {
232
233
 
233
234
  var inputParams = _extends(_extends({}, commonParams), {
234
235
  className: cn('field', input),
235
- type: isVisiblePassword ? 'text' : type
236
+ type: isVisiblePassword ? 'text' : type,
237
+ autoComplete: autoComplete
236
238
  });
237
239
 
238
240
  var inputMaskParams = {
@@ -370,6 +372,8 @@ TextField.propTypes = {
370
372
  disabled: PropTypes.bool,
371
373
  required: PropTypes.bool,
372
374
  type: PropTypes.oneOf(['text', 'password', 'tel', 'email']),
375
+ inputMode: PropTypes.oneOf(['numeric', 'tel', 'decimal', 'email', 'url', 'search', 'none']),
376
+ autoComplete: PropTypes.string,
373
377
  name: PropTypes.string,
374
378
  placeholder: PropTypes.string,
375
379
  id: PropTypes.string,
@@ -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
  },
@@ -9,6 +9,7 @@ export interface IAccordionProps extends IFilterDataAttrs {
9
9
  /** Состояние открытости */
10
10
  isOpened?: boolean;
11
11
  /** Вертикальные отступы */
12
+ /** @deprecated */
12
13
  hasVerticalPaddings?: boolean;
13
14
  /** Дополнительный класс для корневого элемента */
14
15
  className?: string;
@@ -107,7 +107,9 @@ Accordion.propTypes = {
107
107
  }), PropTypes.any])]),
108
108
  title: PropTypes.oneOfType([PropTypes.string, PropTypes.node, PropTypes.arrayOf(PropTypes.node)]).isRequired,
109
109
  isOpened: PropTypes.bool,
110
- hasVerticalPaddings: PropTypes.bool,
110
+ hasVerticalPaddings: function hasVerticalPaddings(props, propName) {
111
+ return props[propName] && new Error('Failed prop type: Prop "hasVerticalPaddings" is deprecated');
112
+ },
111
113
  className: PropTypes.string,
112
114
  classes: PropTypes.shape({
113
115
  openedClass: PropTypes.string,
@@ -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;
@@ -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',
@@ -161,6 +161,7 @@ var Search = function Search(_ref) {
161
161
  e.preventDefault();
162
162
  } else if (e.key === 'Enter' && activeIndex > -1) {
163
163
  handleItemSubmit(activeIndex);
164
+ e.preventDefault();
164
165
  } else if (e.key === 'Enter' && activeIndex === -1) {
165
166
  handleSearchSubmit();
166
167
  }
@@ -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);
@@ -62,8 +62,10 @@ export declare type TextFieldProps = {
62
62
  classes?: {
63
63
  input?: string;
64
64
  };
65
- /** Аргумент элемента input */
65
+ /** Атрибут элемента input */
66
66
  inputMode?: 'numeric' | 'tel' | 'decimal' | 'email' | 'url' | 'search' | 'none';
67
+ /** Атрибут элемента input. Не работает с textarea=true */
68
+ autoComplete?: string;
67
69
  /** Переводит компонент в контролируемое состояние */
68
70
  isControlled?: boolean;
69
71
  /** Обработчик изменения значения */
@@ -121,6 +121,7 @@ var TextField = function TextField(_ref) {
121
121
  noticeText = _ref.noticeText,
122
122
  inputRef = _ref.inputRef,
123
123
  inputMode = _ref.inputMode,
124
+ autoComplete = _ref.autoComplete,
124
125
  _ref$classes = _ref.classes;
125
126
  _ref$classes = _ref$classes === void 0 ? {} : _ref$classes;
126
127
  var input = _ref$classes.input;
@@ -256,7 +257,8 @@ var TextField = function TextField(_ref) {
256
257
  };
257
258
  var inputParams = (0, _extends2["default"])((0, _extends2["default"])({}, commonParams), {
258
259
  className: cn('field', input),
259
- type: isVisiblePassword ? 'text' : type
260
+ type: isVisiblePassword ? 'text' : type,
261
+ autoComplete: autoComplete
260
262
  });
261
263
  var inputMaskParams = {
262
264
  mask: mask,
@@ -392,6 +394,8 @@ TextField.propTypes = {
392
394
  disabled: PropTypes.bool,
393
395
  required: PropTypes.bool,
394
396
  type: PropTypes.oneOf(['text', 'password', 'tel', 'email']),
397
+ inputMode: PropTypes.oneOf(['numeric', 'tel', 'decimal', 'email', 'url', 'search', 'none']),
398
+ autoComplete: PropTypes.string,
395
399
  name: PropTypes.string,
396
400
  placeholder: PropTypes.string,
397
401
  id: PropTypes.string,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@megafon/ui-core",
3
- "version": "2.1.2",
3
+ "version": "2.3.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": "fc16033b1b0f6975f9ffc1f436fcb6114d1e6fa1"
99
+ "gitHead": "135afecf6e64efb26e7a751a6d812609f9c45658"
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;