@megafon/ui-core 4.8.1 → 4.9.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 (36) hide show
  1. package/CHANGELOG.md +28 -0
  2. package/dist/es/components/Checkbox/Checkbox.d.ts +1 -0
  3. package/dist/es/components/Checkbox/Checkbox.js +3 -2
  4. package/dist/es/components/ContentArea/ContentArea.d.ts +5 -0
  5. package/dist/es/components/ContentArea/ContentArea.js +11 -5
  6. package/dist/es/components/Grid/Grid.d.ts +5 -0
  7. package/dist/es/components/Grid/Grid.js +11 -5
  8. package/dist/es/components/Grid/GridColumn.d.ts +4 -0
  9. package/dist/es/components/Grid/GridColumn.js +8 -3
  10. package/dist/es/components/Header/Header.d.ts +1 -1
  11. package/dist/es/components/List/List.css +22 -9
  12. package/dist/es/components/List/List.js +7 -4
  13. package/dist/es/components/Tabs/Tabs.css +3 -0
  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/Checkbox/Checkbox.d.ts +1 -0
  20. package/dist/lib/components/Checkbox/Checkbox.js +3 -2
  21. package/dist/lib/components/ContentArea/ContentArea.d.ts +5 -0
  22. package/dist/lib/components/ContentArea/ContentArea.js +13 -4
  23. package/dist/lib/components/Grid/Grid.d.ts +5 -0
  24. package/dist/lib/components/Grid/Grid.js +13 -4
  25. package/dist/lib/components/Grid/GridColumn.d.ts +4 -0
  26. package/dist/lib/components/Grid/GridColumn.js +10 -2
  27. package/dist/lib/components/Header/Header.d.ts +1 -1
  28. package/dist/lib/components/List/List.css +22 -9
  29. package/dist/lib/components/List/List.js +7 -4
  30. package/dist/lib/components/Tabs/Tabs.css +3 -0
  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 +3 -3
package/CHANGELOG.md CHANGED
@@ -3,6 +3,34 @@
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.0](https://github.com/MegafonWebLab/megafon-ui/compare/@megafon/ui-core@4.8.2...@megafon/ui-core@4.9.0) (2022-11-29)
7
+
8
+
9
+ ### Bug Fixes
10
+
11
+ * **textarea:** fix auto resize ([de31a72](https://github.com/MegafonWebLab/megafon-ui/commit/de31a723f68e24f12623ca872f8281ca60b599c4))
12
+ * **tooltip:** fix close button margin and arrow position ([db99274](https://github.com/MegafonWebLab/megafon-ui/commit/db99274ab17fe58621aaaf1ba7d85bba6afc5e05))
13
+
14
+
15
+ ### Features
16
+
17
+ * **textarea:** add disableEnterLineBreak prop ([3fba0a0](https://github.com/MegafonWebLab/megafon-ui/commit/3fba0a08a4bca66575388c9156103335d68b287b))
18
+
19
+
20
+
21
+
22
+
23
+ ## [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)
24
+
25
+
26
+ ### Bug Fixes
27
+
28
+ * **tabs:** remove tab underline on hover ([1c6cfbd](https://github.com/MegafonWebLab/megafon-ui/commit/1c6cfbde1c66c71c99c42ae4a586f048688f3afb))
29
+
30
+
31
+
32
+
33
+
6
34
  ## [4.8.1](https://github.com/MegafonWebLab/megafon-ui/compare/@megafon/ui-core@4.8.0...@megafon/ui-core@4.8.1) (2022-11-15)
7
35
 
8
36
 
@@ -13,6 +13,7 @@ export interface ICheckboxProps {
13
13
  /** Дополнительные data атрибуты к внутренним элементам */
14
14
  dataAttrs?: {
15
15
  root?: Record<string, string>;
16
+ inner?: Record<string, string>;
16
17
  input?: Record<string, string>;
17
18
  customInput?: Record<string, string>;
18
19
  extraContent?: Record<string, string>;
@@ -60,9 +60,9 @@ var Checkbox = function Checkbox(_ref) {
60
60
  disabled: disabled,
61
61
  error: error
62
62
  }, className)
63
- }, filterDataAttrs(dataAttrs === null || dataAttrs === void 0 ? void 0 : dataAttrs.root)), /*#__PURE__*/React.createElement("div", {
63
+ }, filterDataAttrs(dataAttrs === null || dataAttrs === void 0 ? void 0 : dataAttrs.root)), /*#__PURE__*/React.createElement("div", _extends({
64
64
  className: cn('inner', [classes === null || classes === void 0 ? void 0 : classes.inner])
65
- }, /*#__PURE__*/React.createElement("label", {
65
+ }, filterDataAttrs(dataAttrs === null || dataAttrs === void 0 ? void 0 : dataAttrs.inner)), /*#__PURE__*/React.createElement("label", {
66
66
  className: cn('label', {
67
67
  'no-touch': !isTouch
68
68
  })
@@ -99,6 +99,7 @@ Checkbox.propTypes = {
99
99
  error: PropTypes.bool,
100
100
  dataAttrs: PropTypes.shape({
101
101
  root: PropTypes.objectOf(PropTypes.string.isRequired),
102
+ inner: PropTypes.objectOf(PropTypes.string.isRequired),
102
103
  input: PropTypes.objectOf(PropTypes.string.isRequired),
103
104
  customInput: PropTypes.objectOf(PropTypes.string.isRequired),
104
105
  extraContent: PropTypes.objectOf(PropTypes.string.isRequired)
@@ -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
  };
@@ -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) */
@@ -2,21 +2,24 @@
2
2
  font-family: inherit;
3
3
  font-size: 15px;
4
4
  line-height: 24px;
5
+ display: -webkit-box;
6
+ display: -ms-flexbox;
7
+ display: flex;
8
+ -webkit-box-pack: start;
9
+ -ms-flex-pack: start;
10
+ justify-content: flex-start;
5
11
  margin: 12px 0 12px 40px;
6
- padding: 0;
7
12
  font-style: normal;
8
13
  }
9
- .mfui-list_type_ul {
10
- list-style: disc;
11
- }
12
- .mfui-list_type_ol {
13
- list-style: decimal;
14
- }
15
14
  .mfui-list_h-align_center {
16
- text-align: center;
15
+ -webkit-box-pack: center;
16
+ -ms-flex-pack: center;
17
+ justify-content: center;
17
18
  }
18
19
  .mfui-list_h-align_right {
19
- text-align: right;
20
+ -webkit-box-pack: end;
21
+ -ms-flex-pack: end;
22
+ justify-content: flex-end;
20
23
  }
21
24
  .mfui-list_color_default {
22
25
  color: var(--content);
@@ -51,3 +54,13 @@
51
54
  .mfui-list_weight_bold {
52
55
  font-weight: 600;
53
56
  }
57
+ .mfui-list__inner {
58
+ margin: 0;
59
+ padding: 0;
60
+ }
61
+ .mfui-list__inner_type_ul {
62
+ list-style: disc;
63
+ }
64
+ .mfui-list_inner_type_ol {
65
+ list-style: decimal;
66
+ }
@@ -15,14 +15,17 @@ var List = function List(_ref) {
15
15
  className = _ref.className,
16
16
  children = _ref.children;
17
17
  var ElementType = as;
18
- return /*#__PURE__*/React.createElement(ElementType, {
18
+ return /*#__PURE__*/React.createElement("div", {
19
19
  className: cn({
20
20
  'h-align': align,
21
21
  color: color,
22
- weight: weight,
23
- type: as
22
+ weight: weight
24
23
  }, className)
25
- }, children);
24
+ }, /*#__PURE__*/React.createElement(ElementType, {
25
+ className: cn('inner', {
26
+ type: as
27
+ })
28
+ }, children));
26
29
  };
27
30
 
28
31
  List.propTypes = {
@@ -157,6 +157,9 @@
157
157
  color: var(--spbSky3);
158
158
  fill: var(--spbSky3);
159
159
  }
160
+ .mfui-tabs__tab-inner:hover {
161
+ text-decoration: none;
162
+ }
160
163
  .mfui-tabs__tab-inner:not(.mfui-tabs__tab-inner_current):hover {
161
164
  color: var(--content);
162
165
  fill: var(--content);
@@ -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,