@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
@@ -2,31 +2,33 @@ import _defineProperty from "@babel/runtime/helpers/defineProperty";
2
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
+ import logger from "@semcore/core/lib/utils/logger";
5
6
  import uniqueIDEnhancement from "@semcore/core/lib/utils/uniqueID";
6
7
  import Tooltip from "@semcore/tooltip";
7
8
  import DOMPurify from "dompurify";
8
9
  import React from "react";
10
+ import { History } from "./History.mjs";
9
11
  /*!__reshadow-styles__:"./inputField.shadow.css"*/
10
12
  const style = (
11
13
  /*__reshadow_css_start__*/
12
14
  (sstyled.insert(
13
15
  /*__inner_css_start__*/
14
- '.___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)}',
16
+ '.___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)}',
15
17
  /*__inner_css_end__*/
16
- "mc106_gg_"
18
+ "q6qxb_gg_"
17
19
  ), /*__reshadow_css_end__*/
18
20
  {
19
- "__SInputField": "___SInputField_mc106_gg_",
20
- "_showErrors": "__showErrors_mc106_gg_",
21
- "_readonly": "__readonly_mc106_gg_",
22
- "_disabled": "__disabled_mc106_gg_",
23
- "_size_m": "_size_m_mc106_gg_",
24
- "--minRows": "--minRows_mc106",
25
- "--maxRows": "--maxRows_mc106",
26
- "_size_l": "_size_l_mc106_gg_",
27
- "_state_normal": "_state_normal_mc106_gg_",
28
- "_state_valid": "_state_valid_mc106_gg_",
29
- "_state_invalid": "_state_invalid_mc106_gg_"
21
+ "__SInputField": "___SInputField_q6qxb_gg_",
22
+ "_showErrors": "__showErrors_q6qxb_gg_",
23
+ "_readonly": "__readonly_q6qxb_gg_",
24
+ "_disabled": "__disabled_q6qxb_gg_",
25
+ "_size_m": "_size_m_q6qxb_gg_",
26
+ "--minRows": "--minRows_q6qxb",
27
+ "--maxRows": "--maxRows_q6qxb",
28
+ "_size_l": "_size_l_q6qxb_gg_",
29
+ "_state_normal": "_state_normal_q6qxb_gg_",
30
+ "_state_valid": "_state_valid_q6qxb_gg_",
31
+ "_state_invalid": "_state_invalid_q6qxb_gg_"
30
32
  })
31
33
  );
32
34
  class InputField extends Component {
@@ -35,6 +37,7 @@ class InputField extends Component {
35
37
  _defineProperty(this, "delimiter", "\n");
36
38
  _defineProperty(this, "skipEmptyLines", true);
37
39
  _defineProperty(this, "emptyLineValue", "");
40
+ _defineProperty(this, "emptyLineValueJs", "\uFEFF");
38
41
  _defineProperty(this, "spaceLineValue", " ");
39
42
  _defineProperty(this, "containerRef", /* @__PURE__ */ React.createRef());
40
43
  _defineProperty(this, "textarea", void 0);
@@ -48,6 +51,7 @@ class InputField extends Component {
48
51
  _defineProperty(this, "isFocusing", false);
49
52
  _defineProperty(this, "linesCountTimeout", 0);
50
53
  _defineProperty(this, "observer", void 0);
54
+ _defineProperty(this, "history", new History());
51
55
  _defineProperty(this, "state", {
52
56
  visibleErrorPopper: false,
53
57
  keyboardLineIndex: -1,
@@ -55,6 +59,8 @@ class InputField extends Component {
55
59
  });
56
60
  this.handlePaste = this.handlePaste.bind(this);
57
61
  this.handleChange = this.handleChange.bind(this);
62
+ this.handleCompositionTextStart = this.handleCompositionTextStart.bind(this);
63
+ this.handleCompositionTextEnd = this.handleCompositionTextEnd.bind(this);
58
64
  this.handleFocus = this.handleFocus.bind(this);
59
65
  this.handleBlur = this.handleBlur.bind(this);
60
66
  this.handleKeyDown = this.handleKeyDown.bind(this);
@@ -64,7 +70,7 @@ class InputField extends Component {
64
70
  this.handleScroll = this.handleScroll.bind(this);
65
71
  this.handleSelectAll = this.handleSelectAll.bind(this);
66
72
  this.textarea = this.createContentEditableElement(props);
67
- this.observer = new MutationObserver((mutationsList, observer) => {
73
+ this.observer = new MutationObserver((mutationsList) => {
68
74
  for (const mutation of mutationsList) {
69
75
  if (mutation.type === "characterData" || mutation.type === "childList") {
70
76
  this.props.onImmediatelyChange?.(this.getValues(), this.textarea.textContent ?? "");
@@ -81,12 +87,13 @@ class InputField extends Component {
81
87
  }
82
88
  componentDidMount() {
83
89
  const {
90
+ value,
84
91
  autoFocus,
85
92
  disabled
86
93
  } = this.asProps;
87
94
  this.textarea = this.createContentEditableElement(this.asProps);
88
95
  this.containerRef.current?.append(this.textarea);
89
- this.handleValueOutChange();
96
+ this.handleValueOutChange(value);
90
97
  const config = {
91
98
  childList: true,
92
99
  characterData: true,
@@ -113,8 +120,8 @@ class InputField extends Component {
113
120
  } = this.props;
114
121
  if (prevProps.value !== value) {
115
122
  const currentValue = this.getValues().join(this.delimiter);
116
- if (typeof value === "string" ? value !== currentValue : value.join(this.delimiter) !== currentValue) {
117
- this.handleValueOutChange();
123
+ if (typeof value === "string" ? value !== currentValue : value?.join(this.delimiter) !== currentValue) {
124
+ this.handleValueOutChange(value);
118
125
  }
119
126
  }
120
127
  if (prevProps.showErrors !== showErrors || prevProps.errors !== errors) {
@@ -124,14 +131,14 @@ class InputField extends Component {
124
131
  errorsMap.set(error.lineIndex, error);
125
132
  });
126
133
  this.textarea.childNodes.forEach((node, index) => {
127
- if (node instanceof HTMLParagraphElement) {
134
+ if (node instanceof HTMLLIElement) {
128
135
  const errorItem = errorsMap.get(index);
129
136
  if (errorItem) {
130
137
  node.setAttribute("aria-invalid", "true");
131
138
  node.dataset.errormessage = errorItem.errorMessage;
132
139
  } else {
133
140
  node.removeAttribute("aria-invalid");
134
- node.dataset.errormessage = void 0;
141
+ delete node.dataset.errormessage;
135
142
  }
136
143
  }
137
144
  });
@@ -167,26 +174,28 @@ class InputField extends Component {
167
174
  const newValue = lineProcessing(lines[prevState.keyboardLineIndex] ?? "", lines);
168
175
  const newValueTextNode = document.createTextNode(newValue);
169
176
  const paragraph = this.textarea.childNodes.item(prevState.keyboardLineIndex);
170
- if (paragraph instanceof HTMLParagraphElement) {
177
+ if (paragraph instanceof HTMLLIElement) {
171
178
  if (newValue === "") {
172
- paragraph.innerHTML = this.emptyLineValue;
179
+ if (lines.length === 1) {
180
+ this.textarea.textContent = "";
181
+ } else {
182
+ paragraph.innerHTML = this.emptyLineValue;
183
+ }
173
184
  } else {
174
185
  paragraph.replaceChild(newValueTextNode, paragraph.childNodes.item(0));
175
186
  }
187
+ this.validateLine(paragraph);
176
188
  }
177
- this.validateLine(paragraph);
178
- setTimeout(() => {
179
- const newNode = this.textarea.childNodes.item(keyboardLineIndex);
180
- if (newNode) {
181
- this.setErrorIndex(newNode);
182
- }
183
- }, 0);
184
- }
185
- if (!showErrors) {
186
- this.recalculateErrors();
187
189
  }
190
+ setTimeout(() => {
191
+ const newNode = this.textarea.childNodes.item(keyboardLineIndex);
192
+ if (newNode) {
193
+ this.setErrorIndex(newNode);
194
+ }
195
+ }, 0);
196
+ this.recalculateErrors();
188
197
  this.recalculateLinesCount();
189
- this.asProps.onChangeLineIndex(keyboardLineIndex);
198
+ this.asProps.onChangeLineIndex();
190
199
  }
191
200
  }
192
201
  componentWillUnmount() {
@@ -231,15 +240,14 @@ class InputField extends Component {
231
240
  };
232
241
  }
233
242
  createContentEditableElement(props) {
234
- const textarea = document.createElement("div");
243
+ const textarea = document.createElement("ol");
235
244
  textarea.setAttribute("contentEditable", props.disabled || props.readonly ? "false" : "true");
236
- textarea.setAttribute("role", "textbox");
237
245
  textarea.setAttribute("classname", "editable");
238
246
  if (props.id) {
239
247
  textarea.setAttribute("id", props.id);
240
248
  }
241
249
  if (props.placeholder) {
242
- textarea.setAttribute("placeholder", props.placeholder);
250
+ textarea.dataset.placeholder = Array.isArray(props.placeholder) ? props.placeholder.join("\n") : props.placeholder;
243
251
  }
244
252
  const {
245
253
  extractedAriaProps
@@ -262,12 +270,36 @@ class InputField extends Component {
262
270
  }
263
271
  return textarea;
264
272
  }
265
- handleValueOutChange() {
273
+ focus(node, offset) {
274
+ this.textarea.focus();
275
+ if (node && offset !== void 0) {
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) {
266
299
  const {
267
- value,
268
300
  onChangeLinesCount
269
301
  } = this.props;
270
- if (value === "") {
302
+ if (value === "" || value === void 0) {
271
303
  this.textarea.textContent = "";
272
304
  onChangeLinesCount(0);
273
305
  } else {
@@ -324,172 +356,96 @@ class InputField extends Component {
324
356
  }
325
357
  }
326
358
  handlePaste(event) {
359
+ this.history.push(this.createHistoryState());
360
+ this.insertFromPaste(event);
361
+ this.asProps.onPaste();
362
+ }
363
+ handleCompositionTextStart() {
364
+ this.history.push(this.createHistoryState());
365
+ }
366
+ handleCompositionTextEnd(event) {
327
367
  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
368
  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);
369
+ if (selection?.focusNode === this.textarea) {
370
+ const nodes = this.textarea.childNodes;
371
+ const liElement = nodes.length === 1 ? nodes.item(0) : nodes.length === 2 ? nodes.item(1) : null;
372
+ if (selection && liElement instanceof HTMLLIElement) {
373
+ const offset = selection.focusOffset;
374
+ liElement.textContent = (liElement.textContent ?? "").split("").filter((s) => s !== this.emptyLineValueJs).join("") + event.data;
375
+ selection.setPosition(liElement.firstChild, offset + event.data.length);
376
+ if (nodes.item(0) instanceof HTMLBRElement) {
377
+ this.textarea.removeChild(nodes.item(0));
378
378
  }
379
379
  }
380
- if (textNode instanceof Text) {
381
- this.setSelection(textNode, position ?? 1, position ?? 1);
382
- this.toggleErrorsPopper("keyboardLineIndex", textNode.parentNode);
383
- } else {
384
- console.warn("incorrect child type", textNode, textNode?.parentNode);
380
+ } else {
381
+ const liElement = selection?.focusNode?.parentElement;
382
+ if (selection && liElement instanceof HTMLLIElement) {
383
+ const offset = selection.focusOffset;
384
+ liElement.textContent = (liElement.textContent ?? "").split("").filter((s) => s !== this.emptyLineValueJs).join("");
385
+ selection.setPosition(liElement.firstChild, offset);
385
386
  }
386
387
  }
387
- this.recalculateLinesCount();
388
- if (validateOn.includes("paste") || this.asProps.showErrors) {
388
+ setTimeout(() => {
389
389
  this.recalculateErrors();
390
- }
390
+ }, 0);
391
+ this.toggleErrorsPopperByKeyboard(0);
392
+ this.recalculateLinesCount();
391
393
  }
392
394
  handleChange(event) {
393
- const target = event.target;
394
- if (target instanceof HTMLDivElement && event instanceof InputEvent) {
395
- const nodes = this.textarea.childNodes;
396
- const firstNode = nodes.item(0);
397
- const secondNode = nodes.item(1);
398
- const selection = document.getSelection();
399
- if (firstNode instanceof Text) {
400
- const nodeText = firstNode.textContent ?? "";
401
- const firstRow = document.createElement("p");
402
- const text = document.createTextNode(nodeText);
403
- firstRow.append(text);
404
- firstNode.replaceWith(firstRow);
405
- selection?.setPosition(firstRow, nodeText.length);
406
- } else if (!firstNode || firstNode instanceof HTMLBRElement && nodes.length === 1) {
407
- this.textarea.textContent = "";
408
- this.setState({
409
- keyboardLineIndex: 0
410
- });
411
- } else if (firstNode instanceof HTMLParagraphElement && !firstNode.textContent?.trim()) {
412
- if (nodes.length <= 1 || secondNode instanceof HTMLBRElement) {
413
- this.textarea.textContent = "";
414
- this.setState({
415
- keyboardLineIndex: 0
416
- });
395
+ event.preventDefault();
396
+ const data = event.data ?? "";
397
+ const staticRange = event.getTargetRanges()?.[0];
398
+ if (!staticRange) {
399
+ logger.warn(true, `No staticRange in event: `, event);
400
+ return;
401
+ }
402
+ const [start, end] = this.getRangeTextNodes(staticRange);
403
+ const range = {
404
+ startElement: start[0],
405
+ endElement: end[0],
406
+ startOffset: start[1],
407
+ endOffset: end[1]
408
+ };
409
+ switch (event.inputType) {
410
+ case "insertFromComposition":
411
+ case "insertText": {
412
+ this.history.push(this.createHistoryState());
413
+ if (this.asProps.linesDelimiters?.includes(data)) {
414
+ this.insertParagraph(range);
415
+ return;
417
416
  }
417
+ this.insertText(data, range);
418
+ break;
418
419
  }
419
- let maxDeep = 10;
420
- let rowNode = selection?.focusNode;
421
- while (rowNode?.parentNode !== this.textarea && maxDeep > 0) {
422
- rowNode = rowNode?.parentNode;
423
- maxDeep--;
420
+ case "insertCompositionText":
421
+ case "deleteCompositionText":
422
+ case "historyUndo":
423
+ case "historyRedo":
424
+ case "insertFromPaste": {
425
+ return;
424
426
  }
425
- if (rowNode instanceof HTMLParagraphElement) {
426
- const childNodes = rowNode.childNodes;
427
- const textContent = rowNode.textContent ?? "";
428
- if (childNodes.length > 1) {
429
- const offset = childNodes.item(0).textContent?.length;
430
- rowNode.textContent = textContent;
431
- if (offset) {
432
- this.setSelection(rowNode.childNodes.item(0), offset, offset);
433
- }
434
- }
435
- if (textContent.length > 0) {
436
- const firstSymbol = textContent.at(0);
437
- const lastSymbol = textContent.at(textContent.length - 1);
438
- if (firstSymbol === this.getEmptyParagraph().textContent || lastSymbol === this.getEmptyParagraph().textContent) {
439
- let offset = null;
440
- if (firstSymbol === this.getEmptyParagraph().textContent) {
441
- rowNode.textContent = textContent.substring(1);
442
- offset = event.inputType === "deleteContentBackward" || event.inputType === "deleteContentForward" ? 0 : rowNode.textContent.length;
443
- } else if (lastSymbol === this.getEmptyParagraph().textContent) {
444
- rowNode.textContent = textContent.substring(0, textContent.length - 1);
445
- offset = rowNode.textContent.length;
446
- }
447
- if (offset) {
448
- this.setSelection(rowNode.childNodes.item(0), offset, offset);
449
- }
450
- }
451
- } else if (childNodes.length === 1 && childNodes[0] instanceof HTMLBRElement) {
452
- rowNode.innerHTML = this.emptyLineValue;
453
- }
454
- const {
455
- errors,
456
- showErrors
457
- } = this.asProps;
458
- const isValid = this.validateLine(rowNode);
459
- this.recalculateErrors();
460
- this.setErrorIndex(rowNode);
461
- if (!isValid && showErrors) {
462
- this.toggleErrorsPopper("keyboardLineIndex", rowNode, 0);
463
- }
464
- const trigger = !isValid || isValid && errors.length === 1 && errors[0].lineNode === rowNode ? rowNode : this.textarea;
465
- if (showErrors && this.popper?.current?.state.elements.reference !== trigger) {
466
- if (this.shouldChangePopperTrigger(trigger)) {
467
- this.setPopperTrigger?.(trigger);
468
- } else {
469
- this.setState({
470
- visibleErrorPopper: false
471
- });
472
- }
473
- }
474
- } else if (rowNode === null) {
475
- this.setPopperTrigger?.(this.textarea);
476
- if (selection?.focusNode === this.textarea && this.textarea.childNodes.length > 1) {
477
- const nodeIndex = selection.focusOffset;
478
- const emptyParagraph = this.textarea.childNodes.item(nodeIndex - 1);
479
- const emptyBr = this.textarea.childNodes.item(nodeIndex);
480
- this.textarea.removeChild(emptyBr);
481
- if (emptyParagraph instanceof HTMLParagraphElement) {
482
- emptyParagraph.innerHTML = this.emptyLineValue;
483
- }
484
- if (emptyParagraph) {
485
- this.setSelection(emptyParagraph, 0, 0);
486
- }
487
- } else {
488
- this.setSelection(this.textarea, 0, 0);
489
- }
427
+ case "insertParagraph": {
428
+ this.history.push(this.createHistoryState());
429
+ this.insertParagraph(range);
430
+ break;
431
+ }
432
+ case "deleteContentForward":
433
+ case "deleteContentBackward":
434
+ case "deleteByCut": {
435
+ this.history.push(this.createHistoryState());
436
+ this.deleteText(range, event.inputType);
437
+ break;
438
+ }
439
+ default: {
440
+ logger.warn(true, `Unknown input type "${event.inputType}"`, event);
490
441
  }
491
- this.recalculateLinesCount();
492
442
  }
443
+ setTimeout(() => {
444
+ this.recalculateErrors();
445
+ }, 0);
446
+ this.toggleErrorsPopperByKeyboard(0);
447
+ this.recalculateLinesCount();
448
+ return;
493
449
  }
494
450
  handleFocus() {
495
451
  this.isFocusing = true;
@@ -516,152 +472,36 @@ class InputField extends Component {
516
472
  const valueToChange = typeof value === "string" ? this.getValues().join(this.delimiter) : this.getValues();
517
473
  onBlur(valueToChange, event);
518
474
  setTimeout(() => {
519
- this.setState({
520
- keyboardLineIndex: -1
521
- });
475
+ if (document.activeElement !== this.textarea) {
476
+ this.setState({
477
+ keyboardLineIndex: -1
478
+ });
479
+ }
522
480
  }, 200);
523
481
  }
524
482
  handleKeyDown(event) {
525
483
  this.errorByInteraction = "keyboard";
526
- const {
527
- linesDelimiters
528
- } = this.asProps;
529
484
  const currentNode = this.getNodeFromSelection();
530
- if (event.key === "Enter" || linesDelimiters?.includes(event.key)) {
531
- if (currentNode === this.textarea) {
532
- event.preventDefault();
533
- }
534
- if (currentNode instanceof HTMLParagraphElement) {
535
- const currentRowValue = currentNode.textContent?.trim();
536
- if (!currentRowValue) {
537
- event.preventDefault();
538
- } else {
539
- event.preventDefault();
540
- const selection = document.getSelection();
541
- const selectionNode = selection?.focusNode instanceof Text ? selection.focusNode : selection?.focusNode?.childNodes.item(0);
542
- const selectionOffset = selection?.focusOffset;
543
- let newRowValue = "";
544
- if (selectionNode instanceof Text && selectionOffset !== void 0 && selectionOffset !== selectionNode.textContent?.length) {
545
- newRowValue = selectionNode.textContent?.substring(selectionOffset) ?? this.emptyLineValue;
546
- if (selectionNode.textContent) {
547
- selectionNode.textContent = selectionNode.textContent.substring(0, selectionOffset);
548
- }
549
- }
550
- if (currentNode.textContent?.trim() === "") {
551
- currentNode.innerHTML = this.emptyLineValue;
552
- }
553
- const row = document.createElement("p");
554
- if (newRowValue) {
555
- row.textContent = newRowValue;
556
- } else {
557
- row.innerHTML = this.emptyLineValue;
558
- }
559
- currentNode.after(row);
560
- this.setSelection(row, 0, 0);
561
- this.validateLine(currentNode);
562
- this.validateLine(row);
563
- if (currentNode.previousSibling) {
564
- this.validateLine(currentNode.previousSibling);
565
- }
566
- this.setErrorIndex(row);
567
- if (row.textContent?.trim() !== "") {
568
- this.recalculateLinesCount();
569
- }
570
- setTimeout(() => {
571
- this.recalculateErrors();
572
- }, 0);
573
- this.toggleErrorsPopperByKeyboard(0);
574
- }
575
- }
576
- } else if (event.key === "ArrowDown" || event.key === "ArrowUp" || event.key === "ArrowLeft" || event.key === "ArrowRight") {
577
- if (currentNode instanceof HTMLParagraphElement) {
485
+ if (event.key === "Tab" && currentNode instanceof HTMLLIElement) {
486
+ this.validateLine(currentNode);
487
+ }
488
+ if (event.key === "ArrowDown" || event.key === "ArrowUp" || event.key === "ArrowLeft" || event.key === "ArrowRight") {
489
+ if (currentNode instanceof HTMLLIElement) {
578
490
  this.handleCursorMovement(currentNode, event);
579
491
  }
580
492
  this.toggleErrorsPopperByKeyboard(200);
581
- } else if (this.isDeleteKey(event) && currentNode instanceof HTMLParagraphElement) {
582
- if (currentNode.textContent?.trim() === "" && !this.isRangeSelection()) {
583
- const prevNode = currentNode.previousSibling;
584
- if (prevNode instanceof HTMLParagraphElement) {
585
- event.preventDefault();
586
- this.textarea.removeChild(currentNode);
587
- this.toggleErrorsPopperByKeyboard(0);
588
- if (prevNode.textContent?.trim() === "" && prevNode.previousSibling === null && this.textarea.childNodes.length === 1) {
589
- this.textarea.textContent = "";
590
- this.setSelection(this.textarea, 0, 0);
591
- } else {
592
- if (prevNode instanceof HTMLParagraphElement) {
593
- const text = prevNode.childNodes.item(0);
594
- const offset = text.textContent?.length ?? 0;
595
- this.setSelection(text, offset, offset);
596
- } else {
597
- console.warn("incorrect prevNode type", prevNode);
598
- }
599
- }
600
- setTimeout(() => {
601
- this.recalculateErrors();
602
- }, 0);
603
- this.toggleErrorsPopperByKeyboard(0);
604
- }
605
- } else if (this.isRangeSelection()) {
606
- const selection = document.getSelection();
607
- const direction = this.getSelectionDirection();
608
- const anchorElement = direction === "backward" ? selection?.focusNode : selection?.anchorNode;
609
- const focusElement = direction === "backward" ? selection?.anchorNode : selection?.focusNode;
610
- const anchorOffset = direction === "backward" ? selection?.focusOffset : selection?.anchorOffset;
611
- const focusOffset = direction === "backward" ? selection?.anchorOffset : selection?.focusOffset;
612
- if (anchorElement === focusElement && anchorOffset === 0 && (focusElement === currentNode && focusOffset === 1 || focusOffset === currentNode.textContent?.length)) {
613
- event.preventDefault();
614
- const anchorParagraph = anchorElement?.parentElement;
615
- const focusParagraph = focusElement?.parentElement;
616
- const childNodes = this.textarea.childNodes;
617
- if (anchorParagraph === childNodes.item(0) && focusParagraph === childNodes.item(childNodes.length - 1)) {
618
- this.textarea.textContent = "";
619
- this.setSelection(this.textarea, 0, 0);
620
- } else {
621
- currentNode.innerHTML = this.emptyLineValue;
622
- this.validateLine(currentNode);
623
- }
624
- this.setErrorIndex(currentNode);
625
- this.recalculateLinesCount();
626
- setTimeout(() => {
627
- this.recalculateErrors();
628
- }, 0);
629
- this.toggleErrorsPopperByKeyboard(0);
630
- } 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) {
631
- event.preventDefault();
632
- const paragraphs = Array.from(this.textarea.children);
633
- const anchorParagraph = anchorElement.parentElement;
634
- const focusParagraph = focusElement.parentElement;
635
- const childNodes = this.textarea.childNodes;
636
- if (anchorParagraph === childNodes.item(0) && focusParagraph === childNodes.item(childNodes.length - 1)) {
637
- this.textarea.textContent = "";
638
- this.setSelection(this.textarea, 0, 0);
639
- } else {
640
- let isCleaning = false;
641
- for (const paragraph of paragraphs) {
642
- if (paragraph === anchorParagraph || isCleaning) {
643
- isCleaning = true;
644
- if (paragraph === focusParagraph) {
645
- focusParagraph.innerHTML = this.emptyLineValue;
646
- this.setSelection(focusParagraph, 0, 0);
647
- break;
648
- } else {
649
- this.textarea.removeChild(paragraph);
650
- }
651
- }
652
- }
653
- this.validateLine(currentNode);
654
- }
655
- this.setErrorIndex(currentNode);
656
- this.recalculateLinesCount();
657
- setTimeout(() => {
658
- this.recalculateErrors();
659
- }, 0);
660
- this.toggleErrorsPopperByKeyboard(0);
661
- }
493
+ }
494
+ if (event.key === "z" && !event.shiftKey && (event.ctrlKey || event.metaKey)) {
495
+ const data = this.history.undo(this.createHistoryState());
496
+ if (data) {
497
+ this.restoreHistoryState(data);
498
+ }
499
+ }
500
+ if ((event.key === "z" && event.shiftKey || event.key === "y") && (event.ctrlKey || event.metaKey)) {
501
+ const data = this.history.redo(this.createHistoryState());
502
+ if (data) {
503
+ this.restoreHistoryState(data);
662
504
  }
663
- } else if (event.key === "z" && (event.ctrlKey || event.metaKey)) {
664
- event.preventDefault();
665
505
  }
666
506
  }
667
507
  render() {
@@ -710,6 +550,296 @@ class InputField extends Component {
710
550
  }, _ref)
711
551
  })));
712
552
  }
553
+ insertText(data, range) {
554
+ const {
555
+ startElement,
556
+ endElement,
557
+ startOffset,
558
+ endOffset
559
+ } = range;
560
+ if (startElement === endElement && startOffset === endOffset && startElement.textContent === this.emptyLineValueJs) {
561
+ startElement.textContent = data;
562
+ this.setSelection(startElement, data.length, data.length);
563
+ } else {
564
+ const resultText = `${startElement.textContent.slice(0, range.startOffset)}${data}${endElement.textContent.slice(range.endOffset)}`;
565
+ startElement.textContent = startElement.textContent === this.emptyLineValueJs ? resultText.slice(0, -1) : resultText;
566
+ this.setSelection(startElement, range.startOffset + 1, range.startOffset + 1);
567
+ }
568
+ if (startElement.parentElement instanceof HTMLLIElement) {
569
+ this.validateLine(startElement.parentElement);
570
+ this.setErrorIndex(startElement.parentElement);
571
+ }
572
+ if (startElement !== endElement) {
573
+ this.clearNodes(startElement, endElement);
574
+ }
575
+ }
576
+ insertParagraph(range) {
577
+ let startElement = range.startElement;
578
+ const endElement = range.endElement;
579
+ const parent = startElement.parentElement;
580
+ if (parent instanceof HTMLLIElement) {
581
+ const currentLineText = startElement.textContent.slice(0, range.startOffset);
582
+ const newLineText = endElement.textContent.slice(range.endOffset);
583
+ startElement.textContent = currentLineText;
584
+ if (startElement.textContent === "") {
585
+ parent.innerHTML = this.emptyLineValue;
586
+ startElement = parent.childNodes.item(0);
587
+ }
588
+ if (startElement !== endElement && endElement.parentElement) {
589
+ this.clearNodes(startElement, endElement);
590
+ }
591
+ const row = document.createElement("li");
592
+ if (newLineText === "") {
593
+ row.innerHTML = this.emptyLineValue;
594
+ } else {
595
+ row.textContent = newLineText;
596
+ }
597
+ parent.after(row);
598
+ this.setSelection(row, 0, 0);
599
+ this.validateLine(parent);
600
+ if (newLineText !== "") {
601
+ this.validateLine(row);
602
+ }
603
+ this.setErrorIndex(parent);
604
+ } else {
605
+ logger.warn(true, `Not texts in start/end`, {
606
+ startElement,
607
+ endElement
608
+ });
609
+ }
610
+ }
611
+ deleteText(range, inputType) {
612
+ let startElement = range.startElement;
613
+ const endElement = range.endElement;
614
+ const parent = startElement.parentElement;
615
+ if (parent instanceof HTMLLIElement) {
616
+ let resultText = "";
617
+ if (!(range.startElement instanceof HTMLOListElement) && !(range.endElement instanceof HTMLOListElement)) {
618
+ resultText = `${startElement.textContent === this.emptyLineValueJs ? "" : startElement.textContent.slice(0, range.startOffset)}${endElement.textContent === this.emptyLineValueJs ? "" : endElement.textContent.slice(range.endOffset)}`;
619
+ }
620
+ if (resultText === "" && endElement.textContent === this.emptyLineValueJs) {
621
+ const next = parent.nextSibling;
622
+ const prev = parent.previousSibling;
623
+ if (inputType === "deleteContentForward" && next) {
624
+ this.textarea.removeChild(parent);
625
+ document.getSelection()?.setPosition(next, 0);
626
+ } else if (inputType === "deleteContentBackward" && prev) {
627
+ if (startElement === endElement) {
628
+ if (prev.textContent === this.emptyLineValueJs) {
629
+ document.getSelection()?.setPosition(prev, 0);
630
+ } else {
631
+ document.getSelection()?.setPosition(prev, 1);
632
+ }
633
+ this.textarea.removeChild(parent);
634
+ } else {
635
+ document.getSelection()?.setPosition(startElement, 0);
636
+ }
637
+ }
638
+ } else {
639
+ if (resultText === "") {
640
+ parent.innerHTML = this.emptyLineValue;
641
+ startElement = parent.childNodes.item(0);
642
+ } else {
643
+ startElement.textContent = resultText;
644
+ }
645
+ document.getSelection()?.setPosition(startElement, range.startElement instanceof HTMLOListElement ? 0 : range.startOffset);
646
+ }
647
+ this.validateLine(parent);
648
+ if (startElement !== endElement && endElement.parentElement) {
649
+ this.clearNodes(startElement, endElement);
650
+ }
651
+ if (resultText === "" && this.textarea.childNodes.length <= 1) {
652
+ this.textarea.innerHTML = "";
653
+ }
654
+ this.setErrorIndex(parent);
655
+ }
656
+ }
657
+ clearNodes(startElement, endElement) {
658
+ const nodes = Array.from(this.textarea.childNodes);
659
+ let forClear = false;
660
+ for (const node of nodes) {
661
+ if (forClear) {
662
+ this.textarea.removeChild(node);
663
+ }
664
+ if (node === (endElement instanceof HTMLLIElement ? endElement : endElement.parentElement)) {
665
+ forClear = false;
666
+ break;
667
+ }
668
+ if (node === startElement.parentElement) {
669
+ forClear = true;
670
+ }
671
+ }
672
+ }
673
+ insertFromPaste(event) {
674
+ event.preventDefault();
675
+ const {
676
+ validateOn
677
+ } = this.asProps;
678
+ const value = event.clipboardData?.getData("text/plain");
679
+ const listOfNodes = value ? this.prepareNodesForPaste(value) : [];
680
+ if (listOfNodes.length === 0) return;
681
+ const selection = document.getSelection();
682
+ if (selection?.anchorNode && selection?.focusNode) {
683
+ const anchorOffset = selection.anchorOffset;
684
+ const focusOffset = selection.focusOffset;
685
+ const documentPosition = selection.anchorNode.compareDocumentPosition(selection.focusNode);
686
+ const direction = this.getSelectionDirection();
687
+ const anchorElement = direction === "forward" ? selection.anchorNode : selection.focusNode;
688
+ const focusElement = direction === "forward" ? selection.focusNode : selection.anchorNode;
689
+ const fromOffset = direction === "forward" ? anchorOffset : focusOffset;
690
+ const toOffset = direction === "forward" ? focusOffset : anchorOffset;
691
+ const anchorNode = anchorElement instanceof Text ? anchorElement.parentElement : anchorElement;
692
+ const focusNode = focusElement instanceof Text ? focusElement.parentElement : focusElement;
693
+ let textNode = null;
694
+ let position = null;
695
+ if (focusElement === this.textarea) {
696
+ this.textarea.replaceChildren(...listOfNodes);
697
+ const lastNodeToInsert = listOfNodes[listOfNodes.length - 1];
698
+ textNode = lastNodeToInsert.childNodes.item(0);
699
+ position = (lastNodeToInsert.textContent ?? "").length;
700
+ } else if (focusNode instanceof HTMLLIElement && anchorNode instanceof HTMLLIElement) {
701
+ const before = anchorNode?.textContent?.substring(0, fromOffset) ?? "";
702
+ const after = focusNode?.textContent?.substring(toOffset) ?? "";
703
+ const noEmptyLineBefore = before.trim() === "" ? "" : before;
704
+ const noEmptyLineAfter = after.trim() === "" ? "" : after;
705
+ selection.deleteFromDocument();
706
+ if (documentPosition !== 0) {
707
+ this.textarea.removeChild(focusNode);
708
+ }
709
+ const firstNodeToInsert = listOfNodes.splice(0, 1)[0];
710
+ const lastNodeToInsert = listOfNodes[listOfNodes.length - 1];
711
+ anchorNode.textContent = noEmptyLineBefore + (firstNodeToInsert?.textContent ?? "");
712
+ anchorNode.after(...listOfNodes);
713
+ if (lastNodeToInsert) {
714
+ lastNodeToInsert.textContent = (lastNodeToInsert.textContent ?? "") + noEmptyLineAfter;
715
+ textNode = lastNodeToInsert.childNodes.item(0);
716
+ position = (lastNodeToInsert.textContent ?? "").length;
717
+ this.validateLine(lastNodeToInsert);
718
+ this.setErrorIndex(lastNodeToInsert);
719
+ } else {
720
+ position = (anchorNode.textContent ?? "").length;
721
+ anchorNode.textContent = (anchorNode.textContent ?? "") + noEmptyLineAfter;
722
+ textNode = anchorNode.childNodes.item(0);
723
+ this.validateLine(anchorNode);
724
+ this.setErrorIndex(anchorNode);
725
+ }
726
+ }
727
+ if (textNode instanceof Text) {
728
+ this.setSelection(textNode, position ?? 1, position ?? 1);
729
+ this.toggleErrorsPopper("keyboardLineIndex", textNode.parentNode);
730
+ } else {
731
+ console.warn("incorrect child type", textNode, textNode?.parentNode);
732
+ }
733
+ }
734
+ this.recalculateLinesCount();
735
+ if (validateOn.includes("paste") || this.asProps.showErrors) {
736
+ this.recalculateErrors();
737
+ }
738
+ }
739
+ getRangeTextNodes(range) {
740
+ const start = this.getTextNodeAndOffset(range, "start");
741
+ const end = this.getTextNodeAndOffset(range, "end");
742
+ return [start, end];
743
+ }
744
+ getTextNodeAndOffset(range, type) {
745
+ const node = this.getNode(range, type);
746
+ if (node instanceof Text) {
747
+ return [node, type === "start" ? range.startOffset : range.endOffset];
748
+ }
749
+ if (node instanceof HTMLOListElement) {
750
+ const children = this.textarea.childNodes;
751
+ const item = children.item(type === "start" ? range.startOffset : Math.max(0, range.endOffset - 1));
752
+ if (!item) {
753
+ const node2 = document.createElement("li");
754
+ const text2 = document.createTextNode(this.emptyLineValueJs);
755
+ node2.append(text2);
756
+ this.textarea.append(node2);
757
+ return [text2, 0];
758
+ }
759
+ const text = item.firstChild;
760
+ if (text instanceof Text) {
761
+ return [text, type === "start" ? 0 : text.textContent.trim().length];
762
+ }
763
+ }
764
+ if (node instanceof HTMLLIElement) {
765
+ const text = node.firstChild;
766
+ if (text instanceof Text) {
767
+ return [text, type === "start" ? range.startOffset : range.endOffset];
768
+ }
769
+ }
770
+ throw new Error(`Unknown node element "${node}"`);
771
+ }
772
+ getNode(range, type) {
773
+ const node = type === "start" ? range.startContainer : range.endContainer;
774
+ if (node instanceof Text || node instanceof HTMLLIElement || node instanceof HTMLOListElement) {
775
+ return node;
776
+ }
777
+ throw new Error(`Unknown node element "${node}"`);
778
+ }
779
+ createHistoryState() {
780
+ const lines = [];
781
+ const historySelection = {
782
+ startLine: -1,
783
+ startOffset: -1,
784
+ endLine: -1,
785
+ endOffset: -1
786
+ };
787
+ const selection = document.getSelection();
788
+ const direction = this.getSelectionDirection();
789
+ const anchorElement = direction === "backward" ? selection?.focusNode : selection?.anchorNode;
790
+ const focusElement = direction === "backward" ? selection?.anchorNode : selection?.focusNode;
791
+ const anchorOffset = direction === "backward" ? selection?.focusOffset : selection?.anchorOffset;
792
+ const focusOffset = direction === "backward" ? selection?.anchorOffset : selection?.focusOffset;
793
+ this.textarea.childNodes.forEach((node, index) => {
794
+ if (node.textContent === this.emptyLineValueJs) {
795
+ lines.push("");
796
+ } else {
797
+ lines.push(node.textContent ?? "");
798
+ }
799
+ if ((node === anchorElement || node === anchorElement?.parentElement) && anchorOffset !== void 0) {
800
+ historySelection.startLine = index;
801
+ historySelection.startOffset = anchorOffset;
802
+ }
803
+ if (anchorElement === this.textarea && anchorOffset === index) {
804
+ historySelection.startLine = index;
805
+ historySelection.startOffset = 0;
806
+ }
807
+ if ((node === focusElement || node === focusElement?.parentElement) && focusOffset !== void 0) {
808
+ historySelection.endLine = index;
809
+ historySelection.endOffset = focusOffset;
810
+ }
811
+ if (focusElement === this.textarea && focusOffset === index) {
812
+ historySelection.endLine = index;
813
+ historySelection.endOffset = node.textContent?.length ?? 0;
814
+ }
815
+ });
816
+ if (focusElement === this.textarea && focusOffset !== void 0 && focusOffset === this.textarea.childNodes.length) {
817
+ historySelection.endLine = this.textarea.childNodes.length - 1;
818
+ historySelection.endOffset = this.textarea.lastChild?.textContent?.length ?? 0;
819
+ }
820
+ const historyState = {
821
+ lines,
822
+ selection: historySelection
823
+ };
824
+ return historyState;
825
+ }
826
+ restoreHistoryState(historyState) {
827
+ const isEmptyValue = historyState.lines.length === 1 && historyState.lines[0] === "";
828
+ const newValue = isEmptyValue ? "" : historyState.lines.map((l) => l === "" ? this.emptyLineValueJs : l);
829
+ this.handleValueOutChange(newValue);
830
+ const {
831
+ startLine,
832
+ startOffset,
833
+ endLine,
834
+ endOffset
835
+ } = historyState.selection;
836
+ const nodes = this.textarea.childNodes;
837
+ const startNode = nodes.item(startLine)?.firstChild;
838
+ const endNode = nodes.item(endLine)?.firstChild;
839
+ if (startNode && endNode) {
840
+ this.setSelection([startNode, endNode], startOffset, endOffset, "nearest");
841
+ }
842
+ }
713
843
  prepareNodesForPaste(value) {
714
844
  const listOfNodes = [];
715
845
  const {
@@ -725,8 +855,8 @@ class InputField extends Component {
725
855
  lines.forEach((line, index) => {
726
856
  const preparedLine = lineProcessing(line, index, lines.length);
727
857
  if (preparedLine === "" && skipEmptyLines === false || preparedLine !== "") {
728
- const node = document.createElement("p");
729
- if (preparedLine === "") {
858
+ const node = document.createElement("li");
859
+ if (preparedLine === "" || preparedLine === this.emptyLineValueJs) {
730
860
  node.innerHTML = this.emptyLineValue;
731
861
  } else if (preparedLine.trim() === "") {
732
862
  const allSpacesRegExp = new RegExp("\\s", "g");
@@ -743,7 +873,7 @@ class InputField extends Component {
743
873
  recalculateErrors() {
744
874
  const errors = [];
745
875
  this.textarea.childNodes.forEach((node, index) => {
746
- if (node instanceof HTMLParagraphElement && node.getAttribute("aria-invalid") === "true") {
876
+ if (node instanceof HTMLLIElement && node.getAttribute("aria-invalid") === "true") {
747
877
  const errorItem = {
748
878
  errorMessage: node.dataset.errormessage ?? "",
749
879
  lineNode: node,
@@ -765,9 +895,9 @@ class InputField extends Component {
765
895
  linesCount
766
896
  } = this.asProps;
767
897
  this.textarea.childNodes.forEach((node) => {
768
- if (node instanceof HTMLParagraphElement) {
898
+ if (node instanceof HTMLLIElement) {
769
899
  node.dataset.overMaxRows = "false";
770
- if (node.textContent !== this.getEmptyParagraph().textContent && node.textContent !== "") {
900
+ if (node.textContent !== this.emptyLineValueJs && node.textContent !== "") {
771
901
  lines++;
772
902
  if (lines > maxLines) {
773
903
  node.dataset.overMaxRows = "true";
@@ -783,7 +913,7 @@ class InputField extends Component {
783
913
  getValues() {
784
914
  const values = [];
785
915
  this.textarea.childNodes.forEach((node) => {
786
- if (node.textContent?.trim() === "") {
916
+ if (node.textContent === this.emptyLineValueJs) {
787
917
  values.push("");
788
918
  } else {
789
919
  values.push(node.textContent ?? "");
@@ -810,7 +940,7 @@ class InputField extends Component {
810
940
  }
811
941
  }
812
942
  toggleErrorsPopper(key, target, timer) {
813
- if (target instanceof HTMLDivElement || target instanceof HTMLParagraphElement) {
943
+ if (target instanceof HTMLOListElement || target instanceof HTMLLIElement) {
814
944
  if (this.changeTriggerTimeout) {
815
945
  clearTimeout(this.changeTriggerTimeout);
816
946
  }
@@ -818,7 +948,7 @@ class InputField extends Component {
818
948
  const targetElement = target === this.textarea ? this.getNodeFromSelection() : target;
819
949
  let lineIndex = -1;
820
950
  let isInvalidRow = false;
821
- if (targetElement instanceof HTMLParagraphElement) {
951
+ if (targetElement instanceof HTMLLIElement) {
822
952
  isInvalidRow = targetElement.getAttribute("aria-invalid") === "true";
823
953
  lineIndex = Array.from(this.textarea.childNodes).indexOf(targetElement);
824
954
  } else if (targetElement === this.textarea) {
@@ -865,7 +995,7 @@ class InputField extends Component {
865
995
  const childNodes = this.textarea.childNodes;
866
996
  const node = error ? error.lineNode ?? childNodes.item(error.lineIndex) : null;
867
997
  const selection = document.getSelection();
868
- if (selection && node instanceof HTMLParagraphElement) {
998
+ if (selection && node instanceof HTMLLIElement) {
869
999
  this.setState({
870
1000
  visibleErrorPopper: false
871
1001
  });
@@ -883,7 +1013,7 @@ class InputField extends Component {
883
1013
  const {
884
1014
  lineValidation
885
1015
  } = this.asProps;
886
- if (lineValidation && node instanceof HTMLElement) {
1016
+ if (lineValidation) {
887
1017
  const {
888
1018
  isValid,
889
1019
  errorMessage
@@ -893,7 +1023,7 @@ class InputField extends Component {
893
1023
  node.dataset.errormessage = errorMessage;
894
1024
  } else {
895
1025
  node.removeAttribute("aria-invalid");
896
- node.dataset.errormessage = void 0;
1026
+ delete node.dataset.errormessage;
897
1027
  }
898
1028
  return isValid;
899
1029
  }
@@ -902,11 +1032,12 @@ class InputField extends Component {
902
1032
  setSelection(node, start, end, scrollType = "center") {
903
1033
  const selection = document.getSelection();
904
1034
  const range = document.createRange();
905
- range.setStart(node, start);
906
- range.setEnd(node, end);
1035
+ const [startNode, endNode] = Array.isArray(node) ? node : [node, node];
1036
+ range.setStart(startNode, start);
1037
+ range.setEnd(endNode, end);
907
1038
  selection?.removeAllRanges();
908
1039
  selection?.addRange(range);
909
- const nodeToScroll = node instanceof Text ? node.parentNode : node;
1040
+ const nodeToScroll = endNode instanceof Text ? endNode.parentNode : endNode;
910
1041
  if (nodeToScroll instanceof HTMLElement) {
911
1042
  nodeToScroll.scrollIntoView({
912
1043
  block: scrollType,
@@ -932,20 +1063,20 @@ class InputField extends Component {
932
1063
  nextNode = currentNode.nextSibling;
933
1064
  break;
934
1065
  case "ArrowLeft": {
935
- if (currentNode.textContent === this.getEmptyParagraph().textContent) {
1066
+ if (currentNode.textContent === this.emptyLineValueJs) {
936
1067
  event.preventDefault();
937
1068
  nextNode = currentNode.previousSibling;
938
1069
  }
939
1070
  break;
940
1071
  }
941
1072
  case "ArrowRight": {
942
- if (currentNode.textContent === this.getEmptyParagraph().textContent) {
1073
+ if (currentNode.textContent === this.emptyLineValueJs) {
943
1074
  event.preventDefault();
944
1075
  nextNode = currentNode.nextSibling;
945
1076
  }
946
1077
  }
947
1078
  }
948
- if (nextNode instanceof HTMLParagraphElement) {
1079
+ if (nextNode instanceof HTMLLIElement) {
949
1080
  const selection = document.getSelection();
950
1081
  const firstNode = nextNode.childNodes.item(0);
951
1082
  const nodeToSetSelection = firstNode instanceof Text ? firstNode : nextNode;
@@ -968,17 +1099,11 @@ class InputField extends Component {
968
1099
  });
969
1100
  this.handlers.errorIndex(errorIndex);
970
1101
  }
971
- isDeleteKey(event) {
972
- return event.key === "Backspace" || event.key === "x" && (event.ctrlKey || event.metaKey);
973
- }
974
- getEmptyParagraph() {
975
- const element = document.createElement("p");
976
- element.innerHTML = this.emptyLineValue;
977
- return element;
978
- }
979
1102
  addEventListeners(textarea) {
980
1103
  textarea.addEventListener("paste", this.handlePaste);
981
- textarea.addEventListener("input", this.handleChange);
1104
+ textarea.addEventListener("beforeinput", this.handleChange);
1105
+ textarea.addEventListener("compositionstart", this.handleCompositionTextStart);
1106
+ textarea.addEventListener("compositionend", this.handleCompositionTextEnd);
982
1107
  textarea.addEventListener("focus", this.handleFocus);
983
1108
  textarea.addEventListener("blur", this.handleBlur);
984
1109
  textarea.addEventListener("keydown", this.handleKeyDown);
@@ -990,7 +1115,9 @@ class InputField extends Component {
990
1115
  }
991
1116
  removeEventListeners(textarea) {
992
1117
  textarea.removeEventListener("paste", this.handlePaste);
993
- textarea.removeEventListener("input", this.handleChange);
1118
+ textarea.removeEventListener("beforeinput", this.handleChange);
1119
+ textarea.removeEventListener("compositionstart", this.handleCompositionTextStart);
1120
+ textarea.removeEventListener("compositionend", this.handleCompositionTextEnd);
994
1121
  textarea.removeEventListener("focus", this.handleFocus);
995
1122
  textarea.removeEventListener("blur", this.handleBlur);
996
1123
  textarea.removeEventListener("keydown", this.handleKeyDown);
@@ -1009,10 +1136,6 @@ class InputField extends Component {
1009
1136
  }
1010
1137
  }
1011
1138
  }
1012
- isRangeSelection() {
1013
- const selection = document.getSelection();
1014
- return selection?.focusNode !== selection?.anchorNode || selection?.focusOffset !== selection?.anchorOffset;
1015
- }
1016
1139
  getSelectionDirection() {
1017
1140
  const selection = document.getSelection();
1018
1141
  if (selection?.anchorNode && selection?.focusNode) {