@semcore/bulk-textarea 17.0.0-prerelease.34 → 17.0.0-prerelease.37

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 CHANGED
@@ -2,7 +2,7 @@
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-04-08
5
+ ## [17.0.0] - 2026-04-13
6
6
 
7
7
  ### BREAK
8
8
 
@@ -1,5 +1,5 @@
1
1
  import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
2
- import { createComponent, Component, lastInteraction, assignProps } from "@semcore/core";
2
+ import { Component, lastInteraction, assignProps, createComponent } from "@semcore/core";
3
3
  import { Box } from "@semcore/base-components";
4
4
  import i18nEnhance from "@semcore/core/lib/utils/enhances/i18nEnhance";
5
5
  import uniqueIDEnhancement from "@semcore/core/lib/utils/uniqueID";
@@ -36,7 +36,6 @@ class BulkTextareaRoot extends Component {
36
36
  }
37
37
  });
38
38
  _defineProperty(this, "handleClickClearAll", (e) => {
39
- var _a;
40
39
  this.handlers.showErrors(false);
41
40
  this.handlers.errors([]);
42
41
  this.setState({
@@ -44,7 +43,7 @@ class BulkTextareaRoot extends Component {
44
43
  });
45
44
  this.handlers.value("", e);
46
45
  this.handlers.state("normal");
47
- const textarea = (_a = this.inputFieldRef.current) == null ? void 0 : _a.querySelector('[role="textbox"]');
46
+ const textarea = this.inputFieldRef.current?.querySelector('[role="textbox"]');
48
47
  if (textarea instanceof HTMLDivElement) {
49
48
  textarea.focus();
50
49
  }
@@ -119,7 +118,7 @@ class BulkTextareaRoot extends Component {
119
118
  return {
120
119
  value,
121
120
  size,
122
- state: showErrors && (errors == null ? void 0 : errors.length) > 0 ? "invalid" : "normal",
121
+ state: showErrors && errors?.length > 0 ? "invalid" : "normal",
123
122
  disabled,
124
123
  readonly,
125
124
  minRows,
@@ -132,22 +131,20 @@ class BulkTextareaRoot extends Component {
132
131
  lineProcessing,
133
132
  onChangeLinesCount: this.handleChangeLinesCount,
134
133
  onChangeLineIndex: () => {
135
- if (validateOn == null ? void 0 : validateOn.includes("blurLine")) {
134
+ if (validateOn?.includes("blurLine")) {
136
135
  this.handlers.showErrors(true);
137
136
  }
138
137
  },
139
138
  onBlur: (value2, event) => {
140
- var _a, _b;
141
- if ((validateOn == null ? void 0 : validateOn.includes("blur")) && (lastInteraction.isKeyboard() || event instanceof FocusEvent && event.relatedTarget !== this.clearAllButtonRef.current)) {
139
+ if (validateOn?.includes("blur") && (lastInteraction.isKeyboard() || event instanceof FocusEvent && event.relatedTarget !== this.clearAllButtonRef.current)) {
142
140
  this.handlers.showErrors(true);
143
141
  }
144
- if (this.asProps.showErrors === false && ((validateOn == null ? void 0 : validateOn.includes("blur")) || (validateOn == null ? void 0 : validateOn.includes("blurLine")))) {
142
+ if (this.asProps.showErrors === false && (validateOn?.includes("blur") || validateOn?.includes("blurLine"))) {
145
143
  setTimeout(() => {
146
- var _a2;
147
- (_a2 = this.nextButtonRef.current) == null ? void 0 : _a2.focus();
144
+ this.nextButtonRef.current?.focus();
148
145
  }, 250);
149
146
  }
150
- (_b = (_a = this.props).onChange) == null ? void 0 : _b.call(_a, value2, event);
147
+ this.props.onChange?.(value2, event);
151
148
  },
152
149
  showErrors,
153
150
  validateOn,
@@ -168,7 +165,7 @@ class BulkTextareaRoot extends Component {
168
165
  const newState = newErrors.length === 0 ? "normal" : "invalid";
169
166
  this.handlers.state(newState);
170
167
  }
171
- if ((errors2 == null ? void 0 : errors2.length) === 0) {
168
+ if (errors2?.length === 0) {
172
169
  this.handlers.showErrors(false);
173
170
  setTimeout(() => {
174
171
  this.setState({
@@ -1,12 +1,11 @@
1
1
  import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
2
- import { Component, sstyled, assignProps } from "@semcore/core";
2
+ import { sstyled, Component, assignProps } from "@semcore/core";
3
3
  import { Box } from "@semcore/base-components";
4
4
  import { extractAriaProps } from "@semcore/core/lib/utils/ariaProps";
5
5
  import uniqueIDEnhancement from "@semcore/core/lib/utils/uniqueID";
6
6
  import Tooltip from "@semcore/tooltip";
7
7
  import DOMPurify from "dompurify";
8
8
  import React from "react";
9
- /*!__reshadow-styles__:"./inputField.shadow.css"*/
10
9
  const style = (
11
10
  /*__reshadow_css_start__*/
12
11
  (sstyled.insert(
@@ -65,10 +64,9 @@ class InputField extends Component {
65
64
  this.handleSelectAll = this.handleSelectAll.bind(this);
66
65
  this.textarea = this.createContentEditableElement(props);
67
66
  this.observer = new MutationObserver((mutationsList, observer) => {
68
- var _a, _b;
69
67
  for (const mutation of mutationsList) {
70
68
  if (mutation.type === "characterData" || mutation.type === "childList") {
71
- (_b = (_a = this.props).onImmediatelyChange) == null ? void 0 : _b.call(_a, this.getValues(), this.textarea.textContent ?? "");
69
+ this.props.onImmediatelyChange?.(this.getValues(), this.textarea.textContent ?? "");
72
70
  }
73
71
  }
74
72
  });
@@ -81,13 +79,12 @@ class InputField extends Component {
81
79
  };
82
80
  }
83
81
  componentDidMount() {
84
- var _a;
85
82
  const {
86
83
  autoFocus,
87
84
  disabled,
88
85
  readonly
89
86
  } = this.asProps;
90
- (_a = this.containerRef.current) == null ? void 0 : _a.append(this.textarea);
87
+ this.containerRef.current?.append(this.textarea);
91
88
  this.handleValueOutChange();
92
89
  const config = {
93
90
  childList: true,
@@ -222,10 +219,10 @@ class InputField extends Component {
222
219
  const currentLineIndex = this.errorByInteraction === "keyboard" ? keyboardLineIndex : this.errorByInteraction === "mouse" ? mouseLineIndex : -1;
223
220
  let errorItem = errors[errorIndex];
224
221
  if (currentLineIndex !== -1) {
225
- errorItem = errors.find((e) => (e == null ? void 0 : e.lineIndex) === currentLineIndex);
222
+ errorItem = errors.find((e) => e?.lineIndex === currentLineIndex);
226
223
  }
227
- const errorMessage = errors.length === 0 && !prevError ? null : (errorItem == null ? void 0 : errorItem.errorMessage) ?? (commonErrorMessage === "" || errors.length === 0 ? prevError == null ? void 0 : prevError.errorMessage : commonErrorMessage);
228
- const isCommonError = !(errorItem == null ? void 0 : errorItem.errorMessage) && (commonErrorMessage === "" || errors.length === 0 ? !(prevError == null ? void 0 : prevError.errorMessage) : true);
224
+ const errorMessage = errors.length === 0 && !prevError ? null : errorItem?.errorMessage ?? (commonErrorMessage === "" || errors.length === 0 ? prevError?.errorMessage : commonErrorMessage);
225
+ const isCommonError = !errorItem?.errorMessage && (commonErrorMessage === "" || errors.length === 0 ? !prevError?.errorMessage : true);
229
226
  return {
230
227
  errorMessage,
231
228
  isCommonError
@@ -325,16 +322,15 @@ class InputField extends Component {
325
322
  }
326
323
  }
327
324
  handlePaste(event) {
328
- var _a, _b, _c;
329
325
  event.preventDefault();
330
326
  const {
331
327
  validateOn
332
328
  } = this.asProps;
333
- const value = (_a = event.clipboardData) == null ? void 0 : _a.getData("text/plain");
329
+ const value = event.clipboardData?.getData("text/plain");
334
330
  const listOfNodes = value ? this.prepareNodesForPaste(value) : [];
335
331
  if (listOfNodes.length === 0) return;
336
332
  const selection = document.getSelection();
337
- if ((selection == null ? void 0 : selection.anchorNode) && (selection == null ? void 0 : selection.focusNode)) {
333
+ if (selection?.anchorNode && selection?.focusNode) {
338
334
  const anchorOffset = selection.anchorOffset;
339
335
  const focusOffset = selection.focusOffset;
340
336
  const documentPosition = selection.anchorNode.compareDocumentPosition(selection.focusNode);
@@ -353,8 +349,8 @@ class InputField extends Component {
353
349
  textNode = lastNodeToInsert.childNodes.item(0);
354
350
  position = (lastNodeToInsert.textContent ?? "").length;
355
351
  } else if (focusNode instanceof HTMLParagraphElement && anchorNode instanceof HTMLParagraphElement) {
356
- const before = ((_b = anchorNode == null ? void 0 : anchorNode.textContent) == null ? void 0 : _b.substring(0, fromOffset)) ?? "";
357
- const after = ((_c = focusNode == null ? void 0 : focusNode.textContent) == null ? void 0 : _c.substring(toOffset)) ?? "";
352
+ const before = anchorNode?.textContent?.substring(0, fromOffset) ?? "";
353
+ const after = focusNode?.textContent?.substring(toOffset) ?? "";
358
354
  const noEmptyLineBefore = before.trim() === "" ? "" : before;
359
355
  const noEmptyLineAfter = after.trim() === "" ? "" : after;
360
356
  selection.deleteFromDocument();
@@ -363,7 +359,7 @@ class InputField extends Component {
363
359
  }
364
360
  const firstNodeToInsert = listOfNodes.splice(0, 1)[0];
365
361
  const lastNodeToInsert = listOfNodes[listOfNodes.length - 1];
366
- anchorNode.textContent = noEmptyLineBefore + ((firstNodeToInsert == null ? void 0 : firstNodeToInsert.textContent) ?? "");
362
+ anchorNode.textContent = noEmptyLineBefore + (firstNodeToInsert?.textContent ?? "");
367
363
  anchorNode.after(...listOfNodes);
368
364
  if (lastNodeToInsert) {
369
365
  lastNodeToInsert.textContent = (lastNodeToInsert.textContent ?? "") + noEmptyLineAfter;
@@ -383,7 +379,7 @@ class InputField extends Component {
383
379
  this.setSelection(textNode, position ?? 1, position ?? 1);
384
380
  this.toggleErrorsPopper("keyboardLineIndex", textNode.parentNode);
385
381
  } else {
386
- console.warn("incorrect child type", textNode, textNode == null ? void 0 : textNode.parentNode);
382
+ console.warn("incorrect child type", textNode, textNode?.parentNode);
387
383
  }
388
384
  }
389
385
  this.recalculateLinesCount();
@@ -392,7 +388,6 @@ class InputField extends Component {
392
388
  }
393
389
  }
394
390
  handleChange(event) {
395
- var _a, _b, _c, _d, _e, _f;
396
391
  const target = event.target;
397
392
  if (target instanceof HTMLDivElement && event instanceof InputEvent) {
398
393
  const nodes = this.textarea.childNodes;
@@ -405,13 +400,13 @@ class InputField extends Component {
405
400
  const text = document.createTextNode(nodeText);
406
401
  firstRow.append(text);
407
402
  firstNode.replaceWith(firstRow);
408
- selection == null ? void 0 : selection.setPosition(firstRow, nodeText.length);
403
+ selection?.setPosition(firstRow, nodeText.length);
409
404
  } else if (!firstNode || firstNode instanceof HTMLBRElement && nodes.length === 1) {
410
405
  this.textarea.textContent = "";
411
406
  this.setState({
412
407
  keyboardLineIndex: 0
413
408
  });
414
- } else if (firstNode instanceof HTMLParagraphElement && !((_a = firstNode.textContent) == null ? void 0 : _a.trim())) {
409
+ } else if (firstNode instanceof HTMLParagraphElement && !firstNode.textContent?.trim()) {
415
410
  if (nodes.length <= 1 || secondNode instanceof HTMLBRElement) {
416
411
  this.textarea.textContent = "";
417
412
  this.setState({
@@ -420,16 +415,16 @@ class InputField extends Component {
420
415
  }
421
416
  }
422
417
  let maxDeep = 10;
423
- let rowNode = selection == null ? void 0 : selection.focusNode;
424
- while ((rowNode == null ? void 0 : rowNode.parentNode) !== this.textarea && maxDeep > 0) {
425
- rowNode = rowNode == null ? void 0 : rowNode.parentNode;
418
+ let rowNode = selection?.focusNode;
419
+ while (rowNode?.parentNode !== this.textarea && maxDeep > 0) {
420
+ rowNode = rowNode?.parentNode;
426
421
  maxDeep--;
427
422
  }
428
423
  if (rowNode instanceof HTMLParagraphElement) {
429
424
  const childNodes = rowNode.childNodes;
430
425
  const textContent = rowNode.textContent ?? "";
431
426
  if (childNodes.length > 1) {
432
- const offset = (_b = childNodes.item(0).textContent) == null ? void 0 : _b.length;
427
+ const offset = childNodes.item(0).textContent?.length;
433
428
  rowNode.textContent = textContent;
434
429
  if (offset) {
435
430
  this.setSelection(rowNode.childNodes.item(0), offset, offset);
@@ -465,9 +460,9 @@ class InputField extends Component {
465
460
  this.toggleErrorsPopper("keyboardLineIndex", rowNode, 0);
466
461
  }
467
462
  const trigger = !isValid || isValid && errors.length === 1 && errors[0].lineNode === rowNode ? rowNode : this.textarea;
468
- if (showErrors && ((_d = (_c = this.popper) == null ? void 0 : _c.current) == null ? void 0 : _d.state.elements.reference) !== trigger) {
463
+ if (showErrors && this.popper?.current?.state.elements.reference !== trigger) {
469
464
  if (this.shouldChangePopperTrigger(trigger)) {
470
- (_e = this.setPopperTrigger) == null ? void 0 : _e.call(this, trigger);
465
+ this.setPopperTrigger?.(trigger);
471
466
  } else {
472
467
  this.setState({
473
468
  visibleErrorPopper: false
@@ -475,8 +470,8 @@ class InputField extends Component {
475
470
  }
476
471
  }
477
472
  } else if (rowNode === null) {
478
- (_f = this.setPopperTrigger) == null ? void 0 : _f.call(this, this.textarea);
479
- if ((selection == null ? void 0 : selection.focusNode) === this.textarea && this.textarea.childNodes.length > 1) {
473
+ this.setPopperTrigger?.(this.textarea);
474
+ if (selection?.focusNode === this.textarea && this.textarea.childNodes.length > 1) {
480
475
  const nodeIndex = selection.focusOffset;
481
476
  const emptyParagraph = this.textarea.childNodes.item(nodeIndex - 1);
482
477
  const emptyBr = this.textarea.childNodes.item(nodeIndex);
@@ -525,33 +520,32 @@ class InputField extends Component {
525
520
  }, 200);
526
521
  }
527
522
  handleKeyDown(event) {
528
- var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n;
529
523
  this.errorByInteraction = "keyboard";
530
524
  const {
531
525
  linesDelimiters
532
526
  } = this.asProps;
533
527
  const currentNode = this.getNodeFromSelection();
534
- if (event.key === "Enter" || (linesDelimiters == null ? void 0 : linesDelimiters.includes(event.key))) {
528
+ if (event.key === "Enter" || linesDelimiters?.includes(event.key)) {
535
529
  if (currentNode === this.textarea) {
536
530
  event.preventDefault();
537
531
  }
538
532
  if (currentNode instanceof HTMLParagraphElement) {
539
- const currentRowValue = (_a = currentNode.textContent) == null ? void 0 : _a.trim();
533
+ const currentRowValue = currentNode.textContent?.trim();
540
534
  if (!currentRowValue) {
541
535
  event.preventDefault();
542
536
  } else {
543
537
  event.preventDefault();
544
538
  const selection = document.getSelection();
545
- const selectionNode = (selection == null ? void 0 : selection.focusNode) instanceof Text ? selection.focusNode : (_b = selection == null ? void 0 : selection.focusNode) == null ? void 0 : _b.childNodes.item(0);
546
- const selectionOffset = selection == null ? void 0 : selection.focusOffset;
539
+ const selectionNode = selection?.focusNode instanceof Text ? selection.focusNode : selection?.focusNode?.childNodes.item(0);
540
+ const selectionOffset = selection?.focusOffset;
547
541
  let newRowValue = "";
548
- if (selectionNode instanceof Text && selectionOffset !== void 0 && selectionOffset !== ((_c = selectionNode.textContent) == null ? void 0 : _c.length)) {
549
- newRowValue = ((_d = selectionNode.textContent) == null ? void 0 : _d.substring(selectionOffset)) ?? this.emptyLineValue;
542
+ if (selectionNode instanceof Text && selectionOffset !== void 0 && selectionOffset !== selectionNode.textContent?.length) {
543
+ newRowValue = selectionNode.textContent?.substring(selectionOffset) ?? this.emptyLineValue;
550
544
  if (selectionNode.textContent) {
551
545
  selectionNode.textContent = selectionNode.textContent.substring(0, selectionOffset);
552
546
  }
553
547
  }
554
- if (((_e = currentNode.textContent) == null ? void 0 : _e.trim()) === "") {
548
+ if (currentNode.textContent?.trim() === "") {
555
549
  currentNode.innerHTML = this.emptyLineValue;
556
550
  }
557
551
  const row = document.createElement("p");
@@ -568,7 +562,7 @@ class InputField extends Component {
568
562
  this.validateLine(currentNode.previousSibling);
569
563
  }
570
564
  this.setErrorIndex(row);
571
- if (((_f = row.textContent) == null ? void 0 : _f.trim()) !== "") {
565
+ if (row.textContent?.trim() !== "") {
572
566
  this.recalculateLinesCount();
573
567
  }
574
568
  setTimeout(() => {
@@ -583,19 +577,19 @@ class InputField extends Component {
583
577
  }
584
578
  this.toggleErrorsPopperByKeyboard(200);
585
579
  } else if (this.isDeleteKey(event) && currentNode instanceof HTMLParagraphElement) {
586
- if (((_g = currentNode.textContent) == null ? void 0 : _g.trim()) === "" && !this.isRangeSelection()) {
580
+ if (currentNode.textContent?.trim() === "" && !this.isRangeSelection()) {
587
581
  const prevNode = currentNode.previousSibling;
588
582
  if (prevNode instanceof HTMLParagraphElement) {
589
583
  event.preventDefault();
590
584
  this.textarea.removeChild(currentNode);
591
585
  this.toggleErrorsPopperByKeyboard(0);
592
- if (((_h = prevNode.textContent) == null ? void 0 : _h.trim()) === "" && prevNode.previousSibling === null && this.textarea.childNodes.length === 1) {
586
+ if (prevNode.textContent?.trim() === "" && prevNode.previousSibling === null && this.textarea.childNodes.length === 1) {
593
587
  this.textarea.textContent = "";
594
588
  this.setSelection(this.textarea, 0, 0);
595
589
  } else {
596
590
  if (prevNode instanceof HTMLParagraphElement) {
597
591
  const text = prevNode.childNodes.item(0);
598
- const offset = ((_i = text.textContent) == null ? void 0 : _i.length) ?? 0;
592
+ const offset = text.textContent?.length ?? 0;
599
593
  this.setSelection(text, offset, offset);
600
594
  } else {
601
595
  console.warn("incorrect prevNode type", prevNode);
@@ -609,14 +603,14 @@ class InputField extends Component {
609
603
  } else if (this.isRangeSelection()) {
610
604
  const selection = document.getSelection();
611
605
  const direction = this.getSelectionDirection();
612
- const anchorElement = direction === "backward" ? selection == null ? void 0 : selection.focusNode : selection == null ? void 0 : selection.anchorNode;
613
- const focusElement = direction === "backward" ? selection == null ? void 0 : selection.anchorNode : selection == null ? void 0 : selection.focusNode;
614
- const anchorOffset = direction === "backward" ? selection == null ? void 0 : selection.focusOffset : selection == null ? void 0 : selection.anchorOffset;
615
- const focusOffset = direction === "backward" ? selection == null ? void 0 : selection.anchorOffset : selection == null ? void 0 : selection.focusOffset;
616
- if (anchorElement === focusElement && anchorOffset === 0 && (focusElement === currentNode && focusOffset === 1 || focusOffset === ((_j = currentNode.textContent) == null ? void 0 : _j.length))) {
606
+ const anchorElement = direction === "backward" ? selection?.focusNode : selection?.anchorNode;
607
+ const focusElement = direction === "backward" ? selection?.anchorNode : selection?.focusNode;
608
+ const anchorOffset = direction === "backward" ? selection?.focusOffset : selection?.anchorOffset;
609
+ const focusOffset = direction === "backward" ? selection?.anchorOffset : selection?.focusOffset;
610
+ if (anchorElement === focusElement && anchorOffset === 0 && (focusElement === currentNode && focusOffset === 1 || focusOffset === currentNode.textContent?.length)) {
617
611
  event.preventDefault();
618
- const anchorParagraph = anchorElement == null ? void 0 : anchorElement.parentElement;
619
- const focusParagraph = focusElement == null ? void 0 : focusElement.parentElement;
612
+ const anchorParagraph = anchorElement?.parentElement;
613
+ const focusParagraph = focusElement?.parentElement;
620
614
  const childNodes = this.textarea.childNodes;
621
615
  if (anchorParagraph === childNodes.item(0) && focusParagraph === childNodes.item(childNodes.length - 1)) {
622
616
  this.textarea.textContent = "";
@@ -631,7 +625,7 @@ class InputField extends Component {
631
625
  this.recalculateErrors();
632
626
  }, 0);
633
627
  this.toggleErrorsPopperByKeyboard(0);
634
- } else if (focusElement !== anchorElement && focusElement instanceof Text && anchorElement instanceof Text && (focusElement == null ? void 0 : focusElement.textContent) === ((_k = focusElement == null ? void 0 : focusElement.parentNode) == null ? void 0 : _k.textContent) && (anchorElement == null ? void 0 : anchorElement.textContent) === ((_l = anchorElement == null ? void 0 : anchorElement.parentNode) == null ? void 0 : _l.textContent) && anchorOffset === 0 && focusOffset === ((_n = (_m = focusElement == null ? void 0 : focusElement.parentNode) == null ? void 0 : _m.textContent) == null ? void 0 : _n.length)) {
628
+ } else if (focusElement !== anchorElement && focusElement instanceof Text && anchorElement instanceof Text && focusElement?.textContent === focusElement?.parentNode?.textContent && anchorElement?.textContent === anchorElement?.parentNode?.textContent && anchorOffset === 0 && focusOffset === focusElement?.parentNode?.textContent?.length) {
635
629
  event.preventDefault();
636
630
  const paragraphs = Array.from(this.textarea.children);
637
631
  const anchorParagraph = anchorElement.parentElement;
@@ -719,12 +713,12 @@ class InputField extends Component {
719
713
  const {
720
714
  pasteProps
721
715
  } = this.asProps;
722
- const lineProcessing = (pasteProps == null ? void 0 : pasteProps.lineProcessing) ?? ((line) => {
716
+ const lineProcessing = pasteProps?.lineProcessing ?? ((line) => {
723
717
  const trimmedLine = line.trim();
724
718
  return trimmedLine === "" ? line : trimmedLine;
725
719
  });
726
- const skipEmptyLines = (pasteProps == null ? void 0 : pasteProps.skipEmptyLines) ?? this.skipEmptyLines;
727
- const delimiter = (pasteProps == null ? void 0 : pasteProps.delimiter) ?? this.delimiter;
720
+ const skipEmptyLines = pasteProps?.skipEmptyLines ?? this.skipEmptyLines;
721
+ const delimiter = pasteProps?.delimiter ?? this.delimiter;
728
722
  const lines = Array.isArray(value) ? value : value.split(delimiter);
729
723
  lines.forEach((line, index) => {
730
724
  const preparedLine = lineProcessing(line, index, lines.length);
@@ -787,8 +781,7 @@ class InputField extends Component {
787
781
  getValues() {
788
782
  const values = [];
789
783
  this.textarea.childNodes.forEach((node) => {
790
- var _a;
791
- if (((_a = node.textContent) == null ? void 0 : _a.trim()) === "") {
784
+ if (node.textContent?.trim() === "") {
792
785
  values.push("");
793
786
  } else {
794
787
  values.push(node.textContent ?? "");
@@ -841,11 +834,10 @@ class InputField extends Component {
841
834
  }
842
835
  return newState;
843
836
  }, () => {
844
- var _a;
845
837
  this.errorByInteraction = key === "mouseLineIndex" ? "mouse" : "keyboard";
846
838
  const trigger = isInvalidRow ? targetElement : this.textarea;
847
839
  if (this.shouldChangePopperTrigger(trigger)) {
848
- (_a = this.setPopperTrigger) == null ? void 0 : _a.call(this, trigger);
840
+ this.setPopperTrigger?.(trigger);
849
841
  this.forceUpdate();
850
842
  }
851
843
  });
@@ -910,8 +902,8 @@ class InputField extends Component {
910
902
  const range = document.createRange();
911
903
  range.setStart(node, start);
912
904
  range.setEnd(node, end);
913
- selection == null ? void 0 : selection.removeAllRanges();
914
- selection == null ? void 0 : selection.addRange(range);
905
+ selection?.removeAllRanges();
906
+ selection?.addRange(range);
915
907
  const nodeToScroll = node instanceof Text ? node.parentNode : node;
916
908
  if (nodeToScroll instanceof HTMLElement) {
917
909
  nodeToScroll.scrollIntoView({
@@ -923,11 +915,10 @@ class InputField extends Component {
923
915
  }
924
916
  getNodeFromSelection() {
925
917
  const selection = document.getSelection();
926
- const rowNode = (selection == null ? void 0 : selection.focusNode) instanceof Text ? selection.focusNode.parentNode : selection == null ? void 0 : selection.focusNode;
918
+ const rowNode = selection?.focusNode instanceof Text ? selection.focusNode.parentNode : selection?.focusNode;
927
919
  return rowNode ?? null;
928
920
  }
929
921
  handleCursorMovement(currentNode, event) {
930
- var _a;
931
922
  let nextNode = null;
932
923
  switch (event.key) {
933
924
  case "ArrowUp":
@@ -956,8 +947,8 @@ class InputField extends Component {
956
947
  const selection = document.getSelection();
957
948
  const firstNode = nextNode.childNodes.item(0);
958
949
  const nodeToSetSelection = firstNode instanceof Text ? firstNode : nextNode;
959
- const textNode = ((_a = nextNode.textContent) == null ? void 0 : _a.trim()) ?? "";
960
- const currentOffset = (selection == null ? void 0 : selection.focusOffset) ?? 0;
950
+ const textNode = nextNode.textContent?.trim() ?? "";
951
+ const currentOffset = selection?.focusOffset ?? 0;
961
952
  let offset = currentOffset <= textNode.length ? currentOffset : textNode.length;
962
953
  if (event.key === "ArrowLeft") {
963
954
  offset = textNode.length;
@@ -1018,11 +1009,11 @@ class InputField extends Component {
1018
1009
  }
1019
1010
  isRangeSelection() {
1020
1011
  const selection = document.getSelection();
1021
- return (selection == null ? void 0 : selection.focusNode) !== (selection == null ? void 0 : selection.anchorNode) || (selection == null ? void 0 : selection.focusOffset) !== (selection == null ? void 0 : selection.anchorOffset);
1012
+ return selection?.focusNode !== selection?.anchorNode || selection?.focusOffset !== selection?.anchorOffset;
1022
1013
  }
1023
1014
  getSelectionDirection() {
1024
1015
  const selection = document.getSelection();
1025
- if ((selection == null ? void 0 : selection.anchorNode) && (selection == null ? void 0 : selection.focusNode)) {
1016
+ if (selection?.anchorNode && selection?.focusNode) {
1026
1017
  const documentPosition = selection.anchorNode.compareDocumentPosition(selection.focusNode);
1027
1018
  if (documentPosition === 0 && selection.anchorOffset > selection.focusOffset || // if nodes are the same
1028
1019
  documentPosition === Node.DOCUMENT_POSITION_PRECEDING) {
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@semcore/bulk-textarea",
3
3
  "description": "Semrush BulkTextarea Component",
4
- "version": "17.0.0-prerelease.34",
4
+ "version": "17.0.0-prerelease.37",
5
5
  "main": "lib/cjs/index.js",
6
6
  "module": "lib/es6/index.js",
7
7
  "typings": "lib/types/index.d.ts",
@@ -14,10 +14,10 @@
14
14
  "types": "./lib/types/index.d.ts"
15
15
  },
16
16
  "dependencies": {
17
- "@semcore/button": "^17.0.0-prerelease.34",
18
- "@semcore/typography": "^17.0.0-prerelease.34",
19
- "@semcore/counter": "^17.0.0-prerelease.34",
20
- "@semcore/tooltip": "^17.0.0-prerelease.34",
17
+ "@semcore/button": "^17.0.0-prerelease.37",
18
+ "@semcore/typography": "^17.0.0-prerelease.37",
19
+ "@semcore/counter": "^17.0.0-prerelease.37",
20
+ "@semcore/tooltip": "^17.0.0-prerelease.37",
21
21
  "dompurify": "3.2.3"
22
22
  },
23
23
  "peerDependencies": {
@@ -31,10 +31,10 @@
31
31
  },
32
32
  "devDependencies": {
33
33
  "@types/dompurify": "3.2.0",
34
- "@semcore/core": "17.0.0-prerelease.34",
35
- "@semcore/icon": "16.7.2-prerelease.34",
36
- "@semcore/base-components": "17.0.0-prerelease.34",
37
- "@semcore/testing-utils": "1.0.0"
34
+ "@semcore/core": "17.0.0-prerelease.37",
35
+ "@semcore/base-components": "17.0.0-prerelease.37",
36
+ "@semcore/testing-utils": "1.0.0",
37
+ "@semcore/icon": "16.7.2-prerelease.37"
38
38
  },
39
39
  "scripts": {
40
40
  "build": "pnpm semcore-builder --source=ts && pnpm vite build"