@megafon/ui-core 4.8.2 → 4.9.1

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 (36) hide show
  1. package/CHANGELOG.md +25 -0
  2. package/dist/es/components/ContentArea/ContentArea.d.ts +5 -0
  3. package/dist/es/components/ContentArea/ContentArea.js +11 -5
  4. package/dist/es/components/Counter/Counter.js +13 -12
  5. package/dist/es/components/Grid/Grid.d.ts +5 -0
  6. package/dist/es/components/Grid/Grid.js +11 -5
  7. package/dist/es/components/Grid/GridColumn.d.ts +4 -0
  8. package/dist/es/components/Grid/GridColumn.js +8 -3
  9. package/dist/es/components/Header/Header.d.ts +1 -1
  10. package/dist/es/components/Logo/Logo.d.ts +5 -1
  11. package/dist/es/components/Logo/Logo.js +8 -3
  12. package/dist/es/components/NavArrow/NavArrow.d.ts +2 -0
  13. package/dist/es/components/NavArrow/NavArrow.js +8 -6
  14. package/dist/es/components/TextField/TextField.css +9 -0
  15. package/dist/es/components/TextField/TextField.d.ts +2 -0
  16. package/dist/es/components/TextField/TextField.js +48 -24
  17. package/dist/es/components/Tooltip/Tooltip.css +106 -53
  18. package/dist/es/components/Tooltip/Tooltip.js +22 -19
  19. package/dist/lib/components/ContentArea/ContentArea.d.ts +5 -0
  20. package/dist/lib/components/ContentArea/ContentArea.js +13 -4
  21. package/dist/lib/components/Counter/Counter.js +13 -12
  22. package/dist/lib/components/Grid/Grid.d.ts +5 -0
  23. package/dist/lib/components/Grid/Grid.js +13 -4
  24. package/dist/lib/components/Grid/GridColumn.d.ts +4 -0
  25. package/dist/lib/components/Grid/GridColumn.js +10 -2
  26. package/dist/lib/components/Header/Header.d.ts +1 -1
  27. package/dist/lib/components/Logo/Logo.d.ts +5 -1
  28. package/dist/lib/components/Logo/Logo.js +8 -3
  29. package/dist/lib/components/NavArrow/NavArrow.d.ts +2 -0
  30. package/dist/lib/components/NavArrow/NavArrow.js +8 -6
  31. package/dist/lib/components/TextField/TextField.css +9 -0
  32. package/dist/lib/components/TextField/TextField.d.ts +2 -0
  33. package/dist/lib/components/TextField/TextField.js +49 -23
  34. package/dist/lib/components/Tooltip/Tooltip.css +106 -53
  35. package/dist/lib/components/Tooltip/Tooltip.js +22 -19
  36. package/package.json +2 -2
package/CHANGELOG.md CHANGED
@@ -3,6 +3,31 @@
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
+ ## [4.9.1](https://github.com/MegafonWebLab/megafon-ui/compare/@megafon/ui-core@4.9.0...@megafon/ui-core@4.9.1) (2022-12-06)
7
+
8
+ **Note:** Version bump only for package @megafon/ui-core
9
+
10
+
11
+
12
+
13
+
14
+ # [4.9.0](https://github.com/MegafonWebLab/megafon-ui/compare/@megafon/ui-core@4.8.2...@megafon/ui-core@4.9.0) (2022-11-29)
15
+
16
+
17
+ ### Bug Fixes
18
+
19
+ * **textarea:** fix auto resize ([de31a72](https://github.com/MegafonWebLab/megafon-ui/commit/de31a723f68e24f12623ca872f8281ca60b599c4))
20
+ * **tooltip:** fix close button margin and arrow position ([db99274](https://github.com/MegafonWebLab/megafon-ui/commit/db99274ab17fe58621aaaf1ba7d85bba6afc5e05))
21
+
22
+
23
+ ### Features
24
+
25
+ * **textarea:** add disableEnterLineBreak prop ([3fba0a0](https://github.com/MegafonWebLab/megafon-ui/commit/3fba0a08a4bca66575388c9156103335d68b287b))
26
+
27
+
28
+
29
+
30
+
6
31
  ## [4.8.2](https://github.com/MegafonWebLab/megafon-ui/compare/@megafon/ui-core@4.8.1...@megafon/ui-core@4.8.2) (2022-11-21)
7
32
 
8
33
 
@@ -32,6 +32,11 @@ export interface IConrentAreaProps {
32
32
  root?: string;
33
33
  inner?: string;
34
34
  };
35
+ /** Дополнительные data атрибуты к внутренним элементам */
36
+ dataAttrs?: {
37
+ root?: Record<string, string>;
38
+ inner?: Record<string, string>;
39
+ };
35
40
  }
36
41
  declare const ContentArea: React.FC<IConrentAreaProps>;
37
42
  export default ContentArea;
@@ -1,6 +1,7 @@
1
1
  import "core-js/modules/es.object.values";
2
+ import _extends from "@babel/runtime/helpers/extends";
2
3
  import * as React from 'react';
3
- import { cnCreate } from '@megafon/ui-helpers';
4
+ import { cnCreate, filterDataAttrs } from '@megafon/ui-helpers';
4
5
  import * as PropTypes from 'prop-types';
5
6
  import "./ContentArea.css";
6
7
  var BACKGROUND_COLORS = {
@@ -29,17 +30,18 @@ var ContentArea = function ContentArea(_ref) {
29
30
  disableIndents = _ref.disableIndents,
30
31
  children = _ref.children,
31
32
  className = _ref.className,
32
- classes = _ref.classes;
33
- return /*#__PURE__*/React.createElement("div", {
33
+ classes = _ref.classes,
34
+ dataAttrs = _ref.dataAttrs;
35
+ return /*#__PURE__*/React.createElement("div", _extends({}, filterDataAttrs(dataAttrs === null || dataAttrs === void 0 ? void 0 : dataAttrs.root), {
34
36
  className: cn({
35
37
  'background-color': outerBackgroundColor
36
38
  }, [className, classes === null || classes === void 0 ? void 0 : classes.root])
37
- }, /*#__PURE__*/React.createElement("div", {
39
+ }), /*#__PURE__*/React.createElement("div", _extends({}, filterDataAttrs(dataAttrs === null || dataAttrs === void 0 ? void 0 : dataAttrs.inner), {
38
40
  className: cn('inner', {
39
41
  'disable-indents': disableIndents,
40
42
  'background-color': innerBackgroundColor
41
43
  }, classes === null || classes === void 0 ? void 0 : classes.inner)
42
- }, children));
44
+ }), children));
43
45
  };
44
46
 
45
47
  ContentArea.propTypes = {
@@ -49,6 +51,10 @@ ContentArea.propTypes = {
49
51
  root: PropTypes.string,
50
52
  inner: PropTypes.string
51
53
  }),
54
+ dataAttrs: PropTypes.shape({
55
+ root: PropTypes.objectOf(PropTypes.string.isRequired),
56
+ inner: PropTypes.objectOf(PropTypes.string.isRequired)
57
+ }),
52
58
  outerBackgroundColor: PropTypes.oneOf(Object.values(BACKGROUND_COLORS)),
53
59
  innerBackgroundColor: PropTypes.oneOf(Object.values(BACKGROUND_COLORS))
54
60
  };
@@ -29,7 +29,7 @@ var Counter = function Counter(_ref) {
29
29
  _ref$isControlled = _ref.isControlled,
30
30
  isControlled = _ref$isControlled === void 0 ? false : _ref$isControlled,
31
31
  _ref$value = _ref.value,
32
- value = _ref$value === void 0 ? 0 : _ref$value,
32
+ outerValue = _ref$value === void 0 ? 0 : _ref$value,
33
33
  initialValue = _ref.initialValue,
34
34
  _ref$max = _ref.max,
35
35
  max = _ref$max === void 0 ? 999999 : _ref$max,
@@ -45,15 +45,16 @@ var Counter = function Counter(_ref) {
45
45
 
46
46
  var _React$useState = React.useState(currentInitialValue),
47
47
  _React$useState2 = _slicedToArray(_React$useState, 2),
48
- counter = _React$useState2[0],
49
- setCounter = _React$useState2[1];
48
+ innerValue = _React$useState2[0],
49
+ setInnerValue = _React$useState2[1];
50
50
 
51
+ var currentValue = isControlled ? outerValue : innerValue;
51
52
  React.useEffect(function () {
52
- setCounter(currentInitialValue);
53
+ setInnerValue(currentInitialValue);
53
54
  }, [currentInitialValue]);
54
55
  var handleValueChange = React.useCallback(function (inputValue) {
55
56
  if (!isControlled) {
56
- setCounter(inputValue);
57
+ setInnerValue(inputValue);
57
58
  }
58
59
 
59
60
  if (inputValue < min) {
@@ -69,11 +70,11 @@ var Counter = function Counter(_ref) {
69
70
  }
70
71
  }, [min, max, onChange, isControlled]);
71
72
  var handleMinusClick = React.useCallback(function () {
72
- handleValueChange(isControlled ? value - 1 : counter - 1);
73
- }, [handleValueChange, counter, isControlled, value]);
73
+ handleValueChange(currentValue - 1);
74
+ }, [handleValueChange, currentValue]);
74
75
  var handlePlusClick = React.useCallback(function () {
75
- handleValueChange(isControlled ? value + 1 : counter + 1);
76
- }, [handleValueChange, counter, isControlled, value]);
76
+ handleValueChange(currentValue + 1);
77
+ }, [handleValueChange, currentValue]);
77
78
  var handleInputChange = React.useCallback(function (e) {
78
79
  var pattern = /^[0-9\b]+$/;
79
80
  var inputValue = e.target.value;
@@ -106,7 +107,7 @@ var Counter = function Counter(_ref) {
106
107
  left: true
107
108
  }, classes.buttonMinus),
108
109
  type: "button",
109
- disabled: disabled || (isControlled ? value : counter) <= min,
110
+ disabled: disabled || currentValue <= min,
110
111
  onClick: handleMinusClick
111
112
  }), /*#__PURE__*/React.createElement(IconMinus, {
112
113
  className: cn('icon')
@@ -114,7 +115,7 @@ var Counter = function Counter(_ref) {
114
115
  className: cn('input-box')
115
116
  }, /*#__PURE__*/React.createElement("input", _extends({}, filterDataAttrs(dataAttrs === null || dataAttrs === void 0 ? void 0 : dataAttrs.input), {
116
117
  className: cn('input', classes.input),
117
- value: isControlled ? value : counter,
118
+ value: currentValue,
118
119
  onChange: handleInputChange,
119
120
  onBlur: handleInputBlur,
120
121
  disabled: disabled
@@ -123,7 +124,7 @@ var Counter = function Counter(_ref) {
123
124
  right: true
124
125
  }, classes.buttonPlus),
125
126
  type: "button",
126
- disabled: disabled || counter >= max || value >= max,
127
+ disabled: disabled || currentValue >= max,
127
128
  onClick: handlePlusClick
128
129
  }), /*#__PURE__*/React.createElement(IconPlus, {
129
130
  className: cn('icon')
@@ -14,6 +14,11 @@ export interface IGridProps {
14
14
  multiRow?: boolean;
15
15
  /** Дополнительный класс корневого элемента */
16
16
  className?: string;
17
+ /** Дополнительные data атрибуты к внутренним элементам */
18
+ dataAttrs?: {
19
+ root?: Record<string, string>;
20
+ container?: Record<string, string>;
21
+ };
17
22
  children: Array<React.ReactElement<IGridColumn>> | React.ReactElement<IGridColumn>;
18
23
  }
19
24
  declare const Grid: React.FC<IGridProps>;
@@ -1,6 +1,7 @@
1
1
  import "core-js/modules/es.array.map";
2
+ import _extends from "@babel/runtime/helpers/extends";
2
3
  import * as React from 'react';
3
- import { cnCreate } from '@megafon/ui-helpers';
4
+ import { cnCreate, filterDataAttrs } from '@megafon/ui-helpers';
4
5
  import * as PropTypes from 'prop-types';
5
6
  import "./Grid.css";
6
7
  var cn = cnCreate('mfui-grid');
@@ -13,10 +14,11 @@ var Grid = function Grid(_ref) {
13
14
  multiRow = _ref$multiRow === void 0 ? true : _ref$multiRow,
14
15
  hAlign = _ref.hAlign,
15
16
  vAlign = _ref.vAlign,
16
- className = _ref.className;
17
- return /*#__PURE__*/React.createElement("div", {
17
+ className = _ref.className,
18
+ dataAttrs = _ref.dataAttrs;
19
+ return /*#__PURE__*/React.createElement("div", _extends({}, filterDataAttrs(dataAttrs === null || dataAttrs === void 0 ? void 0 : dataAttrs.root), {
18
20
  className: cn([className])
19
- }, /*#__PURE__*/React.createElement("div", {
21
+ }), /*#__PURE__*/React.createElement("div", _extends({}, filterDataAttrs(dataAttrs === null || dataAttrs === void 0 ? void 0 : dataAttrs.container), {
20
22
  className: cn('container', {
21
23
  'multi-row': multiRow,
22
24
  'h-align': hAlign,
@@ -24,7 +26,7 @@ var Grid = function Grid(_ref) {
24
26
  'gutters-left': guttersLeft,
25
27
  'gutters-bottom': guttersBottom
26
28
  })
27
- }, React.Children.map(children, function (child) {
29
+ }), React.Children.map(children, function (child) {
28
30
  return React.cloneElement(child, {
29
31
  className: cn('column', {
30
32
  'gutter-left': guttersLeft,
@@ -41,6 +43,10 @@ Grid.propTypes = {
41
43
  guttersBottom: PropTypes.oneOf(['large', 'medium']),
42
44
  multiRow: PropTypes.bool,
43
45
  className: PropTypes.string,
46
+ dataAttrs: PropTypes.shape({
47
+ root: PropTypes.objectOf(PropTypes.string.isRequired),
48
+ container: PropTypes.objectOf(PropTypes.string.isRequired)
49
+ }),
44
50
  children: PropTypes.oneOfType([PropTypes.arrayOf(PropTypes.element.isRequired), PropTypes.element.isRequired]).isRequired
45
51
  };
46
52
  export default Grid;
@@ -50,6 +50,10 @@ export interface IGridColumn {
50
50
  flex?: boolean;
51
51
  /** Дополнительный класс корневого элемента */
52
52
  className?: string;
53
+ /** Дополнительные data атрибуты к внутренним элементам */
54
+ dataAttrs?: {
55
+ root?: Record<string, string>;
56
+ };
53
57
  children: React.ReactNode;
54
58
  }
55
59
  declare const GridColumn: React.FC<IGridColumn>;
@@ -1,5 +1,6 @@
1
+ import _extends from "@babel/runtime/helpers/extends";
1
2
  import * as React from 'react';
2
- import { cnCreate } from '@megafon/ui-helpers';
3
+ import { cnCreate, filterDataAttrs } from '@megafon/ui-helpers';
3
4
  import * as PropTypes from 'prop-types';
4
5
  import "./GridColumn.css";
5
6
  var GridSizeValues = PropTypes.oneOf(['1', '2', '3', '4', '5', '6', '7', '8', '9', '10', '11', '12']);
@@ -38,8 +39,9 @@ var GridColumn = function GridColumn(_ref) {
38
39
  _ref$grow = _ref.grow,
39
40
  grow = _ref$grow === void 0 ? false : _ref$grow,
40
41
  align = _ref.align,
42
+ dataAttrs = _ref.dataAttrs,
41
43
  children = _ref.children;
42
- return /*#__PURE__*/React.createElement("div", {
44
+ return /*#__PURE__*/React.createElement("div", _extends({}, filterDataAttrs(dataAttrs === null || dataAttrs === void 0 ? void 0 : dataAttrs.root), {
43
45
  className: cn({
44
46
  flex: flex,
45
47
  grow: grow,
@@ -65,7 +67,7 @@ var GridColumn = function GridColumn(_ref) {
65
67
  'right-offset-tablet': rightOffsetTablet,
66
68
  'right-offset-mobile': rightOffsetMobile
67
69
  }, className)
68
- }, children);
70
+ }), children);
69
71
  };
70
72
 
71
73
  GridColumn.propTypes = {
@@ -88,6 +90,9 @@ GridColumn.propTypes = {
88
90
  grow: PropTypes.bool,
89
91
  flex: PropTypes.bool,
90
92
  className: PropTypes.string,
93
+ dataAttrs: PropTypes.shape({
94
+ root: PropTypes.objectOf(PropTypes.string.isRequired)
95
+ }),
91
96
  children: PropTypes.node.isRequired
92
97
  };
93
98
  export default GridColumn;
@@ -1,6 +1,6 @@
1
1
  import * as React from 'react';
2
2
  import './Header.less';
3
- interface IHeaderProps {
3
+ export interface IHeaderProps {
4
4
  /** Тег */
5
5
  as?: 'h1' | 'h2' | 'h3' | 'h5';
6
6
  /** Поведение текста при встраивании в широкий или узкий контейнер (только для h5) */
@@ -4,13 +4,17 @@ export interface ILogoProps {
4
4
  /** Дополнительный класс корневого элемента */
5
5
  className?: string;
6
6
  /** Цвет */
7
- color?: string;
7
+ color?: 'green';
8
8
  /** Отображение */
9
9
  view?: 'horizontal' | 'vertical';
10
10
  /** Ссылка */
11
11
  href?: string;
12
12
  /** target - аргумент тега <a> */
13
13
  target?: '_self' | '_blank' | '_parent' | '_top';
14
+ /** Дополнительные data атрибуты к внутренним элементам */
15
+ dataAttrs?: {
16
+ root?: Record<string, string>;
17
+ };
14
18
  }
15
19
  declare const Logo: React.FC<ILogoProps>;
16
20
  export default Logo;
@@ -60,13 +60,15 @@ var Logo = function Logo(_ref) {
60
60
  _ref$target = _ref.target,
61
61
  target = _ref$target === void 0 ? '_blank' : _ref$target,
62
62
  _ref$href = _ref.href,
63
- href = _ref$href === void 0 ? '/' : _ref$href;
63
+ href = _ref$href === void 0 ? '/' : _ref$href,
64
+ dataAttrs = _ref.dataAttrs;
64
65
  var images = {
65
66
  'green-horizontal': greenHorizontalImg,
66
67
  'green-vertical': greenVerticalImg
67
68
  };
68
69
  var BackgroundImage = images["".concat(color, "-").concat(view)];
69
70
  return /*#__PURE__*/React.createElement(Link, {
71
+ dataAttrs: dataAttrs,
70
72
  href: href,
71
73
  target: target,
72
74
  className: cn('', {
@@ -80,10 +82,13 @@ var Logo = function Logo(_ref) {
80
82
  };
81
83
 
82
84
  Logo.propTypes = {
83
- color: PropTypes.string,
85
+ color: PropTypes.oneOf(['green']),
84
86
  view: PropTypes.oneOf(['horizontal', 'vertical']),
85
87
  target: PropTypes.oneOf(['_self', '_blank', '_parent', '_top']),
86
88
  href: PropTypes.string,
87
- className: PropTypes.string
89
+ className: PropTypes.string,
90
+ dataAttrs: PropTypes.shape({
91
+ root: PropTypes.objectOf(PropTypes.string.isRequired)
92
+ })
88
93
  };
89
94
  export default Logo;
@@ -13,6 +13,8 @@ declare type ViewType = typeof View[keyof typeof View];
13
13
  export interface INavArrowProps {
14
14
  dataAttrs?: {
15
15
  root?: Record<string, string>;
16
+ prevArrow?: Record<string, string>;
17
+ nextArrow?: Record<string, string>;
16
18
  };
17
19
  className?: string;
18
20
  theme?: ThemeType;
@@ -44,16 +44,16 @@ var NavArrow = function NavArrow(_ref) {
44
44
  var renderIcon = React.useCallback(function () {
45
45
  switch (view) {
46
46
  case View.PREV:
47
- return /*#__PURE__*/React.createElement(ArrowLeft, {
47
+ return /*#__PURE__*/React.createElement(ArrowLeft, _extends({}, filterDataAttrs(dataAttrs === null || dataAttrs === void 0 ? void 0 : dataAttrs.prevArrow), {
48
48
  className: cn('icon')
49
- });
49
+ }));
50
50
 
51
51
  default:
52
- return /*#__PURE__*/React.createElement(ArrowRight, {
52
+ return /*#__PURE__*/React.createElement(ArrowRight, _extends({}, filterDataAttrs(dataAttrs === null || dataAttrs === void 0 ? void 0 : dataAttrs.nextArrow), {
53
53
  className: cn('icon')
54
- });
54
+ }));
55
55
  }
56
- }, [view]);
56
+ }, [dataAttrs === null || dataAttrs === void 0 ? void 0 : dataAttrs.prevArrow, dataAttrs === null || dataAttrs === void 0 ? void 0 : dataAttrs.nextArrow, view]);
57
57
  return /*#__PURE__*/React.createElement("button", _extends({}, filterDataAttrs(dataAttrs === null || dataAttrs === void 0 ? void 0 : dataAttrs.root), {
58
58
  type: "button",
59
59
  className: cn({
@@ -66,7 +66,9 @@ var NavArrow = function NavArrow(_ref) {
66
66
 
67
67
  NavArrow.propTypes = {
68
68
  dataAttrs: PropTypes.shape({
69
- root: PropTypes.objectOf(PropTypes.string.isRequired)
69
+ root: PropTypes.objectOf(PropTypes.string.isRequired),
70
+ prevArrow: PropTypes.objectOf(PropTypes.string.isRequired),
71
+ nextArrow: PropTypes.objectOf(PropTypes.string.isRequired)
70
72
  }),
71
73
  className: PropTypes.string,
72
74
  theme: PropTypes.oneOf(Object.values(Theme)),
@@ -41,6 +41,15 @@
41
41
  overflow-y: auto;
42
42
  resize: none;
43
43
  }
44
+ .mfui-text-field__hidden-textarea {
45
+ position: absolute;
46
+ height: -webkit-min-content;
47
+ height: -moz-min-content;
48
+ height: min-content;
49
+ padding: 0 56px 0 16px;
50
+ word-break: break-all;
51
+ visibility: hidden;
52
+ }
44
53
  .mfui-text-field__field_resized {
45
54
  -webkit-transition: height 0.1s;
46
55
  transition: height 0.1s;
@@ -88,6 +88,8 @@ export declare type TextFieldProps = {
88
88
  minTextareaHeight?: MinTextareaHeightType;
89
89
  /** Скрывает кнопку ресайза для textarea="flexible" */
90
90
  hideResizeButton?: boolean;
91
+ /** Отключает перевод строки по Enter */
92
+ disableEnterLineBreak?: boolean;
91
93
  /** Обработчик изменения значения */
92
94
  onChange?: (e: React.ChangeEvent<HTMLInputElement | HTMLTextAreaElement>) => void;
93
95
  /** Обработчик изменения значения маскированного инпута до обработки маской */
@@ -1,14 +1,19 @@
1
1
  import "core-js/modules/es.array.concat";
2
+ import "core-js/modules/es.date.to-string";
2
3
  import "core-js/modules/es.function.name";
4
+ import "core-js/modules/es.object.to-string";
3
5
  import "core-js/modules/es.object.values";
4
6
  import "core-js/modules/es.parse-float";
5
7
  import "core-js/modules/es.regexp.exec";
8
+ import "core-js/modules/es.regexp.to-string";
6
9
  import "core-js/modules/es.string.replace";
7
10
  import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
8
11
  import _extends from "@babel/runtime/helpers/extends";
12
+
13
+ /* eslint-disable react/no-multi-comp */
9
14
  import * as React from 'react';
10
15
  import { useCallback, useEffect, useState, useRef, useMemo } from 'react';
11
- import { cnCreate, filterDataAttrs } from '@megafon/ui-helpers';
16
+ import { checkEventIsClickOrEnterPress, cnCreate, filterDataAttrs, convert } from '@megafon/ui-helpers';
12
17
  import throttle from 'lodash.throttle';
13
18
  import * as PropTypes from 'prop-types';
14
19
  import InputMask from 'react-input-mask';
@@ -69,6 +74,13 @@ var DEFAULT_PLACEHOLDERS = {
69
74
  password: 'Пароль',
70
75
  text: 'Текст'
71
76
  };
77
+ var converConfig = {
78
+ br: {
79
+ component: function component() {
80
+ return React.createElement('br');
81
+ }
82
+ }
83
+ };
72
84
  export var Verification = {
73
85
  VALID: 'valid',
74
86
  ERROR: 'error'
@@ -79,7 +91,7 @@ export var TextareaTypes = {
79
91
  };
80
92
  export var MinTextareaHeight = {
81
93
  ONE_ROW: ROW_HEIGHT,
82
- THREE_ROWS: ROW_HEIGHT * 3
94
+ THREE_ROWS: ROW_HEIGHT * DEFAULT_ROW_COUNT
83
95
  };
84
96
  var cn = cnCreate('mfui-text-field');
85
97
 
@@ -106,6 +118,8 @@ var TextField = function TextField(_ref) {
106
118
  isControlled = _ref$isControlled === void 0 ? false : _ref$isControlled,
107
119
  _ref$minTextareaHeigh = _ref.minTextareaHeight,
108
120
  minTextareaHeight = _ref$minTextareaHeigh === void 0 ? MinTextareaHeight.THREE_ROWS : _ref$minTextareaHeigh,
121
+ _ref$disableEnterLine = _ref.disableEnterLineBreak,
122
+ disableEnterLineBreak = _ref$disableEnterLine === void 0 ? false : _ref$disableEnterLine,
109
123
  _ref$hideResizeButton = _ref.hideResizeButton,
110
124
  hideResizeButton = _ref$hideResizeButton === void 0 ? false : _ref$hideResizeButton,
111
125
  onBlur = _ref.onBlur,
@@ -142,8 +156,8 @@ var TextField = function TextField(_ref) {
142
156
 
143
157
  var _useState5 = useState(minTextareaHeight),
144
158
  _useState6 = _slicedToArray(_useState5, 2),
145
- initialTextareaHeight = _useState6[0],
146
- setInitialTextareaHeight = _useState6[1];
159
+ textareaHeight = _useState6[0],
160
+ setTextareaHeight = _useState6[1];
147
161
 
148
162
  var _useState7 = useState(false),
149
163
  _useState8 = _slicedToArray(_useState7, 2),
@@ -166,6 +180,7 @@ var TextField = function TextField(_ref) {
166
180
  setIsTextareaResized = _useState14[1];
167
181
 
168
182
  var fieldNode = useRef();
183
+ var hiddenElement = useRef(null);
169
184
  var labelRef = useRef(null);
170
185
  var resizerRef = useRef(null);
171
186
  var isPasswordType = useMemo(function () {
@@ -189,6 +204,15 @@ var TextField = function TextField(_ref) {
189
204
 
190
205
  setIsMaxLimitExceeded(symbolCounter < String(textareaValue).length);
191
206
  }, [symbolCounter]);
207
+ useEffect(function () {
208
+ if (!hiddenElement.current) {
209
+ return;
210
+ }
211
+
212
+ var hiddenElementHeight = hiddenElement.current.scrollHeight;
213
+ var isHiddenHeightCorrect = hiddenElementHeight >= minTextareaHeight && hiddenElementHeight <= TEXTAREA_MAX_HEIGHT;
214
+ !isTextareaResized && setTextareaHeight(isHiddenHeightCorrect ? hiddenElementHeight : minTextareaHeight);
215
+ }, [hiddenElement, isTextareaResized, minTextareaHeight, inputValue]);
192
216
  useEffect(function () {
193
217
  !isControlled && setInputValue(value);
194
218
  checkSymbolMaxLimit(value);
@@ -214,7 +238,7 @@ var TextField = function TextField(_ref) {
214
238
  var currentCoordinateY = moveEvent.clientY || moveEvent.touches[0].clientY;
215
239
  var resizeHeight = originalHeight + (currentCoordinateY - originalCoordinateY);
216
240
  var updatedHeight = resizeHeight < minTextareaHeight ? minTextareaHeight : resizeHeight;
217
- setInitialTextareaHeight(updatedHeight);
241
+ setTextareaHeight(updatedHeight);
218
242
  setIsTextareaResized(true);
219
243
  }, throttleTime.resizeTextarea);
220
244
 
@@ -241,22 +265,7 @@ var TextField = function TextField(_ref) {
241
265
  });
242
266
  }, []);
243
267
 
244
- var setTextareaHeight = function setTextareaHeight() {
245
- if (!(fieldNode === null || fieldNode === void 0 ? void 0 : fieldNode.current) || isTextareaResized) {
246
- return;
247
- }
248
-
249
- var scrollHeight = fieldNode.current.scrollHeight;
250
- var extraRowCount = Math.round((scrollHeight - 28 - minTextareaHeight) / ROW_HEIGHT);
251
- var newHeight = extraRowCount <= DEFAULT_ROW_COUNT ? minTextareaHeight + ROW_HEIGHT * extraRowCount : TEXTAREA_MAX_HEIGHT;
252
- setInitialTextareaHeight(newHeight);
253
- };
254
-
255
268
  var handleInputChange = function handleInputChange(e) {
256
- if (textarea === TextareaTypes.FLEXIBLE) {
257
- setTextareaHeight();
258
- }
259
-
260
269
  !isControlled && setInputValue(e.target.value);
261
270
  checkSymbolMaxLimit(e.target.value);
262
271
  onChange === null || onChange === void 0 ? void 0 : onChange(e);
@@ -281,6 +290,10 @@ var TextField = function TextField(_ref) {
281
290
  labelRef.current.style.top = "".concat(DEFAULT_LABEL_TOP_POSITION - scrollTop, "px");
282
291
  };
283
292
 
293
+ var handleTextareaKeyDown = function handleTextareaKeyDown(e) {
294
+ checkEventIsClickOrEnterPress(e) && !e.shiftKey && e.preventDefault();
295
+ };
296
+
284
297
  var handleIconClick = useCallback(function (e) {
285
298
  var isClearFuncAvailable = !customIcon && !onCustomIconClick && hasClearIcon;
286
299
  var field = fieldNode.current;
@@ -393,13 +406,23 @@ var TextField = function TextField(_ref) {
393
406
  };
394
407
 
395
408
  var renderTextarea = function renderTextarea() {
409
+ var _a;
410
+
411
+ var hiddenValue = inputValue === null || inputValue === void 0 ? void 0 : inputValue.toString().replace(/[\r\n]/g, '<br/>');
396
412
  return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement("textarea", _extends({}, textareaParams, {
397
- onScroll: handleTextareaScroll,
398
413
  style: {
399
- height: "".concat(initialTextareaHeight, "px")
414
+ height: "".concat(textareaHeight, "px")
400
415
  },
401
- ref: getFieldNode
402
- })), renderLabel());
416
+ ref: getFieldNode,
417
+ onKeyDown: disableEnterLineBreak ? handleTextareaKeyDown : undefined,
418
+ onScroll: handleTextareaScroll
419
+ })), !!hiddenValue && /*#__PURE__*/React.createElement("div", {
420
+ className: cn('hidden-textarea'),
421
+ ref: hiddenElement,
422
+ style: {
423
+ width: (_a = fieldNode.current) === null || _a === void 0 ? void 0 : _a.scrollWidth
424
+ }
425
+ }, convert(hiddenValue, converConfig), "."), renderLabel());
403
426
  };
404
427
 
405
428
  var renderIconBlock = function renderIconBlock() {
@@ -496,6 +519,7 @@ TextField.propTypes = {
496
519
  className: PropTypes.string,
497
520
  minTextareaHeight: PropTypes.oneOf([24, 72]),
498
521
  hideResizeButton: PropTypes.bool,
522
+ disableEnterLineBreak: PropTypes.bool,
499
523
  onChange: PropTypes.func,
500
524
  onBeforeMaskChange: PropTypes.func,
501
525
  onBlur: PropTypes.func,