@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.
- package/CHANGELOG.md +6 -0
- package/README.md +4 -4
- package/lib/cjs/BulkTextarea.js +248 -269
- package/lib/cjs/BulkTextarea.js.map +1 -1
- package/lib/cjs/BulkTextarea.types.js.map +1 -1
- package/lib/cjs/components/ClearAll.js +9 -8
- package/lib/cjs/components/ClearAll.js.map +1 -1
- package/lib/cjs/components/Counter.js +12 -10
- package/lib/cjs/components/Counter.js.map +1 -1
- package/lib/cjs/components/ErrorsNavigation.js +22 -20
- package/lib/cjs/components/ErrorsNavigation.js.map +1 -1
- package/lib/cjs/components/InputField/InputField.js +916 -1045
- package/lib/cjs/components/InputField/InputField.js.map +1 -1
- package/lib/cjs/index.js +3 -3
- package/lib/cjs/translations/__intergalactic-dynamic-locales.js +16 -16
- package/lib/cjs/translations/__intergalactic-dynamic-locales.js.map +1 -1
- package/lib/es6/BulkTextarea.js +242 -263
- package/lib/es6/BulkTextarea.js.map +1 -1
- package/lib/es6/BulkTextarea.types.js.map +1 -1
- package/lib/es6/components/ClearAll.js +8 -7
- package/lib/es6/components/ClearAll.js.map +1 -1
- package/lib/es6/components/Counter.js +7 -5
- package/lib/es6/components/Counter.js.map +1 -1
- package/lib/es6/components/ErrorsNavigation.js +15 -13
- package/lib/es6/components/ErrorsNavigation.js.map +1 -1
- package/lib/es6/components/InputField/InputField.js +910 -1040
- package/lib/es6/components/InputField/InputField.js.map +1 -1
- package/lib/es6/translations/__intergalactic-dynamic-locales.js +15 -15
- package/lib/es6/translations/__intergalactic-dynamic-locales.js.map +1 -1
- package/lib/esm/BulkTextarea.mjs +244 -223
- package/lib/esm/components/ClearAll.mjs +8 -7
- package/lib/esm/components/Counter.mjs +7 -2
- package/lib/esm/components/ErrorsNavigation.mjs +13 -2
- package/lib/esm/components/InputField/InputField.mjs +903 -981
- package/lib/esm/translations/__intergalactic-dynamic-locales.mjs +1 -1
- package/lib/types/BulkTextarea.types.d.ts +1 -1
- package/lib/types/components/InputField/InputField.d.ts +6 -2
- package/package.json +11 -11
package/CHANGELOG.md
CHANGED
package/README.md
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
[](https://www.npmjs.com/@semcore/bulk-textarea)
|
|
4
4
|
[](https://www.npmjs.com/package/@semcore/bulk-textarea)
|
|
5
|
-
[](https://github.com/semrush/intergalactic/blob/
|
|
5
|
+
[](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/
|
|
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/
|
|
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/
|
|
37
|
+
This project is [MIT](https://github.com/semrush/intergalactic/blob/HEAD/LICENSE) licensed.
|
package/lib/cjs/BulkTextarea.js
CHANGED
|
@@ -1,299 +1,280 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault")
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
|
|
4
4
|
Object.defineProperty(exports, "__esModule", {
|
|
5
5
|
value: true
|
|
6
6
|
});
|
|
7
|
-
exports
|
|
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
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
(0,
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
(0, _defineProperty2
|
|
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
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
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
|
-
|
|
50
|
-
|
|
51
|
-
|
|
40
|
+
this.handlers.showErrors(false);
|
|
41
|
+
this.handlers.errors([]);
|
|
42
|
+
this.handlers.state('normal');
|
|
52
43
|
}
|
|
53
44
|
});
|
|
54
|
-
(0, _defineProperty2
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
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
|
-
|
|
62
|
-
|
|
63
|
-
|
|
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
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
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
|
-
(
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
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 (
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
176
|
+
if (errors?.length === 0) {
|
|
177
|
+
this.handlers.showErrors(false);
|
|
178
|
+
setTimeout(() => {
|
|
179
|
+
this.setState({
|
|
180
|
+
prevError: undefined
|
|
181
|
+
});
|
|
182
|
+
}, 150);
|
|
172
183
|
}
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
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
|
-
|
|
295
|
-
|
|
296
|
-
|
|
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
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
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
|