torgbox-ui 1.0.7 → 1.0.8

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 (286) hide show
  1. package/dist/.storybook/decorators/ReduxDecorator.d.ts +2 -0
  2. package/dist/.storybook/decorators/ReduxDecorator.js +4 -0
  3. package/dist/.storybook/decorators/RouterDecorator.d.ts +2 -0
  4. package/dist/.storybook/decorators/RouterDecorator.js +3 -0
  5. package/dist/.storybook/decorators/index.d.ts +2 -0
  6. package/dist/.storybook/decorators/index.js +2 -0
  7. package/dist/src/Inputs/Button/Button.js +30 -0
  8. package/dist/src/Inputs/Button/Button.stories.d.ts +21 -0
  9. package/dist/src/Inputs/Button/Button.stories.js +210 -0
  10. package/dist/src/Inputs/Button/Icon.stories.d.ts +20 -0
  11. package/dist/src/Inputs/Button/Icon.stories.js +196 -0
  12. package/dist/src/Inputs/Button/button.scss +358 -0
  13. package/dist/src/Inputs/Button/index.js +1 -0
  14. package/dist/src/Inputs/Checkbox/Checkbox.js +29 -0
  15. package/dist/src/Inputs/Checkbox/Checkbox.stories.d.ts +11 -0
  16. package/dist/src/Inputs/Checkbox/Checkbox.stories.js +108 -0
  17. package/dist/src/Inputs/Checkbox/checkbox.scss +63 -0
  18. package/dist/src/Inputs/Checkbox/index.js +1 -0
  19. package/dist/src/Inputs/EmailField/EmailField.js +61 -0
  20. package/dist/src/Inputs/EmailField/EmailField.stories.d.ts +8 -0
  21. package/dist/src/Inputs/EmailField/EmailField.stories.js +43 -0
  22. package/dist/src/Inputs/EmailField/ErrorMessages.js +3 -0
  23. package/dist/src/Inputs/EmailField/index.js +2 -0
  24. package/dist/src/Inputs/InnField/ErrorMessages.js +1 -0
  25. package/dist/src/Inputs/InnField/InnField.js +33 -0
  26. package/dist/src/Inputs/InnField/InnField.stories.d.ts +8 -0
  27. package/dist/src/Inputs/InnField/InnField.stories.js +43 -0
  28. package/dist/src/Inputs/InnField/index.js +2 -0
  29. package/dist/src/Inputs/NameField/ErrorMessages.js +8 -0
  30. package/dist/src/Inputs/NameField/NameField.js +54 -0
  31. package/dist/src/Inputs/NameField/NameField.stories.d.ts +8 -0
  32. package/dist/src/Inputs/NameField/NameField.stories.js +43 -0
  33. package/dist/src/Inputs/NameField/index.js +2 -0
  34. package/dist/src/Inputs/OtpInput/ErrorMessages.js +1 -0
  35. package/dist/src/Inputs/OtpInput/OtpInput.js +78 -0
  36. package/dist/src/Inputs/OtpInput/OtpInput.stories.d.ts +8 -0
  37. package/dist/src/Inputs/OtpInput/OtpInput.stories.js +52 -0
  38. package/dist/src/Inputs/OtpInput/index.js +2 -0
  39. package/dist/src/Inputs/OtpInput/otpInput.scss +39 -0
  40. package/dist/src/Inputs/PasswordField/ErrorMessages.js +2 -0
  41. package/dist/src/Inputs/PasswordField/PasswordField.js +35 -0
  42. package/dist/src/Inputs/PasswordField/PasswordField.stories.d.ts +8 -0
  43. package/dist/src/Inputs/PasswordField/PasswordField.stories.js +43 -0
  44. package/dist/src/Inputs/PasswordField/index.js +2 -0
  45. package/dist/src/Inputs/PhoneField/ErrorMessages.js +2 -0
  46. package/dist/src/Inputs/PhoneField/PhoneField.js +74 -0
  47. package/dist/src/Inputs/PhoneField/PhoneField.stories.d.ts +8 -0
  48. package/dist/src/Inputs/PhoneField/PhoneField.stories.js +43 -0
  49. package/dist/src/Inputs/PhoneField/index.js +2 -0
  50. package/dist/src/Inputs/RepeatPasswordField/ErrorMessages.js +2 -0
  51. package/dist/src/Inputs/RepeatPasswordField/RepeatPasswordField.js +22 -0
  52. package/dist/src/Inputs/RepeatPasswordField/index.js +2 -0
  53. package/dist/src/Inputs/Selector/Collapse.js +40 -0
  54. package/dist/src/Inputs/Selector/Collapse.stories.d.ts +8 -0
  55. package/dist/src/Inputs/Selector/Collapse.stories.js +108 -0
  56. package/dist/src/Inputs/Selector/Dropdown.js +81 -0
  57. package/dist/src/Inputs/Selector/Dropdown.stories.d.ts +9 -0
  58. package/dist/src/Inputs/Selector/Dropdown.stories.js +103 -0
  59. package/dist/src/Inputs/Selector/Option/Option.js +10 -0
  60. package/dist/src/Inputs/Selector/Option/Option.stories.d.ts +9 -0
  61. package/dist/src/Inputs/Selector/Option/Option.stories.js +47 -0
  62. package/dist/src/Inputs/Selector/Option/option.scss +44 -0
  63. package/dist/src/Inputs/Selector/index.js +3 -0
  64. package/dist/src/Inputs/Selector/selector.scss +101 -0
  65. package/dist/src/Inputs/TextField/TextField.js +85 -0
  66. package/dist/src/Inputs/TextField/TextField.stories.d.ts +12 -0
  67. package/dist/src/Inputs/TextField/TextField.stories.js +101 -0
  68. package/dist/src/Inputs/TextField/index.js +1 -0
  69. package/dist/src/Inputs/TextField/textField.module.scss +157 -0
  70. package/dist/src/Inputs/TextField/textField.scss +156 -0
  71. package/dist/src/Inputs/index.js +11 -0
  72. package/dist/src/Inputs/index.scss +6 -0
  73. package/dist/src/Pages/ContentPage/ContentPage.js +22 -0
  74. package/dist/src/Pages/ContentPage/ContentPage.stories.d.ts +6 -0
  75. package/dist/src/Pages/ContentPage/ContentPage.stories.js +17 -0
  76. package/dist/src/Pages/ContentPage/contentPage.scss +10 -0
  77. package/dist/src/Pages/ContentPage/index.js +1 -0
  78. package/dist/src/Pages/CreatePasswordPage/CreatePasswordPage.js +47 -0
  79. package/dist/src/Pages/CreatePasswordPage/CreatePasswordPage.stories.d.ts +7 -0
  80. package/dist/src/Pages/CreatePasswordPage/CreatePasswordPage.stories.js +96 -0
  81. package/dist/src/Pages/CreatePasswordPage/createPasswordPage.scss +42 -0
  82. package/dist/src/Pages/CreatePasswordPage/index.js +1 -0
  83. package/dist/src/Pages/CreateTeamPage/CreateTeamPage.js +46 -0
  84. package/dist/src/Pages/CreateTeamPage/CreateTeamPage.stories.d.ts +7 -0
  85. package/dist/src/Pages/CreateTeamPage/CreateTeamPage.stories.js +82 -0
  86. package/dist/src/Pages/CreateTeamPage/createTeamPage.scss +82 -0
  87. package/dist/src/Pages/CreateTeamPage/index.js +1 -0
  88. package/dist/src/Pages/EmailConfirmationPage/EmailConfirmationPage.js +34 -0
  89. package/dist/src/Pages/EmailConfirmationPage/EmailConfirmationPage.stories.d.ts +8 -0
  90. package/dist/src/Pages/EmailConfirmationPage/EmailConfirmationPage.stories.js +86 -0
  91. package/dist/src/Pages/EmailConfirmationPage/emailConfirmationPage.scss +92 -0
  92. package/dist/src/Pages/EmailConfirmationPage/index.js +1 -0
  93. package/dist/src/Pages/JoinTeamPage/JoinTeamPage.js +6 -0
  94. package/dist/src/Pages/JoinTeamPage/JoinTeamPage.stories.d.ts +7 -0
  95. package/dist/src/Pages/JoinTeamPage/JoinTeamPage.stories.js +24 -0
  96. package/dist/src/Pages/JoinTeamPage/index.js +1 -0
  97. package/dist/src/Pages/JoinTeamPage/joinTeamPage.scss +50 -0
  98. package/dist/src/Pages/LoginPage/LoginPage.js +32 -0
  99. package/dist/src/Pages/LoginPage/LoginPage.stories.d.ts +7 -0
  100. package/dist/src/Pages/LoginPage/LoginPage.stories.js +108 -0
  101. package/dist/src/Pages/LoginPage/index.js +1 -0
  102. package/dist/src/Pages/LoginPage/loginPage.scss +80 -0
  103. package/dist/src/Pages/RegisterPage/RegisterPage.js +34 -0
  104. package/dist/src/Pages/RegisterPage/RegisterPage.stories.d.ts +7 -0
  105. package/dist/src/Pages/RegisterPage/RegisterPage.stories.js +149 -0
  106. package/dist/src/Pages/RegisterPage/index.js +1 -0
  107. package/dist/src/Pages/RegisterPage/registerPage.scss +72 -0
  108. package/dist/src/Pages/ResetPasswordPage/ResetPasswordPage.js +10 -0
  109. package/dist/src/Pages/ResetPasswordPage/ResetPasswordPage.stories.d.ts +7 -0
  110. package/dist/src/Pages/ResetPasswordPage/ResetPasswordPage.stories.js +24 -0
  111. package/dist/src/Pages/ResetPasswordPage/index.js +1 -0
  112. package/dist/src/Pages/ResetPasswordPage/resetPasswordPage.scss +41 -0
  113. package/dist/src/Pages/StartPage/StartPage.js +22 -0
  114. package/dist/src/Pages/StartPage/StartPage.stories.d.ts +7 -0
  115. package/dist/src/Pages/StartPage/StartPage.stories.js +48 -0
  116. package/dist/src/Pages/StartPage/index.js +1 -0
  117. package/dist/src/Pages/StartPage/startPage.scss +58 -0
  118. package/dist/src/Pages/index.js +6 -0
  119. package/dist/src/Pages/index.scss +9 -0
  120. package/dist/src/Utils/Divider/Divider.js +2 -0
  121. package/dist/src/Utils/Divider/divider.scss +11 -0
  122. package/dist/src/Utils/ErrorBanner/ErrorBanner.js +6 -0
  123. package/dist/src/Utils/ErrorBanner/errorBanner.scss +24 -0
  124. package/dist/src/Utils/ErrorBanner/index.js +1 -0
  125. package/dist/src/Utils/Link/Link.js +5 -0
  126. package/dist/src/Utils/Link/Link.stories.d.ts +8 -0
  127. package/dist/src/Utils/Link/Link.stories.js +49 -0
  128. package/dist/src/Utils/Link/index.js +1 -0
  129. package/dist/src/Utils/Link/index.scss +1 -0
  130. package/dist/src/Utils/Link/link.scss +21 -0
  131. package/dist/src/Utils/Modal/Modal.js +24 -0
  132. package/dist/src/Utils/Modal/Modal.stories.d.ts +6 -0
  133. package/dist/src/Utils/Modal/Modal.stories.js +38 -0
  134. package/dist/src/Utils/Modal/index.js +1 -0
  135. package/dist/src/Utils/Modal/modal.scss +33 -0
  136. package/dist/src/Utils/Portal/Portal.js +5 -0
  137. package/dist/src/Utils/SectionPlaceholder/SectionPlaceholder.js +2 -0
  138. package/dist/src/Utils/SectionPlaceholder/sectionPlaceholder.scss +22 -0
  139. package/dist/src/Utils/Spinner/Spinner.js +5 -0
  140. package/dist/src/Utils/Spinner/spinner.scss +41 -0
  141. package/dist/src/Utils/api.js +7 -0
  142. package/dist/src/Utils/index.js +7 -0
  143. package/dist/src/Utils/index.scss +6 -0
  144. package/dist/src/Widgets/Header/Header.js +18 -0
  145. package/dist/src/Widgets/Header/Header.stories.d.ts +6 -0
  146. package/dist/src/Widgets/Header/Header.stories.js +17 -0
  147. package/dist/src/Widgets/Header/header.scss +50 -0
  148. package/dist/src/Widgets/Header/index.js +1 -0
  149. package/dist/src/Widgets/Sidebar/Sidebar.js +25 -0
  150. package/dist/src/Widgets/Sidebar/Sidebar.stories.d.ts +6 -0
  151. package/dist/src/Widgets/Sidebar/Sidebar.stories.js +17 -0
  152. package/dist/src/Widgets/Sidebar/index.js +1 -0
  153. package/dist/src/Widgets/Sidebar/sidebar.scss +23 -0
  154. package/dist/src/Widgets/index.js +2 -0
  155. package/dist/src/Widgets/index.scss +2 -0
  156. package/dist/src/app/main.js +7 -0
  157. package/dist/src/app/routes/AppRouter.js +31 -0
  158. package/dist/src/app/routes/index.js +1 -0
  159. package/dist/src/app/store/index.js +1 -0
  160. package/dist/src/app/store/store.js +13 -0
  161. package/dist/src/assets/scss/index.scss +5 -0
  162. package/dist/src/assets/scss/settings/fonts.scss +29 -0
  163. package/dist/src/assets/scss/settings/globals.scss +5 -0
  164. package/dist/src/assets/scss/settings/helpers.scss +3 -0
  165. package/dist/src/assets/scss/settings/reset.scss +8 -0
  166. package/dist/src/assets/scss/settings/variables.scss +91 -0
  167. package/dist/src/entities/user/api/api.js +41 -0
  168. package/dist/src/entities/user/api/index.js +1 -0
  169. package/dist/src/entities/user/index.js +2 -0
  170. package/dist/src/entities/user/model/index.js +2 -0
  171. package/dist/src/entities/user/model/selectors.js +2 -0
  172. package/dist/src/entities/user/model/slice.js +31 -0
  173. package/dist/src/entities/user/model/types.js +1 -0
  174. package/dist/src/index.js +3 -0
  175. package/dist/src/index.scss +6 -0
  176. package/dist/src/shared/model/api.js +6 -0
  177. package/dist/src/shared/model/constants.js +1 -0
  178. package/dist/src/shared/model/index.js +2 -0
  179. package/dist/src/shared/ui/Avatar/Avatar.js +6 -0
  180. package/dist/src/shared/ui/Avatar/Avatar.stories.d.ts +6 -0
  181. package/dist/src/shared/ui/Avatar/Avatar.stories.js +17 -0
  182. package/dist/src/shared/ui/Avatar/avatar.scss +62 -0
  183. package/dist/src/shared/ui/index.d.ts +1 -0
  184. package/dist/src/shared/ui/index.js +1 -0
  185. package/dist/src/shared/ui/index.scss +1 -0
  186. package/dist/src/tools/customValidators.js +19 -0
  187. package/dist/src/tools/getCoords.js +18 -0
  188. package/dist/src/tools/regExp.js +5 -0
  189. package/dist/{types → src}/ui.d.ts +0 -1
  190. package/dist/src/ui.js +3 -0
  191. package/dist/src/ui.scss +4 -0
  192. package/dist/tsconfig.tsbuildinfo +1 -0
  193. package/package.json +9 -8
  194. package/dist/torgbox-ui.cjs.js +0 -31
  195. package/dist/torgbox-ui.css +0 -1
  196. package/dist/torgbox-ui.es.js +0 -4799
  197. /package/dist/{types → src}/Inputs/Button/Button.d.ts +0 -0
  198. /package/dist/{types → src}/Inputs/Button/index.d.ts +0 -0
  199. /package/dist/{types → src}/Inputs/Checkbox/Checkbox.d.ts +0 -0
  200. /package/dist/{types → src}/Inputs/Checkbox/index.d.ts +0 -0
  201. /package/dist/{types → src}/Inputs/EmailField/EmailField.d.ts +0 -0
  202. /package/dist/{types → src}/Inputs/EmailField/ErrorMessages.d.ts +0 -0
  203. /package/dist/{types → src}/Inputs/EmailField/index.d.ts +0 -0
  204. /package/dist/{types → src}/Inputs/InnField/ErrorMessages.d.ts +0 -0
  205. /package/dist/{types → src}/Inputs/InnField/InnField.d.ts +0 -0
  206. /package/dist/{types → src}/Inputs/InnField/index.d.ts +0 -0
  207. /package/dist/{types → src}/Inputs/NameField/ErrorMessages.d.ts +0 -0
  208. /package/dist/{types → src}/Inputs/NameField/NameField.d.ts +0 -0
  209. /package/dist/{types → src}/Inputs/NameField/index.d.ts +0 -0
  210. /package/dist/{types → src}/Inputs/OtpInput/ErrorMessages.d.ts +0 -0
  211. /package/dist/{types → src}/Inputs/OtpInput/OtpInput.d.ts +0 -0
  212. /package/dist/{types → src}/Inputs/OtpInput/index.d.ts +0 -0
  213. /package/dist/{types → src}/Inputs/PasswordField/ErrorMessages.d.ts +0 -0
  214. /package/dist/{types → src}/Inputs/PasswordField/PasswordField.d.ts +0 -0
  215. /package/dist/{types → src}/Inputs/PasswordField/index.d.ts +0 -0
  216. /package/dist/{types → src}/Inputs/PhoneField/ErrorMessages.d.ts +0 -0
  217. /package/dist/{types → src}/Inputs/PhoneField/PhoneField.d.ts +0 -0
  218. /package/dist/{types → src}/Inputs/PhoneField/index.d.ts +0 -0
  219. /package/dist/{types → src}/Inputs/RepeatPasswordField/ErrorMessages.d.ts +0 -0
  220. /package/dist/{types → src}/Inputs/RepeatPasswordField/RepeatPasswordField.d.ts +0 -0
  221. /package/dist/{types → src}/Inputs/RepeatPasswordField/index.d.ts +0 -0
  222. /package/dist/{types → src}/Inputs/Selector/Collapse.d.ts +0 -0
  223. /package/dist/{types → src}/Inputs/Selector/Dropdown.d.ts +0 -0
  224. /package/dist/{types → src}/Inputs/Selector/Option/Option.d.ts +0 -0
  225. /package/dist/{types → src}/Inputs/Selector/index.d.ts +0 -0
  226. /package/dist/{types → src}/Inputs/TextField/TextField.d.ts +0 -0
  227. /package/dist/{types → src}/Inputs/TextField/index.d.ts +0 -0
  228. /package/dist/{types → src}/Inputs/index.d.ts +0 -0
  229. /package/dist/{types → src}/Pages/ContentPage/ContentPage.d.ts +0 -0
  230. /package/dist/{types → src}/Pages/ContentPage/index.d.ts +0 -0
  231. /package/dist/{types → src}/Pages/CreatePasswordPage/CreatePasswordPage.d.ts +0 -0
  232. /package/dist/{types → src}/Pages/CreatePasswordPage/index.d.ts +0 -0
  233. /package/dist/{types → src}/Pages/CreateTeamPage/CreateTeamPage.d.ts +0 -0
  234. /package/dist/{types → src}/Pages/CreateTeamPage/index.d.ts +0 -0
  235. /package/dist/{types → src}/Pages/EmailConfirmationPage/EmailConfirmationPage.d.ts +0 -0
  236. /package/dist/{types → src}/Pages/EmailConfirmationPage/index.d.ts +0 -0
  237. /package/dist/{types → src}/Pages/JoinTeamPage/JoinTeamPage.d.ts +0 -0
  238. /package/dist/{types → src}/Pages/JoinTeamPage/index.d.ts +0 -0
  239. /package/dist/{types → src}/Pages/LoginPage/LoginPage.d.ts +0 -0
  240. /package/dist/{types → src}/Pages/LoginPage/index.d.ts +0 -0
  241. /package/dist/{types → src}/Pages/RegisterPage/RegisterPage.d.ts +0 -0
  242. /package/dist/{types → src}/Pages/RegisterPage/index.d.ts +0 -0
  243. /package/dist/{types → src}/Pages/ResetPasswordPage/ResetPasswordPage.d.ts +0 -0
  244. /package/dist/{types → src}/Pages/ResetPasswordPage/index.d.ts +0 -0
  245. /package/dist/{types → src}/Pages/StartPage/StartPage.d.ts +0 -0
  246. /package/dist/{types → src}/Pages/StartPage/index.d.ts +0 -0
  247. /package/dist/{types → src}/Pages/index.d.ts +0 -0
  248. /package/dist/{types → src}/Utils/Divider/Divider.d.ts +0 -0
  249. /package/dist/{types → src}/Utils/ErrorBanner/ErrorBanner.d.ts +0 -0
  250. /package/dist/{types → src}/Utils/ErrorBanner/index.d.ts +0 -0
  251. /package/dist/{types → src}/Utils/Link/Link.d.ts +0 -0
  252. /package/dist/{types → src}/Utils/Link/index.d.ts +0 -0
  253. /package/dist/{types → src}/Utils/Modal/Modal.d.ts +0 -0
  254. /package/dist/{types → src}/Utils/Modal/index.d.ts +0 -0
  255. /package/dist/{types → src}/Utils/Portal/Portal.d.ts +0 -0
  256. /package/dist/{types → src}/Utils/SectionPlaceholder/SectionPlaceholder.d.ts +0 -0
  257. /package/dist/{types → src}/Utils/Spinner/Spinner.d.ts +0 -0
  258. /package/dist/{types → src}/Utils/api.d.ts +0 -0
  259. /package/dist/{types → src}/Utils/index.d.ts +0 -0
  260. /package/dist/{types → src}/Widgets/Header/Header.d.ts +0 -0
  261. /package/dist/{types → src}/Widgets/Header/index.d.ts +0 -0
  262. /package/dist/{types → src}/Widgets/Sidebar/Sidebar.d.ts +0 -0
  263. /package/dist/{types → src}/Widgets/Sidebar/index.d.ts +0 -0
  264. /package/dist/{types → src}/Widgets/index.d.ts +0 -0
  265. /package/dist/{types → src}/app/main.d.ts +0 -0
  266. /package/dist/{types → src}/app/routes/AppRouter.d.ts +0 -0
  267. /package/dist/{types → src}/app/routes/index.d.ts +0 -0
  268. /package/dist/{types → src}/app/store/index.d.ts +0 -0
  269. /package/dist/{types → src}/app/store/store.d.ts +0 -0
  270. /package/dist/{types → src}/entities/user/api/api.d.ts +0 -0
  271. /package/dist/{types → src}/entities/user/api/index.d.ts +0 -0
  272. /package/dist/{types → src}/entities/user/index.d.ts +0 -0
  273. /package/dist/{types → src}/entities/user/model/index.d.ts +0 -0
  274. /package/dist/{types → src}/entities/user/model/selectors.d.ts +0 -0
  275. /package/dist/{types → src}/entities/user/model/slice.d.ts +0 -0
  276. /package/dist/{types → src}/entities/user/model/types.d.ts +0 -0
  277. /package/dist/{types → src}/index.d.ts +0 -0
  278. /package/dist/{types → src}/shared/model/api.d.ts +0 -0
  279. /package/dist/{types → src}/shared/model/constants.d.ts +0 -0
  280. /package/dist/{types → src}/shared/model/index.d.ts +0 -0
  281. /package/dist/{types → src}/shared/ui/Avatar/Avatar.d.ts +0 -0
  282. /package/dist/{types → src}/shared/ui/Avatar/index.d.ts +0 -0
  283. /package/dist/{types/shared/ui/index.d.ts → src/shared/ui/Avatar/index.js} +0 -0
  284. /package/dist/{types → src}/tools/customValidators.d.ts +0 -0
  285. /package/dist/{types → src}/tools/getCoords.d.ts +0 -0
  286. /package/dist/{types → src}/tools/regExp.d.ts +0 -0
@@ -0,0 +1,33 @@
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ import { useEffect, useState } from 'react';
3
+ import { innValidator } from '../../tools/customValidators';
4
+ import { TextField } from '../TextField';
5
+ import { InnError } from './ErrorMessages';
6
+ export const InnField = (props) => {
7
+ const { onValidated, onTextValid } = props;
8
+ const [errorMessage, setErrorMessage] = useState('');
9
+ const [touched, setTouched] = useState(false);
10
+ const [inn, setInn] = useState('');
11
+ const getInputNumbersValue = (value) => {
12
+ return value.replace(/\D/g, '');
13
+ };
14
+ const onInnInput = (value, e) => {
15
+ setInn(getInputNumbersValue(value));
16
+ };
17
+ useEffect(() => {
18
+ if (!touched) {
19
+ return;
20
+ }
21
+ const valid = innValidator(inn);
22
+ if (!valid) {
23
+ onValidated(false);
24
+ onTextValid('');
25
+ setErrorMessage(InnError);
26
+ return;
27
+ }
28
+ onValidated(true);
29
+ onTextValid(inn);
30
+ setErrorMessage('');
31
+ }, [inn, onTextValid, onValidated, touched]);
32
+ return (_jsx(TextField, { onChange: onInnInput, onTouched: setTouched, state: touched && errorMessage ? 'error' : 'idle', errorMessage: errorMessage, label: '\u0418\u041D\u041D', type: 'text', description: '\u0412\u0432\u0435\u0434\u0438\u0442\u0435 10 \u0446\u0438\u0444\u0440 \u0434\u043B\u044F \u042E\u041B \u0438\u043B\u0438 12 \u0434\u043B\u044F \u0424\u041B', value: inn, maxLength: 12, required: true, searchIcon: true, ...props }));
33
+ };
@@ -0,0 +1,8 @@
1
+ import type { Meta, StoryObj } from '@storybook/react';
2
+ import type { ITextField } from '../TextField';
3
+ declare const meta: Meta;
4
+ export default meta;
5
+ type Story = StoryObj<ITextField>;
6
+ export declare const InnFieldInactive: Story;
7
+ export declare const InnFieldError: Story;
8
+ export declare const InnFieldWithValue: Story;
@@ -0,0 +1,43 @@
1
+ import { InnField } from './InnField';
2
+ const meta = {
3
+ title: 'Inputs/InnField',
4
+ component: InnField,
5
+ tags: ['autodocs'],
6
+ args: {
7
+ onValidated: () => { },
8
+ onTextValid: () => { }
9
+ }
10
+ };
11
+ export default meta;
12
+ export const InnFieldInactive = {
13
+ args: {},
14
+ parameters: {
15
+ design: {
16
+ type: 'figma',
17
+ url: 'https://www.figma.com/file/8cQcICaes5IWFubU66DMdl/Torgbox-CRM?type=design&node-id=12816-23279&mode=design&t=wnKZYt4uc5mLPiqN-4',
18
+ }
19
+ }
20
+ };
21
+ export const InnFieldError = {
22
+ args: {
23
+ state: 'error',
24
+ errorMessage: 'Some error'
25
+ },
26
+ parameters: {
27
+ design: {
28
+ type: 'figma',
29
+ url: 'https://www.figma.com/file/8cQcICaes5IWFubU66DMdl/Torgbox-CRM?type=design&node-id=12816-23279&mode=design&t=wnKZYt4uc5mLPiqN-4',
30
+ },
31
+ },
32
+ };
33
+ export const InnFieldWithValue = {
34
+ args: {
35
+ value: '1024120485',
36
+ },
37
+ parameters: {
38
+ design: {
39
+ type: 'figma',
40
+ url: 'https://www.figma.com/file/8cQcICaes5IWFubU66DMdl/Torgbox-CRM?type=design&node-id=12816-23279&mode=design&t=wnKZYt4uc5mLPiqN-4',
41
+ },
42
+ },
43
+ };
@@ -0,0 +1,2 @@
1
+ export { InnField } from './InnField';
2
+ export { InnError } from './ErrorMessages';
@@ -0,0 +1,8 @@
1
+ export const emptyFirstNameError = 'Введите имя';
2
+ export const emptyLastNameError = 'Введите фамилию';
3
+ export const emptyPatronymicNameError = 'Введите отчество';
4
+ export const emptyFullNameError = 'Введите ФИО';
5
+ export const notCorrectFirstNameError = 'Некорректное имя';
6
+ export const notCorrectLastNameError = 'Некорректная фамилия';
7
+ export const notCorrectPatronymicNameError = 'Некорректное отчество';
8
+ export const notCorrectFullNameError = 'Некорректное ФИО';
@@ -0,0 +1,54 @@
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ import { useEffect, useState } from 'react';
3
+ import { nameValidator } from '../../tools/customValidators';
4
+ import { TextField } from '../TextField';
5
+ import { emptyFirstNameError, emptyLastNameError, emptyPatronymicNameError, emptyFullNameError, notCorrectFirstNameError, notCorrectLastNameError, notCorrectPatronymicNameError, notCorrectFullNameError } from './ErrorMessages';
6
+ ;
7
+ export const NameField = (props) => {
8
+ const { nameType = 'fullName', onValidated, onTextValid } = props;
9
+ const [errorMessage, setErrorMessage] = useState('');
10
+ const [touched, setTouched] = useState(false);
11
+ const [name, setName] = useState('');
12
+ const nameArgs = {
13
+ firstName: {
14
+ label: 'Имя',
15
+ emptyMessage: emptyFirstNameError,
16
+ notCorrectMessage: notCorrectFirstNameError,
17
+ },
18
+ lastName: {
19
+ label: 'Фамилия',
20
+ emptyMessage: emptyLastNameError,
21
+ notCorrectMessage: notCorrectLastNameError,
22
+ },
23
+ patronymic: {
24
+ label: 'Отчество',
25
+ emptyMessage: emptyPatronymicNameError,
26
+ notCorrectMessage: notCorrectPatronymicNameError,
27
+ },
28
+ fullName: {
29
+ label: 'ФИО',
30
+ emptyMessage: emptyFullNameError,
31
+ notCorrectMessage: notCorrectFullNameError,
32
+ }
33
+ };
34
+ const { label, emptyMessage, notCorrectMessage } = nameArgs[nameType];
35
+ useEffect(() => {
36
+ if (!touched) {
37
+ return;
38
+ }
39
+ const valid = nameValidator(nameType === 'fullName' ? name.split(' ') : name);
40
+ if (!valid) {
41
+ onValidated(false);
42
+ onTextValid('');
43
+ const error = (!name && emptyMessage) ||
44
+ (!valid && notCorrectMessage) ||
45
+ '';
46
+ setErrorMessage(error);
47
+ return;
48
+ }
49
+ onValidated(true);
50
+ onTextValid(name);
51
+ setErrorMessage('');
52
+ }, [emptyMessage, name, nameType, notCorrectMessage, onTextValid, onValidated, touched]);
53
+ return (_jsx(TextField, { onChange: setName, onTouched: setTouched, state: touched && errorMessage ? 'error' : 'idle', errorMessage: errorMessage, label: label, type: 'text', value: name, required: true, checkIcon: true, ...props }));
54
+ };
@@ -0,0 +1,8 @@
1
+ import type { Meta, StoryObj } from '@storybook/react';
2
+ import type { ITextField } from '../TextField';
3
+ declare const meta: Meta;
4
+ export default meta;
5
+ type Story = StoryObj<ITextField>;
6
+ export declare const NameFieldInactive: Story;
7
+ export declare const NameFieldError: Story;
8
+ export declare const NameFieldWithValue: Story;
@@ -0,0 +1,43 @@
1
+ import { NameField } from './NameField';
2
+ const meta = {
3
+ title: 'Inputs/NameField',
4
+ component: NameField,
5
+ tags: ['autodocs'],
6
+ args: {
7
+ onValidated: () => { },
8
+ onTextValid: () => { }
9
+ }
10
+ };
11
+ export default meta;
12
+ export const NameFieldInactive = {
13
+ args: {},
14
+ parameters: {
15
+ design: {
16
+ type: 'figma',
17
+ url: 'https://www.figma.com/file/8cQcICaes5IWFubU66DMdl/Torgbox-CRM?type=design&node-id=12786-34704&mode=design&t=H9AcJSW51fS3aPiW-4',
18
+ },
19
+ },
20
+ };
21
+ export const NameFieldError = {
22
+ args: {
23
+ state: 'error',
24
+ errorMessage: 'Some error'
25
+ },
26
+ parameters: {
27
+ design: {
28
+ type: 'figma',
29
+ url: 'https://www.figma.com/file/8cQcICaes5IWFubU66DMdl/Torgbox-CRM?type=design&node-id=12786-36350&mode=design&t=H9AcJSW51fS3aPiW-4',
30
+ },
31
+ },
32
+ };
33
+ export const NameFieldWithValue = {
34
+ args: {
35
+ value: 'Константин',
36
+ },
37
+ parameters: {
38
+ design: {
39
+ type: 'figma',
40
+ url: 'https://www.figma.com/file/8cQcICaes5IWFubU66DMdl/Torgbox-CRM?type=design&node-id=12786-34760&mode=design&t=H9AcJSW51fS3aPiW-4',
41
+ },
42
+ },
43
+ };
@@ -0,0 +1,2 @@
1
+ export { NameField } from './NameField';
2
+ export { emptyFirstNameError, emptyLastNameError, emptyPatronymicNameError, emptyFullNameError, notCorrectFirstNameError, notCorrectLastNameError, notCorrectPatronymicNameError, notCorrectFullNameError } from './ErrorMessages';
@@ -0,0 +1 @@
1
+ export const otpError = 'Неверный код. Сверьтесь с письмом';
@@ -0,0 +1,78 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ import cn from 'classnames';
3
+ import _ from 'lodash/fp';
4
+ import { useRef, useState, useEffect } from 'react';
5
+ export const OtpInput = (props) => {
6
+ const { length = 6, onComplete = _.noop, errorMessage = '', setErrorMessage = _.noop, responseReceived = false, loading = false, } = props;
7
+ const inputRef = useRef(Array(length).fill(null));
8
+ const [Otp, setOtp] = useState(Array(length).fill(''));
9
+ const currentTarget = inputRef.current;
10
+ const handleComplete = (value, index) => {
11
+ onComplete(value.join(''));
12
+ currentTarget[index].blur();
13
+ };
14
+ const handleTextChange = (index) => (e) => {
15
+ setErrorMessage('');
16
+ const newPin = [...Otp];
17
+ const input = e.target.value.replace(/\D/g, '');
18
+ newPin[index] = input;
19
+ setOtp(newPin);
20
+ if (input.length === 1 && index < length - 1) {
21
+ currentTarget[index + 1]?.focus();
22
+ }
23
+ if (input.length === 0 && index > 0) {
24
+ currentTarget[index - 1]?.focus();
25
+ }
26
+ if (newPin.every((digit) => digit !== '')) {
27
+ onComplete(newPin.join(''));
28
+ currentTarget[index].blur();
29
+ }
30
+ };
31
+ const handlePaste = (index) => (e) => {
32
+ setErrorMessage('');
33
+ const value = e.clipboardData?.getData('text');
34
+ const updatedValue = value
35
+ .toString()
36
+ .replace(/\D/g, '')
37
+ .split('')
38
+ .slice(0, length);
39
+ setOtp(updatedValue);
40
+ if (updatedValue.length === length) {
41
+ handleComplete(updatedValue, index);
42
+ }
43
+ };
44
+ const goToFirstEmptyInput = () => {
45
+ const firstEmptyInput = currentTarget.findIndex((el) => el.value === '');
46
+ firstEmptyInput >= 0
47
+ ?
48
+ currentTarget[firstEmptyInput].focus()
49
+ :
50
+ currentTarget[length - 1].focus();
51
+ setErrorMessage('');
52
+ };
53
+ const handleBackspace = (index) => (e) => {
54
+ if (e.key === 'Backspace' &&
55
+ index !== 0 &&
56
+ currentTarget[index].value.length === 0) {
57
+ currentTarget[index - 1]?.focus();
58
+ }
59
+ };
60
+ const handleKeyDown = (e) => {
61
+ if (Number.parseInt(e.key) >= 0) {
62
+ goToFirstEmptyInput();
63
+ }
64
+ };
65
+ const inputMods = [
66
+ 'otp__input',
67
+ { 'otp__input--error': errorMessage },
68
+ ];
69
+ useEffect(() => {
70
+ !loading && currentTarget[0].focus();
71
+ }, [responseReceived, loading, currentTarget]);
72
+ useEffect(() => {
73
+ if (responseReceived) {
74
+ setOtp(Array(length).fill(''));
75
+ }
76
+ }, [responseReceived, length]);
77
+ return (_jsxs("div", { className: 'otp', children: [Array.from({ length }, (_, index) => (_jsx("input", { value: Otp[index], onChange: handleTextChange(index), onPaste: handlePaste(index), onKeyUp: handleBackspace(index), onKeyDown: handleKeyDown, onClick: goToFirstEmptyInput, ref: (ref) => (currentTarget[index] = ref), type: 'text', maxLength: 1, className: cn(inputMods), tabIndex: index + 1 }, index))), errorMessage && (_jsx("span", { className: 'otp__error', children: errorMessage }))] }));
78
+ };
@@ -0,0 +1,8 @@
1
+ import type { Meta, StoryObj } from '@storybook/react';
2
+ import { type IOtpInput } from './OtpInput';
3
+ declare const meta: Meta;
4
+ export default meta;
5
+ type Story = StoryObj<IOtpInput>;
6
+ export declare const OtpInputDefault: Story;
7
+ export declare const OtpInputError: Story;
8
+ export declare const OtpInputWithValue: Story;
@@ -0,0 +1,52 @@
1
+ import { userEvent, within } from '@storybook/test';
2
+ import { OtpInput } from './OtpInput';
3
+ const meta = {
4
+ title: 'Inputs/OtpInput',
5
+ component: OtpInput,
6
+ tags: ['autodocs'],
7
+ args: {
8
+ length: 6
9
+ },
10
+ argTypes: {
11
+ length: {
12
+ control: 'text',
13
+ }
14
+ }
15
+ };
16
+ export default meta;
17
+ export const OtpInputDefault = {
18
+ args: {},
19
+ parameters: {
20
+ design: {
21
+ type: 'figma',
22
+ url: 'https://www.figma.com/file/8cQcICaes5IWFubU66DMdl/Torgbox-CRM?type=design&node-id=12659-13838&mode=design&t=5Wp3lAOqtDnPV63y-4',
23
+ },
24
+ }
25
+ };
26
+ export const OtpInputError = {
27
+ args: {
28
+ errorMessage: 'some error'
29
+ },
30
+ parameters: {
31
+ design: {
32
+ type: 'figma',
33
+ url: 'https://www.figma.com/file/8cQcICaes5IWFubU66DMdl/Torgbox-CRM?type=design&node-id=12659-13838&mode=design&t=5Wp3lAOqtDnPV63y-4',
34
+ },
35
+ }
36
+ };
37
+ export const OtpInputWithValue = {
38
+ args: {},
39
+ parameters: {
40
+ design: {
41
+ type: 'figma',
42
+ url: 'https://www.figma.com/file/8cQcICaes5IWFubU66DMdl/Torgbox-CRM?type=design&node-id=12659-13838&mode=design&t=5Wp3lAOqtDnPV63y-4',
43
+ },
44
+ },
45
+ play: async ({ canvasElement, step }) => {
46
+ const canvas = within(canvasElement);
47
+ const input = canvas.getAllByRole('textbox');
48
+ await step('Typing OTP', async () => {
49
+ await userEvent.type(input[0], '222222', { delay: 500 });
50
+ });
51
+ },
52
+ };
@@ -0,0 +1,2 @@
1
+ export { OtpInput } from './OtpInput';
2
+ export { otpError } from './ErrorMessages';
@@ -0,0 +1,39 @@
1
+ $border-color: $neutral-border-low;
2
+ $border-color-focus: $primary-border-high;
3
+ $error-message: $error-high;
4
+ $border-error: $error-border-high;
5
+
6
+ .otp {
7
+ display: flex;
8
+ gap: 8px;
9
+ position: relative;
10
+
11
+ &__input {
12
+ font-size: 16px;
13
+ line-height: 24px;
14
+ height: 44px;
15
+ width: 36px;
16
+ border: 1px solid $border-color;
17
+ border-radius: 4px;
18
+ text-align: center;
19
+ outline: none;
20
+
21
+ &:focus,
22
+ :active {
23
+ border-color: $border-color-focus;
24
+ }
25
+
26
+ &--error,
27
+ &--error:focus {
28
+ border-color: $border-error;
29
+ }
30
+ }
31
+ &__error {
32
+ font-size: 12px;
33
+ line-height: 16px;
34
+ color: $error-message;
35
+ position: absolute;
36
+ bottom: -16px;
37
+ left: 0;
38
+ }
39
+ }
@@ -0,0 +1,2 @@
1
+ export const emptyPasswordError = 'Введите пароль';
2
+ export const notCorrectPasswordError = 'Введите пароль не менее 6 символов';
@@ -0,0 +1,35 @@
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ import _ from 'lodash/fp';
3
+ import { useEffect, useState } from 'react';
4
+ import { passwordValidator } from '../../tools/customValidators';
5
+ import { TextField, } from '../TextField';
6
+ import { emptyPasswordError, notCorrectPasswordError } from './ErrorMessages';
7
+ export const PasswordField = (props) => {
8
+ const { onValidated, onPasswordInput, hidePassword = true, } = props;
9
+ const [errorMessage, setErrorMessage] = useState('');
10
+ const [touched, setTouched] = useState(false);
11
+ const [password, setPassword] = useState('');
12
+ useEffect(() => {
13
+ if (!touched) {
14
+ return;
15
+ }
16
+ onPasswordInput(password);
17
+ const valid = passwordValidator(password);
18
+ if (!valid) {
19
+ onValidated(false);
20
+ setErrorMessage(_.cond([
21
+ [() => !password, () => emptyPasswordError],
22
+ [() => !valid, () => notCorrectPasswordError],
23
+ ]));
24
+ return;
25
+ }
26
+ onValidated(true);
27
+ setErrorMessage('');
28
+ }, [
29
+ password,
30
+ onPasswordInput,
31
+ onValidated,
32
+ touched
33
+ ]);
34
+ return (_jsx(TextField, { onChange: setPassword, onTouched: setTouched, state: touched && errorMessage ? 'error' : 'idle', errorMessage: errorMessage, label: '\u041F\u0430\u0440\u043E\u043B\u044C', type: hidePassword ? 'password' : 'text', value: password, eyeIcon: true, checkIcon: true, required: true, ...props }));
35
+ };
@@ -0,0 +1,8 @@
1
+ import type { Meta, StoryObj } from '@storybook/react';
2
+ import { type ITextField } from '../index';
3
+ declare const meta: Meta;
4
+ export default meta;
5
+ type Story = StoryObj<ITextField>;
6
+ export declare const PasswordFieldInactive: Story;
7
+ export declare const PasswordFieldError: Story;
8
+ export declare const PasswordFieldWithValue: Story;
@@ -0,0 +1,43 @@
1
+ import { PasswordField } from '../index';
2
+ const meta = {
3
+ title: 'Inputs/PasswordField',
4
+ component: PasswordField,
5
+ tags: ['autodocs'],
6
+ args: {
7
+ onValidated: () => { },
8
+ onPasswordInput: () => { }
9
+ }
10
+ };
11
+ export default meta;
12
+ export const PasswordFieldInactive = {
13
+ args: {},
14
+ parameters: {
15
+ design: {
16
+ type: 'figma',
17
+ url: 'https://www.figma.com/file/8cQcICaes5IWFubU66DMdl/Torgbox-CRM?type=design&node-id=12786-38832&mode=design&t=mI94vejMFxk5S920-4',
18
+ },
19
+ },
20
+ };
21
+ export const PasswordFieldError = {
22
+ args: {
23
+ state: 'error',
24
+ errorMessage: 'Some error'
25
+ },
26
+ parameters: {
27
+ design: {
28
+ type: 'figma',
29
+ url: 'https://www.figma.com/file/8cQcICaes5IWFubU66DMdl/Torgbox-CRM?type=design&node-id=12786-38856&mode=design&t=mI94vejMFxk5S920-4',
30
+ },
31
+ },
32
+ };
33
+ export const PasswordFieldWithValue = {
34
+ args: {
35
+ value: 'somePass',
36
+ },
37
+ parameters: {
38
+ design: {
39
+ type: 'figma',
40
+ url: 'https://www.figma.com/file/8cQcICaes5IWFubU66DMdl/Torgbox-CRM?type=design&node-id=12816-20475&mode=design&t=mI94vejMFxk5S920-4',
41
+ },
42
+ },
43
+ };
@@ -0,0 +1,2 @@
1
+ export { PasswordField } from './PasswordField';
2
+ export { emptyPasswordError, notCorrectPasswordError } from './ErrorMessages';
@@ -0,0 +1,2 @@
1
+ export const emptyPhoneError = 'Введите номер телефона';
2
+ export const notCorrectPhoneError = 'Номер телефона — 10 цифр';
@@ -0,0 +1,74 @@
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ import _ from 'lodash/fp';
3
+ import { useEffect, useState } from 'react';
4
+ import { phoneValidator } from '../../tools/customValidators';
5
+ import { TextField } from '../TextField';
6
+ import { emptyPhoneError, notCorrectPhoneError } from './ErrorMessages';
7
+ export const PhoneField = (props) => {
8
+ const { onValidated, onTextValid } = props;
9
+ const [errorMessage, setErrorMessage] = useState('');
10
+ const [touched, setTouched] = useState(false);
11
+ const [phoneNumber, setPhoneNumber] = useState('');
12
+ const getInputNumbersValue = (value) => {
13
+ return value.replace(/\D/g, '');
14
+ };
15
+ const onPhoneInput = (value, e) => {
16
+ const { target } = e;
17
+ const { selectionStart } = target;
18
+ let inputNumbersValue = getInputNumbersValue(value);
19
+ let formattedInputValue = '';
20
+ const { data, inputType } = e.nativeEvent;
21
+ if (inputType === 'deleteContentBackward' && value.length === 0) {
22
+ setPhoneNumber('');
23
+ return;
24
+ }
25
+ if (value.length !== selectionStart) {
26
+ if (data === null || /\d/g.test(data)) {
27
+ setPhoneNumber(value);
28
+ }
29
+ return;
30
+ }
31
+ if (['7', '8', '9'].includes(inputNumbersValue[0])) {
32
+ if (inputNumbersValue[0] === '9')
33
+ inputNumbersValue = '7' + inputNumbersValue;
34
+ const firstSymbols = (inputNumbersValue[0] === '8') ? '8' : '+7';
35
+ formattedInputValue = firstSymbols;
36
+ if (inputNumbersValue.length > 1) {
37
+ formattedInputValue += '(' + inputNumbersValue.substring(1, 4);
38
+ }
39
+ if (inputNumbersValue.length >= 5) {
40
+ formattedInputValue += ')' + inputNumbersValue.substring(4, 7);
41
+ }
42
+ if (inputNumbersValue.length >= 8) {
43
+ formattedInputValue += '-' + inputNumbersValue.substring(7, 9);
44
+ }
45
+ if (inputNumbersValue.length >= 10) {
46
+ formattedInputValue += '-' + inputNumbersValue.substring(9, 11);
47
+ }
48
+ }
49
+ else {
50
+ formattedInputValue = '+' + inputNumbersValue.substring(0, 16);
51
+ }
52
+ setPhoneNumber(formattedInputValue);
53
+ };
54
+ useEffect(() => {
55
+ if (!touched) {
56
+ return;
57
+ }
58
+ const valid = phoneValidator(phoneNumber);
59
+ if (!valid) {
60
+ onValidated(false);
61
+ onTextValid('');
62
+ setErrorMessage(_.cond([
63
+ [_.isEmpty, () => emptyPhoneError],
64
+ [() => !valid, () => notCorrectPhoneError],
65
+ [_.stubTrue, _.stubString]
66
+ ]));
67
+ return;
68
+ }
69
+ onValidated(true);
70
+ onTextValid(phoneNumber.replace(/\D/g, ''));
71
+ setErrorMessage('');
72
+ }, [onTextValid, onValidated, phoneNumber, touched]);
73
+ return (_jsx(TextField, { onChange: onPhoneInput, onTouched: setTouched, state: touched && errorMessage ? 'error' : 'idle', errorMessage: errorMessage, label: '\u041C\u043E\u0431\u0438\u043B\u044C\u043D\u044B\u0439 \u0442\u0435\u043B\u0435\u0444\u043E\u043D', type: 'tel', value: phoneNumber, required: true, checkIcon: true, ...props }));
74
+ };
@@ -0,0 +1,8 @@
1
+ import type { Meta, StoryObj } from '@storybook/react';
2
+ import type { ITextField } from '../TextField';
3
+ declare const meta: Meta;
4
+ export default meta;
5
+ type Story = StoryObj<ITextField>;
6
+ export declare const PhoneFieldInactive: Story;
7
+ export declare const PhoneFieldError: Story;
8
+ export declare const PhoneFieldWithValue: Story;
@@ -0,0 +1,43 @@
1
+ import { PhoneField } from './PhoneField';
2
+ const meta = {
3
+ title: 'Inputs/PhoneField',
4
+ component: PhoneField,
5
+ tags: ['autodocs'],
6
+ args: {
7
+ onValidated: () => { },
8
+ onTextValid: () => { }
9
+ }
10
+ };
11
+ export default meta;
12
+ export const PhoneFieldInactive = {
13
+ args: {},
14
+ parameters: {
15
+ design: {
16
+ type: 'figma',
17
+ url: 'https://www.figma.com/file/8cQcICaes5IWFubU66DMdl/Torgbox-CRM?type=design&node-id=12786-37669&mode=design&t=H9AcJSW51fS3aPiW-4',
18
+ },
19
+ },
20
+ };
21
+ export const PhoneFieldError = {
22
+ args: {
23
+ state: 'error',
24
+ errorMessage: 'Some error'
25
+ },
26
+ parameters: {
27
+ design: {
28
+ type: 'figma',
29
+ url: 'https://www.figma.com/file/8cQcICaes5IWFubU66DMdl/Torgbox-CRM?type=design&node-id=12786-37685&mode=design&t=H9AcJSW51fS3aPiW-4',
30
+ },
31
+ },
32
+ };
33
+ export const PhoneFieldWithValue = {
34
+ args: {
35
+ value: '79990002211',
36
+ },
37
+ parameters: {
38
+ design: {
39
+ type: 'figma',
40
+ url: 'https://www.figma.com/file/8cQcICaes5IWFubU66DMdl/Torgbox-CRM?type=design&node-id=12786-37681&mode=design&t=H9AcJSW51fS3aPiW-4',
41
+ },
42
+ },
43
+ };
@@ -0,0 +1,2 @@
1
+ export { PhoneField } from './PhoneField';
2
+ export { emptyPhoneError, notCorrectPhoneError } from './ErrorMessages';
@@ -0,0 +1,2 @@
1
+ export const emptyRepeatPasswordError = 'Введите пароль повторно';
2
+ export const notCorrectRepeatPasswordError = 'Пароли не совпадают';
@@ -0,0 +1,22 @@
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ import _ from 'lodash/fp';
3
+ import { useEffect, useState } from 'react';
4
+ import { TextField, } from '../TextField';
5
+ import { emptyRepeatPasswordError, notCorrectRepeatPasswordError } from './ErrorMessages';
6
+ export const RepeatPasswordField = (props) => {
7
+ const { equalHandler, comparedValue } = props;
8
+ const [touched, setTouched] = useState(false);
9
+ const [password, setPassword] = useState('');
10
+ const [errorMessage, setErrorMessage] = useState('');
11
+ useEffect(() => {
12
+ equalHandler(comparedValue === password);
13
+ if (!touched) {
14
+ return;
15
+ }
16
+ setErrorMessage(_.cond([
17
+ [() => !password, () => emptyRepeatPasswordError],
18
+ [() => comparedValue !== password, () => notCorrectRepeatPasswordError],
19
+ ]));
20
+ }, [touched, password, comparedValue, equalHandler]);
21
+ return (_jsx(TextField, { onChange: setPassword, onTouched: setTouched, state: touched && errorMessage ? 'error' : 'idle', errorMessage: errorMessage, label: '\u041F\u043E\u0432\u0442\u043E\u0440\u0438\u0442\u0435 \u043F\u0430\u0440\u043E\u043B\u044C', type: 'password', value: password, eyeIcon: true, checkIcon: true, required: true, ...props }));
22
+ };