@semcore/bulk-textarea 17.2.1-prerelease.0 → 17.2.2-prerelease.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 (46) hide show
  1. package/CHANGELOG.md +13 -1
  2. package/lib/cjs/BulkTextarea.js +18 -12
  3. package/lib/cjs/BulkTextarea.js.map +1 -1
  4. package/lib/cjs/BulkTextarea.types.js.map +1 -1
  5. package/lib/cjs/components/ClearAll.js.map +1 -1
  6. package/lib/cjs/components/Counter.js.map +1 -1
  7. package/lib/cjs/components/ErrorsNavigation.js +5 -2
  8. package/lib/cjs/components/ErrorsNavigation.js.map +1 -1
  9. package/lib/cjs/components/InputField/History.js +46 -0
  10. package/lib/cjs/components/InputField/History.js.map +1 -0
  11. package/lib/cjs/components/InputField/InputField.js +494 -361
  12. package/lib/cjs/components/InputField/InputField.js.map +1 -1
  13. package/lib/cjs/components/InputField/inputField.shadow.css +42 -51
  14. package/lib/cjs/index.js.map +1 -1
  15. package/lib/es6/BulkTextarea.js +18 -12
  16. package/lib/es6/BulkTextarea.js.map +1 -1
  17. package/lib/es6/BulkTextarea.types.js.map +1 -1
  18. package/lib/es6/components/ClearAll.js.map +1 -1
  19. package/lib/es6/components/Counter.js.map +1 -1
  20. package/lib/es6/components/ErrorsNavigation.js +5 -2
  21. package/lib/es6/components/ErrorsNavigation.js.map +1 -1
  22. package/lib/es6/components/InputField/History.js +38 -0
  23. package/lib/es6/components/InputField/History.js.map +1 -0
  24. package/lib/es6/components/InputField/InputField.js +494 -361
  25. package/lib/es6/components/InputField/InputField.js.map +1 -1
  26. package/lib/es6/components/InputField/inputField.shadow.css +42 -51
  27. package/lib/es6/index.js.map +1 -1
  28. package/lib/esm/BulkTextarea.mjs +12 -5
  29. package/lib/esm/components/ErrorsNavigation.mjs +5 -2
  30. package/lib/esm/components/InputField/History.mjs +40 -0
  31. package/lib/esm/components/InputField/InputField.mjs +481 -358
  32. package/lib/esm/components/InputField/inputField.shadow.css +42 -51
  33. package/lib/types/BulkTextarea.d.ts +108 -2
  34. package/lib/types/BulkTextarea.types.d.ts +245 -147
  35. package/lib/types/components/ClearAll.d.ts +4 -6
  36. package/lib/types/components/Counter.d.ts +4 -9
  37. package/lib/types/components/ErrorsNavigation.d.ts +4 -14
  38. package/lib/types/components/InputField/History.d.ts +20 -0
  39. package/lib/types/components/InputField/InputField.d.ts +30 -24
  40. package/lib/types/index.d.ts +1 -2
  41. package/package.json +9 -9
  42. package/lib/cjs/components/InputField/InputField.types.js +0 -2
  43. package/lib/cjs/components/InputField/InputField.types.js.map +0 -1
  44. package/lib/es6/components/InputField/InputField.types.js +0 -2
  45. package/lib/es6/components/InputField/InputField.types.js.map +0 -1
  46. package/lib/types/components/InputField/InputField.types.d.ts +0 -44
@@ -4,25 +4,27 @@ import { assignProps as _assignProps } from "@semcore/core";
4
4
  import { Box } from '@semcore/base-components';
5
5
  import { Component, sstyled, Root } from '@semcore/core';
6
6
  import { extractAriaProps } from '@semcore/core/lib/utils/ariaProps';
7
+ import logger from '@semcore/core/lib/utils/logger';
7
8
  import uniqueIDEnhancement from '@semcore/core/lib/utils/uniqueID';
8
9
  import Tooltip from '@semcore/tooltip';
9
10
  import DOMPurify from 'dompurify';
10
11
  import React from 'react';
12
+ import { History } from './History';
11
13
  /*!__reshadow-styles__:"./inputField.shadow.css"*/
12
- const style = (/*__reshadow_css_start__*/_sstyled.insert(/*__inner_css_start__*/".___SInputField_mc106_gg_>div{box-sizing:initial;outline-color:#0000;border-radius:var(--intergalactic-control-rounded,6px);border-color:var(--intergalactic-border-primary,#000c0829);border-style:solid;border-width:1px;overflow:auto;position:relative;background-color:var(--intergalactic-bg-primary-neutral,oklch(1 0 0));color:var(--intergalactic-text-primary,oklch(.1 .03 137/.899));word-wrap:break-word;word-break:break-word;font-family:inherit}@media (color-gamut:p3){.___SInputField_mc106_gg_>div{border-color:var(--intergalactic-border-primary,oklch(.137 .026 175.7/.161))}}.___SInputField_mc106_gg_>div:empty:before{content:\"1. \" attr(placeholder);color:var(--intergalactic-text-placeholder,oklch(.098 .023 157.4/.457));position:absolute}.___SInputField_mc106_gg_>div:nth-child(2n){color:red;counter-increment:row;margin-bottom:var(--intergalactic-spacing-1x,4px);position:relative;word-break:break-all}.___SInputField_mc106_gg_>div:nth-child(2n):before{content:counter(row) \".\";display:inline-block;white-space:nowrap;text-align:right;color:var(--intergalactic-text-secondary,#00030095);margin-right:var(--intergalactic-spacing-1x,4px)}@media (color-gamut:p3){.___SInputField_mc106_gg_>div:nth-child(2n):before{color:var(--intergalactic-text-secondary,oklch(.088 .026 147.7/.583))}}.___SInputField_mc106_gg_>div>p{counter-increment:row;margin:0 0 var(--intergalactic-spacing-1x,4px) 0;position:relative;word-break:break-all;white-space:pre-wrap;padding:0 var(--intergalactic-spacing-5x,20px) 0 var(--intergalactic-spacing-4x,16px)}.___SInputField_mc106_gg_>div>p:last-of-type{margin-bottom:0}.___SInputField_mc106_gg_>div>p:not(:empty):before{content:counter(row) \".\";display:inline-block;white-space:nowrap;text-align:right;color:var(--intergalactic-text-secondary,#00030095);margin-right:var(--intergalactic-spacing-1x,4px);position:absolute;left:0}@media (color-gamut:p3){.___SInputField_mc106_gg_>div>p:not(:empty):before{color:var(--intergalactic-text-secondary,oklch(.088 .026 147.7/.583))}}.___SInputField_mc106_gg_>div>p[data-over-max-rows=true]{background-color:var(--intergalactic-bg-secondary-critical,#ffebef)}@media (color-gamut:rec2020){.___SInputField_mc106_gg_>div>p[data-over-max-rows=true]{background-color:var(--intergalactic-bg-secondary-critical,oklch(.958 .029 5.7))}}.___SInputField_mc106_gg_>div:has(p:nth-child(n+10))>p{padding-left:var(--intergalactic-spacing-6x,24px)}.___SInputField_mc106_gg_>div:has(p:nth-child(n+10))>p:nth-child(-n+9):before{padding-left:var(--intergalactic-spacing-2x,8px)}.___SInputField_mc106_gg_>div:has(p:nth-child(n+100))>p{padding-left:var(--intergalactic-spacing-8x,32px)}.___SInputField_mc106_gg_>div:has(p:nth-child(n+100))>p:nth-child(-n+9):before{padding-left:var(--intergalactic-spacing-4x,16px)}.___SInputField_mc106_gg_>div:has(p:nth-child(n+100))>p:nth-child(n+10):before{padding-left:var(--intergalactic-spacing-2x,8px)}.___SInputField_mc106_gg_>div:has(p:nth-child(n+100))>p:nth-child(n+100):before{padding-left:0}.___SInputField_mc106_gg_>div:has(p:nth-child(n+1000))>p{padding-left:calc(var(--intergalactic-spacing-10x, 40px) + var(--intergalactic-spacing-1x, 4px))}.___SInputField_mc106_gg_>div:has(p:nth-child(n+1000))>p:nth-child(-n+9):before{padding-left:var(--intergalactic-spacing-6x,24px)}.___SInputField_mc106_gg_>div:has(p:nth-child(n+1000))>p:nth-child(n+10):before{padding-left:var(--intergalactic-spacing-4x,16px)}.___SInputField_mc106_gg_>div:has(p:nth-child(n+1000))>p:nth-child(n+100):before{padding-left:var(--intergalactic-spacing-2x,8px)}.___SInputField_mc106_gg_>div:has(p:nth-child(n+1000))>p:nth-child(n+1000):before{padding-left:0}.___SInputField_mc106_gg_.__showErrors_mc106_gg_>div[aria-invalid]>p[aria-invalid]:after{content:url(\"data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHdpZHRoPSIxNiIgaGVpZ2h0PSIxNiIgZmlsbD0iI2QxMDAyZiIgdmlld0JveD0iMCAwIDE2IDE2Ij48cGF0aCBkPSJNNyA2aDJ2NEg3em0yIDd2LTJIN3YyeiIvPjxwYXRoIGZpbGwtcnVsZT0iZXZlbm9kZCIgZD0iTTYuMTUyIDEuMTcyYy43MTktMS41NjMgMi45NzctMS41NjMgMy42OTYgMGw2LjA0MyAxMy4xNDFjLjM2My43OTEtLjIyNSAxLjY4Ny0xLjEwOSAxLjY4N0gxLjIxOGMtLjg4NCAwLTEuNDcyLS44OTYtMS4xMDktMS42ODd6bTcuMzc0IDEyLjgzN0w4IDEuOTkgMi40NzQgMTQuMDF6IiBjbGlwLXJ1bGU9ImV2ZW5vZGQiLz48L3N2Zz4=\");position:absolute;right:0;top:var(--intergalactic-spacing-05x,2px)}.___SInputField_mc106_gg_._size_m_mc106_gg_>div{padding:var(--intergalactic-spacing-2x,8px) var(--intergalactic-spacing-4x,16px);font-size:var(--intergalactic-fs-200,14px);line-height:var(--intergalactic-lh-200,142%);min-height:calc(var(--minRows_mc106)*20px);max-height:calc((var(--maxRows_mc106) - 1)*(20px + var(--intergalactic-spacing-1x, 4px)) + 18px)}.___SInputField_mc106_gg_._size_m_mc106_gg_>div:empty{padding-left:var(--intergalactic-spacing-8x,32px)}.___SInputField_mc106_gg_._size_m_mc106_gg_>div:empty:before{left:var(--intergalactic-spacing-4x,16px)}.___SInputField_mc106_gg_._size_l_mc106_gg_>div{padding:var(--intergalactic-spacing-3x,12px) var(--intergalactic-spacing-4x,16px);font-size:var(--intergalactic-fs-300,16px);line-height:var(--intergalactic-lh-300,150%);min-height:calc(var(--minRows_mc106)*24px);max-height:calc((var(--maxRows_mc106) - 1)*(24px + var(--intergalactic-spacing-1x, 4px)) + 20px)}.___SInputField_mc106_gg_._size_l_mc106_gg_>div:empty{padding-left:calc(var(--intergalactic-spacing-8x, 32px) + var(--intergalactic-spacing-05x, 2px))}.___SInputField_mc106_gg_._size_l_mc106_gg_>div:empty:before{left:var(--intergalactic-spacing-4x,16px)}.___SInputField_mc106_gg_._state_normal_mc106_gg_:not(.__disabled_mc106_gg_)>div:focus{border-color:var(--intergalactic-border-info-active,oklch(.7 .131 275.2));outline-color:var(--intergalactic-keyboard-focus-outline,#0020dd78);outline-style:solid;outline-width:2px;outline-offset:2px;transition-duration:calc(var(--intergalactic-duration-extra-fast, 100)*1ms);transition-timing-function:ease-in-out;transition-property:outline-color,outline-width,outline-offset;outline-offset:0;transition-property:outline-color,outline-width}@media (color-gamut:p3){.___SInputField_mc106_gg_._state_normal_mc106_gg_:not(.__disabled_mc106_gg_)>div:focus{outline-color:var(--intergalactic-keyboard-focus-outline,oklch(.424 .269 264.2/.469))}}.___SInputField_mc106_gg_._state_valid_mc106_gg_>div{border-color:var(--intergalactic-border-success-active,#00b991)}@media (color-gamut:p3){.___SInputField_mc106_gg_._state_valid_mc106_gg_>div{border-color:var(--intergalactic-border-success-active,oklch(.7 .166 170))}}.___SInputField_mc106_gg_._state_valid_mc106_gg_>div:focus{border-color:var(--intergalactic-border-success-active,#00b991);outline-color:var(--intergalactic-keyboard-focus-outline,#0020dd78);outline-style:solid;outline-width:2px;outline-offset:2px;transition-duration:calc(var(--intergalactic-duration-extra-fast, 100)*1ms);transition-timing-function:ease-in-out;transition-property:outline-color,outline-width,outline-offset;outline-offset:0;transition-property:outline-color,outline-width}@media (color-gamut:p3){.___SInputField_mc106_gg_._state_valid_mc106_gg_>div:focus{border-color:var(--intergalactic-border-success-active,oklch(.7 .166 170));outline-color:var(--intergalactic-keyboard-focus-outline,oklch(.424 .269 264.2/.469))}}@supports (color:oklab(0% 0 0%)){.___SInputField_mc106_gg_._state_valid_mc106_gg_>div:focus{outline-color:var(--intergalactic-keyboard-focus-valid-outline,#00be8e)}@media (color-gamut:p3){.___SInputField_mc106_gg_._state_valid_mc106_gg_>div:focus{outline-color:var(--intergalactic-keyboard-focus-valid-outline,oklch(.711 .146 166.9))}}}.___SInputField_mc106_gg_._state_invalid_mc106_gg_>div{border-color:var(--intergalactic-border-critical-active,#ff6364);background-image:var(--intergalactic-border-critical-pattern,repeating-linear-gradient(315deg,#ff6364 0,#ff6364 1px,#0000 0,#0000 50%));background-size:6px 6px;background-color:var(--intergalactic-bg-primary-neutral,oklch(1 0 0));border-bottom-left-radius:var(--intergalactic-control-rounded,6px);border-top-left-radius:var(--intergalactic-control-rounded,6px);background-repeat:repeat-y}@media (color-gamut:p3){.___SInputField_mc106_gg_._state_invalid_mc106_gg_>div{border-color:var(--intergalactic-border-critical-active,oklch(.7 .21 23));background-image:var(--intergalactic-border-critical-pattern,repeating-linear-gradient(315deg,oklch(.7 .21 23) 0,oklch(.7 .21 23) 1px,#0000 0,#0000 50%))}}.___SInputField_mc106_gg_._state_invalid_mc106_gg_>div:focus{border-color:var(--intergalactic-border-critical-active,#ff6364);outline-color:var(--intergalactic-keyboard-focus-outline,#0020dd78);outline-style:solid;outline-width:2px;outline-offset:2px;transition-duration:calc(var(--intergalactic-duration-extra-fast, 100)*1ms);transition-timing-function:ease-in-out;transition-property:outline-color,outline-width,outline-offset;outline-offset:0;transition-property:outline-color,outline-width}@media (color-gamut:p3){.___SInputField_mc106_gg_._state_invalid_mc106_gg_>div:focus{border-color:var(--intergalactic-border-critical-active,oklch(.7 .21 23));outline-color:var(--intergalactic-keyboard-focus-outline,oklch(.424 .269 264.2/.469))}}@supports (color:oklab(0% 0 0%)){.___SInputField_mc106_gg_._state_invalid_mc106_gg_>div:focus{outline-color:var(--intergalactic-keyboard-focus-invalid-outline,oklch(.628 .257 28.9/.652))}}.___SInputField_mc106_gg_.__readonly_mc106_gg_>div{background-color:var(--intergalactic-bg-secondary-neutral,oklch(.98 .001 180))}.___SInputField_mc106_gg_.__disabled_mc106_gg_>div{opacity:var(--intergalactic-disabled-opacity,.4)}", /*__inner_css_end__*/"mc106_gg_"),
14
+ const style = (/*__reshadow_css_start__*/_sstyled.insert(/*__inner_css_start__*/".___SInputField_q6qxb_gg_>ol{box-sizing:initial;outline-color:#0000;border-radius:var(--intergalactic-control-rounded,6px);border-color:var(--intergalactic-border-primary,#000c0829);border-style:solid;border-width:1px;overflow:auto;position:relative;background-color:var(--intergalactic-bg-primary-neutral,oklch(1 0 0));color:var(--intergalactic-text-primary,oklch(.1 .03 137/.899));word-wrap:break-word;word-break:break-word;font-family:inherit;margin:0;list-style-type:none;counter-reset:list-counter}@media (color-gamut:p3){.___SInputField_q6qxb_gg_>ol{border-color:var(--intergalactic-border-primary,oklch(.137 .026 175.7/.161))}}.___SInputField_q6qxb_gg_>ol:empty:before{content:\"1. \" attr(data-placeholder);color:var(--intergalactic-text-placeholder,oklch(.098 .023 157.4/.457));position:absolute;white-space:pre-wrap;padding-left:var(--intergalactic-spacing-4x,16px);text-indent:calc(var(--intergalactic-spacing-4x, 16px)*-1)}.___SInputField_q6qxb_gg_>ol>li{counter-increment:list-counter;margin:0 0 var(--intergalactic-spacing-1x,4px) 0;position:relative;word-break:break-all;white-space:pre-wrap;padding:0 var(--intergalactic-spacing-5x,20px) 0 var(--intergalactic-spacing-4x,16px)}.___SInputField_q6qxb_gg_>ol>li:last-of-type{margin-bottom:0}.___SInputField_q6qxb_gg_>ol>li:before{content:counter(list-counter) \".\";position:absolute;left:0;white-space:nowrap;display:inline-block;text-align:right;color:var(--intergalactic-text-secondary,#00030095);margin-right:var(--intergalactic-spacing-1x,4px);font-feature-settings:normal;font-variant-numeric:normal;font-weight:300}@media (color-gamut:p3){.___SInputField_q6qxb_gg_>ol>li:before{color:var(--intergalactic-text-secondary,oklch(.088 .026 147.7/.583))}}.___SInputField_q6qxb_gg_>ol>li[data-over-max-rows=true]{background-color:var(--intergalactic-bg-secondary-critical,#ffebef)}@media (color-gamut:rec2020){.___SInputField_q6qxb_gg_>ol>li[data-over-max-rows=true]{background-color:var(--intergalactic-bg-secondary-critical,oklch(.958 .029 5.7))}}.___SInputField_q6qxb_gg_>ol:has(li:nth-child(n+10))>li{padding-left:var(--intergalactic-spacing-6x,24px)}.___SInputField_q6qxb_gg_>ol:has(li:nth-child(n+10))>li:nth-child(-n+9):before{padding-left:var(--intergalactic-spacing-2x,8px)}.___SInputField_q6qxb_gg_>ol:has(li:nth-child(n+100))>li{padding-left:var(--intergalactic-spacing-8x,32px)}.___SInputField_q6qxb_gg_>ol:has(li:nth-child(n+100))>li:nth-child(-n+9):before{padding-left:var(--intergalactic-spacing-4x,16px)}.___SInputField_q6qxb_gg_>ol:has(li:nth-child(n+100))>li:nth-child(n+10):before{padding-left:var(--intergalactic-spacing-2x,8px)}.___SInputField_q6qxb_gg_>ol:has(li:nth-child(n+100))>li:nth-child(n+100):before{padding-left:0}.___SInputField_q6qxb_gg_>ol:has(li:nth-child(n+1000))>li{padding-left:calc(var(--intergalactic-spacing-10x, 40px) + var(--intergalactic-spacing-1x, 4px))}.___SInputField_q6qxb_gg_>ol:has(li:nth-child(n+1000))>li:nth-child(-n+9):before{padding-left:var(--intergalactic-spacing-6x,24px)}.___SInputField_q6qxb_gg_>ol:has(li:nth-child(n+1000))>li:nth-child(n+10):before{padding-left:var(--intergalactic-spacing-4x,16px)}.___SInputField_q6qxb_gg_>ol:has(li:nth-child(n+1000))>li:nth-child(n+100):before{padding-left:var(--intergalactic-spacing-2x,8px)}.___SInputField_q6qxb_gg_>ol:has(li:nth-child(n+1000))>li:nth-child(n+1000):before{padding-left:0}.___SInputField_q6qxb_gg_.__showErrors_q6qxb_gg_>ol[aria-invalid]>li[aria-invalid]:after{content:url(\"data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHdpZHRoPSIxNiIgaGVpZ2h0PSIxNiIgZmlsbD0iI2QxMDAyZiIgdmlld0JveD0iMCAwIDE2IDE2Ij48cGF0aCBkPSJNNyA2aDJ2NEg3em0yIDd2LTJIN3YyeiIvPjxwYXRoIGZpbGwtcnVsZT0iZXZlbm9kZCIgZD0iTTYuMTUyIDEuMTcyYy43MTktMS41NjMgMi45NzctMS41NjMgMy42OTYgMGw2LjA0MyAxMy4xNDFjLjM2My43OTEtLjIyNSAxLjY4Ny0xLjEwOSAxLjY4N0gxLjIxOGMtLjg4NCAwLTEuNDcyLS44OTYtMS4xMDktMS42ODd6bTcuMzc0IDEyLjgzN0w4IDEuOTkgMi40NzQgMTQuMDF6IiBjbGlwLXJ1bGU9ImV2ZW5vZGQiLz48L3N2Zz4=\");position:absolute;right:0;top:var(--intergalactic-spacing-05x,2px)}.___SInputField_q6qxb_gg_._size_m_q6qxb_gg_>ol{padding:var(--intergalactic-spacing-2x,8px) var(--intergalactic-spacing-4x,16px);font-size:var(--intergalactic-fs-200,14px);line-height:var(--intergalactic-lh-200,142%);min-height:calc(var(--minRows_q6qxb)*20px);max-height:calc((var(--maxRows_q6qxb) - 1)*(20px + var(--intergalactic-spacing-1x, 4px)) + 18px)}.___SInputField_q6qxb_gg_._size_m_q6qxb_gg_>ol:empty{padding-left:var(--intergalactic-spacing-8x,32px)}.___SInputField_q6qxb_gg_._size_m_q6qxb_gg_>ol:empty:before{left:calc(var(--intergalactic-spacing-4x, 16px) + 1px)}.___SInputField_q6qxb_gg_._size_l_q6qxb_gg_>ol{padding:var(--intergalactic-spacing-3x,12px) var(--intergalactic-spacing-4x,16px);font-size:var(--intergalactic-fs-300,16px);line-height:var(--intergalactic-lh-300,150%);min-height:calc(var(--minRows_q6qxb)*24px);max-height:calc((var(--maxRows_q6qxb) - 1)*(24px + var(--intergalactic-spacing-1x, 4px)) + 20px)}.___SInputField_q6qxb_gg_._size_l_q6qxb_gg_>ol:empty{padding-left:calc(var(--intergalactic-spacing-8x, 32px) + var(--intergalactic-spacing-05x, 2px))}.___SInputField_q6qxb_gg_._size_l_q6qxb_gg_>ol:empty:before{left:var(--intergalactic-spacing-4x,16px)}.___SInputField_q6qxb_gg_._state_normal_q6qxb_gg_:not(.__disabled_q6qxb_gg_)>ol:focus{border-color:var(--intergalactic-border-info-active,oklch(.7 .131 275.2));outline-color:var(--intergalactic-keyboard-focus-outline,#0020dd78);outline-style:solid;outline-width:2px;outline-offset:2px;transition-duration:calc(var(--intergalactic-duration-extra-fast, 100)*1ms);transition-timing-function:ease-in-out;transition-property:outline-color,outline-width,outline-offset;outline-offset:0;transition-property:outline-color,outline-width}@media (color-gamut:p3){.___SInputField_q6qxb_gg_._state_normal_q6qxb_gg_:not(.__disabled_q6qxb_gg_)>ol:focus{outline-color:var(--intergalactic-keyboard-focus-outline,oklch(.424 .269 264.2/.469))}}.___SInputField_q6qxb_gg_._state_valid_q6qxb_gg_>ol{border-color:var(--intergalactic-border-success-active,#00b991)}@media (color-gamut:p3){.___SInputField_q6qxb_gg_._state_valid_q6qxb_gg_>ol{border-color:var(--intergalactic-border-success-active,oklch(.7 .166 170))}}.___SInputField_q6qxb_gg_._state_valid_q6qxb_gg_>ol:focus{border-color:var(--intergalactic-border-success-active,#00b991);outline-color:var(--intergalactic-keyboard-focus-outline,#0020dd78);outline-style:solid;outline-width:2px;outline-offset:2px;transition-duration:calc(var(--intergalactic-duration-extra-fast, 100)*1ms);transition-timing-function:ease-in-out;transition-property:outline-color,outline-width,outline-offset;outline-offset:0;transition-property:outline-color,outline-width}@media (color-gamut:p3){.___SInputField_q6qxb_gg_._state_valid_q6qxb_gg_>ol:focus{border-color:var(--intergalactic-border-success-active,oklch(.7 .166 170));outline-color:var(--intergalactic-keyboard-focus-outline,oklch(.424 .269 264.2/.469))}}@supports (color:oklab(0% 0 0%)){.___SInputField_q6qxb_gg_._state_valid_q6qxb_gg_>ol:focus{outline-color:var(--intergalactic-keyboard-focus-valid-outline,#00be8e)}@media (color-gamut:p3){.___SInputField_q6qxb_gg_._state_valid_q6qxb_gg_>ol:focus{outline-color:var(--intergalactic-keyboard-focus-valid-outline,oklch(.711 .146 166.9))}}}.___SInputField_q6qxb_gg_._state_invalid_q6qxb_gg_>ol{border-color:var(--intergalactic-border-critical-active,#ff6364);background-image:var(--intergalactic-border-critical-pattern,repeating-linear-gradient(315deg,#ff6364 0,#ff6364 1px,#0000 0,#0000 50%));background-size:6px 6px;background-color:var(--intergalactic-bg-primary-neutral,oklch(1 0 0));border-bottom-left-radius:var(--intergalactic-control-rounded,6px);border-top-left-radius:var(--intergalactic-control-rounded,6px);background-repeat:repeat-y}@media (color-gamut:p3){.___SInputField_q6qxb_gg_._state_invalid_q6qxb_gg_>ol{border-color:var(--intergalactic-border-critical-active,oklch(.7 .21 23));background-image:var(--intergalactic-border-critical-pattern,repeating-linear-gradient(315deg,oklch(.7 .21 23) 0,oklch(.7 .21 23) 1px,#0000 0,#0000 50%))}}.___SInputField_q6qxb_gg_._state_invalid_q6qxb_gg_>ol:focus{border-color:var(--intergalactic-border-critical-active,#ff6364);outline-color:var(--intergalactic-keyboard-focus-outline,#0020dd78);outline-style:solid;outline-width:2px;outline-offset:2px;transition-duration:calc(var(--intergalactic-duration-extra-fast, 100)*1ms);transition-timing-function:ease-in-out;transition-property:outline-color,outline-width,outline-offset;outline-offset:0;transition-property:outline-color,outline-width}@media (color-gamut:p3){.___SInputField_q6qxb_gg_._state_invalid_q6qxb_gg_>ol:focus{border-color:var(--intergalactic-border-critical-active,oklch(.7 .21 23));outline-color:var(--intergalactic-keyboard-focus-outline,oklch(.424 .269 264.2/.469))}}@supports (color:oklab(0% 0 0%)){.___SInputField_q6qxb_gg_._state_invalid_q6qxb_gg_>ol:focus{outline-color:var(--intergalactic-keyboard-focus-invalid-outline,oklch(.628 .257 28.9/.652))}}.___SInputField_q6qxb_gg_.__readonly_q6qxb_gg_>ol{background-color:var(--intergalactic-bg-secondary-neutral,oklch(.98 .001 180))}.___SInputField_q6qxb_gg_.__disabled_q6qxb_gg_>ol{opacity:var(--intergalactic-disabled-opacity,.4)}", /*__inner_css_end__*/"q6qxb_gg_"),
13
15
  /*__reshadow_css_end__*/
14
16
  {
15
- "__SInputField": "___SInputField_mc106_gg_",
16
- "_showErrors": "__showErrors_mc106_gg_",
17
- "_readonly": "__readonly_mc106_gg_",
18
- "_disabled": "__disabled_mc106_gg_",
19
- "_size_m": "_size_m_mc106_gg_",
20
- "--minRows": "--minRows_mc106",
21
- "--maxRows": "--maxRows_mc106",
22
- "_size_l": "_size_l_mc106_gg_",
23
- "_state_normal": "_state_normal_mc106_gg_",
24
- "_state_valid": "_state_valid_mc106_gg_",
25
- "_state_invalid": "_state_invalid_mc106_gg_"
17
+ "__SInputField": "___SInputField_q6qxb_gg_",
18
+ "_showErrors": "__showErrors_q6qxb_gg_",
19
+ "_readonly": "__readonly_q6qxb_gg_",
20
+ "_disabled": "__disabled_q6qxb_gg_",
21
+ "_size_m": "_size_m_q6qxb_gg_",
22
+ "--minRows": "--minRows_q6qxb",
23
+ "--maxRows": "--maxRows_q6qxb",
24
+ "_size_l": "_size_l_q6qxb_gg_",
25
+ "_state_normal": "_state_normal_q6qxb_gg_",
26
+ "_state_valid": "_state_valid_q6qxb_gg_",
27
+ "_state_invalid": "_state_invalid_q6qxb_gg_"
26
28
  });
27
29
  class InputField extends Component {
28
30
  constructor(props) {
@@ -30,6 +32,7 @@ class InputField extends Component {
30
32
  _defineProperty(this, "delimiter", '\n');
31
33
  _defineProperty(this, "skipEmptyLines", true);
32
34
  _defineProperty(this, "emptyLineValue", '');
35
+ _defineProperty(this, "emptyLineValueJs", '\uFEFF');
33
36
  _defineProperty(this, "spaceLineValue", ' ');
34
37
  _defineProperty(this, "containerRef", /*#__PURE__*/React.createRef());
35
38
  _defineProperty(this, "textarea", void 0);
@@ -43,6 +46,7 @@ class InputField extends Component {
43
46
  _defineProperty(this, "isFocusing", false);
44
47
  _defineProperty(this, "linesCountTimeout", 0);
45
48
  _defineProperty(this, "observer", void 0);
49
+ _defineProperty(this, "history", new History());
46
50
  _defineProperty(this, "state", {
47
51
  visibleErrorPopper: false,
48
52
  keyboardLineIndex: -1,
@@ -50,6 +54,8 @@ class InputField extends Component {
50
54
  });
51
55
  this.handlePaste = this.handlePaste.bind(this);
52
56
  this.handleChange = this.handleChange.bind(this);
57
+ this.handleCompositionTextStart = this.handleCompositionTextStart.bind(this);
58
+ this.handleCompositionTextEnd = this.handleCompositionTextEnd.bind(this);
53
59
  this.handleFocus = this.handleFocus.bind(this);
54
60
  this.handleBlur = this.handleBlur.bind(this);
55
61
  this.handleKeyDown = this.handleKeyDown.bind(this);
@@ -59,7 +65,7 @@ class InputField extends Component {
59
65
  this.handleScroll = this.handleScroll.bind(this);
60
66
  this.handleSelectAll = this.handleSelectAll.bind(this);
61
67
  this.textarea = this.createContentEditableElement(props);
62
- this.observer = new MutationObserver((mutationsList, observer) => {
68
+ this.observer = new MutationObserver(mutationsList => {
63
69
  for (const mutation of mutationsList) {
64
70
  if (mutation.type === 'characterData' || mutation.type === 'childList') {
65
71
  this.props.onImmediatelyChange?.(this.getValues(), this.textarea.textContent ?? '');
@@ -76,12 +82,13 @@ class InputField extends Component {
76
82
  }
77
83
  componentDidMount() {
78
84
  const {
85
+ value,
79
86
  autoFocus,
80
87
  disabled
81
88
  } = this.asProps;
82
89
  this.textarea = this.createContentEditableElement(this.asProps);
83
90
  this.containerRef.current?.append(this.textarea);
84
- this.handleValueOutChange();
91
+ this.handleValueOutChange(value);
85
92
  const config = {
86
93
  childList: true,
87
94
  characterData: true,
@@ -111,8 +118,8 @@ class InputField extends Component {
111
118
  } = this.props;
112
119
  if (prevProps.value !== value) {
113
120
  const currentValue = this.getValues().join(this.delimiter);
114
- if (typeof value === 'string' ? value !== currentValue : value.join(this.delimiter) !== currentValue) {
115
- this.handleValueOutChange();
121
+ if (typeof value === 'string' ? value !== currentValue : value?.join(this.delimiter) !== currentValue) {
122
+ this.handleValueOutChange(value);
116
123
  }
117
124
  }
118
125
  if (prevProps.showErrors !== showErrors || prevProps.errors !== errors) {
@@ -122,14 +129,14 @@ class InputField extends Component {
122
129
  errorsMap.set(error.lineIndex, error);
123
130
  });
124
131
  this.textarea.childNodes.forEach((node, index) => {
125
- if (node instanceof HTMLParagraphElement) {
132
+ if (node instanceof HTMLLIElement) {
126
133
  const errorItem = errorsMap.get(index);
127
134
  if (errorItem) {
128
135
  node.setAttribute('aria-invalid', 'true');
129
136
  node.dataset.errormessage = errorItem.errorMessage;
130
137
  } else {
131
138
  node.removeAttribute('aria-invalid');
132
- node.dataset.errormessage = undefined;
139
+ delete node.dataset.errormessage;
133
140
  }
134
141
  }
135
142
  });
@@ -165,26 +172,29 @@ class InputField extends Component {
165
172
  const newValue = lineProcessing(lines[prevState.keyboardLineIndex] ?? '', lines);
166
173
  const newValueTextNode = document.createTextNode(newValue);
167
174
  const paragraph = this.textarea.childNodes.item(prevState.keyboardLineIndex);
168
- if (paragraph instanceof HTMLParagraphElement) {
175
+ if (paragraph instanceof HTMLLIElement) {
169
176
  if (newValue === '') {
170
- paragraph.innerHTML = this.emptyLineValue;
177
+ if (lines.length === 1) {
178
+ this.textarea.textContent = '';
179
+ } else {
180
+ paragraph.innerHTML = this.emptyLineValue;
181
+ }
171
182
  } else {
172
183
  paragraph.replaceChild(newValueTextNode, paragraph.childNodes.item(0));
173
184
  }
185
+ this.validateLine(paragraph);
174
186
  }
175
- this.validateLine(paragraph);
176
- setTimeout(() => {
177
- const newNode = this.textarea.childNodes.item(keyboardLineIndex);
178
- if (newNode) {
179
- this.setErrorIndex(newNode);
180
- }
181
- }, 0); // need this timeout to update errorIndex to the new (usually empty) line
182
- }
183
- if (!showErrors) {
184
- this.recalculateErrors();
185
187
  }
188
+ setTimeout(() => {
189
+ const newNode = this.textarea.childNodes.item(keyboardLineIndex);
190
+ if (newNode) {
191
+ this.setErrorIndex(newNode);
192
+ }
193
+ }, 0); // need this timeout to update errorIndex to the new (usually empty) line
194
+
195
+ this.recalculateErrors();
186
196
  this.recalculateLinesCount();
187
- this.asProps.onChangeLineIndex(keyboardLineIndex);
197
+ this.asProps.onChangeLineIndex();
188
198
  }
189
199
  }
190
200
  componentWillUnmount() {
@@ -230,15 +240,14 @@ class InputField extends Component {
230
240
  };
231
241
  }
232
242
  createContentEditableElement(props) {
233
- const textarea = document.createElement('div');
243
+ const textarea = document.createElement('ol');
234
244
  textarea.setAttribute('contentEditable', props.disabled || props.readonly ? 'false' : 'true');
235
- textarea.setAttribute('role', 'textbox');
236
245
  textarea.setAttribute('classname', 'editable');
237
246
  if (props.id) {
238
247
  textarea.setAttribute('id', props.id);
239
248
  }
240
249
  if (props.placeholder) {
241
- textarea.setAttribute('placeholder', props.placeholder);
250
+ textarea.dataset.placeholder = Array.isArray(props.placeholder) ? props.placeholder.join('\n') : props.placeholder;
242
251
  }
243
252
  const {
244
253
  extractedAriaProps
@@ -261,12 +270,36 @@ class InputField extends Component {
261
270
  }
262
271
  return textarea;
263
272
  }
264
- handleValueOutChange() {
273
+ focus(node, offset) {
274
+ this.textarea.focus();
275
+ if (node && offset !== undefined) {
276
+ const startOffset = Array.isArray(offset) ? offset[0] : offset;
277
+ const endOffset = Array.isArray(offset) ? offset[1] : offset;
278
+ this.setSelection(node, startOffset, endOffset);
279
+ }
280
+ }
281
+ async addLine(value) {
282
+ return new Promise(resolve => {
283
+ const row = document.createElement('li');
284
+ if (value === '') {
285
+ row.innerHTML = this.emptyLineValue;
286
+ } else {
287
+ row.textContent = value;
288
+ }
289
+ const lastRow = this.textarea.lastChild;
290
+ if (lastRow instanceof HTMLLIElement) {
291
+ lastRow.after(row);
292
+ } else {
293
+ this.textarea.append(row);
294
+ }
295
+ resolve(row);
296
+ });
297
+ }
298
+ handleValueOutChange(value) {
265
299
  const {
266
- value,
267
300
  onChangeLinesCount
268
301
  } = this.props;
269
- if (value === '') {
302
+ if (value === '' || value === undefined) {
270
303
  this.textarea.textContent = '';
271
304
  onChangeLinesCount(0);
272
305
  } else {
@@ -324,173 +357,104 @@ class InputField extends Component {
324
357
  }
325
358
  }
326
359
  handlePaste(event) {
360
+ this.history.push(this.createHistoryState());
361
+ this.insertFromPaste(event);
362
+ this.asProps.onPaste();
363
+ }
364
+ handleCompositionTextStart() {
365
+ this.history.push(this.createHistoryState());
366
+ }
367
+ handleCompositionTextEnd(event) {
327
368
  event.preventDefault();
328
- const {
329
- validateOn
330
- } = this.asProps;
331
- const value = event.clipboardData?.getData('text/plain');
332
- const listOfNodes = value ? this.prepareNodesForPaste(value) : [];
333
- if (listOfNodes.length === 0) return;
334
369
  const selection = document.getSelection();
335
- if (selection?.anchorNode && selection?.focusNode) {
336
- const anchorOffset = selection.anchorOffset;
337
- const focusOffset = selection.focusOffset;
338
- const documentPosition = selection.anchorNode.compareDocumentPosition(selection.focusNode);
339
- const direction = this.getSelectionDirection();
340
- const anchorElement = direction === 'forward' ? selection.anchorNode : selection.focusNode;
341
- const focusElement = direction === 'forward' ? selection.focusNode : selection.anchorNode;
342
- const fromOffset = direction === 'forward' ? anchorOffset : focusOffset;
343
- const toOffset = direction === 'forward' ? focusOffset : anchorOffset;
344
- const anchorNode = anchorElement instanceof Text ? anchorElement.parentElement : anchorElement;
345
- const focusNode = focusElement instanceof Text ? focusElement.parentElement : focusElement;
346
- let textNode = null;
347
- let position = null;
348
- if (focusElement === this.textarea) {
349
- this.textarea.replaceChildren(...listOfNodes);
350
- const lastNodeToInsert = listOfNodes[listOfNodes.length - 1];
351
- textNode = lastNodeToInsert.childNodes.item(0);
352
- position = (lastNodeToInsert.textContent ?? '').length;
353
- } else if (focusNode instanceof HTMLParagraphElement && anchorNode instanceof HTMLParagraphElement) {
354
- const before = anchorNode?.textContent?.substring(0, fromOffset) ?? '';
355
- const after = focusNode?.textContent?.substring(toOffset) ?? '';
356
- const noEmptyLineBefore = before.trim() === '' ? '' : before;
357
- const noEmptyLineAfter = after.trim() === '' ? '' : after;
358
- selection.deleteFromDocument();
359
- if (documentPosition !== 0) {
360
- this.textarea.removeChild(focusNode);
361
- }
362
- const firstNodeToInsert = listOfNodes.splice(0, 1)[0];
363
- const lastNodeToInsert = listOfNodes[listOfNodes.length - 1];
364
- anchorNode.textContent = noEmptyLineBefore + (firstNodeToInsert?.textContent ?? '');
365
- anchorNode.after(...listOfNodes);
366
- if (lastNodeToInsert) {
367
- lastNodeToInsert.textContent = (lastNodeToInsert.textContent ?? '') + noEmptyLineAfter;
368
- textNode = lastNodeToInsert.childNodes.item(0);
369
- position = (lastNodeToInsert.textContent ?? '').length;
370
- this.validateLine(lastNodeToInsert);
371
- this.setErrorIndex(lastNodeToInsert);
372
- } else {
373
- position = (anchorNode.textContent ?? '').length;
374
- anchorNode.textContent = (anchorNode.textContent ?? '') + noEmptyLineAfter;
375
- textNode = anchorNode.childNodes.item(0);
376
- this.validateLine(anchorNode);
377
- this.setErrorIndex(anchorNode);
370
+
371
+ // FF and Safari
372
+ if (selection?.focusNode === this.textarea) {
373
+ const nodes = this.textarea.childNodes;
374
+ const liElement = nodes.length === 1 ? nodes.item(0) : nodes.length === 2 ? nodes.item(1) : null;
375
+ if (selection && liElement instanceof HTMLLIElement) {
376
+ const offset = selection.focusOffset;
377
+ liElement.textContent = (liElement.textContent ?? '').split('').filter(s => s !== this.emptyLineValueJs).join('') + event.data;
378
+ selection.setPosition(liElement.firstChild, offset + event.data.length);
379
+ if (nodes.item(0) instanceof HTMLBRElement) {
380
+ this.textarea.removeChild(nodes.item(0));
378
381
  }
379
382
  }
380
- if (textNode instanceof Text) {
381
- this.setSelection(textNode, position ?? 1, position ?? 1);
382
- this.toggleErrorsPopper('keyboardLineIndex', textNode.parentNode);
383
- } else {
384
- // eslint-disable-next-line no-console
385
- console.warn('incorrect child type', textNode, textNode?.parentNode);
383
+ } else {
384
+ const liElement = selection?.focusNode?.parentElement;
385
+ if (selection && liElement instanceof HTMLLIElement) {
386
+ const offset = selection.focusOffset;
387
+ liElement.textContent = (liElement.textContent ?? '').split('').filter(s => s !== this.emptyLineValueJs).join('');
388
+ selection.setPosition(liElement.firstChild, offset);
386
389
  }
387
390
  }
388
- this.recalculateLinesCount();
389
- if (validateOn.includes('paste') || this.asProps.showErrors) {
391
+ setTimeout(() => {
390
392
  this.recalculateErrors();
391
- }
393
+ }, 0);
394
+ this.toggleErrorsPopperByKeyboard(0);
395
+ this.recalculateLinesCount();
392
396
  }
393
397
  handleChange(event) {
394
- const target = event.target;
395
- if (target instanceof HTMLDivElement && event instanceof InputEvent) {
396
- const nodes = this.textarea.childNodes;
397
- const firstNode = nodes.item(0);
398
- const secondNode = nodes.item(1);
399
- const selection = document.getSelection();
400
- if (firstNode instanceof Text) {
401
- const nodeText = firstNode.textContent ?? '';
402
- const firstRow = document.createElement('p');
403
- const text = document.createTextNode(nodeText);
404
- firstRow.append(text);
405
- firstNode.replaceWith(firstRow);
406
- selection?.setPosition(firstRow, nodeText.length);
407
- } else if (!firstNode || firstNode instanceof HTMLBRElement && nodes.length === 1) {
408
- this.textarea.textContent = '';
409
- this.setState({
410
- keyboardLineIndex: 0
411
- });
412
- } else if (firstNode instanceof HTMLParagraphElement && !firstNode.textContent?.trim()) {
413
- if (nodes.length <= 1 || secondNode instanceof HTMLBRElement) {
414
- this.textarea.textContent = '';
415
- this.setState({
416
- keyboardLineIndex: 0
417
- });
418
- }
419
- }
420
- let maxDeep = 10;
421
- let rowNode = selection?.focusNode;
422
- while (rowNode?.parentNode !== this.textarea && maxDeep > 0) {
423
- rowNode = rowNode?.parentNode;
424
- maxDeep--;
425
- }
426
- if (rowNode instanceof HTMLParagraphElement) {
427
- const childNodes = rowNode.childNodes;
428
- const textContent = rowNode.textContent ?? '';
429
- if (childNodes.length > 1) {
430
- const offset = childNodes.item(0).textContent?.length;
431
- rowNode.textContent = textContent;
432
- if (offset) {
433
- this.setSelection(rowNode.childNodes.item(0), offset, offset);
398
+ event.preventDefault();
399
+ const data = event.data ?? '';
400
+ const staticRange = event.getTargetRanges()?.[0];
401
+ if (!staticRange) {
402
+ logger.warn(true, `No staticRange in event: `, event);
403
+ return;
404
+ }
405
+ const [start, end] = this.getRangeTextNodes(staticRange);
406
+ const range = {
407
+ startElement: start[0],
408
+ endElement: end[0],
409
+ startOffset: start[1],
410
+ endOffset: end[1]
411
+ };
412
+ switch (event.inputType) {
413
+ case 'insertFromComposition':
414
+ case 'insertText':
415
+ {
416
+ this.history.push(this.createHistoryState());
417
+ if (this.asProps.linesDelimiters?.includes(data)) {
418
+ this.insertParagraph(range);
419
+ return;
434
420
  }
421
+ this.insertText(data, range);
422
+ break;
435
423
  }
436
- if (textContent.length > 0) {
437
- const firstSymbol = textContent.at(0);
438
- const lastSymbol = textContent.at(textContent.length - 1);
439
- if (firstSymbol === this.getEmptyParagraph().textContent || lastSymbol === this.getEmptyParagraph().textContent) {
440
- let offset = null;
441
- if (firstSymbol === this.getEmptyParagraph().textContent) {
442
- rowNode.textContent = textContent.substring(1);
443
- offset = event.inputType === 'deleteContentBackward' || event.inputType === 'deleteContentForward' ? 0 : rowNode.textContent.length;
444
- } else if (lastSymbol === this.getEmptyParagraph().textContent) {
445
- rowNode.textContent = textContent.substring(0, textContent.length - 1);
446
- offset = rowNode.textContent.length;
447
- }
448
- if (offset) {
449
- this.setSelection(rowNode.childNodes.item(0), offset, offset);
450
- }
451
- }
452
- } else if (childNodes.length === 1 && childNodes[0] instanceof HTMLBRElement) {
453
- rowNode.innerHTML = this.emptyLineValue;
424
+ case 'insertCompositionText':
425
+ case 'deleteCompositionText':
426
+ case 'historyUndo':
427
+ case 'historyRedo':
428
+ case 'insertFromPaste':
429
+ {
430
+ // handled by native events
431
+ return;
454
432
  }
455
- const {
456
- errors,
457
- showErrors
458
- } = this.asProps;
459
- const isValid = this.validateLine(rowNode);
460
- this.recalculateErrors();
461
- this.setErrorIndex(rowNode);
462
- if (!isValid && showErrors) {
463
- this.toggleErrorsPopper('keyboardLineIndex', rowNode, 0);
433
+ case 'insertParagraph':
434
+ {
435
+ this.history.push(this.createHistoryState());
436
+ this.insertParagraph(range);
437
+ break;
464
438
  }
465
- const trigger = !isValid || isValid && errors.length === 1 && errors[0].lineNode === rowNode ? rowNode : this.textarea;
466
- if (showErrors && this.popper?.current?.state.elements.reference !== trigger) {
467
- if (this.shouldChangePopperTrigger(trigger)) {
468
- this.setPopperTrigger?.(trigger);
469
- } else {
470
- this.setState({
471
- visibleErrorPopper: false
472
- });
473
- }
439
+ case 'deleteContentForward':
440
+ case 'deleteContentBackward':
441
+ case 'deleteByCut':
442
+ {
443
+ this.history.push(this.createHistoryState());
444
+ this.deleteText(range, event.inputType);
445
+ break;
474
446
  }
475
- } else if (rowNode === null) {
476
- this.setPopperTrigger?.(this.textarea);
477
- if (selection?.focusNode === this.textarea && this.textarea.childNodes.length > 1) {
478
- const nodeIndex = selection.focusOffset;
479
- const emptyParagraph = this.textarea.childNodes.item(nodeIndex - 1);
480
- const emptyBr = this.textarea.childNodes.item(nodeIndex);
481
- this.textarea.removeChild(emptyBr);
482
- if (emptyParagraph instanceof HTMLParagraphElement) {
483
- emptyParagraph.innerHTML = this.emptyLineValue;
484
- }
485
- if (emptyParagraph) {
486
- this.setSelection(emptyParagraph, 0, 0);
487
- }
488
- } else {
489
- this.setSelection(this.textarea, 0, 0);
447
+ default:
448
+ {
449
+ logger.warn(true, `Unknown input type "${event.inputType}"`, event);
490
450
  }
491
- }
492
- this.recalculateLinesCount();
493
451
  }
452
+ setTimeout(() => {
453
+ this.recalculateErrors();
454
+ }, 0);
455
+ this.toggleErrorsPopperByKeyboard(0);
456
+ this.recalculateLinesCount();
457
+ return;
494
458
  }
495
459
  handleFocus() {
496
460
  this.isFocusing = true;
@@ -517,157 +481,36 @@ class InputField extends Component {
517
481
  const valueToChange = typeof value === 'string' ? this.getValues().join(this.delimiter) : this.getValues();
518
482
  onBlur(valueToChange, event);
519
483
  setTimeout(() => {
520
- this.setState({
521
- keyboardLineIndex: -1
522
- });
484
+ if (document.activeElement !== this.textarea) {
485
+ this.setState({
486
+ keyboardLineIndex: -1
487
+ });
488
+ }
523
489
  }, 200);
524
490
  }
525
491
  handleKeyDown(event) {
526
492
  this.errorByInteraction = 'keyboard';
527
- const {
528
- linesDelimiters
529
- } = this.asProps;
530
493
  const currentNode = this.getNodeFromSelection();
531
- if (event.key === 'Enter' || linesDelimiters?.includes(event.key)) {
532
- if (currentNode === this.textarea) {
533
- event.preventDefault();
534
- }
535
- if (currentNode instanceof HTMLParagraphElement) {
536
- const currentRowValue = currentNode.textContent?.trim();
537
- if (!currentRowValue) {
538
- event.preventDefault();
539
- } else {
540
- event.preventDefault();
541
- const selection = document.getSelection();
542
- const selectionNode = selection?.focusNode instanceof Text ? selection.focusNode : selection?.focusNode?.childNodes.item(0);
543
- const selectionOffset = selection?.focusOffset;
544
- let newRowValue = '';
545
- if (selectionNode instanceof Text && selectionOffset !== undefined && selectionOffset !== selectionNode.textContent?.length) {
546
- newRowValue = selectionNode.textContent?.substring(selectionOffset) ?? this.emptyLineValue;
547
- if (selectionNode.textContent) {
548
- selectionNode.textContent = selectionNode.textContent.substring(0, selectionOffset);
549
- }
550
- }
551
- if (currentNode.textContent?.trim() === '') {
552
- currentNode.innerHTML = this.emptyLineValue;
553
- }
554
- const row = document.createElement('p');
555
- if (newRowValue) {
556
- row.textContent = newRowValue;
557
- } else {
558
- row.innerHTML = this.emptyLineValue;
559
- }
560
- currentNode.after(row);
561
- this.setSelection(row, 0, 0);
562
- this.validateLine(currentNode);
563
- this.validateLine(row);
564
- if (currentNode.previousSibling) {
565
- this.validateLine(currentNode.previousSibling);
566
- }
567
- this.setErrorIndex(row);
568
- if (row.textContent?.trim() !== '') {
569
- this.recalculateLinesCount();
570
- }
571
- setTimeout(() => {
572
- this.recalculateErrors();
573
- }, 0);
574
- this.toggleErrorsPopperByKeyboard(0);
575
- }
576
- }
577
- } else if (event.key === 'ArrowDown' || event.key === 'ArrowUp' || event.key === 'ArrowLeft' || event.key === 'ArrowRight') {
578
- if (currentNode instanceof HTMLParagraphElement) {
494
+ if (event.key === 'Tab' && currentNode instanceof HTMLLIElement) {
495
+ this.validateLine(currentNode);
496
+ }
497
+ if (event.key === 'ArrowDown' || event.key === 'ArrowUp' || event.key === 'ArrowLeft' || event.key === 'ArrowRight') {
498
+ if (currentNode instanceof HTMLLIElement) {
579
499
  this.handleCursorMovement(currentNode, event);
580
500
  }
581
501
  this.toggleErrorsPopperByKeyboard(200);
582
- } else if (this.isDeleteKey(event) && currentNode instanceof HTMLParagraphElement) {
583
- if (currentNode.textContent?.trim() === '' && !this.isRangeSelection()) {
584
- // Backspace on empty row
585
- const prevNode = currentNode.previousSibling;
586
- if (prevNode instanceof HTMLParagraphElement) {
587
- event.preventDefault();
588
- this.textarea.removeChild(currentNode);
589
- this.toggleErrorsPopperByKeyboard(0);
590
- if (prevNode.textContent?.trim() === '' && prevNode.previousSibling === null && this.textarea.childNodes.length === 1) {
591
- this.textarea.textContent = '';
592
- this.setSelection(this.textarea, 0, 0);
593
- } else {
594
- if (prevNode instanceof HTMLParagraphElement) {
595
- const text = prevNode.childNodes.item(0);
596
- const offset = text.textContent?.length ?? 0;
597
- this.setSelection(text, offset, offset);
598
- } else {
599
- // eslint-disable-next-line no-console
600
- console.warn('incorrect prevNode type', prevNode);
601
- }
602
- }
603
- setTimeout(() => {
604
- this.recalculateErrors();
605
- }, 0);
606
- this.toggleErrorsPopperByKeyboard(0);
607
- }
608
- } else if (this.isRangeSelection()) {
609
- const selection = document.getSelection();
610
- const direction = this.getSelectionDirection();
611
- const anchorElement = direction === 'backward' ? selection?.focusNode : selection?.anchorNode;
612
- const focusElement = direction === 'backward' ? selection?.anchorNode : selection?.focusNode;
613
- const anchorOffset = direction === 'backward' ? selection?.focusOffset : selection?.anchorOffset;
614
- const focusOffset = direction === 'backward' ? selection?.anchorOffset : selection?.focusOffset;
615
-
616
- // Backspace on selected full row
617
- if (anchorElement === focusElement && anchorOffset === 0 && (focusElement === currentNode && focusOffset === 1 || focusOffset === currentNode.textContent?.length)) {
618
- event.preventDefault();
619
- const anchorParagraph = anchorElement?.parentElement;
620
- const focusParagraph = focusElement?.parentElement;
621
- const childNodes = this.textarea.childNodes;
622
- if (anchorParagraph === childNodes.item(0) && focusParagraph === childNodes.item(childNodes.length - 1)) {
623
- this.textarea.textContent = '';
624
- this.setSelection(this.textarea, 0, 0);
625
- } else {
626
- currentNode.innerHTML = this.emptyLineValue;
627
- this.validateLine(currentNode);
628
- }
629
- this.setErrorIndex(currentNode);
630
- this.recalculateLinesCount();
631
- setTimeout(() => {
632
- this.recalculateErrors();
633
- }, 0);
634
- this.toggleErrorsPopperByKeyboard(0);
635
- } 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) {
636
- // Backspace on selected few full rows
637
- event.preventDefault();
638
- const paragraphs = Array.from(this.textarea.children);
639
- const anchorParagraph = anchorElement.parentElement;
640
- const focusParagraph = focusElement.parentElement;
641
- const childNodes = this.textarea.childNodes;
642
- if (anchorParagraph === childNodes.item(0) && focusParagraph === childNodes.item(childNodes.length - 1)) {
643
- this.textarea.textContent = '';
644
- this.setSelection(this.textarea, 0, 0);
645
- } else {
646
- let isCleaning = false;
647
- for (const paragraph of paragraphs) {
648
- if (paragraph === anchorParagraph || isCleaning) {
649
- isCleaning = true;
650
- if (paragraph === focusParagraph) {
651
- focusParagraph.innerHTML = this.emptyLineValue;
652
- this.setSelection(focusParagraph, 0, 0);
653
- break;
654
- } else {
655
- this.textarea.removeChild(paragraph);
656
- }
657
- }
658
- }
659
- this.validateLine(currentNode);
660
- }
661
- this.setErrorIndex(currentNode);
662
- this.recalculateLinesCount();
663
- setTimeout(() => {
664
- this.recalculateErrors();
665
- }, 0);
666
- this.toggleErrorsPopperByKeyboard(0);
667
- }
502
+ }
503
+ if (event.key === 'z' && !event.shiftKey && (event.ctrlKey || event.metaKey)) {
504
+ const data = this.history.undo(this.createHistoryState());
505
+ if (data) {
506
+ this.restoreHistoryState(data);
507
+ }
508
+ }
509
+ if ((event.key === 'z' && event.shiftKey || event.key === 'y') && (event.ctrlKey || event.metaKey)) {
510
+ const data = this.history.redo(this.createHistoryState());
511
+ if (data) {
512
+ this.restoreHistoryState(data);
668
513
  }
669
- } else if (event.key === 'z' && (event.ctrlKey || event.metaKey)) {
670
- event.preventDefault();
671
514
  }
672
515
  }
673
516
  render() {
@@ -718,6 +561,303 @@ class InputField extends Component {
718
561
  }, _ref)
719
562
  })));
720
563
  }
564
+ insertText(data, range) {
565
+ const {
566
+ startElement,
567
+ endElement,
568
+ startOffset,
569
+ endOffset
570
+ } = range;
571
+ if (startElement === endElement && startOffset === endOffset && startElement.textContent === this.emptyLineValueJs) {
572
+ startElement.textContent = data;
573
+ this.setSelection(startElement, data.length, data.length);
574
+ } else {
575
+ const resultText = `${startElement.textContent.slice(0, range.startOffset)}${data}${endElement.textContent.slice(range.endOffset)}`;
576
+
577
+ // we need to clear empty value in the line node, because this is unnecessary symbol in the next calculations
578
+ startElement.textContent = startElement.textContent === this.emptyLineValueJs ? resultText.slice(0, -1) : resultText;
579
+ this.setSelection(startElement, range.startOffset + 1, range.startOffset + 1);
580
+ }
581
+ if (startElement.parentElement instanceof HTMLLIElement) {
582
+ this.validateLine(startElement.parentElement);
583
+ this.setErrorIndex(startElement.parentElement);
584
+ }
585
+ if (startElement !== endElement) {
586
+ this.clearNodes(startElement, endElement);
587
+ }
588
+ }
589
+ insertParagraph(range) {
590
+ let startElement = range.startElement;
591
+ const endElement = range.endElement;
592
+ const parent = startElement.parentElement;
593
+ if (parent instanceof HTMLLIElement) {
594
+ const currentLineText = startElement.textContent.slice(0, range.startOffset);
595
+ const newLineText = endElement.textContent.slice(range.endOffset);
596
+ startElement.textContent = currentLineText;
597
+ if (startElement.textContent === '') {
598
+ parent.innerHTML = this.emptyLineValue;
599
+ startElement = parent.childNodes.item(0);
600
+ }
601
+ if (startElement !== endElement && endElement.parentElement) {
602
+ this.clearNodes(startElement, endElement);
603
+ }
604
+ const row = document.createElement('li');
605
+ if (newLineText === '') {
606
+ row.innerHTML = this.emptyLineValue;
607
+ } else {
608
+ row.textContent = newLineText;
609
+ }
610
+ parent.after(row);
611
+ this.setSelection(row, 0, 0);
612
+ this.validateLine(parent);
613
+ if (newLineText !== '') {
614
+ this.validateLine(row);
615
+ }
616
+ this.setErrorIndex(parent);
617
+ } else {
618
+ logger.warn(true, `Not texts in start/end`, {
619
+ startElement,
620
+ endElement
621
+ });
622
+ }
623
+ }
624
+ deleteText(range, inputType) {
625
+ let startElement = range.startElement;
626
+ const endElement = range.endElement;
627
+ const parent = startElement.parentElement;
628
+ if (parent instanceof HTMLLIElement) {
629
+ let resultText = '';
630
+ if (!(range.startElement instanceof HTMLOListElement) && !(range.endElement instanceof HTMLOListElement)) {
631
+ resultText = `${startElement.textContent === this.emptyLineValueJs ? '' : startElement.textContent.slice(0, range.startOffset)}${endElement.textContent === this.emptyLineValueJs ? '' : endElement.textContent.slice(range.endOffset)}`;
632
+ }
633
+ if (resultText === '' && endElement.textContent === this.emptyLineValueJs) {
634
+ const next = parent.nextSibling;
635
+ const prev = parent.previousSibling;
636
+ if (inputType === 'deleteContentForward' && next) {
637
+ this.textarea.removeChild(parent);
638
+ document.getSelection()?.setPosition(next, 0);
639
+ } else if (inputType === 'deleteContentBackward' && prev) {
640
+ if (startElement === endElement) {
641
+ if (prev.textContent === this.emptyLineValueJs) {
642
+ document.getSelection()?.setPosition(prev, 0);
643
+ } else {
644
+ document.getSelection()?.setPosition(prev, 1);
645
+ }
646
+ this.textarea.removeChild(parent);
647
+ } else {
648
+ document.getSelection()?.setPosition(startElement, 0);
649
+ }
650
+ }
651
+ } else {
652
+ if (resultText === '') {
653
+ parent.innerHTML = this.emptyLineValue;
654
+ startElement = parent.childNodes.item(0);
655
+ } else {
656
+ startElement.textContent = resultText;
657
+ }
658
+ document.getSelection()?.setPosition(startElement, range.startElement instanceof HTMLOListElement ? 0 : range.startOffset);
659
+ }
660
+ this.validateLine(parent);
661
+ if (startElement !== endElement && endElement.parentElement) {
662
+ this.clearNodes(startElement, endElement);
663
+ }
664
+ if (resultText === '' && this.textarea.childNodes.length <= 1) {
665
+ this.textarea.innerHTML = '';
666
+ }
667
+ this.setErrorIndex(parent);
668
+ }
669
+ }
670
+ clearNodes(startElement, endElement) {
671
+ const nodes = Array.from(this.textarea.childNodes);
672
+ let forClear = false;
673
+ for (const node of nodes) {
674
+ if (forClear) {
675
+ this.textarea.removeChild(node);
676
+ }
677
+ if (node === (endElement instanceof HTMLLIElement ? endElement : endElement.parentElement)) {
678
+ forClear = false;
679
+ break;
680
+ }
681
+ if (node === startElement.parentElement) {
682
+ forClear = true;
683
+ }
684
+ }
685
+ }
686
+ insertFromPaste(event) {
687
+ event.preventDefault();
688
+ const {
689
+ validateOn
690
+ } = this.asProps;
691
+ const value = event.clipboardData?.getData('text/plain');
692
+ const listOfNodes = value ? this.prepareNodesForPaste(value) : [];
693
+ if (listOfNodes.length === 0) return;
694
+ const selection = document.getSelection();
695
+ if (selection?.anchorNode && selection?.focusNode) {
696
+ const anchorOffset = selection.anchorOffset;
697
+ const focusOffset = selection.focusOffset;
698
+ const documentPosition = selection.anchorNode.compareDocumentPosition(selection.focusNode);
699
+ const direction = this.getSelectionDirection();
700
+ const anchorElement = direction === 'forward' ? selection.anchorNode : selection.focusNode;
701
+ const focusElement = direction === 'forward' ? selection.focusNode : selection.anchorNode;
702
+ const fromOffset = direction === 'forward' ? anchorOffset : focusOffset;
703
+ const toOffset = direction === 'forward' ? focusOffset : anchorOffset;
704
+ const anchorNode = anchorElement instanceof Text ? anchorElement.parentElement : anchorElement;
705
+ const focusNode = focusElement instanceof Text ? focusElement.parentElement : focusElement;
706
+ let textNode = null;
707
+ let position = null;
708
+ if (focusElement === this.textarea) {
709
+ this.textarea.replaceChildren(...listOfNodes);
710
+ const lastNodeToInsert = listOfNodes[listOfNodes.length - 1];
711
+ textNode = lastNodeToInsert.childNodes.item(0);
712
+ position = (lastNodeToInsert.textContent ?? '').length;
713
+ } else if (focusNode instanceof HTMLLIElement && anchorNode instanceof HTMLLIElement) {
714
+ const before = anchorNode?.textContent?.substring(0, fromOffset) ?? '';
715
+ const after = focusNode?.textContent?.substring(toOffset) ?? '';
716
+ const noEmptyLineBefore = before.trim() === '' ? '' : before;
717
+ const noEmptyLineAfter = after.trim() === '' ? '' : after;
718
+ selection.deleteFromDocument();
719
+ if (documentPosition !== 0) {
720
+ this.textarea.removeChild(focusNode);
721
+ }
722
+ const firstNodeToInsert = listOfNodes.splice(0, 1)[0];
723
+ const lastNodeToInsert = listOfNodes[listOfNodes.length - 1];
724
+ anchorNode.textContent = noEmptyLineBefore + (firstNodeToInsert?.textContent ?? '');
725
+ anchorNode.after(...listOfNodes);
726
+ if (lastNodeToInsert) {
727
+ lastNodeToInsert.textContent = (lastNodeToInsert.textContent ?? '') + noEmptyLineAfter;
728
+ textNode = lastNodeToInsert.childNodes.item(0);
729
+ position = (lastNodeToInsert.textContent ?? '').length;
730
+ this.validateLine(lastNodeToInsert);
731
+ this.setErrorIndex(lastNodeToInsert);
732
+ } else {
733
+ position = (anchorNode.textContent ?? '').length;
734
+ anchorNode.textContent = (anchorNode.textContent ?? '') + noEmptyLineAfter;
735
+ textNode = anchorNode.childNodes.item(0);
736
+ this.validateLine(anchorNode);
737
+ this.setErrorIndex(anchorNode);
738
+ }
739
+ }
740
+ if (textNode instanceof Text) {
741
+ this.setSelection(textNode, position ?? 1, position ?? 1);
742
+ this.toggleErrorsPopper('keyboardLineIndex', textNode.parentNode);
743
+ } else {
744
+ // eslint-disable-next-line no-console
745
+ console.warn('incorrect child type', textNode, textNode?.parentNode);
746
+ }
747
+ }
748
+ this.recalculateLinesCount();
749
+ if (validateOn.includes('paste') || this.asProps.showErrors) {
750
+ this.recalculateErrors();
751
+ }
752
+ }
753
+ getRangeTextNodes(range) {
754
+ const start = this.getTextNodeAndOffset(range, 'start');
755
+ const end = this.getTextNodeAndOffset(range, 'end');
756
+ return [start, end];
757
+ }
758
+ getTextNodeAndOffset(range, type) {
759
+ const node = this.getNode(range, type);
760
+ if (node instanceof Text) {
761
+ return [node, type === 'start' ? range.startOffset : range.endOffset];
762
+ }
763
+ if (node instanceof HTMLOListElement) {
764
+ const children = this.textarea.childNodes;
765
+ const item = children.item(type === 'start' ? range.startOffset : Math.max(0, range.endOffset - 1));
766
+ if (!item) {
767
+ const node = document.createElement('li');
768
+ const text = document.createTextNode(this.emptyLineValueJs);
769
+ node.append(text);
770
+ this.textarea.append(node);
771
+ return [text, 0];
772
+ }
773
+ const text = item.firstChild;
774
+ if (text instanceof Text) {
775
+ return [text, type === 'start' ? 0 : text.textContent.trim().length];
776
+ }
777
+ }
778
+ if (node instanceof HTMLLIElement) {
779
+ const text = node.firstChild;
780
+ if (text instanceof Text) {
781
+ return [text, type === 'start' ? range.startOffset : range.endOffset];
782
+ }
783
+ }
784
+ throw new Error(`Unknown node element "${node}"`);
785
+ }
786
+ getNode(range, type) {
787
+ const node = type === 'start' ? range.startContainer : range.endContainer;
788
+ if (node instanceof Text || node instanceof HTMLLIElement || node instanceof HTMLOListElement) {
789
+ return node;
790
+ }
791
+ throw new Error(`Unknown node element "${node}"`);
792
+ }
793
+ createHistoryState() {
794
+ const lines = [];
795
+ const historySelection = {
796
+ startLine: -1,
797
+ startOffset: -1,
798
+ endLine: -1,
799
+ endOffset: -1
800
+ };
801
+ const selection = document.getSelection();
802
+ const direction = this.getSelectionDirection();
803
+ const anchorElement = direction === 'backward' ? selection?.focusNode : selection?.anchorNode;
804
+ const focusElement = direction === 'backward' ? selection?.anchorNode : selection?.focusNode;
805
+ const anchorOffset = direction === 'backward' ? selection?.focusOffset : selection?.anchorOffset;
806
+ const focusOffset = direction === 'backward' ? selection?.anchorOffset : selection?.focusOffset;
807
+ this.textarea.childNodes.forEach((node, index) => {
808
+ if (node.textContent === this.emptyLineValueJs) {
809
+ lines.push('');
810
+ } else {
811
+ lines.push(node.textContent ?? '');
812
+ }
813
+ if ((node === anchorElement || node === anchorElement?.parentElement) && anchorOffset !== undefined) {
814
+ historySelection.startLine = index;
815
+ historySelection.startOffset = anchorOffset;
816
+ }
817
+ // for FF
818
+ if (anchorElement === this.textarea && anchorOffset === index) {
819
+ historySelection.startLine = index;
820
+ historySelection.startOffset = 0;
821
+ }
822
+ if ((node === focusElement || node === focusElement?.parentElement) && focusOffset !== undefined) {
823
+ historySelection.endLine = index;
824
+ historySelection.endOffset = focusOffset;
825
+ }
826
+ // for FF
827
+ if (focusElement === this.textarea && focusOffset === index) {
828
+ historySelection.endLine = index;
829
+ historySelection.endOffset = node.textContent?.length ?? 0;
830
+ }
831
+ });
832
+
833
+ // for FF
834
+ if (focusElement === this.textarea && focusOffset !== undefined && focusOffset === this.textarea.childNodes.length) {
835
+ historySelection.endLine = this.textarea.childNodes.length - 1;
836
+ historySelection.endOffset = this.textarea.lastChild?.textContent?.length ?? 0;
837
+ }
838
+ const historyState = {
839
+ lines,
840
+ selection: historySelection
841
+ };
842
+ return historyState;
843
+ }
844
+ restoreHistoryState(historyState) {
845
+ const isEmptyValue = historyState.lines.length === 1 && historyState.lines[0] === '';
846
+ const newValue = isEmptyValue ? '' : historyState.lines.map(l => l === '' ? this.emptyLineValueJs : l);
847
+ this.handleValueOutChange(newValue);
848
+ const {
849
+ startLine,
850
+ startOffset,
851
+ endLine,
852
+ endOffset
853
+ } = historyState.selection;
854
+ const nodes = this.textarea.childNodes;
855
+ const startNode = nodes.item(startLine)?.firstChild;
856
+ const endNode = nodes.item(endLine)?.firstChild;
857
+ if (startNode && endNode) {
858
+ this.setSelection([startNode, endNode], startOffset, endOffset, 'nearest');
859
+ }
860
+ }
721
861
  prepareNodesForPaste(value) {
722
862
  const listOfNodes = [];
723
863
  const {
@@ -733,8 +873,8 @@ class InputField extends Component {
733
873
  lines.forEach((line, index) => {
734
874
  const preparedLine = lineProcessing(line, index, lines.length);
735
875
  if (preparedLine === '' && skipEmptyLines === false || preparedLine !== '') {
736
- const node = document.createElement('p');
737
- if (preparedLine === '') {
876
+ const node = document.createElement('li');
877
+ if (preparedLine === '' || preparedLine === this.emptyLineValueJs) {
738
878
  node.innerHTML = this.emptyLineValue;
739
879
  } else if (preparedLine.trim() === '') {
740
880
  const allSpacesRegExp = new RegExp('\\s', 'g');
@@ -751,7 +891,7 @@ class InputField extends Component {
751
891
  recalculateErrors() {
752
892
  const errors = [];
753
893
  this.textarea.childNodes.forEach((node, index) => {
754
- if (node instanceof HTMLParagraphElement && node.getAttribute('aria-invalid') === 'true') {
894
+ if (node instanceof HTMLLIElement && node.getAttribute('aria-invalid') === 'true') {
755
895
  const errorItem = {
756
896
  errorMessage: node.dataset.errormessage ?? '',
757
897
  lineNode: node,
@@ -773,9 +913,9 @@ class InputField extends Component {
773
913
  linesCount
774
914
  } = this.asProps;
775
915
  this.textarea.childNodes.forEach(node => {
776
- if (node instanceof HTMLParagraphElement) {
916
+ if (node instanceof HTMLLIElement) {
777
917
  node.dataset.overMaxRows = 'false';
778
- if (node.textContent !== this.getEmptyParagraph().textContent && node.textContent !== '') {
918
+ if (node.textContent !== this.emptyLineValueJs && node.textContent !== '') {
779
919
  lines++;
780
920
  if (lines > maxLines) {
781
921
  node.dataset.overMaxRows = 'true';
@@ -791,7 +931,7 @@ class InputField extends Component {
791
931
  getValues() {
792
932
  const values = [];
793
933
  this.textarea.childNodes.forEach(node => {
794
- if (node.textContent?.trim() === '') {
934
+ if (node.textContent === this.emptyLineValueJs) {
795
935
  values.push('');
796
936
  } else {
797
937
  values.push(node.textContent ?? '');
@@ -818,7 +958,7 @@ class InputField extends Component {
818
958
  }
819
959
  }
820
960
  toggleErrorsPopper(key, target, timer) {
821
- if (target instanceof HTMLDivElement || target instanceof HTMLParagraphElement) {
961
+ if (target instanceof HTMLOListElement || target instanceof HTMLLIElement) {
822
962
  if (this.changeTriggerTimeout) {
823
963
  clearTimeout(this.changeTriggerTimeout);
824
964
  }
@@ -826,7 +966,7 @@ class InputField extends Component {
826
966
  const targetElement = target === this.textarea ? this.getNodeFromSelection() : target;
827
967
  let lineIndex = -1;
828
968
  let isInvalidRow = false;
829
- if (targetElement instanceof HTMLParagraphElement) {
969
+ if (targetElement instanceof HTMLLIElement) {
830
970
  isInvalidRow = targetElement.getAttribute('aria-invalid') === 'true';
831
971
  lineIndex = Array.from(this.textarea.childNodes).indexOf(targetElement);
832
972
  } else if (targetElement === this.textarea) {
@@ -873,7 +1013,7 @@ class InputField extends Component {
873
1013
  const childNodes = this.textarea.childNodes;
874
1014
  const node = error ? error.lineNode ?? childNodes.item(error.lineIndex) : null;
875
1015
  const selection = document.getSelection();
876
- if (selection && node instanceof HTMLParagraphElement) {
1016
+ if (selection && node instanceof HTMLLIElement) {
877
1017
  this.setState({
878
1018
  visibleErrorPopper: false
879
1019
  });
@@ -891,7 +1031,7 @@ class InputField extends Component {
891
1031
  const {
892
1032
  lineValidation
893
1033
  } = this.asProps;
894
- if (lineValidation && node instanceof HTMLElement) {
1034
+ if (lineValidation) {
895
1035
  const {
896
1036
  isValid,
897
1037
  errorMessage
@@ -901,7 +1041,7 @@ class InputField extends Component {
901
1041
  node.dataset.errormessage = errorMessage;
902
1042
  } else {
903
1043
  node.removeAttribute('aria-invalid');
904
- node.dataset.errormessage = undefined;
1044
+ delete node.dataset.errormessage;
905
1045
  }
906
1046
  return isValid;
907
1047
  }
@@ -910,11 +1050,12 @@ class InputField extends Component {
910
1050
  setSelection(node, start, end, scrollType = 'center') {
911
1051
  const selection = document.getSelection();
912
1052
  const range = document.createRange();
913
- range.setStart(node, start);
914
- range.setEnd(node, end);
1053
+ const [startNode, endNode] = Array.isArray(node) ? node : [node, node];
1054
+ range.setStart(startNode, start);
1055
+ range.setEnd(endNode, end);
915
1056
  selection?.removeAllRanges();
916
1057
  selection?.addRange(range);
917
- const nodeToScroll = node instanceof Text ? node.parentNode : node;
1058
+ const nodeToScroll = endNode instanceof Text ? endNode.parentNode : endNode;
918
1059
  if (nodeToScroll instanceof HTMLElement) {
919
1060
  nodeToScroll.scrollIntoView({
920
1061
  block: scrollType,
@@ -941,7 +1082,7 @@ class InputField extends Component {
941
1082
  break;
942
1083
  case 'ArrowLeft':
943
1084
  {
944
- if (currentNode.textContent === this.getEmptyParagraph().textContent) {
1085
+ if (currentNode.textContent === this.emptyLineValueJs) {
945
1086
  event.preventDefault();
946
1087
  nextNode = currentNode.previousSibling;
947
1088
  }
@@ -949,13 +1090,13 @@ class InputField extends Component {
949
1090
  }
950
1091
  case 'ArrowRight':
951
1092
  {
952
- if (currentNode.textContent === this.getEmptyParagraph().textContent) {
1093
+ if (currentNode.textContent === this.emptyLineValueJs) {
953
1094
  event.preventDefault();
954
1095
  nextNode = currentNode.nextSibling;
955
1096
  }
956
1097
  }
957
1098
  }
958
- if (nextNode instanceof HTMLParagraphElement) {
1099
+ if (nextNode instanceof HTMLLIElement) {
959
1100
  const selection = document.getSelection();
960
1101
  const firstNode = nextNode.childNodes.item(0);
961
1102
  const nodeToSetSelection = firstNode instanceof Text ? firstNode : nextNode;
@@ -980,17 +1121,11 @@ class InputField extends Component {
980
1121
  });
981
1122
  this.handlers.errorIndex(errorIndex);
982
1123
  }
983
- isDeleteKey(event) {
984
- return event.key === 'Backspace' || event.key === 'x' && (event.ctrlKey || event.metaKey);
985
- }
986
- getEmptyParagraph() {
987
- const element = document.createElement('p');
988
- element.innerHTML = this.emptyLineValue;
989
- return element;
990
- }
991
1124
  addEventListeners(textarea) {
992
1125
  textarea.addEventListener('paste', this.handlePaste);
993
- textarea.addEventListener('input', this.handleChange);
1126
+ textarea.addEventListener('beforeinput', this.handleChange);
1127
+ textarea.addEventListener('compositionstart', this.handleCompositionTextStart);
1128
+ textarea.addEventListener('compositionend', this.handleCompositionTextEnd);
994
1129
  textarea.addEventListener('focus', this.handleFocus);
995
1130
  textarea.addEventListener('blur', this.handleBlur);
996
1131
  textarea.addEventListener('keydown', this.handleKeyDown);
@@ -1002,7 +1137,9 @@ class InputField extends Component {
1002
1137
  }
1003
1138
  removeEventListeners(textarea) {
1004
1139
  textarea.removeEventListener('paste', this.handlePaste);
1005
- textarea.removeEventListener('input', this.handleChange);
1140
+ textarea.removeEventListener('beforeinput', this.handleChange);
1141
+ textarea.removeEventListener('compositionstart', this.handleCompositionTextStart);
1142
+ textarea.removeEventListener('compositionend', this.handleCompositionTextEnd);
1006
1143
  textarea.removeEventListener('focus', this.handleFocus);
1007
1144
  textarea.removeEventListener('blur', this.handleBlur);
1008
1145
  textarea.removeEventListener('keydown', this.handleKeyDown);
@@ -1021,10 +1158,6 @@ class InputField extends Component {
1021
1158
  }
1022
1159
  }
1023
1160
  }
1024
- isRangeSelection() {
1025
- const selection = document.getSelection();
1026
- return selection?.focusNode !== selection?.anchorNode || selection?.focusOffset !== selection?.anchorOffset;
1027
- }
1028
1161
  getSelectionDirection() {
1029
1162
  const selection = document.getSelection();
1030
1163
  if (selection?.anchorNode && selection?.focusNode) {