@semcore/bulk-textarea 16.6.2 → 17.0.0-prerelease.17

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 (38) hide show
  1. package/CHANGELOG.md +6 -0
  2. package/README.md +4 -4
  3. package/lib/cjs/BulkTextarea.js +248 -269
  4. package/lib/cjs/BulkTextarea.js.map +1 -1
  5. package/lib/cjs/BulkTextarea.types.js.map +1 -1
  6. package/lib/cjs/components/ClearAll.js +9 -8
  7. package/lib/cjs/components/ClearAll.js.map +1 -1
  8. package/lib/cjs/components/Counter.js +12 -10
  9. package/lib/cjs/components/Counter.js.map +1 -1
  10. package/lib/cjs/components/ErrorsNavigation.js +22 -20
  11. package/lib/cjs/components/ErrorsNavigation.js.map +1 -1
  12. package/lib/cjs/components/InputField/InputField.js +916 -1045
  13. package/lib/cjs/components/InputField/InputField.js.map +1 -1
  14. package/lib/cjs/index.js +3 -3
  15. package/lib/cjs/translations/__intergalactic-dynamic-locales.js +16 -16
  16. package/lib/cjs/translations/__intergalactic-dynamic-locales.js.map +1 -1
  17. package/lib/es6/BulkTextarea.js +242 -263
  18. package/lib/es6/BulkTextarea.js.map +1 -1
  19. package/lib/es6/BulkTextarea.types.js.map +1 -1
  20. package/lib/es6/components/ClearAll.js +8 -7
  21. package/lib/es6/components/ClearAll.js.map +1 -1
  22. package/lib/es6/components/Counter.js +7 -5
  23. package/lib/es6/components/Counter.js.map +1 -1
  24. package/lib/es6/components/ErrorsNavigation.js +15 -13
  25. package/lib/es6/components/ErrorsNavigation.js.map +1 -1
  26. package/lib/es6/components/InputField/InputField.js +910 -1040
  27. package/lib/es6/components/InputField/InputField.js.map +1 -1
  28. package/lib/es6/translations/__intergalactic-dynamic-locales.js +15 -15
  29. package/lib/es6/translations/__intergalactic-dynamic-locales.js.map +1 -1
  30. package/lib/esm/BulkTextarea.mjs +244 -223
  31. package/lib/esm/components/ClearAll.mjs +8 -7
  32. package/lib/esm/components/Counter.mjs +7 -2
  33. package/lib/esm/components/ErrorsNavigation.mjs +13 -2
  34. package/lib/esm/components/InputField/InputField.mjs +903 -981
  35. package/lib/esm/translations/__intergalactic-dynamic-locales.mjs +1 -1
  36. package/lib/types/BulkTextarea.types.d.ts +1 -1
  37. package/lib/types/components/InputField/InputField.d.ts +6 -2
  38. package/package.json +11 -11
package/CHANGELOG.md CHANGED
@@ -2,6 +2,12 @@
2
2
 
3
3
  CHANGELOG.md standards are inspired by [keepachangelog.com](https://keepachangelog.com/en/1.0.0/).
4
4
 
5
+ ## [17.0.0] - 2026-02-18
6
+
7
+ ### BREAK
8
+
9
+ - New major version.
10
+
5
11
  ## [16.6.2] - 2025-11-17
6
12
 
7
13
  ### Changed
package/README.md CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  [![version](https://img.shields.io/npm/v/@semcore/bulk-textarea.svg)](https://www.npmjs.com/@semcore/bulk-textarea)
4
4
  [![downloads](https://img.shields.io/npm/dt/@semcore/bulk-textarea.svg)](https://www.npmjs.com/package/@semcore/bulk-textarea)
5
- [![License: MIT](https://img.shields.io/badge/License-MIT-green.svg)](https://github.com/semrush/intergalactic/blob/master/LICENSE)
5
+ [![License: MIT](https://img.shields.io/badge/License-MIT-green.svg)](https://github.com/semrush/intergalactic/blob/HEAD/LICENSE)
6
6
 
7
7
  > This component is part of the Intergalactic Design System
8
8
 
@@ -20,13 +20,13 @@ npm install @semcore/bulk-textarea
20
20
 
21
21
  ## 👤 Author
22
22
 
23
- [UI-kit team](https://github.com/semrush/intergalactic/blob/master/MAINTAINERS) and [others ❤️](https://github.com/semrush/intergalactic/graphs/contributors)
23
+ [UI-kit team](https://github.com/semrush/intergalactic/blob/HEAD/MAINTAINERS) and [others ❤️](https://github.com/semrush/intergalactic/graphs/contributors)
24
24
 
25
25
  ## 🤝 Contributing
26
26
 
27
27
  Contributions, issues and feature requests are welcome!
28
28
 
29
- Feel free to check [issues page](https://github.com/semrush/intergalactic/issues). You can also take a look at the [contributing guide](https://github.com/semrush/intergalactic/blob/master/CONTRIBUTING.md).
29
+ Feel free to check [issues page](https://github.com/semrush/intergalactic/issues). You can also take a look at the [contributing guide](https://github.com/semrush/intergalactic/blob/HEAD/CONTRIBUTING.md).
30
30
 
31
31
  ## Show your support
32
32
 
@@ -34,4 +34,4 @@ Give a ⭐️ if this project helped you!
34
34
 
35
35
  ## 📝 License
36
36
 
37
- This project is [MIT](https://github.com/semrush/intergalactic/blob/master/LICENSE) licensed.
37
+ This project is [MIT](https://github.com/semrush/intergalactic/blob/HEAD/LICENSE) licensed.
@@ -1,299 +1,280 @@
1
1
  "use strict";
2
2
 
3
- var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault")["default"];
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
4
4
  Object.defineProperty(exports, "__esModule", {
5
5
  value: true
6
6
  });
7
- exports["default"] = void 0;
8
- var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
9
- var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
10
- var _callSuper2 = _interopRequireDefault(require("@babel/runtime/helpers/callSuper"));
11
- var _inherits2 = _interopRequireDefault(require("@babel/runtime/helpers/inherits"));
7
+ exports.default = void 0;
12
8
  var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
13
9
  var _core = require("@semcore/core");
10
+ var _baseComponents = require("@semcore/base-components");
14
11
  var _i18nEnhance = _interopRequireDefault(require("@semcore/core/lib/utils/enhances/i18nEnhance"));
15
12
  var _uniqueID = _interopRequireDefault(require("@semcore/core/lib/utils/uniqueID"));
16
- var _flexBox = require("@semcore/flex-box");
17
13
  var _react = _interopRequireDefault(require("react"));
18
14
  var _ClearAll = require("./components/ClearAll");
19
15
  var _Counter = require("./components/Counter");
20
16
  var _ErrorsNavigation = require("./components/ErrorsNavigation");
21
17
  var _InputField = require("./components/InputField/InputField");
22
18
  var _intergalacticDynamicLocales = require("./translations/__intergalactic-dynamic-locales");
23
- var BulkTextareaRoot = /*#__PURE__*/function (_Component) {
24
- function BulkTextareaRoot() {
25
- var _this;
26
- (0, _classCallCheck2["default"])(this, BulkTextareaRoot);
27
- for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
28
- args[_key] = arguments[_key];
29
- }
30
- _this = (0, _callSuper2["default"])(this, BulkTextareaRoot, [].concat(args));
31
- (0, _defineProperty2["default"])(_this, "inputFieldRef", /*#__PURE__*/_react["default"].createRef());
32
- (0, _defineProperty2["default"])(_this, "clearAllButtonRef", /*#__PURE__*/_react["default"].createRef());
33
- (0, _defineProperty2["default"])(_this, "nextButtonRef", /*#__PURE__*/_react["default"].createRef());
34
- (0, _defineProperty2["default"])(_this, "prevButtonRef", /*#__PURE__*/_react["default"].createRef());
35
- (0, _defineProperty2["default"])(_this, "counterRef", /*#__PURE__*/_react["default"].createRef());
36
- (0, _defineProperty2["default"])(_this, "state", {
19
+ class BulkTextareaRoot extends _core.Component {
20
+ constructor(...args) {
21
+ super(...args);
22
+ (0, _defineProperty2.default)(this, "inputFieldRef", /*#__PURE__*/_react.default.createRef());
23
+ (0, _defineProperty2.default)(this, "clearAllButtonRef", /*#__PURE__*/_react.default.createRef());
24
+ (0, _defineProperty2.default)(this, "nextButtonRef", /*#__PURE__*/_react.default.createRef());
25
+ (0, _defineProperty2.default)(this, "prevButtonRef", /*#__PURE__*/_react.default.createRef());
26
+ (0, _defineProperty2.default)(this, "counterRef", /*#__PURE__*/_react.default.createRef());
27
+ (0, _defineProperty2.default)(this, "state", {
37
28
  linesCount: 0,
38
29
  isEmptyText: true,
39
30
  errorIndex: -1,
40
31
  highlightErrorIndex: false
41
32
  });
42
- (0, _defineProperty2["default"])(_this, "handleChangeLinesCount", function (linesCount) {
43
- var isEmpty = !linesCount;
44
- _this.setState({
45
- linesCount: linesCount,
33
+ (0, _defineProperty2.default)(this, "handleChangeLinesCount", linesCount => {
34
+ const isEmpty = !linesCount;
35
+ this.setState({
36
+ linesCount,
46
37
  isEmptyText: isEmpty
47
38
  });
48
39
  if (isEmpty) {
49
- _this.handlers.showErrors(false);
50
- _this.handlers.errors([]);
51
- _this.handlers.state('normal');
40
+ this.handlers.showErrors(false);
41
+ this.handlers.errors([]);
42
+ this.handlers.state('normal');
52
43
  }
53
44
  });
54
- (0, _defineProperty2["default"])(_this, "handleClickClearAll", function (e) {
55
- var _this$inputFieldRef$c;
56
- _this.handlers.showErrors(false);
57
- _this.handlers.errors([]);
58
- _this.setState({
45
+ (0, _defineProperty2.default)(this, "handleClickClearAll", e => {
46
+ this.handlers.showErrors(false);
47
+ this.handlers.errors([]);
48
+ this.setState({
59
49
  errorIndex: -1
60
50
  });
61
- _this.handlers.value('', e);
62
- _this.handlers.state('normal');
63
- var textarea = (_this$inputFieldRef$c = _this.inputFieldRef.current) === null || _this$inputFieldRef$c === void 0 ? void 0 : _this$inputFieldRef$c.querySelector('[role="textbox"]');
51
+ // @ts-ignore
52
+ this.handlers.value('', e);
53
+ this.handlers.state('normal');
54
+ const textarea = this.inputFieldRef.current?.querySelector('[role="textbox"]');
64
55
  if (textarea instanceof HTMLDivElement) {
65
56
  textarea.focus();
66
57
  }
67
58
  });
68
- (0, _defineProperty2["default"])(_this, "handleChangeErrorIndex", function (amount) {
69
- return function () {
70
- var _this$asProps$errors = _this.asProps.errors,
71
- errors = _this$asProps$errors === void 0 ? [] : _this$asProps$errors;
72
- var errorIndex = _this.state.errorIndex;
73
- var itemsIndex = errors.length - 1;
74
- var newIndex = errorIndex + amount;
75
- if (newIndex < 0) {
76
- newIndex = amount + itemsIndex + 1;
77
- } else if (newIndex > itemsIndex) {
78
- newIndex = newIndex - itemsIndex - 1;
79
- }
80
- if (!errors[newIndex]) {
81
- _this.handleChangeErrorIndex(amount < 0 ? amount - 1 : amount + 1)();
82
- } else {
83
- _this.handlers.showErrors(false);
84
- _this.setState({
85
- errorIndex: -1
86
- });
87
- setTimeout(function () {
88
- _this.handlers.showErrors(true);
89
- _this.setState({
90
- errorIndex: newIndex,
91
- highlightErrorIndex: true
92
- });
59
+ (0, _defineProperty2.default)(this, "handleChangeErrorIndex", amount => () => {
60
+ const {
61
+ errors = []
62
+ } = this.asProps;
63
+ const {
64
+ errorIndex
65
+ } = this.state;
66
+ const itemsIndex = errors.length - 1;
67
+ let newIndex = errorIndex + amount;
68
+ if (newIndex < 0) {
69
+ newIndex = amount + itemsIndex + 1;
70
+ } else if (newIndex > itemsIndex) {
71
+ newIndex = newIndex - itemsIndex - 1;
72
+ }
73
+ if (!errors[newIndex]) {
74
+ this.handleChangeErrorIndex(amount < 0 ? amount - 1 : amount + 1)();
75
+ } else {
76
+ this.handlers.showErrors(false);
77
+ this.setState({
78
+ errorIndex: -1
79
+ });
80
+ setTimeout(() => {
81
+ this.handlers.showErrors(true);
82
+ this.setState({
83
+ errorIndex: newIndex,
84
+ highlightErrorIndex: true
93
85
  });
94
- }
95
- };
86
+ });
87
+ }
96
88
  });
97
- return _this;
98
89
  }
99
- (0, _inherits2["default"])(BulkTextareaRoot, _Component);
100
- return (0, _createClass2["default"])(BulkTextareaRoot, [{
101
- key: "uncontrolledProps",
102
- value: function uncontrolledProps() {
103
- return {
104
- value: null,
105
- state: null,
106
- showErrors: null,
107
- errors: null
108
- };
109
- }
110
- }, {
111
- key: "counterId",
112
- get: function get() {
113
- return "".concat(this.asProps.uid, "_counter");
114
- }
115
- }, {
116
- key: "getInputFieldProps",
117
- value: function getInputFieldProps() {
118
- var _this2 = this;
119
- var _this$asProps = this.asProps,
120
- value = _this$asProps.value,
121
- size = _this$asProps.size,
122
- minRows = _this$asProps.minRows,
123
- maxRows = _this$asProps.maxRows,
124
- lineValidation = _this$asProps.lineValidation,
125
- placeholder = _this$asProps.placeholder,
126
- validateOn = _this$asProps.validateOn,
127
- linesDelimiters = _this$asProps.linesDelimiters,
128
- maxLines = _this$asProps.maxLines,
129
- disabled = _this$asProps.disabled,
130
- readonly = _this$asProps.readonly,
131
- pasteProps = _this$asProps.pasteProps,
132
- lineProcessing = _this$asProps.lineProcessing,
133
- _this$asProps$errors2 = _this$asProps.errors,
134
- errors = _this$asProps$errors2 === void 0 ? [] : _this$asProps$errors2,
135
- showErrors = _this$asProps.showErrors,
136
- onImmediatelyChange = _this$asProps.onImmediatelyChange;
137
- var _this$state = this.state,
138
- errorIndex = _this$state.errorIndex,
139
- prevError = _this$state.prevError,
140
- linesCount = _this$state.linesCount,
141
- highlightErrorIndex = _this$state.highlightErrorIndex;
142
- return (0, _defineProperty2["default"])((0, _defineProperty2["default"])({
143
- value: value,
144
- size: size,
145
- state: showErrors && (errors === null || errors === void 0 ? void 0 : errors.length) > 0 ? 'invalid' : 'normal',
146
- disabled: disabled,
147
- readonly: readonly,
148
- minRows: minRows,
149
- maxRows: maxRows,
150
- maxLines: maxLines,
151
- placeholder: placeholder,
152
- prevError: prevError,
153
- pasteProps: pasteProps,
154
- linesCount: linesCount,
155
- lineProcessing: lineProcessing,
156
- onChangeLinesCount: this.handleChangeLinesCount,
157
- onChangeLineIndex: function onChangeLineIndex() {
158
- if (validateOn !== null && validateOn !== void 0 && validateOn.includes('blurLine')) {
159
- _this2.handlers.showErrors(true);
160
- }
161
- },
162
- onBlur: function onBlur(value, event) {
163
- var _this2$props$onChange, _this2$props;
164
- if (validateOn !== null && validateOn !== void 0 && validateOn.includes('blur') && (_core.lastInteraction.isKeyboard() || event instanceof FocusEvent && event.relatedTarget !== _this2.clearAllButtonRef.current)) {
165
- _this2.handlers.showErrors(true);
90
+ uncontrolledProps() {
91
+ return {
92
+ value: null,
93
+ state: null,
94
+ showErrors: null,
95
+ errors: null
96
+ };
97
+ }
98
+ get counterId() {
99
+ return `${this.asProps.uid}_counter`;
100
+ }
101
+ getInputFieldProps() {
102
+ const {
103
+ value,
104
+ size,
105
+ minRows,
106
+ maxRows,
107
+ lineValidation,
108
+ placeholder,
109
+ validateOn,
110
+ linesDelimiters,
111
+ maxLines,
112
+ disabled,
113
+ readonly,
114
+ pasteProps,
115
+ lineProcessing,
116
+ errors = [],
117
+ showErrors,
118
+ onImmediatelyChange
119
+ } = this.asProps;
120
+ const {
121
+ errorIndex,
122
+ prevError,
123
+ linesCount,
124
+ highlightErrorIndex
125
+ } = this.state;
126
+ return {
127
+ value,
128
+ size,
129
+ state: showErrors && errors?.length > 0 ? 'invalid' : 'normal',
130
+ disabled,
131
+ readonly,
132
+ minRows,
133
+ maxRows,
134
+ maxLines,
135
+ placeholder,
136
+ prevError,
137
+ pasteProps,
138
+ linesCount,
139
+ lineProcessing,
140
+ onChangeLinesCount: this.handleChangeLinesCount,
141
+ onChangeLineIndex: () => {
142
+ if (validateOn?.includes('blurLine')) {
143
+ this.handlers.showErrors(true);
144
+ }
145
+ },
146
+ onBlur: (value, event) => {
147
+ if (validateOn?.includes('blur') && (_core.lastInteraction.isKeyboard() || event instanceof FocusEvent && event.relatedTarget !== this.clearAllButtonRef.current)) {
148
+ this.handlers.showErrors(true);
149
+ }
150
+ if (this.asProps.showErrors === false && (validateOn?.includes('blur') || validateOn?.includes('blurLine'))) {
151
+ setTimeout(() => {
152
+ this.nextButtonRef.current?.focus();
153
+ }, 250);
154
+ }
155
+ this.props.onChange?.(value, event);
156
+ },
157
+ showErrors,
158
+ validateOn,
159
+ lineValidation: lineValidation,
160
+ errors,
161
+ onErrorsChange: newErrors => {
162
+ const prevError = newErrors.length === 0 ? errors[0] : undefined;
163
+ this.handlers.errors(newErrors);
164
+ this.setState({
165
+ prevError
166
+ });
167
+ setTimeout(() => {
168
+ const {
169
+ showErrors,
170
+ errors
171
+ } = this.asProps;
172
+ if (showErrors) {
173
+ const newState = newErrors.length === 0 ? 'normal' : 'invalid';
174
+ this.handlers.state(newState);
166
175
  }
167
- if (_this2.asProps.showErrors === false && (validateOn !== null && validateOn !== void 0 && validateOn.includes('blur') || validateOn !== null && validateOn !== void 0 && validateOn.includes('blurLine'))) {
168
- setTimeout(function () {
169
- var _this2$nextButtonRef$;
170
- (_this2$nextButtonRef$ = _this2.nextButtonRef.current) === null || _this2$nextButtonRef$ === void 0 || _this2$nextButtonRef$.focus();
171
- }, 250);
176
+ if (errors?.length === 0) {
177
+ this.handlers.showErrors(false);
178
+ setTimeout(() => {
179
+ this.setState({
180
+ prevError: undefined
181
+ });
182
+ }, 150);
172
183
  }
173
- (_this2$props$onChange = (_this2$props = _this2.props).onChange) === null || _this2$props$onChange === void 0 || _this2$props$onChange.call(_this2$props, value, event);
174
- },
175
- showErrors: showErrors,
176
- validateOn: validateOn,
177
- lineValidation: lineValidation,
178
- errors: errors,
179
- onErrorsChange: function onErrorsChange(newErrors) {
180
- var prevError = newErrors.length === 0 ? errors[0] : undefined;
181
- _this2.handlers.errors(newErrors);
182
- _this2.setState({
183
- prevError: prevError
184
- });
185
- setTimeout(function () {
186
- var _this2$asProps = _this2.asProps,
187
- showErrors = _this2$asProps.showErrors,
188
- errors = _this2$asProps.errors;
189
- if (showErrors) {
190
- var newState = newErrors.length === 0 ? 'normal' : 'invalid';
191
- _this2.handlers.state(newState);
192
- }
193
- if ((errors === null || errors === void 0 ? void 0 : errors.length) === 0) {
194
- _this2.handlers.showErrors(false);
195
- setTimeout(function () {
196
- _this2.setState({
197
- prevError: undefined
198
- });
199
- }, 150);
200
- }
201
- }, 10); // this timeout to be sure that code will be after state change
202
- },
203
- highlightErrorIndex: highlightErrorIndex,
204
- errorIndex: errorIndex,
205
- onErrorIndexChange: function onErrorIndexChange(newErrorIndex) {
206
- var prevError = errors[errorIndex];
207
- _this2.setState({
208
- errorIndex: newErrorIndex,
209
- prevError: prevError,
210
- highlightErrorIndex: false
211
- });
212
- },
213
- linesDelimiters: linesDelimiters,
214
- ref: this.inputFieldRef
215
- }, 'aria-describedby', this.counterId), "onImmediatelyChange", onImmediatelyChange);
216
- }
217
- }, {
218
- key: "getCounterProps",
219
- value: function getCounterProps() {
220
- var _this$asProps2 = this.asProps,
221
- maxLines = _this$asProps2.maxLines,
222
- getI18nText = _this$asProps2.getI18nText,
223
- size = _this$asProps2.size;
224
- var _this$state2 = this.state,
225
- linesCount = _this$state2.linesCount,
226
- isEmptyText = _this$state2.isEmptyText;
227
- var counterTheme = '';
228
- if (linesCount === maxLines) {
229
- counterTheme = 'warning';
230
- } else if (linesCount > maxLines) {
231
- counterTheme = 'danger';
232
- }
233
- return {
234
- id: this.counterId,
235
- ref: this.counterRef,
236
- getI18nText: getI18nText,
237
- theme: counterTheme,
238
- linesCount: isEmptyText ? 0 : linesCount,
239
- maxLines: maxLines,
240
- size: size
241
- };
242
- }
243
- }, {
244
- key: "getClearAllProps",
245
- value: function getClearAllProps() {
246
- var _this$asProps3 = this.asProps,
247
- size = _this$asProps3.size,
248
- getI18nText = _this$asProps3.getI18nText,
249
- disabled = _this$asProps3.disabled,
250
- readonly = _this$asProps3.readonly;
251
- return {
252
- onClick: this.handleClickClearAll,
253
- isHidden: this.state.isEmptyText,
254
- size: size,
255
- getI18nText: getI18nText,
256
- ref: this.clearAllButtonRef,
257
- disabled: disabled || readonly
258
- };
259
- }
260
- }, {
261
- key: "getErrorsNavigationProps",
262
- value: function getErrorsNavigationProps() {
263
- var _this$asProps4 = this.asProps,
264
- size = _this$asProps4.size,
265
- getI18nText = _this$asProps4.getI18nText,
266
- disabled = _this$asProps4.disabled,
267
- readonly = _this$asProps4.readonly,
268
- _this$asProps4$errors = _this$asProps4.errors,
269
- errors = _this$asProps4$errors === void 0 ? [] : _this$asProps4$errors,
270
- showErrors = _this$asProps4.showErrors;
271
- var errorIndex = this.state.errorIndex;
272
- return {
273
- size: size,
274
- getI18nText: getI18nText,
275
- errorIndex: errorIndex,
276
- onPrevError: this.handleChangeErrorIndex(-1),
277
- onNextError: this.handleChangeErrorIndex(1),
278
- errorsCount: errors.map(Boolean).length,
279
- showErrors: showErrors,
280
- disabled: disabled || readonly || false,
281
- nextButtonRef: this.nextButtonRef,
282
- prevButtonRef: this.prevButtonRef
283
- };
284
- }
285
- }, {
286
- key: "render",
287
- value: function render() {
288
- var _ref = this.asProps;
289
- return /*#__PURE__*/_react["default"].createElement(_flexBox.Box, (0, _core.assignProps)({
290
- "__excludeProps": ['onBlur', 'value', 'placeholder']
291
- }, _ref));
184
+ }, 10); // this timeout to be sure that code will be after state change
185
+ },
186
+ highlightErrorIndex,
187
+ errorIndex,
188
+ onErrorIndexChange: newErrorIndex => {
189
+ const prevError = errors[errorIndex];
190
+ this.setState({
191
+ errorIndex: newErrorIndex,
192
+ prevError,
193
+ highlightErrorIndex: false
194
+ });
195
+ },
196
+ linesDelimiters,
197
+ ref: this.inputFieldRef,
198
+ ['aria-describedby']: this.counterId,
199
+ onImmediatelyChange
200
+ };
201
+ }
202
+ getCounterProps() {
203
+ const {
204
+ maxLines,
205
+ getI18nText,
206
+ size
207
+ } = this.asProps;
208
+ const {
209
+ linesCount,
210
+ isEmptyText
211
+ } = this.state;
212
+ let counterTheme = '';
213
+ if (linesCount === maxLines) {
214
+ counterTheme = 'warning';
215
+ } else if (linesCount > maxLines) {
216
+ counterTheme = 'danger';
292
217
  }
293
- }]);
294
- }(_core.Component);
295
- (0, _defineProperty2["default"])(BulkTextareaRoot, "displayName", 'BulkTextarea');
296
- (0, _defineProperty2["default"])(BulkTextareaRoot, "defaultProps", {
218
+ return {
219
+ id: this.counterId,
220
+ ref: this.counterRef,
221
+ getI18nText,
222
+ theme: counterTheme,
223
+ linesCount: isEmptyText ? 0 : linesCount,
224
+ maxLines,
225
+ size
226
+ };
227
+ }
228
+ getClearAllProps() {
229
+ const {
230
+ size,
231
+ getI18nText,
232
+ disabled,
233
+ readonly
234
+ } = this.asProps;
235
+ return {
236
+ onClick: this.handleClickClearAll,
237
+ isHidden: this.state.isEmptyText,
238
+ size,
239
+ getI18nText,
240
+ ref: this.clearAllButtonRef,
241
+ disabled: disabled || readonly
242
+ };
243
+ }
244
+ getErrorsNavigationProps() {
245
+ const {
246
+ size,
247
+ getI18nText,
248
+ disabled,
249
+ readonly,
250
+ errors = [],
251
+ showErrors
252
+ } = this.asProps;
253
+ const {
254
+ errorIndex
255
+ } = this.state;
256
+ return {
257
+ size,
258
+ getI18nText,
259
+ errorIndex: errorIndex,
260
+ onPrevError: this.handleChangeErrorIndex(-1),
261
+ onNextError: this.handleChangeErrorIndex(1),
262
+ errorsCount: errors.map(Boolean).length,
263
+ showErrors,
264
+ disabled: disabled || readonly || false,
265
+ nextButtonRef: this.nextButtonRef,
266
+ prevButtonRef: this.prevButtonRef
267
+ };
268
+ }
269
+ render() {
270
+ var _ref = this.asProps;
271
+ return /*#__PURE__*/_react.default.createElement(_baseComponents.Box, (0, _core.assignProps)({
272
+ "__excludeProps": ['onBlur', 'value', 'placeholder']
273
+ }, _ref));
274
+ }
275
+ }
276
+ (0, _defineProperty2.default)(BulkTextareaRoot, "displayName", 'BulkTextarea');
277
+ (0, _defineProperty2.default)(BulkTextareaRoot, "defaultProps", {
297
278
  defaultValue: '',
298
279
  size: 'm',
299
280
  defaultState: 'normal',
@@ -305,14 +286,12 @@ var BulkTextareaRoot = /*#__PURE__*/function (_Component) {
305
286
  defaultErrors: [],
306
287
  defaultShowErrors: false
307
288
  });
308
- (0, _defineProperty2["default"])(BulkTextareaRoot, "enhance", [(0, _i18nEnhance["default"])(_intergalacticDynamicLocales.localizedMessages), (0, _uniqueID["default"])()]);
309
- var BulkTextarea = function () {
310
- return (0, _core.createComponent)(BulkTextareaRoot, {
311
- InputField: _InputField.InputField,
312
- Counter: _Counter.Counter,
313
- ClearAll: _ClearAll.ClearAll,
314
- ErrorsNavigation: _ErrorsNavigation.ErrorsNavigation
315
- });
316
- }();
317
- var _default = exports["default"] = BulkTextarea;
289
+ (0, _defineProperty2.default)(BulkTextareaRoot, "enhance", [(0, _i18nEnhance.default)(_intergalacticDynamicLocales.localizedMessages), (0, _uniqueID.default)()]);
290
+ const BulkTextarea = (() => (0, _core.createComponent)(BulkTextareaRoot, {
291
+ InputField: _InputField.InputField,
292
+ Counter: _Counter.Counter,
293
+ ClearAll: _ClearAll.ClearAll,
294
+ ErrorsNavigation: _ErrorsNavigation.ErrorsNavigation
295
+ }))();
296
+ var _default = exports.default = BulkTextarea;
318
297
  //# sourceMappingURL=BulkTextarea.js.map