@salutejs/plasma-new-hope 0.336.0-canary.2205.17476690989.0 → 0.336.0-canary.2210.17487143389.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 (261) hide show
  1. package/cjs/components/CodeField/CodeField.css +7 -6
  2. package/cjs/components/CodeField/CodeField.js +54 -23
  3. package/cjs/components/CodeField/CodeField.js.map +1 -1
  4. package/cjs/components/CodeField/CodeField.styles.js +7 -1
  5. package/cjs/components/CodeField/CodeField.styles.js.map +1 -1
  6. package/cjs/components/CodeField/{CodeField.styles_ebdpd0.css → CodeField.styles_14p25hi.css} +1 -0
  7. package/cjs/components/CodeField/hooks/useWebOTP.js +103 -0
  8. package/cjs/components/CodeField/hooks/useWebOTP.js.map +1 -0
  9. package/cjs/components/CodeField/utils/handleCodeError.js +2 -2
  10. package/cjs/components/CodeField/utils/handleCodeError.js.map +1 -1
  11. package/cjs/components/CodeField/utils/handleItemError.js +14 -4
  12. package/cjs/components/CodeField/utils/handleItemError.js.map +1 -1
  13. package/cjs/components/CodeField/utils/isWebOTPSupported.js +10 -0
  14. package/cjs/components/CodeField/utils/isWebOTPSupported.js.map +1 -0
  15. package/cjs/components/Combobox/ComboboxNew/Combobox.css +6 -6
  16. package/cjs/components/Combobox/ComboboxNew/Combobox.js +23 -22
  17. package/cjs/components/Combobox/ComboboxNew/Combobox.js.map +1 -1
  18. package/cjs/components/Combobox/ComboboxNew/Combobox.styles.js +4 -3
  19. package/cjs/components/Combobox/ComboboxNew/Combobox.styles.js.map +1 -1
  20. package/{es/components/Combobox/ComboboxNew/Combobox.styles_261unw.css → cjs/components/Combobox/ComboboxNew/Combobox.styles_isfa46.css} +1 -1
  21. package/cjs/components/Combobox/ComboboxNew/Combobox.tokens.js +1 -1
  22. package/cjs/components/Combobox/ComboboxNew/Combobox.tokens.js.map +1 -1
  23. package/cjs/components/Combobox/ComboboxNew/hooks/useKeyboardNavigation.js +7 -3
  24. package/cjs/components/Combobox/ComboboxNew/hooks/useKeyboardNavigation.js.map +1 -1
  25. package/cjs/components/Combobox/ComboboxNew/ui/Inner/Inner.css +6 -6
  26. package/cjs/components/Combobox/ComboboxNew/ui/Inner/Inner.js +5 -11
  27. package/cjs/components/Combobox/ComboboxNew/ui/Inner/Inner.js.map +1 -1
  28. package/cjs/components/Combobox/ComboboxOld/Combobox.css +2 -2
  29. package/cjs/components/Combobox/ComboboxOld/ui/ComboboxDivider/ComboboxDivider.css +2 -2
  30. package/cjs/components/Combobox/ComboboxOld/ui/ComboboxFooter/ComboboxFooter.css +2 -2
  31. package/cjs/components/Combobox/ComboboxOld/ui/ComboboxGroup/ComboboxGroup.css +2 -2
  32. package/cjs/components/Combobox/ComboboxOld/ui/ComboboxHeader/ComboboxHeader.css +2 -2
  33. package/cjs/components/Dropdown/Dropdown.css +2 -2
  34. package/cjs/components/Dropdown/Dropdown.js +10 -6
  35. package/cjs/components/Dropdown/Dropdown.js.map +1 -1
  36. package/cjs/components/Dropdown/Dropdown.styles.js +9 -2
  37. package/cjs/components/Dropdown/Dropdown.styles.js.map +1 -1
  38. package/{es/components/Dropdown/Dropdown.styles_kkvnr1.css → cjs/components/Dropdown/Dropdown.styles_zheit5.css} +1 -1
  39. package/cjs/components/Dropdown/hooks/useKeyboardNavigation.js +7 -3
  40. package/cjs/components/Dropdown/hooks/useKeyboardNavigation.js.map +1 -1
  41. package/cjs/components/Dropdown/ui/DropdownInner/DropdownInner.css +2 -2
  42. package/cjs/components/Dropdown/ui/DropdownInner/DropdownInner.js +9 -9
  43. package/cjs/components/Dropdown/ui/DropdownInner/DropdownInner.js.map +1 -1
  44. package/cjs/components/Pagination/Pagination.css +2 -2
  45. package/cjs/components/Pagination/ui/PaginationSelectPerPage/PaginationSelectPerPage.css +2 -2
  46. package/cjs/components/Select/Select.css +2 -2
  47. package/cjs/components/Select/Select.js +3 -4
  48. package/cjs/components/Select/Select.js.map +1 -1
  49. package/cjs/components/Select/Select.styles.js +4 -3
  50. package/cjs/components/Select/Select.styles.js.map +1 -1
  51. package/{es/components/Select/Select.styles_dta4dl.css → cjs/components/Select/Select.styles_bjoo18.css} +1 -1
  52. package/cjs/components/Select/hooks/useKeyboardNavigation.js +7 -3
  53. package/cjs/components/Select/hooks/useKeyboardNavigation.js.map +1 -1
  54. package/cjs/components/Select/ui/Inner/Inner.css +2 -2
  55. package/cjs/components/Select/ui/Inner/Inner.js +5 -11
  56. package/cjs/components/Select/ui/Inner/Inner.js.map +1 -1
  57. package/cjs/components/Table/Table.css +2 -2
  58. package/cjs/components/Table/ui/Cell/Cell.css +2 -2
  59. package/cjs/components/Table/ui/EditableCell/EditableCell.css +2 -2
  60. package/cjs/components/Table/ui/HeadCell/HeadCell.css +2 -2
  61. package/cjs/components/Table/ui/HeadCell/ui/Filter/Filter.css +2 -2
  62. package/cjs/index.css +17 -16
  63. package/emotion/cjs/components/CodeField/CodeField.js +47 -19
  64. package/emotion/cjs/components/CodeField/CodeField.styles.js +18 -11
  65. package/emotion/cjs/components/CodeField/hooks/useWebOTP.js +254 -0
  66. package/emotion/cjs/components/CodeField/utils/handleCodeError.js +2 -2
  67. package/emotion/cjs/components/CodeField/utils/handleItemError.js +12 -3
  68. package/emotion/cjs/components/CodeField/utils/index.js +4 -0
  69. package/emotion/cjs/components/CodeField/utils/isWebOTPSupported.js +13 -0
  70. package/emotion/cjs/components/Combobox/ComboboxNew/Combobox.js +22 -20
  71. package/emotion/cjs/components/Combobox/ComboboxNew/Combobox.styles.js +16 -16
  72. package/emotion/cjs/components/Combobox/ComboboxNew/Combobox.tokens.js +1 -1
  73. package/emotion/cjs/components/Combobox/ComboboxNew/hooks/useKeyboardNavigation.js +7 -3
  74. package/emotion/cjs/components/Combobox/ComboboxNew/ui/Inner/Inner.js +9 -50
  75. package/emotion/cjs/components/Dropdown/Dropdown.js +10 -6
  76. package/emotion/cjs/components/Dropdown/Dropdown.styles.js +8 -5
  77. package/emotion/cjs/components/Dropdown/hooks/useKeyboardNavigation.js +7 -3
  78. package/emotion/cjs/components/Dropdown/ui/DropdownInner/DropdownInner.js +11 -48
  79. package/emotion/cjs/components/Select/Select.js +2 -4
  80. package/emotion/cjs/components/Select/Select.styles.js +8 -8
  81. package/emotion/cjs/components/Select/hooks/useKeyboardNavigation.js +7 -3
  82. package/emotion/cjs/components/Select/ui/Inner/Inner.js +9 -50
  83. package/emotion/cjs/examples/components/Combobox/Combobox.js +0 -15
  84. package/emotion/es/components/CodeField/CodeField.js +49 -21
  85. package/emotion/es/components/CodeField/CodeField.styles.js +15 -11
  86. package/emotion/es/components/CodeField/hooks/useWebOTP.js +244 -0
  87. package/emotion/es/components/CodeField/utils/handleCodeError.js +2 -2
  88. package/emotion/es/components/CodeField/utils/handleItemError.js +12 -3
  89. package/emotion/es/components/CodeField/utils/index.js +1 -0
  90. package/emotion/es/components/CodeField/utils/isWebOTPSupported.js +3 -0
  91. package/emotion/es/components/Combobox/ComboboxNew/Combobox.js +22 -20
  92. package/emotion/es/components/Combobox/ComboboxNew/Combobox.styles.js +16 -16
  93. package/emotion/es/components/Combobox/ComboboxNew/Combobox.tokens.js +1 -1
  94. package/emotion/es/components/Combobox/ComboboxNew/hooks/useKeyboardNavigation.js +7 -3
  95. package/emotion/es/components/Combobox/ComboboxNew/ui/Inner/Inner.js +6 -11
  96. package/emotion/es/components/Dropdown/Dropdown.js +10 -6
  97. package/emotion/es/components/Dropdown/Dropdown.styles.js +8 -5
  98. package/emotion/es/components/Dropdown/hooks/useKeyboardNavigation.js +7 -3
  99. package/emotion/es/components/Dropdown/ui/DropdownInner/DropdownInner.js +8 -9
  100. package/emotion/es/components/Select/Select.js +2 -4
  101. package/emotion/es/components/Select/Select.styles.js +8 -8
  102. package/emotion/es/components/Select/hooks/useKeyboardNavigation.js +7 -3
  103. package/emotion/es/components/Select/ui/Inner/Inner.js +6 -11
  104. package/es/components/CodeField/CodeField.css +7 -6
  105. package/es/components/CodeField/CodeField.js +56 -25
  106. package/es/components/CodeField/CodeField.js.map +1 -1
  107. package/es/components/CodeField/CodeField.styles.js +7 -2
  108. package/es/components/CodeField/CodeField.styles.js.map +1 -1
  109. package/es/components/CodeField/{CodeField.styles_ebdpd0.css → CodeField.styles_14p25hi.css} +1 -0
  110. package/es/components/CodeField/hooks/useWebOTP.js +99 -0
  111. package/es/components/CodeField/hooks/useWebOTP.js.map +1 -0
  112. package/es/components/CodeField/utils/handleCodeError.js +2 -2
  113. package/es/components/CodeField/utils/handleCodeError.js.map +1 -1
  114. package/es/components/CodeField/utils/handleItemError.js +14 -4
  115. package/es/components/CodeField/utils/handleItemError.js.map +1 -1
  116. package/es/components/CodeField/utils/isWebOTPSupported.js +6 -0
  117. package/es/components/CodeField/utils/isWebOTPSupported.js.map +1 -0
  118. package/es/components/Combobox/ComboboxNew/Combobox.css +6 -6
  119. package/es/components/Combobox/ComboboxNew/Combobox.js +23 -22
  120. package/es/components/Combobox/ComboboxNew/Combobox.js.map +1 -1
  121. package/es/components/Combobox/ComboboxNew/Combobox.styles.js +4 -3
  122. package/es/components/Combobox/ComboboxNew/Combobox.styles.js.map +1 -1
  123. package/{cjs/components/Combobox/ComboboxNew/Combobox.styles_261unw.css → es/components/Combobox/ComboboxNew/Combobox.styles_isfa46.css} +1 -1
  124. package/es/components/Combobox/ComboboxNew/Combobox.tokens.js +1 -1
  125. package/es/components/Combobox/ComboboxNew/Combobox.tokens.js.map +1 -1
  126. package/es/components/Combobox/ComboboxNew/hooks/useKeyboardNavigation.js +7 -3
  127. package/es/components/Combobox/ComboboxNew/hooks/useKeyboardNavigation.js.map +1 -1
  128. package/es/components/Combobox/ComboboxNew/ui/Inner/Inner.css +6 -6
  129. package/es/components/Combobox/ComboboxNew/ui/Inner/Inner.js +6 -12
  130. package/es/components/Combobox/ComboboxNew/ui/Inner/Inner.js.map +1 -1
  131. package/es/components/Combobox/ComboboxOld/Combobox.css +2 -2
  132. package/es/components/Combobox/ComboboxOld/ui/ComboboxDivider/ComboboxDivider.css +2 -2
  133. package/es/components/Combobox/ComboboxOld/ui/ComboboxFooter/ComboboxFooter.css +2 -2
  134. package/es/components/Combobox/ComboboxOld/ui/ComboboxGroup/ComboboxGroup.css +2 -2
  135. package/es/components/Combobox/ComboboxOld/ui/ComboboxHeader/ComboboxHeader.css +2 -2
  136. package/es/components/Dropdown/Dropdown.css +2 -2
  137. package/es/components/Dropdown/Dropdown.js +10 -6
  138. package/es/components/Dropdown/Dropdown.js.map +1 -1
  139. package/es/components/Dropdown/Dropdown.styles.js +9 -2
  140. package/es/components/Dropdown/Dropdown.styles.js.map +1 -1
  141. package/{cjs/components/Dropdown/Dropdown.styles_kkvnr1.css → es/components/Dropdown/Dropdown.styles_zheit5.css} +1 -1
  142. package/es/components/Dropdown/hooks/useKeyboardNavigation.js +7 -3
  143. package/es/components/Dropdown/hooks/useKeyboardNavigation.js.map +1 -1
  144. package/es/components/Dropdown/ui/DropdownInner/DropdownInner.css +2 -2
  145. package/es/components/Dropdown/ui/DropdownInner/DropdownInner.js +10 -10
  146. package/es/components/Dropdown/ui/DropdownInner/DropdownInner.js.map +1 -1
  147. package/es/components/Pagination/Pagination.css +2 -2
  148. package/es/components/Pagination/ui/PaginationSelectPerPage/PaginationSelectPerPage.css +2 -2
  149. package/es/components/Select/Select.css +2 -2
  150. package/es/components/Select/Select.js +3 -4
  151. package/es/components/Select/Select.js.map +1 -1
  152. package/es/components/Select/Select.styles.js +4 -3
  153. package/es/components/Select/Select.styles.js.map +1 -1
  154. package/{cjs/components/Select/Select.styles_dta4dl.css → es/components/Select/Select.styles_bjoo18.css} +1 -1
  155. package/es/components/Select/hooks/useKeyboardNavigation.js +7 -3
  156. package/es/components/Select/hooks/useKeyboardNavigation.js.map +1 -1
  157. package/es/components/Select/ui/Inner/Inner.css +2 -2
  158. package/es/components/Select/ui/Inner/Inner.js +6 -12
  159. package/es/components/Select/ui/Inner/Inner.js.map +1 -1
  160. package/es/components/Table/Table.css +2 -2
  161. package/es/components/Table/ui/Cell/Cell.css +2 -2
  162. package/es/components/Table/ui/EditableCell/EditableCell.css +2 -2
  163. package/es/components/Table/ui/HeadCell/HeadCell.css +2 -2
  164. package/es/components/Table/ui/HeadCell/ui/Filter/Filter.css +2 -2
  165. package/es/index.css +17 -16
  166. package/package.json +2 -2
  167. package/styled-components/cjs/components/CodeField/CodeField.js +47 -19
  168. package/styled-components/cjs/components/CodeField/CodeField.styles.js +14 -5
  169. package/styled-components/cjs/components/CodeField/hooks/useWebOTP.js +254 -0
  170. package/styled-components/cjs/components/CodeField/utils/handleCodeError.js +2 -2
  171. package/styled-components/cjs/components/CodeField/utils/handleItemError.js +12 -3
  172. package/styled-components/cjs/components/CodeField/utils/index.js +4 -0
  173. package/styled-components/cjs/components/CodeField/utils/isWebOTPSupported.js +13 -0
  174. package/styled-components/cjs/components/Combobox/ComboboxNew/Combobox.js +22 -20
  175. package/styled-components/cjs/components/Combobox/ComboboxNew/Combobox.styles.js +9 -9
  176. package/styled-components/cjs/components/Combobox/ComboboxNew/Combobox.tokens.js +1 -1
  177. package/styled-components/cjs/components/Combobox/ComboboxNew/hooks/useKeyboardNavigation.js +7 -3
  178. package/styled-components/cjs/components/Combobox/ComboboxNew/ui/Inner/Inner.js +9 -50
  179. package/styled-components/cjs/components/Dropdown/Dropdown.js +10 -6
  180. package/styled-components/cjs/components/Dropdown/Dropdown.styles.js +7 -3
  181. package/styled-components/cjs/components/Dropdown/hooks/useKeyboardNavigation.js +7 -3
  182. package/styled-components/cjs/components/Dropdown/ui/DropdownInner/DropdownInner.js +11 -48
  183. package/styled-components/cjs/components/Select/Select.js +2 -4
  184. package/styled-components/cjs/components/Select/Select.styles.js +5 -5
  185. package/styled-components/cjs/components/Select/hooks/useKeyboardNavigation.js +7 -3
  186. package/styled-components/cjs/components/Select/ui/Inner/Inner.js +9 -50
  187. package/styled-components/es/components/CodeField/CodeField.js +49 -21
  188. package/styled-components/es/components/CodeField/CodeField.styles.js +11 -5
  189. package/styled-components/es/components/CodeField/hooks/useWebOTP.js +244 -0
  190. package/styled-components/es/components/CodeField/utils/handleCodeError.js +2 -2
  191. package/styled-components/es/components/CodeField/utils/handleItemError.js +12 -3
  192. package/styled-components/es/components/CodeField/utils/index.js +1 -0
  193. package/styled-components/es/components/CodeField/utils/isWebOTPSupported.js +3 -0
  194. package/styled-components/es/components/Combobox/ComboboxNew/Combobox.js +22 -20
  195. package/styled-components/es/components/Combobox/ComboboxNew/Combobox.styles.js +9 -9
  196. package/styled-components/es/components/Combobox/ComboboxNew/Combobox.tokens.js +1 -1
  197. package/styled-components/es/components/Combobox/ComboboxNew/hooks/useKeyboardNavigation.js +7 -3
  198. package/styled-components/es/components/Combobox/ComboboxNew/ui/Inner/Inner.js +6 -11
  199. package/styled-components/es/components/Dropdown/Dropdown.js +10 -6
  200. package/styled-components/es/components/Dropdown/Dropdown.styles.js +7 -3
  201. package/styled-components/es/components/Dropdown/hooks/useKeyboardNavigation.js +7 -3
  202. package/styled-components/es/components/Dropdown/ui/DropdownInner/DropdownInner.js +8 -9
  203. package/styled-components/es/components/Select/Select.js +2 -4
  204. package/styled-components/es/components/Select/Select.styles.js +5 -5
  205. package/styled-components/es/components/Select/hooks/useKeyboardNavigation.js +7 -3
  206. package/styled-components/es/components/Select/ui/Inner/Inner.js +6 -11
  207. package/types/components/CodeField/CodeField.d.ts.map +1 -1
  208. package/types/components/CodeField/CodeField.styles.d.ts +1 -0
  209. package/types/components/CodeField/CodeField.styles.d.ts.map +1 -1
  210. package/types/components/CodeField/hooks/useWebOTP.d.ts +23 -0
  211. package/types/components/CodeField/hooks/useWebOTP.d.ts.map +1 -0
  212. package/types/components/CodeField/utils/handleCodeError.d.ts +2 -2
  213. package/types/components/CodeField/utils/handleCodeError.d.ts.map +1 -1
  214. package/types/components/CodeField/utils/handleItemError.d.ts +3 -2
  215. package/types/components/CodeField/utils/handleItemError.d.ts.map +1 -1
  216. package/types/components/CodeField/utils/index.d.ts +1 -0
  217. package/types/components/CodeField/utils/index.d.ts.map +1 -1
  218. package/types/components/CodeField/utils/isWebOTPSupported.d.ts +2 -0
  219. package/types/components/CodeField/utils/isWebOTPSupported.d.ts.map +1 -0
  220. package/types/components/Combobox/ComboboxNew/Combobox.d.ts.map +1 -1
  221. package/types/components/Combobox/ComboboxNew/Combobox.styles.d.ts +1 -0
  222. package/types/components/Combobox/ComboboxNew/Combobox.styles.d.ts.map +1 -1
  223. package/types/components/Combobox/ComboboxNew/Combobox.tokens.d.ts +1 -1
  224. package/types/components/Combobox/ComboboxNew/Combobox.types.d.ts +6 -6
  225. package/types/components/Combobox/ComboboxNew/Combobox.types.d.ts.map +1 -1
  226. package/types/components/Combobox/ComboboxNew/ui/Inner/Inner.d.ts.map +1 -1
  227. package/types/components/Combobox/ComboboxNew/ui/Inner/Inner.type.d.ts +1 -2
  228. package/types/components/Combobox/ComboboxNew/ui/Inner/Inner.type.d.ts.map +1 -1
  229. package/types/components/Combobox/ComboboxNew/ui/Inner/ui/Item/Item.types.d.ts +2 -6
  230. package/types/components/Combobox/ComboboxNew/ui/Inner/ui/Item/Item.types.d.ts.map +1 -1
  231. package/types/components/Dropdown/Dropdown.d.ts +2 -2
  232. package/types/components/Dropdown/Dropdown.d.ts.map +1 -1
  233. package/types/components/Dropdown/Dropdown.styles.d.ts +1 -0
  234. package/types/components/Dropdown/Dropdown.styles.d.ts.map +1 -1
  235. package/types/components/Dropdown/Dropdown.types.d.ts +5 -5
  236. package/types/components/Dropdown/Dropdown.types.d.ts.map +1 -1
  237. package/types/components/Dropdown/ui/DropdownInner/DropdownInner.d.ts.map +1 -1
  238. package/types/components/Dropdown/ui/DropdownInner/DropdownInner.type.d.ts +3 -2
  239. package/types/components/Dropdown/ui/DropdownInner/DropdownInner.type.d.ts.map +1 -1
  240. package/types/components/Dropdown/ui/DropdownItem/DropdownItem.type.d.ts +3 -7
  241. package/types/components/Dropdown/ui/DropdownItem/DropdownItem.type.d.ts.map +1 -1
  242. package/types/components/Pagination/ui/PaginationSelectPerPage/PaginationSelectPerPage.styles.d.ts +6 -6
  243. package/types/components/Pagination/ui/PaginationSelectPerPage/PaginationSelectPerPage.styles.d.ts.map +1 -1
  244. package/types/components/Select/Select.d.ts.map +1 -1
  245. package/types/components/Select/Select.styles.d.ts +1 -0
  246. package/types/components/Select/Select.styles.d.ts.map +1 -1
  247. package/types/components/Select/Select.types.d.ts +10 -10
  248. package/types/components/Select/Select.types.d.ts.map +1 -1
  249. package/types/components/Select/ui/Inner/Inner.d.ts.map +1 -1
  250. package/types/components/Select/ui/Inner/Inner.type.d.ts +1 -2
  251. package/types/components/Select/ui/Inner/Inner.type.d.ts.map +1 -1
  252. package/types/components/Select/ui/Inner/ui/Item/Item.types.d.ts +3 -11
  253. package/types/components/Select/ui/Inner/ui/Item/Item.types.d.ts.map +1 -1
  254. package/types/components/Table/ui/HeadCell/ui/Filter/Filter.styles.d.ts +6 -6
  255. package/types/components/Table/ui/HeadCell/ui/Filter/Filter.styles.d.ts.map +1 -1
  256. package/types/examples/components/Combobox/Combobox.d.ts +24 -24
  257. package/types/examples/components/Combobox/Combobox.d.ts.map +1 -1
  258. package/types/examples/components/Dropdown/Dropdown.d.ts +1 -1
  259. package/types/examples/components/Dropdown/Dropdown.d.ts.map +1 -1
  260. package/types/examples/components/Select/Select.d.ts +6 -6
  261. package/types/examples/components/Select/Select.d.ts.map +1 -1
@@ -1,10 +1,10 @@
1
- import React, { useRef } from "react";
1
+ import React from "react";
2
2
  import { isEmpty, safeUseId } from "../../../../utils";
3
3
  import { Ul, ListWrapper } from "../../Select.styles";
4
4
  import { FloatingPopover } from "../../FloatingPopover";
5
5
  import { Item } from "./ui/Item/Item";
6
6
  export var Inner = function(param) {
7
- var item = param.item, currentLevel = param.currentLevel, path = param.path, dispatchPath = param.dispatchPath, index = param.index, listWidth = param.listWidth, portal = param.portal;
7
+ var item = param.item, currentLevel = param.currentLevel, path = param.path, dispatchPath = param.dispatchPath, index = param.index, listWidth = param.listWidth;
8
8
  var handleToggle = function(opened) {
9
9
  if (opened) {
10
10
  dispatchPath({
@@ -19,7 +19,6 @@ export var Inner = function(param) {
19
19
  });
20
20
  }
21
21
  };
22
- var listWrapperRef = useRef(null);
23
22
  var isCurrentListOpen = path[currentLevel + 1] === item.value.toString();
24
23
  var treeId = safeUseId();
25
24
  var listId = "".concat(treeId, "_tree_level_").concat(currentLevel + 2);
@@ -40,16 +39,13 @@ export var Inner = function(param) {
40
39
  ariaLevel: nextLevel,
41
40
  ariaLabel: item.label
42
41
  }),
43
- isInner: true,
44
- portal: portal
42
+ isInner: true
45
43
  }, /*#__PURE__*/ React.createElement(ListWrapper, {
46
- listWidth: listWidth,
47
- ref: listWrapperRef
44
+ listWidth: listWidth
48
45
  }, /*#__PURE__*/ React.createElement(Ul, {
49
46
  role: "group",
50
47
  id: listId,
51
- virtual: false,
52
- listMaxHeight: item === null || item === void 0 ? void 0 : item.listMaxHeight
48
+ virtual: false
53
49
  }, (_item_items = item.items) === null || _item_items === void 0 ? void 0 : _item_items.map(function(innerItem, innerIndex) {
54
50
  return /*#__PURE__*/ React.createElement(Inner, {
55
51
  key: "".concat(innerIndex, "/").concat(currentLevel),
@@ -58,8 +54,7 @@ export var Inner = function(param) {
58
54
  path: path,
59
55
  dispatchPath: dispatchPath,
60
56
  index: innerIndex,
61
- listWidth: listWidth,
62
- portal: listWrapperRef
57
+ listWidth: listWidth
63
58
  });
64
59
  }))));
65
60
  }
@@ -1,9 +1,10 @@
1
- .CodeField_styles_ebdpd0_b1xx9skx__3407b383{display:-webkit-box;display:-webkit-flex;display:-ms-flexbox;display:flex;-webkit-flex-direction:column;-ms-flex-direction:column;flex-direction:column;-webkit-box-pack:center;-webkit-justify-content:center;-ms-flex-pack:center;justify-content:center;width:-webkit-min-content;width:-moz-min-content;width:min-content;-webkit-align-items:center;-webkit-box-align:center;-ms-flex-align:center;align-items:center;}.CodeField_styles_ebdpd0_b1xx9skx__3407b383.CodeField_styles_ebdpd0_codefieldCaptionAlignLeft__3407b383{-webkit-align-items:flex-start;-webkit-box-align:flex-start;-ms-flex-align:flex-start;align-items:flex-start;}
2
- .CodeField_styles_ebdpd0_c1wzspax__3407b383{display:-webkit-box;display:-webkit-flex;display:-ms-flexbox;display:flex;-webkit-align-items:center;-webkit-box-align:center;-ms-flex-align:center;align-items:center;}
3
- .CodeField_styles_ebdpd0_c7swj1z__3407b383{display:-webkit-box;display:-webkit-flex;display:-ms-flexbox;display:flex;-webkit-align-items:center;-webkit-box-align:center;-ms-flex-align:center;align-items:center;}
4
- .CodeField_styles_ebdpd0_s13uxcg8__3407b383{width:var(--plasma-codefield-separator-width);}
5
- .CodeField_styles_ebdpd0_ig5h1kg__3407b383{box-sizing:border-box;-webkit-appearance:none;-moz-appearance:none;appearance:none;border:0;padding:0;outline:none;pointer-events:none;text-align:center;}
6
- .CodeField_styles_ebdpd0_c1jpzjak__3407b383{text-align:var(--c1jpzjak-0);-webkit-align-self:var(--c1jpzjak-0);-ms-flex-item-align:var(--c1jpzjak-0);align-self:var(--c1jpzjak-0);width:var(--c1jpzjak-1);white-space:pre-line;}
1
+ .CodeField_styles_14p25hi_b1xx9skx__a0f2e82d{display:-webkit-box;display:-webkit-flex;display:-ms-flexbox;display:flex;-webkit-flex-direction:column;-ms-flex-direction:column;flex-direction:column;-webkit-box-pack:center;-webkit-justify-content:center;-ms-flex-pack:center;justify-content:center;width:-webkit-min-content;width:-moz-min-content;width:min-content;-webkit-align-items:center;-webkit-box-align:center;-ms-flex-align:center;align-items:center;}.CodeField_styles_14p25hi_b1xx9skx__a0f2e82d.CodeField_styles_14p25hi_codefieldCaptionAlignLeft__a0f2e82d{-webkit-align-items:flex-start;-webkit-box-align:flex-start;-ms-flex-align:flex-start;align-items:flex-start;}
2
+ .CodeField_styles_14p25hi_c1wzspax__a0f2e82d{display:-webkit-box;display:-webkit-flex;display:-ms-flexbox;display:flex;-webkit-align-items:center;-webkit-box-align:center;-ms-flex-align:center;align-items:center;}
3
+ .CodeField_styles_14p25hi_c7swj1z__a0f2e82d{display:-webkit-box;display:-webkit-flex;display:-ms-flexbox;display:flex;-webkit-align-items:center;-webkit-box-align:center;-ms-flex-align:center;align-items:center;}
4
+ .CodeField_styles_14p25hi_s13uxcg8__a0f2e82d{width:var(--plasma-codefield-separator-width);}
5
+ .CodeField_styles_14p25hi_ig5h1kg__a0f2e82d{box-sizing:border-box;-webkit-appearance:none;-moz-appearance:none;appearance:none;border:0;padding:0;outline:none;pointer-events:none;text-align:center;}
6
+ .CodeField_styles_14p25hi_c1jpzjak__a0f2e82d{text-align:var(--c1jpzjak-0);-webkit-align-self:var(--c1jpzjak-0);-ms-flex-item-align:var(--c1jpzjak-0);align-self:var(--c1jpzjak-0);width:var(--c1jpzjak-1);white-space:pre-line;}
7
+ .CodeField_styles_14p25hi_h1x845wl__a0f2e82d{display:none;}
7
8
 
8
9
  .base_9a5yza_b1g41h91__e66aaab8 .base_9a5yza_c1jpzjak__e66aaab8{color:var(--plasma-codefield-caption-color);}.base_9a5yza_b1g41h91__e66aaab8 .base_9a5yza_c1jpzjak__e66aaab8.base_9a5yza_codefieldCaptionError__e66aaab8{color:var(--plasma-codefield-caption-color-error);}.base_9a5yza_b1g41h91__e66aaab8 .base_9a5yza_ig5h1kg__e66aaab8{color:var(--plasma-codefield-code-color);caret-color:var(--plasma-codefield-caret-color);background-color:var(--plasma-codefield-background-color);box-shadow:inset 0 0 0 var(--plasma-codefield-border-width) var(--plasma-codefield-border-color);}.base_9a5yza_b1g41h91__e66aaab8:hover .base_9a5yza_codefieldItemHoverEnabled__e66aaab8{background-color:var(--plasma-codefield-background-color-hover);box-shadow:inset 0 0 0 var(--plasma-codefield-border-width) var(--plasma-codefield-border-color-hover);}.base_9a5yza_b1g41h91__e66aaab8:focus-within .base_9a5yza_ig5h1kg__e66aaab8:focus-within{background-color:var(--plasma-codefield-background-color-focus);box-shadow:inset 0 0 0 var(--plasma-codefield-border-width) var(--plasma-codefield-border-color-focus);}.base_9a5yza_b1g41h91__e66aaab8.base_9a5yza_b1g41h91__e66aaab8 .base_9a5yza_codefieldCodeErrorAnimation__e66aaab8{-webkit-animation:base_9a5yza_shakingErrorB1g41h91__e66aaab8 0.3s forwards;animation:base_9a5yza_shakingErrorB1g41h91__e66aaab8 0.3s forwards;}.base_9a5yza_b1g41h91__e66aaab8.base_9a5yza_b1g41h91__e66aaab8 .base_9a5yza_codefieldCodeError__e66aaab8 .base_9a5yza_ig5h1kg__e66aaab8{color:var(--plasma-codefield-code-color-error);background-color:var(--plasma-codefield-background-error-color);box-shadow:inset 0 0 0 var(--plasma-codefield-border-width) var(--plasma-codefield-border-error-color);}.base_9a5yza_b1g41h91__e66aaab8.base_9a5yza_b1g41h91__e66aaab8 .base_9a5yza_codefieldCodeError__e66aaab8:focus-within .base_9a5yza_ig5h1kg__e66aaab8{background-color:var(--plasma-codefield-background-error-color);box-shadow:inset 0 0 0 var(--plasma-codefield-border-width) var(--plasma-codefield-border-error-color);}.base_9a5yza_b1g41h91__e66aaab8.base_9a5yza_b1g41h91__e66aaab8 .base_9a5yza_codefieldCodeError__e66aaab8.base_9a5yza_codefieldCodeErrorFade__e66aaab8 .base_9a5yza_ig5h1kg__e66aaab8{-webkit-animation:base_9a5yza_fadeErrorB1g41h91__e66aaab8 0.3s forwards;animation:base_9a5yza_fadeErrorB1g41h91__e66aaab8 0.3s forwards;}.base_9a5yza_b1g41h91__e66aaab8.base_9a5yza_b1g41h91__e66aaab8 .base_9a5yza_codefieldItemErrorAnimation__e66aaab8{-webkit-animation:base_9a5yza_shakingErrorB1g41h91__e66aaab8 0.3s forwards;animation:base_9a5yza_shakingErrorB1g41h91__e66aaab8 0.3s forwards;}.base_9a5yza_b1g41h91__e66aaab8.base_9a5yza_b1g41h91__e66aaab8 .base_9a5yza_codefieldItemError__e66aaab8,.base_9a5yza_b1g41h91__e66aaab8.base_9a5yza_b1g41h91__e66aaab8 .base_9a5yza_codefieldItemError__e66aaab8:focus-within{color:var(--plasma-codefield-code-color-error);background-color:var(--plasma-codefield-background-error-color);box-shadow:inset 0 0 0 var(--plasma-codefield-border-width) var(--plasma-codefield-border-error-color);}.base_9a5yza_b1g41h91__e66aaab8.base_9a5yza_b1g41h91__e66aaab8 .base_9a5yza_codefieldItemError__e66aaab8.base_9a5yza_codefieldCodeErrorFade__e66aaab8,.base_9a5yza_b1g41h91__e66aaab8.base_9a5yza_b1g41h91__e66aaab8 .base_9a5yza_codefieldItemError__e66aaab8:focus-within.base_9a5yza_codefieldCodeErrorFade__e66aaab8{-webkit-animation:base_9a5yza_shakingErrorB1g41h91__e66aaab8 0.3s forwards :local(fadeError-b1g41h91) 0.3s :local(forwards);animation:base_9a5yza_shakingErrorB1g41h91__e66aaab8 0.3s forwards :local(fadeError-b1g41h91) 0.3s :local(forwards);}@-webkit-keyframes base_9a5yza_shakingErrorB1g41h91__e66aaab8{14%{-webkit-transform:translateX(-0.125rem);-ms-transform:translateX(-0.125rem);transform:translateX(-0.125rem);}28%{-webkit-transform:translateX(0.125rem);-ms-transform:translateX(0.125rem);transform:translateX(0.125rem);}42%{-webkit-transform:translateX(-0.125rem);-ms-transform:translateX(-0.125rem);transform:translateX(-0.125rem);}57%{-webkit-transform:translateX(0.125rem);-ms-transform:translateX(0.125rem);transform:translateX(0.125rem);}71%{-webkit-transform:translateX(-0.125rem);-ms-transform:translateX(-0.125rem);transform:translateX(-0.125rem);}85%{-webkit-transform:translateX(0.125rem);-ms-transform:translateX(0.125rem);transform:translateX(0.125rem);}100%{-webkit-transform:translateX(-0.125rem);-ms-transform:translateX(-0.125rem);transform:translateX(-0.125rem);}}@keyframes base_9a5yza_shakingErrorB1g41h91__e66aaab8{14%{-webkit-transform:translateX(-0.125rem);-ms-transform:translateX(-0.125rem);transform:translateX(-0.125rem);}28%{-webkit-transform:translateX(0.125rem);-ms-transform:translateX(0.125rem);transform:translateX(0.125rem);}42%{-webkit-transform:translateX(-0.125rem);-ms-transform:translateX(-0.125rem);transform:translateX(-0.125rem);}57%{-webkit-transform:translateX(0.125rem);-ms-transform:translateX(0.125rem);transform:translateX(0.125rem);}71%{-webkit-transform:translateX(-0.125rem);-ms-transform:translateX(-0.125rem);transform:translateX(-0.125rem);}85%{-webkit-transform:translateX(0.125rem);-ms-transform:translateX(0.125rem);transform:translateX(0.125rem);}100%{-webkit-transform:translateX(-0.125rem);-ms-transform:translateX(-0.125rem);transform:translateX(-0.125rem);}}@-webkit-keyframes base_9a5yza_fadeErrorB1g41h91__e66aaab8{50%{color:var(--plasma-codefield-code-color-error);}100%{color:transparent;}}@keyframes base_9a5yza_fadeErrorB1g41h91__e66aaab8{50%{color:var(--plasma-codefield-code-color-error);}100%{color:transparent;}}
9
10
 
@@ -1,18 +1,20 @@
1
- import { objectWithoutProperties as _objectWithoutProperties, slicedToArray as _slicedToArray, extends as _extends, defineProperty as _defineProperty, toConsumableArray as _toConsumableArray } from '../../_virtual/_rollupPluginBabelHelpers.js';
1
+ import { objectWithoutProperties as _objectWithoutProperties, slicedToArray as _slicedToArray, extends as _extends, objectSpread2 as _objectSpread2, defineProperty as _defineProperty, toConsumableArray as _toConsumableArray } from '../../_virtual/_rollupPluginBabelHelpers.js';
2
2
  import React, { forwardRef, useState, useRef, useCallback, Fragment } from 'react';
3
3
  import cls from 'classnames';
4
4
  import { FORBIDDEN_KEYS, BACKSPACE_KEY, ONLY_DIGITS_PATTERN } from './utils/constants.js';
5
5
  import { classes } from './CodeField.tokens.js';
6
- import { CodeWrapper, CodeGroup, ItemInput, Separator, CaptionWrapper, base } from './CodeField.styles.js';
6
+ import { CodeWrapper, CodeGroup, ItemInput, Separator, CaptionWrapper, HiddenInput, base } from './CodeField.styles.js';
7
7
  import { base as base$1 } from './variations/_view/base.js';
8
8
  import { base as base$2 } from './variations/_size/base.js';
9
9
  import { base as base$3 } from './variations/_shape/base.js';
10
10
  import { base as base$4 } from './variations/_disabled/base.js';
11
+ import { useWebOTP } from './hooks/useWebOTP.js';
11
12
  import { getCodeValue, getPlaceholderValue, getFieldPattern } from './utils/initialValuesHelper.js';
12
13
  import { useCodeHook } from '../../hooks/useCodeHook.js';
13
14
  import { useDidMountEffect } from '../../hooks/useDidMountEffect.js';
14
15
  import { handleCodeError } from './utils/handleCodeError.js';
15
16
  import { getSizeValueFromProp } from '../../utils/getSizeValueFromProp.js';
17
+ import { isWebOTPSupported } from './utils/isWebOTPSupported.js';
16
18
  import { handleItemError } from './utils/handleItemError.js';
17
19
 
18
20
  var _Separator;
@@ -47,10 +49,11 @@ var codeFieldRoot = function codeFieldRoot(Root) {
47
49
  onChange = _ref.onChange,
48
50
  onFullCodeEnter = _ref.onFullCodeEnter,
49
51
  rest = _objectWithoutProperties(_ref, _excluded);
50
- var _useState = useState(getCodeValue(codeLength, outerValue || '')),
52
+ var _useState = useState(getCodeValue(codeLength, '')),
51
53
  _useState2 = _slicedToArray(_useState, 2),
52
- code = _useState2[0],
53
- setCode = _useState2[1];
54
+ innerValue = _useState2[0],
55
+ setInnerValue = _useState2[1];
56
+ var code = outerValue !== null && outerValue !== void 0 && outerValue.length ? getCodeValue(codeLength, outerValue) : innerValue;
54
57
  var _useState3 = useState(code.join('')),
55
58
  _useState4 = _slicedToArray(_useState3, 2),
56
59
  originalValue = _useState4[0],
@@ -62,6 +65,7 @@ var codeFieldRoot = function codeFieldRoot(Root) {
62
65
  var placeholderValue = getPlaceholderValue(codeLength, placeholder);
63
66
  var parts = codeLength === 6 ? 2 : 1;
64
67
  var widthValue = width ? getSizeValueFromProp(width, 'rem') : undefined;
68
+ var isWebOTPEnabled = autoComplete === 'one-time-code' && !disabled && !isWebOTPSupported();
65
69
  var getLastActiveIndex = function getLastActiveIndex() {
66
70
  if (code.length && code.length < codeLength) {
67
71
  return code.length;
@@ -71,6 +75,27 @@ var codeFieldRoot = function codeFieldRoot(Root) {
71
75
  });
72
76
  return lastEmptyIndex >= 0 ? lastEmptyIndex : codeLength - 1;
73
77
  };
78
+ var codeSetter = function codeSetter(newCode) {
79
+ setInnerValue(newCode);
80
+ var originalCode = newCode.join('');
81
+ setOriginalValue(originalCode);
82
+ if (onChange) {
83
+ onChange(originalCode);
84
+ }
85
+ if (originalCode.length > 0) {
86
+ stopWebOTPListener();
87
+ }
88
+ };
89
+ var _useWebOTP = useWebOTP({
90
+ codeString: originalValue,
91
+ enableSMSAutoRead: autoComplete === 'one-time-code',
92
+ disabled: Boolean(disabled),
93
+ codeLength: codeLength,
94
+ codeSetter: codeSetter,
95
+ onFullCodeEnter: onFullCodeEnter
96
+ }),
97
+ startWebOTPListener = _useWebOTP.startWebOTPListener,
98
+ stopWebOTPListener = _useWebOTP.stopWebOTPListener;
74
99
  var handleClick = function handleClick() {
75
100
  if (disabled) {
76
101
  return;
@@ -90,28 +115,33 @@ var codeFieldRoot = function codeFieldRoot(Root) {
90
115
  return;
91
116
  }
92
117
  if (key === BACKSPACE_KEY) {
93
- if (index > 0 && code[index] === '') {
94
- var _inputRefs$current;
95
- (_inputRefs$current = inputRefs.current[index - 1]) === null || _inputRefs$current === void 0 || _inputRefs$current.focus();
118
+ if (index > 0) {
119
+ var _inputRefs$current$in;
120
+ var newCode = _toConsumableArray(code);
121
+ newCode[index] = '';
122
+ if (index >= codeLength - 1 && code[index]) {
123
+ codeSetter(newCode);
124
+ return;
125
+ }
126
+ if (!code[index]) {
127
+ var _inputRefs$current;
128
+ newCode[index - 1] = '';
129
+ (_inputRefs$current = inputRefs.current[index - 1]) === null || _inputRefs$current === void 0 || _inputRefs$current.focus();
130
+ }
131
+ (_inputRefs$current$in = inputRefs.current[index]) === null || _inputRefs$current$in === void 0 || _inputRefs$current$in.classList.remove(classes.itemError);
132
+ codeSetter(newCode);
96
133
  }
97
134
  }
98
135
  };
99
- var codeSetter = function codeSetter(newCode) {
100
- setCode(newCode);
101
- setOriginalValue(newCode.join(''));
102
- if (onChange) {
103
- onChange(newCode.join(''));
104
- }
105
- };
106
136
  var handleChange = function handleChange(event, index) {
107
- var _inputRefs$current$in;
137
+ var _inputRefs$current$in2;
108
138
  if (disabled) {
109
139
  return;
110
140
  }
111
141
  var rawSymbol = event.currentTarget.value;
112
142
  var symbol = rawSymbol.charAt(rawSymbol.length - 1);
113
143
  var newCode = _toConsumableArray(code);
114
- (_inputRefs$current$in = inputRefs.current[index]) === null || _inputRefs$current$in === void 0 || _inputRefs$current$in.classList.remove(classes.itemError);
144
+ (_inputRefs$current$in2 = inputRefs.current[index]) === null || _inputRefs$current$in2 === void 0 || _inputRefs$current$in2.classList.remove(classes.itemError);
115
145
  if (isError) {
116
146
  var _captionRef$current;
117
147
  (_captionRef$current = captionRef.current) === null || _captionRef$current === void 0 || _captionRef$current.classList.remove(classes.captionError);
@@ -133,8 +163,6 @@ var codeFieldRoot = function codeFieldRoot(Root) {
133
163
  return;
134
164
  }
135
165
  if (!symbol) {
136
- newCode[index] = '';
137
- codeSetter(newCode);
138
166
  return;
139
167
  }
140
168
  if (fieldPattern.test(symbol)) {
@@ -152,8 +180,9 @@ var codeFieldRoot = function codeFieldRoot(Root) {
152
180
  index: index,
153
181
  newCode: newCode,
154
182
  inputRefs: inputRefs,
155
- setCode: setCode,
156
- codeSetter: codeSetter
183
+ setInnerValue: setInnerValue,
184
+ codeSetter: codeSetter,
185
+ onChange: onChange
157
186
  });
158
187
  }
159
188
  };
@@ -180,6 +209,7 @@ var codeFieldRoot = function codeFieldRoot(Root) {
180
209
  if (onFullCodeEnter) {
181
210
  onFullCodeEnter(fullCode);
182
211
  }
212
+ startWebOTPListener();
183
213
  }, []);
184
214
  useCodeHook({
185
215
  inputRefs: inputRefs,
@@ -199,7 +229,7 @@ var codeFieldRoot = function codeFieldRoot(Root) {
199
229
  inputRefs: inputRefs,
200
230
  inputContainerRef: inputContainerRef,
201
231
  captionRef: captionRef,
202
- setCode: setCode,
232
+ setInnerValue: setInnerValue,
203
233
  codeSetter: codeSetter
204
234
  });
205
235
  }
@@ -212,7 +242,7 @@ var codeFieldRoot = function codeFieldRoot(Root) {
212
242
  disabled: disabled,
213
243
  onClick: handleClick,
214
244
  className: cls(className, _defineProperty({}, classes.captionAlignLeft, captionAlign === 'left'))
215
- }, rest), /*#__PURE__*/React.createElement(CodeWrapper, {
245
+ }, !isWebOTPEnabled && _objectSpread2({}, rest)), /*#__PURE__*/React.createElement(CodeWrapper, {
216
246
  ref: inputContainerRef
217
247
  }, _toConsumableArray(Array(parts)).map(function (_, partIndex) {
218
248
  return /*#__PURE__*/React.createElement(Fragment, {
@@ -228,7 +258,6 @@ var codeFieldRoot = function codeFieldRoot(Root) {
228
258
  },
229
259
  className: cls(_defineProperty(_defineProperty({}, classes.segmented, shape === 'segmented'), classes.hoverEnabled, !disabled && inputCorrectIndex >= originalValue.length)),
230
260
  value: code[inputCorrectIndex] || '',
231
- autoComplete: autoComplete,
232
261
  onChange: function onChange(e) {
233
262
  handleChange(e, inputCorrectIndex);
234
263
  },
@@ -245,7 +274,9 @@ var codeFieldRoot = function codeFieldRoot(Root) {
245
274
  ref: captionRef,
246
275
  captionAlign: captionAlign,
247
276
  widthValue: widthValue
248
- }, caption));
277
+ }, caption), isWebOTPEnabled && /*#__PURE__*/React.createElement(HiddenInput, _extends({
278
+ tabIndex: -1
279
+ }, rest)));
249
280
  });
250
281
  };
251
282
  var codeFieldConfig = {
@@ -1 +1 @@
1
- {"version":3,"file":"CodeField.js","sources":["../../../src/components/CodeField/CodeField.tsx"],"sourcesContent":["import React, { forwardRef, Fragment, useCallback, useRef, useState } from 'react';\nimport cls from 'classnames';\nimport type { ChangeEvent, KeyboardEvent, ClipboardEvent } from 'react';\nimport type { RootProps } from 'src/engines';\nimport { useDidMountEffect } from 'src/hooks';\nimport { getSizeValueFromProp } from 'src/utils';\n\nimport { useCodeHook } from '../../hooks';\n\nimport type { CodeFieldProps } from './CodeField.types';\nimport { BACKSPACE_KEY, FORBIDDEN_KEYS, ONLY_DIGITS_PATTERN } from './utils/constants';\nimport { getCodeValue, getFieldPattern, getPlaceholderValue, handleCodeError, handleItemError } from './utils';\nimport { classes } from './CodeField.tokens';\nimport { base, CaptionWrapper, CodeGroup, CodeWrapper, ItemInput, Separator } from './CodeField.styles';\nimport { base as viewCSS } from './variations/_view/base';\nimport { base as sizeCSS } from './variations/_size/base';\nimport { base as shapeCSS } from './variations/_shape/base';\nimport { base as disabledCSS } from './variations/_disabled/base';\n\nexport const codeFieldRoot = (Root: RootProps<HTMLDivElement, CodeFieldProps>) =>\n forwardRef<HTMLInputElement, CodeFieldProps>(\n (\n {\n className,\n value: outerValue,\n placeholder,\n autoFocus,\n codeLength = 6,\n caption,\n captionAlign = 'left',\n width,\n shape = 'default',\n view,\n size,\n disabled,\n isError,\n allowedSymbols = ONLY_DIGITS_PATTERN,\n itemErrorBehavior = 'remove-symbol',\n codeErrorBehavior = 'remove-code',\n autoComplete = 'one-time-code',\n setIsError,\n onChange,\n onFullCodeEnter,\n ...rest\n },\n ref,\n ) => {\n const [code, setCode] = useState<Array<string>>(getCodeValue(codeLength, outerValue || ''));\n const [originalValue, setOriginalValue] = useState<string>(code.join(''));\n\n const inputRefs = useRef<Array<HTMLInputElement>>([]);\n const inputContainerRef = useRef<HTMLDivElement | null>(null);\n const captionRef = useRef<HTMLDivElement | null>(null);\n\n const fieldPattern = getFieldPattern(allowedSymbols);\n const placeholderValue = getPlaceholderValue(codeLength, placeholder);\n const parts = codeLength === 6 ? 2 : 1;\n\n const widthValue = width ? getSizeValueFromProp(width, 'rem') : undefined;\n\n const getLastActiveIndex = () => {\n if (code.length && code.length < codeLength) {\n return code.length;\n }\n\n const lastEmptyIndex = code.findIndex((digit) => digit === '');\n return lastEmptyIndex >= 0 ? lastEmptyIndex : codeLength - 1;\n };\n\n const handleClick = () => {\n if (disabled) {\n return;\n }\n\n const lastActiveIndex = getLastActiveIndex();\n\n if (inputRefs.current[lastActiveIndex]) {\n inputRefs.current[lastActiveIndex].focus();\n }\n };\n\n const handleOnKeyDown = (event: KeyboardEvent<HTMLInputElement>, index: number) => {\n if (disabled) {\n return;\n }\n\n const { key } = event;\n if (FORBIDDEN_KEYS.includes(key)) {\n event.preventDefault();\n\n return;\n }\n\n if (key === BACKSPACE_KEY) {\n if (index > 0 && code[index] === '') {\n inputRefs.current[index - 1]?.focus();\n }\n }\n };\n\n const codeSetter = (newCode: Array<string>) => {\n setCode(newCode);\n setOriginalValue(newCode.join(''));\n\n if (onChange) {\n onChange(newCode.join(''));\n }\n };\n\n const handleChange = (event: ChangeEvent<HTMLInputElement>, index: number) => {\n if (disabled) {\n return;\n }\n\n const rawSymbol = event.currentTarget.value;\n const symbol = rawSymbol.charAt(rawSymbol.length - 1);\n const newCode = [...code];\n\n inputRefs.current[index]?.classList.remove(classes.itemError);\n if (isError) {\n captionRef.current?.classList.remove(classes.captionError);\n\n if (codeErrorBehavior === 'keep') {\n inputContainerRef.current?.classList.remove(classes.codeError, classes.codeErrorAnimation);\n }\n\n if (setIsError) {\n setIsError(false);\n }\n }\n\n if (!fieldPattern) {\n newCode[index] = symbol;\n codeSetter(newCode);\n\n if (symbol && index < codeLength - 1) {\n inputRefs.current[index + 1]?.focus();\n }\n\n return;\n }\n\n if (!symbol) {\n newCode[index] = '';\n codeSetter(newCode);\n\n return;\n }\n\n if (fieldPattern.test(symbol)) {\n newCode[index] = symbol.charAt(symbol.length - 1);\n codeSetter(newCode);\n\n if (index < codeLength - 1) {\n inputRefs.current[index + 1]?.focus();\n }\n } else {\n newCode[index] = symbol.charAt(symbol.length - 1);\n\n handleItemError({\n currentSymbol: symbol,\n itemErrorBehavior,\n index,\n newCode,\n inputRefs,\n setCode,\n codeSetter,\n });\n }\n };\n\n const handlePaste = (event: ClipboardEvent<HTMLInputElement>) => {\n const newCode = [...code];\n\n if (disabled) {\n return;\n }\n\n event.preventDefault();\n\n const rawData = event.clipboardData.getData('text/plain');\n\n const pastedData = (fieldPattern\n ? rawData\n .split('')\n .map((symb) => symb.match(fieldPattern)?.[0] || '')\n .filter(Boolean) || []\n : rawData.split('')\n ).slice(0, codeLength);\n\n pastedData.forEach((element, index) => {\n newCode[index] = element;\n });\n\n const activeIndex = Math.min(pastedData.length, codeLength - 1);\n inputRefs.current[activeIndex]?.focus();\n\n codeSetter(newCode);\n };\n\n const handleFullCodeEnter = useCallback((fullCode: string) => {\n if (onFullCodeEnter) {\n onFullCodeEnter(fullCode);\n }\n }, []);\n\n useCodeHook({\n inputRefs,\n codeLength,\n disabled,\n autoFocus,\n originalValue,\n getLastActiveIndex,\n handleFullCodeEnter,\n });\n\n useDidMountEffect(() => {\n if (isError) {\n handleCodeError({\n codeLength,\n codeErrorBehavior,\n currentCode: code,\n inputRefs,\n inputContainerRef,\n captionRef,\n setCode,\n codeSetter,\n });\n }\n }, [isError]);\n\n return (\n <Root\n ref={ref}\n view={view}\n size={size}\n shape={shape}\n disabled={disabled}\n onClick={handleClick}\n className={cls(className, {\n [classes.captionAlignLeft]: captionAlign === 'left',\n })}\n {...rest}\n >\n <CodeWrapper ref={inputContainerRef}>\n {[...Array(parts)].map((_, partIndex) => (\n <Fragment key={partIndex}>\n <CodeGroup role=\"group\">\n {[...Array(codeLength / parts)].map((_, i) => {\n const inputCorrectIndex = i + (codeLength / parts) * partIndex;\n\n return (\n <ItemInput\n key={partIndex + i + partIndex * i}\n ref={(element: HTMLInputElement) => {\n inputRefs.current[inputCorrectIndex] = element;\n }}\n className={cls({\n [classes.segmented]: shape === 'segmented',\n [classes.hoverEnabled]:\n !disabled && inputCorrectIndex >= originalValue.length,\n })}\n value={code[inputCorrectIndex] || ''}\n autoComplete={autoComplete}\n onChange={(e: ChangeEvent<HTMLInputElement>) => {\n handleChange(e, inputCorrectIndex);\n }}\n onKeyDown={(e: KeyboardEvent<HTMLInputElement>) => {\n handleOnKeyDown(e, inputCorrectIndex);\n }}\n onPaste={handlePaste}\n tabIndex={\n !disabled && originalValue.length === inputCorrectIndex ? 0 : -1\n }\n {...(placeholderValue && {\n placeholder: placeholderValue[inputCorrectIndex],\n })}\n />\n );\n })}\n </CodeGroup>\n {partIndex !== parts - 1 && <Separator />}\n </Fragment>\n ))}\n </CodeWrapper>\n {caption && (\n <CaptionWrapper ref={captionRef} captionAlign={captionAlign} widthValue={widthValue}>\n {caption}\n </CaptionWrapper>\n )}\n </Root>\n );\n },\n );\n\nexport const codeFieldConfig = {\n name: 'CodeField',\n tag: 'div',\n layout: codeFieldRoot,\n base,\n variations: {\n view: {\n css: viewCSS,\n },\n size: {\n css: sizeCSS,\n },\n shape: {\n css: shapeCSS,\n },\n disabled: {\n css: disabledCSS,\n attrs: true,\n },\n },\n defaults: {\n size: 'm',\n view: 'default',\n shape: 'default',\n },\n};\n"],"names":["codeFieldRoot","Root","forwardRef","_ref","ref","className","outerValue","value","placeholder","autoFocus","_ref$codeLength","codeLength","caption","_ref$captionAlign","captionAlign","width","_ref$shape","shape","view","size","disabled","isError","_ref$allowedSymbols","allowedSymbols","ONLY_DIGITS_PATTERN","_ref$itemErrorBehavio","itemErrorBehavior","_ref$codeErrorBehavio","codeErrorBehavior","_ref$autoComplete","autoComplete","setIsError","onChange","onFullCodeEnter","rest","_objectWithoutProperties","_excluded","_useState","useState","getCodeValue","_useState2","_slicedToArray","code","setCode","_useState3","join","_useState4","originalValue","setOriginalValue","inputRefs","useRef","inputContainerRef","captionRef","fieldPattern","getFieldPattern","placeholderValue","getPlaceholderValue","parts","widthValue","getSizeValueFromProp","undefined","getLastActiveIndex","length","lastEmptyIndex","findIndex","digit","handleClick","lastActiveIndex","current","focus","handleOnKeyDown","event","index","key","FORBIDDEN_KEYS","includes","preventDefault","BACKSPACE_KEY","_inputRefs$current","codeSetter","newCode","handleChange","_inputRefs$current$in","rawSymbol","currentTarget","symbol","charAt","_toConsumableArray","classList","remove","classes","itemError","_captionRef$current","captionError","_inputContainerRef$cu","codeError","codeErrorAnimation","_inputRefs$current2","test","_inputRefs$current3","handleItemError","currentSymbol","handlePaste","_inputRefs$current$ac","rawData","clipboardData","getData","pastedData","split","map","symb","_symb$match","match","filter","Boolean","slice","forEach","element","activeIndex","Math","min","handleFullCodeEnter","useCallback","fullCode","useCodeHook","useDidMountEffect","handleCodeError","currentCode","React","createElement","_extends","onClick","cls","_defineProperty","captionAlignLeft","CodeWrapper","Array","_","partIndex","Fragment","CodeGroup","role","i","inputCorrectIndex","ItemInput","segmented","hoverEnabled","e","onKeyDown","onPaste","tabIndex","_Separator","Separator","CaptionWrapper","codeFieldConfig","name","tag","layout","base","variations","css","viewCSS","sizeCSS","shapeCSS","disabledCSS","attrs","defaults"],"mappings":";;;;;;;;;;;;;;;;;;;IAmBaA,aAAa,GAAG,SAAhBA,aAAaA,CAAIC,IAA+C,EAAA;AAAA,EAAA,oBACzEC,UAAU,CACN,UAAAC,IAAA,EAwBIC,GAAG,EACF;AAAA,IAAA,IAvBGC,SAAS,GAAAF,IAAA,CAATE,SAAS;MACFC,UAAU,GAAAH,IAAA,CAAjBI,KAAK;MACLC,WAAW,GAAAL,IAAA,CAAXK,WAAW;MACXC,SAAS,GAAAN,IAAA,CAATM,SAAS;MAAAC,eAAA,GAAAP,IAAA,CACTQ,UAAU;AAAVA,MAAAA,UAAU,GAAAD,eAAA,KAAG,KAAA,CAAA,GAAA,CAAC,GAAAA,eAAA;MACdE,OAAO,GAAAT,IAAA,CAAPS,OAAO;MAAAC,iBAAA,GAAAV,IAAA,CACPW,YAAY;AAAZA,MAAAA,YAAY,GAAAD,iBAAA,KAAG,KAAA,CAAA,GAAA,MAAM,GAAAA,iBAAA;MACrBE,KAAK,GAAAZ,IAAA,CAALY,KAAK;MAAAC,UAAA,GAAAb,IAAA,CACLc,KAAK;AAALA,MAAAA,KAAK,GAAAD,UAAA,KAAG,KAAA,CAAA,GAAA,SAAS,GAAAA,UAAA;MACjBE,IAAI,GAAAf,IAAA,CAAJe,IAAI;MACJC,IAAI,GAAAhB,IAAA,CAAJgB,IAAI;MACJC,QAAQ,GAAAjB,IAAA,CAARiB,QAAQ;MACRC,OAAO,GAAAlB,IAAA,CAAPkB,OAAO;MAAAC,mBAAA,GAAAnB,IAAA,CACPoB,cAAc;AAAdA,MAAAA,cAAc,GAAAD,mBAAA,KAAGE,KAAAA,CAAAA,GAAAA,mBAAmB,GAAAF,mBAAA;MAAAG,qBAAA,GAAAtB,IAAA,CACpCuB,iBAAi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,EAAAA,MAAM,EAAE7J,aAAa;AACrB8J,EAAAA,IAAI,EAAJA,IAAI;AACJC,EAAAA,UAAU,EAAE;AACR7I,IAAAA,IAAI,EAAE;AACF8I,MAAAA,GAAG,EAAEC,MAAAA;KACR;AACD9I,IAAAA,IAAI,EAAE;AACF6I,MAAAA,GAAG,EAAEE,MAAAA;KACR;AACDjJ,IAAAA,KAAK,EAAE;AACH+I,MAAAA,GAAG,EAAEG,MAAAA;KACR;AACD/I,IAAAA,QAAQ,EAAE;AACN4I,MAAAA,GAAG,EAAEI,MAAW;AAChBC,MAAAA,KAAK,EAAE,IAAA;AACX,KAAA;GACH;AACDC,EAAAA,QAAQ,EAAE;AACNnJ,IAAAA,IAAI,EAAE,GAAG;AACTD,IAAAA,IAAI,EAAE,SAAS;AACfD,IAAAA,KAAK,EAAE,SAAA;AACX,GAAA;AACJ;;;;"}
1
+ {"version":3,"file":"CodeField.js","sources":["../../../src/components/CodeField/CodeField.tsx"],"sourcesContent":["import React, { forwardRef, Fragment, useCallback, useRef, useState } from 'react';\nimport cls from 'classnames';\nimport type { ChangeEvent, KeyboardEvent, ClipboardEvent } from 'react';\nimport type { RootProps } from 'src/engines';\nimport { useDidMountEffect } from 'src/hooks';\nimport { getSizeValueFromProp } from 'src/utils';\n\nimport { useCodeHook } from '../../hooks';\n\nimport type { CodeFieldProps } from './CodeField.types';\nimport { BACKSPACE_KEY, FORBIDDEN_KEYS, ONLY_DIGITS_PATTERN } from './utils/constants';\nimport {\n getCodeValue,\n getFieldPattern,\n getPlaceholderValue,\n handleCodeError,\n handleItemError,\n isWebOTPSupported,\n} from './utils';\nimport { classes } from './CodeField.tokens';\nimport { base, CaptionWrapper, CodeGroup, CodeWrapper, HiddenInput, ItemInput, Separator } from './CodeField.styles';\nimport { base as viewCSS } from './variations/_view/base';\nimport { base as sizeCSS } from './variations/_size/base';\nimport { base as shapeCSS } from './variations/_shape/base';\nimport { base as disabledCSS } from './variations/_disabled/base';\nimport { useWebOTP } from './hooks/useWebOTP';\n\nexport const codeFieldRoot = (Root: RootProps<HTMLDivElement, CodeFieldProps>) =>\n forwardRef<HTMLInputElement, CodeFieldProps>(\n (\n {\n className,\n value: outerValue,\n placeholder,\n autoFocus,\n codeLength = 6,\n caption,\n captionAlign = 'left',\n width,\n shape = 'default',\n view,\n size,\n disabled,\n isError,\n allowedSymbols = ONLY_DIGITS_PATTERN,\n itemErrorBehavior = 'remove-symbol',\n codeErrorBehavior = 'remove-code',\n autoComplete = 'one-time-code',\n setIsError,\n onChange,\n onFullCodeEnter,\n ...rest\n },\n ref,\n ) => {\n const [innerValue, setInnerValue] = useState<Array<string>>(getCodeValue(codeLength, ''));\n const code = outerValue?.length ? getCodeValue(codeLength, outerValue) : innerValue;\n\n const [originalValue, setOriginalValue] = useState<string>(code.join(''));\n\n const inputRefs = useRef<Array<HTMLInputElement>>([]);\n const inputContainerRef = useRef<HTMLDivElement | null>(null);\n const captionRef = useRef<HTMLDivElement | null>(null);\n\n const fieldPattern = getFieldPattern(allowedSymbols);\n const placeholderValue = getPlaceholderValue(codeLength, placeholder);\n const parts = codeLength === 6 ? 2 : 1;\n\n const widthValue = width ? getSizeValueFromProp(width, 'rem') : undefined;\n const isWebOTPEnabled = autoComplete === 'one-time-code' && !disabled && !isWebOTPSupported();\n\n const getLastActiveIndex = () => {\n if (code.length && code.length < codeLength) {\n return code.length;\n }\n\n const lastEmptyIndex = code.findIndex((digit) => digit === '');\n return lastEmptyIndex >= 0 ? lastEmptyIndex : codeLength - 1;\n };\n\n const codeSetter = (newCode: Array<string>) => {\n setInnerValue(newCode);\n const originalCode = newCode.join('');\n setOriginalValue(originalCode);\n\n if (onChange) {\n onChange(originalCode);\n }\n\n if (originalCode.length > 0) {\n stopWebOTPListener();\n }\n };\n\n const { startWebOTPListener, stopWebOTPListener } = useWebOTP({\n codeString: originalValue,\n enableSMSAutoRead: autoComplete === 'one-time-code',\n disabled: Boolean(disabled),\n codeLength,\n codeSetter,\n onFullCodeEnter,\n });\n\n const handleClick = () => {\n if (disabled) {\n return;\n }\n\n const lastActiveIndex = getLastActiveIndex();\n\n if (inputRefs.current[lastActiveIndex]) {\n inputRefs.current[lastActiveIndex].focus();\n }\n };\n\n const handleOnKeyDown = (event: KeyboardEvent<HTMLInputElement>, index: number) => {\n if (disabled) {\n return;\n }\n\n const { key } = event;\n if (FORBIDDEN_KEYS.includes(key)) {\n event.preventDefault();\n\n return;\n }\n\n if (key === BACKSPACE_KEY) {\n if (index > 0) {\n const newCode = [...code];\n\n newCode[index] = '';\n\n if (index >= codeLength - 1 && code[index]) {\n codeSetter(newCode);\n return;\n }\n\n if (!code[index]) {\n newCode[index - 1] = '';\n inputRefs.current[index - 1]?.focus();\n }\n\n inputRefs.current[index]?.classList.remove(classes.itemError);\n codeSetter(newCode);\n }\n }\n };\n\n const handleChange = (event: ChangeEvent<HTMLInputElement>, index: number) => {\n if (disabled) {\n return;\n }\n\n const rawSymbol = event.currentTarget.value;\n const symbol = rawSymbol.charAt(rawSymbol.length - 1);\n const newCode = [...code];\n\n inputRefs.current[index]?.classList.remove(classes.itemError);\n if (isError) {\n captionRef.current?.classList.remove(classes.captionError);\n\n if (codeErrorBehavior === 'keep') {\n inputContainerRef.current?.classList.remove(classes.codeError, classes.codeErrorAnimation);\n }\n\n if (setIsError) {\n setIsError(false);\n }\n }\n\n if (!fieldPattern) {\n newCode[index] = symbol;\n codeSetter(newCode);\n\n if (symbol && index < codeLength - 1) {\n inputRefs.current[index + 1]?.focus();\n }\n\n return;\n }\n\n if (!symbol) {\n return;\n }\n\n if (fieldPattern.test(symbol)) {\n newCode[index] = symbol.charAt(symbol.length - 1);\n codeSetter(newCode);\n\n if (index < codeLength - 1) {\n inputRefs.current[index + 1]?.focus();\n }\n } else {\n newCode[index] = symbol.charAt(symbol.length - 1);\n\n handleItemError({\n currentSymbol: symbol,\n itemErrorBehavior,\n index,\n newCode,\n inputRefs,\n setInnerValue,\n codeSetter,\n onChange,\n });\n }\n };\n\n const handlePaste = (event: ClipboardEvent<HTMLInputElement>) => {\n const newCode = [...code];\n\n if (disabled) {\n return;\n }\n\n event.preventDefault();\n\n const rawData = event.clipboardData.getData('text/plain');\n\n const pastedData = (fieldPattern\n ? rawData\n .split('')\n .map((symb) => symb.match(fieldPattern)?.[0] || '')\n .filter(Boolean) || []\n : rawData.split('')\n ).slice(0, codeLength);\n\n pastedData.forEach((element, index) => {\n newCode[index] = element;\n });\n\n const activeIndex = Math.min(pastedData.length, codeLength - 1);\n inputRefs.current[activeIndex]?.focus();\n\n codeSetter(newCode);\n };\n\n const handleFullCodeEnter = useCallback((fullCode: string) => {\n if (onFullCodeEnter) {\n onFullCodeEnter(fullCode);\n }\n\n startWebOTPListener();\n }, []);\n\n useCodeHook({\n inputRefs,\n codeLength,\n disabled,\n autoFocus,\n originalValue,\n getLastActiveIndex,\n handleFullCodeEnter,\n });\n\n useDidMountEffect(() => {\n if (isError) {\n handleCodeError({\n codeLength,\n codeErrorBehavior,\n currentCode: code,\n inputRefs,\n inputContainerRef,\n captionRef,\n setInnerValue,\n codeSetter,\n });\n }\n }, [isError]);\n\n return (\n <Root\n ref={ref}\n view={view}\n size={size}\n shape={shape}\n disabled={disabled}\n onClick={handleClick}\n className={cls(className, {\n [classes.captionAlignLeft]: captionAlign === 'left',\n })}\n {...(!isWebOTPEnabled && { ...rest })}\n >\n <CodeWrapper ref={inputContainerRef}>\n {[...Array(parts)].map((_, partIndex) => (\n <Fragment key={partIndex}>\n <CodeGroup role=\"group\">\n {[...Array(codeLength / parts)].map((_, i) => {\n const inputCorrectIndex = i + (codeLength / parts) * partIndex;\n\n return (\n <ItemInput\n key={partIndex + i + partIndex * i}\n ref={(element: HTMLInputElement) => {\n inputRefs.current[inputCorrectIndex] = element;\n }}\n className={cls({\n [classes.segmented]: shape === 'segmented',\n [classes.hoverEnabled]:\n !disabled && inputCorrectIndex >= originalValue.length,\n })}\n value={code[inputCorrectIndex] || ''}\n onChange={(e: ChangeEvent<HTMLInputElement>) => {\n handleChange(e, inputCorrectIndex);\n }}\n onKeyDown={(e: KeyboardEvent<HTMLInputElement>) => {\n handleOnKeyDown(e, inputCorrectIndex);\n }}\n onPaste={handlePaste}\n tabIndex={\n !disabled && originalValue.length === inputCorrectIndex ? 0 : -1\n }\n {...(placeholderValue && {\n placeholder: placeholderValue[inputCorrectIndex],\n })}\n />\n );\n })}\n </CodeGroup>\n {partIndex !== parts - 1 && <Separator />}\n </Fragment>\n ))}\n </CodeWrapper>\n\n {caption && (\n <CaptionWrapper ref={captionRef} captionAlign={captionAlign} widthValue={widthValue}>\n {caption}\n </CaptionWrapper>\n )}\n\n {isWebOTPEnabled && <HiddenInput tabIndex={-1} {...rest} />}\n </Root>\n );\n },\n );\n\nexport const codeFieldConfig = {\n name: 'CodeField',\n tag: 'div',\n layout: codeFieldRoot,\n base,\n variations: {\n view: {\n css: viewCSS,\n },\n size: {\n css: sizeCSS,\n },\n shape: {\n css: shapeCSS,\n },\n disabled: {\n css: disabledCSS,\n attrs: true,\n },\n },\n defaults: {\n size: 'm',\n view: 'default',\n shape: 'default',\n },\n};\n"],"names":["codeFieldRoot","Root","forwardRef","_ref","ref","className","outerValue","value","placeholder","autoFocus","_ref$codeLength","codeLength","caption","_ref$captionAlign","captionAlign","width","_ref$shape","shape","view","size","disabled","isError","_ref$allowedSymbols","allowedSymbols","ONLY_DIGITS_PATTERN","_ref$itemErrorBehavio","itemErrorBehavior","_ref$codeErrorBehavio","codeErrorBehavior","_ref$autoComplete","autoComplete","setIsError","onChange","onFullCodeEnter","rest","_objectWithoutProperties","_excluded","_useState","useState","getCodeValue","_useState2","_slicedToArray","innerValue","setInnerValue","code","length","_useState3","join","_useState4","originalValue","setOriginalValue","inputRefs","useRef","inputContainerRef","captionRef","fieldPattern","getFieldPattern","placeholderValue","getPlaceholderValue","parts","widthValue","getSizeValueFromProp","undefined","isWebOTPEnabled","isWebOTPSupported","getLastActiveIndex","lastEmptyIndex","findIndex","digit","codeSetter","newCode","originalCode","stopWebOTPListener","_useWebOTP","useWebOTP","codeString","enableSMSAutoRead","Boolean","startWebOTPListener","handleClick","lastActiveIndex","current","focus","handleOnKeyDown","event","index","key","FORBIDDEN_KEYS","includes","preventDefault","BACKSPACE_KEY","_inputRefs$current$in","_toConsumableArray","_inputRefs$current","classList","remove","classes","itemError","handleChange","_inputRefs$current$in2","rawSymbol","currentTarget","symbol","charAt","_captionRef$current","captionError","_inputContainerRef$cu","codeError","codeErrorAnimation","_inputRefs$current2","test","_inputRefs$current3","handleItemError","currentSymbol","handlePaste","_inputRefs$current$ac","rawData","clipboardData","getData","pastedData","split","map","symb","_symb$match","match","filter","slice","forEach","element","activeIndex","Math","min","handleFullCodeEnter","useCallback","fullCode","useCodeHook","useDidMountEffect","handleCodeError","currentCode","React","createElement","_extends","onClick","cls","_defineProperty","captionAlignLeft","_objectSpread","CodeWrapper","Array","_","partIndex","Fragment","CodeGroup","role","i","inputCorrectIndex","ItemInput","segmented","hoverEnabled","e","onKeyDown","onPaste","tabIndex","_Separator","Separator","CaptionWrapper","HiddenInput","codeFieldConfig","name","tag","layout","base","variations","css","viewCSS","sizeCSS","shapeCSS","disabledCSS","attrs","defaults"],"mappings":";;;;;;;;;;;;;;;;;;;;;IA2BaA,aAAa,GAAG,SAAhBA,aAAaA,CAAIC,IAA+C,EAAA;AAAA,EAAA,oBACzEC,UAAU,CACN,UAAAC,IAAA,EAwBIC,GAAG,EACF;AAAA,IAAA,IAvBGC,SAAS,GAAAF,IAAA,CAATE,SAAS;MACFC,UAAU,GAAAH,IAAA,CAAjBI,KAAK;MACLC,WAAW,GAAAL,IAAA,CAAXK,WAAW;MACXC,SAAS,GAAAN,IAAA,CAATM,SAAS;MAAAC,eAAA,GAAAP,IAAA,CACTQ,UAAU;AAAVA,MAAAA,UAAU,GAAAD,eAAA,KAAG,KAAA,CAAA,GAAA,CAAC,GAAAA,eAAA;MACdE,OAAO,GAAAT,IAAA,CAAPS,OAAO;MAAAC,iBAAA,GAAAV,IAAA,CACPW,YAAY;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AAEI,MAAW;AAChBC,MAAAA,KAAK,EAAE,IAAA;AACX,KAAA;GACH;AACDC,EAAAA,QAAQ,EAAE;AACNhK,IAAAA,IAAI,EAAE,GAAG;AACTD,IAAAA,IAAI,EAAE,SAAS;AACfD,IAAAA,KAAK,EAAE,SAAA;AACX,GAAA;AACJ;;;;"}
@@ -1,4 +1,4 @@
1
- import './CodeField.styles_ebdpd0.css';
1
+ import './CodeField.styles_14p25hi.css';
2
2
  import { styled } from '@linaria/react';
3
3
 
4
4
  var base = "b1xx9skx";
@@ -43,6 +43,11 @@ var CaptionWrapper = /*#__PURE__*/styled('div')({
43
43
  "c1jpzjak-1": [/*#__PURE__*/_exp5()]
44
44
  }
45
45
  });
46
+ var HiddenInput = /*#__PURE__*/styled('input')({
47
+ name: "HiddenInput",
48
+ "class": "h1x845wl",
49
+ propsAsIs: false
50
+ });
46
51
 
47
- export { CaptionWrapper, CodeGroup, CodeWrapper, ItemInput, Separator, base };
52
+ export { CaptionWrapper, CodeGroup, CodeWrapper, HiddenInput, ItemInput, Separator, base };
48
53
  //# sourceMappingURL=CodeField.styles.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"CodeField.styles.js","sources":["../../../src/components/CodeField/CodeField.styles.ts"],"sourcesContent":["import { css } from '@linaria/core';\nimport { styled } from '@linaria/react';\n\nimport { classes, tokens } from './CodeField.tokens';\n\nexport const base = css`\n display: flex;\n flex-direction: column;\n justify-content: center;\n width: min-content;\n align-items: center;\n\n &.${classes.captionAlignLeft} {\n align-items: flex-start;\n }\n`;\n\nexport const CodeWrapper = styled.div`\n display: flex;\n align-items: center;\n`;\n\nexport const CodeGroup = styled.div`\n display: flex;\n align-items: center;\n`;\n\nexport const Separator = styled.div`\n width: var(${tokens.separatorWidth});\n`;\n\nexport const ItemInput = styled.input`\n box-sizing: border-box;\n appearance: none;\n border: 0;\n padding: 0;\n outline: none;\n pointer-events: none;\n text-align: center;\n`;\n\nexport const CaptionWrapper = styled.div<{ captionAlign: 'left' | 'center'; widthValue?: string }>`\n text-align: ${({ captionAlign }) => captionAlign};\n align-self: ${({ captionAlign }) => captionAlign};\n width: ${({ widthValue }) => widthValue || 'auto'};\n white-space: pre-line;\n`;\n"],"names":["base","CodeWrapper","styled","name","class","propsAsIs","CodeGroup","Separator","ItemInput","_exp4","_ref","captionAlign","_exp5","_ref2","widthValue","CaptionWrapper","vars"],"mappings":";;AAKO,IAAMA,IAAI,GAUhB,WAAA;AAEM,IAAMC,WAAW,gBAAGC,MAAM,CAAA,KAAA,CAAA,CAAA;AAAAC,EAAAA,IAAA,EAAA,aAAA;AAAAC,EAAAA,OAAAA,EAAA,UAAA;AAAAC,EAAAA,SAAA,EAAA,KAAA;AAAA,CAGhC,EAAA;AAEM,IAAMC,SAAS,gBAAGJ,MAAM,CAAA,KAAA,CAAA,CAAA;AAAAC,EAAAA,IAAA,EAAA,WAAA;AAAAC,EAAAA,OAAAA,EAAA,SAAA;AAAAC,EAAAA,SAAA,EAAA,KAAA;AAAA,CAG9B,EAAA;AAEM,IAAME,SAAS,gBAAGL,MAAM,CAAA,KAAA,CAAA,CAAA;AAAAC,EAAAA,IAAA,EAAA,WAAA;AAAAC,EAAAA,OAAAA,EAAA,UAAA;AAAAC,EAAAA,SAAA,EAAA,KAAA;AAAA,CAE9B,EAAA;AAEM,IAAMG,SAAS,gBAAGN,MAAM,CAAA,OAAA,CAAA,CAAA;AAAAC,EAAAA,IAAA,EAAA,WAAA;AAAAC,EAAAA,OAAAA,EAAA,SAAA;AAAAC,EAAAA,SAAA,EAAA,KAAA;AAAA,CAQ9B,EAAA;AAAC,IAAAI,KAAA,GAtCgBA,SAsChBA,KAAAA,GAAA;AAAA,EAAA,OAIgB,UAAAC,IAAA,EAAA;AAAA,IAAA,IAAGC,YAAAA,GAAAA,IAAAA,CAAAA,YAAAA,CAAAA;AAAAA,IAAAA,OAAmBA,YAAY,CAAA;AAAA,GAAA,CAAA;AAAA,CAAA,CAAA;AAAA,IAAAC,KAAA,GA1ClCA,SA0CkCA,KAAAA,GAAA;AAAA,EAAA,OACvC,UAAAC,KAAA,EAAA;AAAA,IAAA,IAAGC,UAAAA,GAAAA,KAAAA,CAAAA,UAAAA,CAAAA;IAAAA,OAAiBA,UAAU,IAAI,MAAM,CAAA;AAAA,GAAA,CAAA;AAAA,CAAA,CAAA;AAH9C,IAAMC,cAAc,gBAAGb,MAAM,CAAA,KAAA,CAAA,CAAA;AAAAC,EAAAA,IAAA,EAAA,gBAAA;AAAAC,EAAAA,OAAAA,EAAA,UAAA;AAAAC,EAAAA,SAAA,EAAA,KAAA;AAAAW,EAAAA,IAAA,EAAA;AAAA,IAAA,YAAA,EAAA,cAElBP,KAAkC,EAAA,CAAA;AAAA,IAAA,YAAA,EAAA,cACvCG,KAAwC,EAAA,CAAA;AAAA,GAAA;AAAA,CAEpD;;;;"}
1
+ {"version":3,"file":"CodeField.styles.js","sources":["../../../src/components/CodeField/CodeField.styles.ts"],"sourcesContent":["import { css } from '@linaria/core';\nimport { styled } from '@linaria/react';\n\nimport { classes, tokens } from './CodeField.tokens';\n\nexport const base = css`\n display: flex;\n flex-direction: column;\n justify-content: center;\n width: min-content;\n align-items: center;\n\n &.${classes.captionAlignLeft} {\n align-items: flex-start;\n }\n`;\n\nexport const CodeWrapper = styled.div`\n display: flex;\n align-items: center;\n`;\n\nexport const CodeGroup = styled.div`\n display: flex;\n align-items: center;\n`;\n\nexport const Separator = styled.div`\n width: var(${tokens.separatorWidth});\n`;\n\nexport const ItemInput = styled.input`\n box-sizing: border-box;\n appearance: none;\n border: 0;\n padding: 0;\n outline: none;\n pointer-events: none;\n text-align: center;\n`;\n\nexport const CaptionWrapper = styled.div<{ captionAlign: 'left' | 'center'; widthValue?: string }>`\n text-align: ${({ captionAlign }) => captionAlign};\n align-self: ${({ captionAlign }) => captionAlign};\n width: ${({ widthValue }) => widthValue || 'auto'};\n white-space: pre-line;\n`;\n\nexport const HiddenInput = styled.input`\n display: none;\n`;\n"],"names":["base","CodeWrapper","styled","name","class","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AI,MAAM,CAAA;AAAA,GAAA,CAAA;AAAA,CAAA,CAAA;AAH9C,IAAMC,cAAc,gBAAGb,MAAM,CAAA,KAAA,CAAA,CAAA;AAAAC,EAAAA,IAAA,EAAA,gBAAA;AAAAC,EAAAA,OAAAA,EAAA,UAAA;AAAAC,EAAAA,SAAA,EAAA,KAAA;AAAAW,EAAAA,IAAA,EAAA;AAAA,IAAA,YAAA,EAAA,cAElBP,KAAkC,EAAA,CAAA;AAAA,IAAA,YAAA,EAAA,cACvCG,KAAwC,EAAA,CAAA;AAAA,GAAA;AAAA,CAEpD,EAAA;AAEM,IAAMK,WAAW,gBAAGf,MAAM,CAAA,OAAA,CAAA,CAAA;AAAAC,EAAAA,IAAA,EAAA,aAAA;AAAAC,EAAAA,OAAAA,EAAA,UAAA;AAAAC,EAAAA,SAAA,EAAA,KAAA;AAAA,CAEhC;;;;"}
@@ -4,3 +4,4 @@
4
4
  .s13uxcg8{width:var(--plasma-codefield-separator-width);}
5
5
  .ig5h1kg{box-sizing:border-box;-webkit-appearance:none;-moz-appearance:none;appearance:none;border:0;padding:0;outline:none;pointer-events:none;text-align:center;}
6
6
  .c1jpzjak{text-align:var(--c1jpzjak-0);-webkit-align-self:var(--c1jpzjak-0);-ms-flex-item-align:var(--c1jpzjak-0);align-self:var(--c1jpzjak-0);width:var(--c1jpzjak-1);white-space:pre-line;}
7
+ .h1x845wl{display:none;}
@@ -0,0 +1,99 @@
1
+ import { asyncToGenerator as _asyncToGenerator, regeneratorRuntime as _regeneratorRuntime } from '../../../_virtual/_rollupPluginBabelHelpers.js';
2
+ import { useRef, useCallback, useEffect } from 'react';
3
+ import { isWebOTPSupported } from '../utils/isWebOTPSupported.js';
4
+ import { getCodeValue } from '../utils/initialValuesHelper.js';
5
+
6
+ // Type guard function to check if credential is OTPCredential
7
+ var isOTPCredential = function isOTPCredential(credential) {
8
+ return credential !== null && 'code' in credential;
9
+ };
10
+ var useWebOTP = function useWebOTP(_ref) {
11
+ var codeString = _ref.codeString,
12
+ enableSMSAutoRead = _ref.enableSMSAutoRead,
13
+ disabled = _ref.disabled,
14
+ codeLength = _ref.codeLength,
15
+ codeSetter = _ref.codeSetter,
16
+ onFullCodeEnter = _ref.onFullCodeEnter;
17
+ var abortControllerRef = useRef(null);
18
+ var startWebOTPListener = useCallback(/*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
19
+ var otp, otpCode, newCode;
20
+ return _regeneratorRuntime().wrap(function _callee$(_context) {
21
+ while (1) switch (_context.prev = _context.next) {
22
+ case 0:
23
+ if (!(!enableSMSAutoRead || disabled || !isWebOTPSupported())) {
24
+ _context.next = 2;
25
+ break;
26
+ }
27
+ return _context.abrupt("return");
28
+ case 2:
29
+ if (abortControllerRef.current) {
30
+ abortControllerRef.current.abort();
31
+ }
32
+ abortControllerRef.current = new AbortController();
33
+ _context.prev = 4;
34
+ _context.next = 7;
35
+ return navigator.credentials.get({
36
+ otp: {
37
+ transport: ['sms']
38
+ },
39
+ signal: abortControllerRef.current.signal
40
+ });
41
+ case 7:
42
+ otp = _context.sent;
43
+ // Type guard to check if it's an OTP credential
44
+ if (otp && isOTPCredential(otp) && otp.code) {
45
+ otpCode = otp.code; // Validate the OTP code length matches our expected length
46
+ if (otpCode.length === codeLength) {
47
+ newCode = getCodeValue(codeLength, otpCode);
48
+ codeSetter(newCode);
49
+
50
+ // Trigger full code enter callback
51
+ if (onFullCodeEnter) {
52
+ onFullCodeEnter(otpCode);
53
+ }
54
+ }
55
+ }
56
+ _context.next = 14;
57
+ break;
58
+ case 11:
59
+ _context.prev = 11;
60
+ _context.t0 = _context["catch"](4);
61
+ if (_context.t0 instanceof DOMException) {
62
+ if (_context.t0.name !== 'AbortError' && _context.t0.name !== 'NotAllowedError') {
63
+ console.warn('Web OTP API error:', _context.t0);
64
+ }
65
+ } else if (_context.t0 instanceof Error) {
66
+ console.warn('Web OTP API error:', _context.t0);
67
+ } else {
68
+ console.warn('Unknown Web OTP API error:', _context.t0);
69
+ }
70
+ case 14:
71
+ case "end":
72
+ return _context.stop();
73
+ }
74
+ }, _callee, null, [[4, 11]]);
75
+ })), [enableSMSAutoRead, disabled, codeLength, onFullCodeEnter]);
76
+ var stopWebOTPListener = useCallback(function () {
77
+ if (abortControllerRef.current) {
78
+ abortControllerRef.current.abort();
79
+ abortControllerRef.current = null;
80
+ }
81
+ }, []);
82
+ useEffect(function () {
83
+ if (isWebOTPSupported() && codeString === '' && enableSMSAutoRead && !disabled) {
84
+ startWebOTPListener();
85
+ } else {
86
+ stopWebOTPListener();
87
+ }
88
+ return function () {
89
+ stopWebOTPListener();
90
+ };
91
+ }, [codeString, enableSMSAutoRead, disabled, startWebOTPListener, stopWebOTPListener]);
92
+ return {
93
+ startWebOTPListener: startWebOTPListener,
94
+ stopWebOTPListener: stopWebOTPListener
95
+ };
96
+ };
97
+
98
+ export { useWebOTP };
99
+ //# sourceMappingURL=useWebOTP.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useWebOTP.js","sources":["../../../../src/components/CodeField/hooks/useWebOTP.ts"],"sourcesContent":["import { useCallback, useEffect, useRef } from 'react';\n\nimport { getCodeValue, isWebOTPSupported } from '../utils';\n\ntype UseWebOTPProps = {\n codeString: string;\n enableSMSAutoRead: boolean;\n disabled: boolean;\n codeLength: number;\n codeSetter: (newCode: Array<string>) => void;\n onFullCodeEnter?: (code: string) => void;\n};\n\ntype OTPTransport = 'sms';\n\ninterface OTPCredential extends Credential {\n code: string;\n}\n\ndeclare global {\n interface CredentialRequestOptions {\n otp?: {\n transport: OTPTransport[];\n };\n signal?: AbortSignal;\n }\n}\n\n// Type guard function to check if credential is OTPCredential\nconst isOTPCredential = (credential: Credential | null): credential is OTPCredential => {\n return credential !== null && 'code' in credential;\n};\n\nexport const useWebOTP = ({\n codeString,\n enableSMSAutoRead,\n disabled,\n codeLength,\n codeSetter,\n onFullCodeEnter,\n}: UseWebOTPProps) => {\n const abortControllerRef = useRef<AbortController | null>(null);\n\n const startWebOTPListener = useCallback(async () => {\n if (!enableSMSAutoRead || disabled || !isWebOTPSupported()) {\n return;\n }\n\n if (abortControllerRef.current) {\n abortControllerRef.current.abort();\n }\n\n abortControllerRef.current = new AbortController();\n\n try {\n const otp = await navigator.credentials.get({\n otp: { transport: ['sms'] as OTPTransport[] },\n signal: abortControllerRef.current.signal,\n });\n\n // Type guard to check if it's an OTP credential\n if (otp && isOTPCredential(otp) && otp.code) {\n const otpCode = otp.code;\n\n // Validate the OTP code length matches our expected length\n if (otpCode.length === codeLength) {\n const newCode = getCodeValue(codeLength, otpCode);\n codeSetter(newCode);\n\n // Trigger full code enter callback\n if (onFullCodeEnter) {\n onFullCodeEnter(otpCode);\n }\n }\n }\n } catch (err) {\n if (err instanceof DOMException) {\n if (err.name !== 'AbortError' && err.name !== 'NotAllowedError') {\n console.warn('Web OTP API error:', err);\n }\n } else if (err instanceof Error) {\n console.warn('Web OTP API error:', err);\n } else {\n console.warn('Unknown Web OTP API error:', err);\n }\n }\n }, [enableSMSAutoRead, disabled, codeLength, onFullCodeEnter]);\n\n const stopWebOTPListener = useCallback(() => {\n if (abortControllerRef.current) {\n abortControllerRef.current.abort();\n abortControllerRef.current = null;\n }\n }, []);\n\n useEffect(() => {\n if (isWebOTPSupported() && codeString === '' && enableSMSAutoRead && !disabled) {\n startWebOTPListener();\n } else {\n stopWebOTPListener();\n }\n\n return () => {\n stopWebOTPListener();\n };\n }, [codeString, enableSMSAutoRead, disabled, startWebOTPListener, stopWebOTPListener]);\n\n return { startWebOTPListener, stopWebOTPListener };\n};\n"],"names":["isOTPCredential","credential","useWebOTP","_ref","codeString","enableSMSAutoRead","disabled","codeLength","codeSetter","onFullCodeEnter","abortControllerRef","useRef","startWebOTPListener","useCallback","_asyncToGenerator","_regeneratorRuntime","mark","_callee","otp","otpCode","newCode","wrap","_callee$","_context","prev","next","isWebOTPSupported","abrupt","current","abort","AbortController","navigator","credentials","get","transport","signal","sent","code","length","getCodeValue","t0","DOMException","name","console","warn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mC,MAAAA,kBAAkB,EAAE,CAAA;AACxB,KAAA;AAEA,IAAA,OAAO,YAAM;AACTA,MAAAA,kBAAkB,EAAE,CAAA;KACvB,CAAA;AACL,GAAC,EAAE,CAAC3C,UAAU,EAAEC,iBAAiB,EAAEC,QAAQ,EAAEM,mBAAmB,EAAEmC,kBAAkB,CAAC,CAAC,CAAA;EAEtF,OAAO;AAAEnC,IAAAA,mBAAmB,EAAnBA,mBAAmB;AAAEmC,IAAAA,kBAAkB,EAAlBA,kBAAAA;GAAoB,CAAA;AACtD;;;;"}
@@ -11,7 +11,7 @@ var handleCodeError = function handleCodeError(_ref) {
11
11
  inputRefs = _ref.inputRefs,
12
12
  inputContainerRef = _ref.inputContainerRef,
13
13
  captionRef = _ref.captionRef,
14
- setCode = _ref.setCode,
14
+ setInnerValue = _ref.setInnerValue,
15
15
  codeSetter = _ref.codeSetter;
16
16
  if (!inputContainerRef.current) {
17
17
  return;
@@ -25,7 +25,7 @@ var handleCodeError = function handleCodeError(_ref) {
25
25
  var newCode = _toConsumableArray(currentCode);
26
26
  newCode.pop();
27
27
  codeSetter(newCode);
28
- setCode(currentCode);
28
+ setInnerValue(currentCode);
29
29
  (_inputContainerRef$cu = inputContainerRef.current) === null || _inputContainerRef$cu === void 0 || _inputContainerRef$cu.classList.remove(classes.codeErrorAnimation);
30
30
  setTimeout(function () {
31
31
  var _inputRefs$current, _inputRefs$current2;
@@ -1 +1 @@
1
- {"version":3,"file":"handleCodeError.js","sources":["../../../../src/components/CodeField/utils/handleCodeError.ts"],"sourcesContent":["import { Dispatch, MutableRefObject, SetStateAction } from 'react';\n\nimport type { CodeErrorBehavior } from '../CodeField.types';\nimport { classes } from '../CodeField.tokens';\n\nimport { ANIMATION_TIMEOUT } from './constants';\nimport { getCodeValue } from './initialValuesHelper';\n\ntype ValidateSymbolsArgs = {\n codeLength: number;\n codeErrorBehavior: CodeErrorBehavior;\n currentCode: Array<string>;\n inputContainerRef: MutableRefObject<HTMLDivElement | null>;\n inputRefs: MutableRefObject<Array<HTMLInputElement | null>>;\n captionRef: MutableRefObject<HTMLDivElement | null>;\n setCode: Dispatch<SetStateAction<Array<string>>>;\n codeSetter: (newCode: Array<string>) => void;\n};\n\nexport const handleCodeError = ({\n codeLength,\n codeErrorBehavior,\n currentCode,\n inputRefs,\n inputContainerRef,\n captionRef,\n setCode,\n codeSetter,\n}: ValidateSymbolsArgs) => {\n if (!inputContainerRef.current) {\n return;\n }\n\n switch (codeErrorBehavior) {\n case 'keep':\n inputContainerRef.current.classList.add(classes.codeError, classes.codeErrorAnimation);\n captionRef.current?.classList.add(classes.captionError);\n\n setTimeout(() => {\n const newCode = [...currentCode];\n\n newCode.pop();\n codeSetter(newCode);\n setCode(currentCode);\n\n inputContainerRef.current?.classList.remove(classes.codeErrorAnimation);\n\n setTimeout(() => {\n inputRefs.current[inputRefs.current.length - 1]?.setSelectionRange(0, 1);\n inputRefs.current[inputRefs.current.length - 1]?.focus();\n }, 0);\n }, ANIMATION_TIMEOUT);\n\n break;\n case 'remove-code':\n default:\n inputContainerRef.current.classList.add(\n classes.codeError,\n classes.codeErrorAnimation,\n classes.codeErrorFade,\n );\n captionRef.current?.classList.add(classes.captionError);\n\n setTimeout(() => {\n codeSetter(getCodeValue(codeLength, ''));\n\n inputRefs.current[0]?.focus();\n inputContainerRef.current?.classList.remove(\n classes.codeError,\n classes.codeErrorAnimation,\n classes.codeErrorFade,\n );\n }, ANIMATION_TIMEOUT);\n }\n};\n"],"names":["handleCodeError","_ref","_captionRef$current","_captionRef$current2","codeLength","codeErrorBehavior","currentCode","inputRefs","inputContainerRef","captionRef","setCode","codeSetter","current","classList","add","classes","codeError","codeErrorAnimation","captionError","setTimeout","_inputContainerRef$cu","newCode","_toConsumableArray","pop","remove","_inputRefs$current","_inputRefs$current2","length","setSelectionRange","focus","ANIMATION_TIMEOUT","codeErrorFade","_inputRefs$current$","_inputContainerRef$cu2","getCodeValue"],"mappings":";;;;;IAmBaA,eAAe,GAAG,SAAlBA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AAI,sBAAA,GAAAzB,iBAAiB,CAACI,OAAO,cAAAqB,sBAAA,KAAA,KAAA,CAAA,IAAzBA,sBAAA,CAA2BpB,SAAS,CAACW,MAAM,CACvCT,OAAO,CAACC,SAAS,EACjBD,OAAO,CAACE,kBAAkB,EAC1BF,OAAO,CAACgB,aACZ,CAAC,CAAA;OACJ,EAAED,iBAAiB,CAAC,CAAA;AAC7B,GAAA;AACJ;;;;"}
1
+ {"version":3,"file":"handleCodeError.js","sources":["../../../../src/components/CodeField/utils/handleCodeError.ts"],"sourcesContent":["import { Dispatch, MutableRefObject, SetStateAction } from 'react';\n\nimport type { CodeErrorBehavior } from '../CodeField.types';\nimport { classes } from '../CodeField.tokens';\n\nimport { ANIMATION_TIMEOUT } from './constants';\nimport { getCodeValue } from './initialValuesHelper';\n\ntype ValidateSymbolsArgs = {\n codeLength: number;\n codeErrorBehavior: CodeErrorBehavior;\n currentCode: Array<string>;\n inputContainerRef: MutableRefObject<HTMLDivElement | null>;\n inputRefs: MutableRefObject<Array<HTMLInputElement | null>>;\n captionRef: MutableRefObject<HTMLDivElement | null>;\n setInnerValue: Dispatch<SetStateAction<Array<string>>>;\n codeSetter: (newCode: Array<string>) => void;\n};\n\nexport const handleCodeError = ({\n codeLength,\n codeErrorBehavior,\n currentCode,\n inputRefs,\n inputContainerRef,\n captionRef,\n setInnerValue,\n codeSetter,\n}: ValidateSymbolsArgs) => {\n if (!inputContainerRef.current) {\n return;\n }\n\n switch (codeErrorBehavior) {\n case 'keep':\n inputContainerRef.current.classList.add(classes.codeError, classes.codeErrorAnimation);\n captionRef.current?.classList.add(classes.captionError);\n\n setTimeout(() => {\n const newCode = [...currentCode];\n\n newCode.pop();\n codeSetter(newCode);\n setInnerValue(currentCode);\n\n inputContainerRef.current?.classList.remove(classes.codeErrorAnimation);\n\n setTimeout(() => {\n inputRefs.current[inputRefs.current.length - 1]?.setSelectionRange(0, 1);\n inputRefs.current[inputRefs.current.length - 1]?.focus();\n }, 0);\n }, ANIMATION_TIMEOUT);\n\n break;\n case 'remove-code':\n default:\n inputContainerRef.current.classList.add(\n classes.codeError,\n classes.codeErrorAnimation,\n classes.codeErrorFade,\n );\n captionRef.current?.classList.add(classes.captionError);\n\n setTimeout(() => {\n codeSetter(getCodeValue(codeLength, ''));\n\n inputRefs.current[0]?.focus();\n inputContainerRef.current?.classList.remove(\n classes.codeError,\n classes.codeErrorAnimation,\n classes.codeErrorFade,\n );\n }, ANIMATION_TIMEOUT);\n }\n};\n"],"names":["handleCodeError","_ref","_captionRef$current","_captionRef$current2","codeLength","codeErrorBehavior","currentCode","inputRefs","inputContainerRef","captionRef","setInnerValue","codeSetter","current","classList","add","classes","codeError","codeErrorAnimation","captionError","setTimeout","_inputContainerRef$cu","newCode","_toConsumableArray","pop","remove","_inputRefs$current","_inputRefs$current2","length","setSelectionRange","focus","ANIMATION_TIMEOUT","codeErrorFade","_inputRefs$current$","_inputContainerRef$cu2","getCodeValue"],"mappings":";;;;;IAmBaA,eAAe,GAAG,SAAlBA,eAAeA,CAAAC,IAAA,EASD;EAAA,IAAAC,mBAAA,EAAAC,oBAAA,CAAA;AAAA,EAAA,IARvBC,UAAU,GAAAH,IAAA,CAAVG,UAAU;IACVC,iBAAiB,GAAAJ,IAAA,CAAjBI,iBAAiB;IACjBC,WAAW,GAAAL,IAAA,CAAXK,WAAW;IACXC,SAAS,GAAAN,IAAA,CAATM,SAAS;IACTC,iBAAiB,GAAAP,IAAA,CAAjBO,iBAAiB;IACjBC,UAAU,GAAAR,IAAA,CAAVQ,UAAU;IACVC,aAAa,GAAAT,IAAA,CAAbS,aAAa;IACbC,UAAU,GAAAV,IAAA,CAAVU,UAAU,CAAA;AAEV,EAAA,IAAI,CAACH,iBAAiB,CAACI,OAAO,EAAE;AAC5B,IAAA,OAAA;AACJ,GAAA;AAEA,EAAA,QAAQP,iBAAiB;AACrB,IAAA,KAAK,MAAM;AACPG,MAAAA,iBAAiB,CAACI,OAAO,CAACC,SAAS,CAACC,GAAG,C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