@alfalab/core-components-confirmation 9.0.7 → 10.1.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 (233) hide show
  1. package/CHANGELOG.md +57 -0
  2. package/dist/component.d.ts +4 -164
  3. package/dist/component.js +113 -101
  4. package/dist/components/countdown-loader/component.d.ts +1 -1
  5. package/dist/components/countdown-loader/component.js +1 -1
  6. package/dist/components/countdown-loader/index.css +2 -2
  7. package/dist/components/index.d.ts +1 -3
  8. package/dist/components/index.js +15 -14
  9. package/dist/components/screens/fatal-error/component.d.ts +3 -0
  10. package/dist/components/screens/fatal-error/component.js +25 -0
  11. package/dist/components/screens/fatal-error/index.css +61 -0
  12. package/dist/components/{code-input → screens/fatal-error}/index.d.ts +0 -0
  13. package/dist/components/screens/fatal-error/index.js +13 -0
  14. package/dist/components/screens/hint/component.d.ts +3 -0
  15. package/dist/components/screens/hint/component.js +45 -0
  16. package/dist/components/screens/hint/index.css +103 -0
  17. package/dist/components/{countdown → screens/hint}/index.d.ts +0 -0
  18. package/dist/components/screens/hint/index.js +15 -0
  19. package/dist/components/screens/index.d.ts +4 -0
  20. package/dist/components/screens/index.js +26 -0
  21. package/dist/components/screens/initial/component.d.ts +3 -0
  22. package/dist/components/screens/initial/component.js +95 -0
  23. package/dist/components/screens/initial/countdown-section.d.ts +0 -0
  24. package/dist/components/screens/initial/countdown-section.js +15 -0
  25. package/dist/components/screens/initial/index.css +98 -0
  26. package/dist/components/{overlimit → screens/initial}/index.d.ts +0 -0
  27. package/dist/components/screens/initial/index.js +19 -0
  28. package/dist/components/screens/temp-block/component.d.ts +3 -0
  29. package/dist/components/screens/temp-block/component.js +36 -0
  30. package/dist/components/{overlimit → screens/temp-block}/index.css +9 -31
  31. package/dist/components/{sign-confirmation → screens/temp-block}/index.d.ts +0 -0
  32. package/dist/components/screens/temp-block/index.js +13 -0
  33. package/dist/context.d.ts +4 -0
  34. package/dist/context.js +27 -0
  35. package/dist/countdown-section-4cb91876.d.ts +9 -0
  36. package/dist/countdown-section-4cb91876.js +41 -0
  37. package/dist/cssm/component.d.ts +4 -164
  38. package/dist/cssm/component.js +115 -103
  39. package/dist/cssm/components/countdown-loader/component.d.ts +1 -1
  40. package/dist/cssm/components/index.d.ts +1 -3
  41. package/dist/cssm/components/index.js +19 -18
  42. package/dist/cssm/components/screens/fatal-error/component.d.ts +3 -0
  43. package/dist/cssm/components/screens/fatal-error/component.js +24 -0
  44. package/dist/cssm/components/{code-input → screens/fatal-error}/index.d.ts +0 -0
  45. package/dist/cssm/components/screens/fatal-error/index.js +14 -0
  46. package/dist/cssm/components/screens/fatal-error/index.module.css +60 -0
  47. package/dist/cssm/components/screens/hint/component.d.ts +3 -0
  48. package/dist/cssm/components/screens/hint/component.js +44 -0
  49. package/dist/cssm/components/{countdown → screens/hint}/index.d.ts +0 -0
  50. package/dist/cssm/components/screens/hint/index.js +16 -0
  51. package/dist/cssm/components/screens/hint/index.module.css +102 -0
  52. package/dist/cssm/components/screens/index.d.ts +4 -0
  53. package/dist/cssm/components/screens/index.js +31 -0
  54. package/dist/cssm/components/screens/initial/component.d.ts +3 -0
  55. package/dist/cssm/components/screens/initial/component.js +97 -0
  56. package/dist/cssm/components/screens/initial/countdown-section.d.ts +9 -0
  57. package/dist/cssm/components/screens/initial/countdown-section.js +41 -0
  58. package/dist/cssm/components/{overlimit → screens/initial}/index.d.ts +0 -0
  59. package/dist/cssm/components/screens/initial/index.js +20 -0
  60. package/dist/cssm/components/{sign-confirmation → screens/initial}/index.module.css +40 -50
  61. package/dist/cssm/components/screens/temp-block/component.d.ts +3 -0
  62. package/dist/cssm/components/screens/temp-block/component.js +36 -0
  63. package/dist/cssm/components/{sign-confirmation → screens/temp-block}/index.d.ts +0 -0
  64. package/dist/cssm/components/screens/temp-block/index.js +15 -0
  65. package/dist/cssm/components/{overlimit → screens/temp-block}/index.module.css +6 -28
  66. package/dist/cssm/context.d.ts +4 -0
  67. package/dist/cssm/context.js +27 -0
  68. package/dist/cssm/index.d.ts +3 -0
  69. package/dist/cssm/index.js +29 -20
  70. package/dist/cssm/index.module.css +5 -77
  71. package/dist/cssm/types.d.ts +130 -0
  72. package/dist/cssm/types.js +23 -0
  73. package/dist/cssm/utils.d.ts +30 -0
  74. package/dist/cssm/utils.js +84 -0
  75. package/dist/esm/component.d.ts +4 -164
  76. package/dist/esm/component.js +114 -102
  77. package/dist/esm/components/countdown-loader/component.d.ts +1 -1
  78. package/dist/esm/components/countdown-loader/component.js +1 -1
  79. package/dist/esm/components/countdown-loader/index.css +2 -2
  80. package/dist/esm/components/index.d.ts +1 -3
  81. package/dist/esm/components/index.js +11 -10
  82. package/dist/esm/components/screens/fatal-error/component.d.ts +3 -0
  83. package/dist/esm/components/screens/fatal-error/component.js +17 -0
  84. package/dist/esm/components/screens/fatal-error/index.css +61 -0
  85. package/dist/esm/components/{code-input → screens/fatal-error}/index.d.ts +0 -0
  86. package/dist/esm/components/screens/fatal-error/index.js +5 -0
  87. package/dist/esm/components/screens/hint/component.d.ts +3 -0
  88. package/dist/esm/components/screens/hint/component.js +36 -0
  89. package/dist/esm/components/screens/hint/index.css +103 -0
  90. package/dist/esm/components/{countdown → screens/hint}/index.d.ts +0 -0
  91. package/dist/esm/components/screens/hint/index.js +7 -0
  92. package/dist/esm/components/screens/index.d.ts +4 -0
  93. package/dist/esm/components/screens/index.js +15 -0
  94. package/dist/esm/components/screens/initial/component.d.ts +3 -0
  95. package/dist/esm/components/screens/initial/component.js +86 -0
  96. package/dist/esm/components/screens/initial/countdown-section.d.ts +0 -0
  97. package/dist/esm/components/screens/initial/countdown-section.js +7 -0
  98. package/dist/esm/components/screens/initial/index.css +98 -0
  99. package/dist/esm/components/{overlimit → screens/initial}/index.d.ts +0 -0
  100. package/dist/esm/components/screens/initial/index.js +11 -0
  101. package/dist/esm/components/screens/temp-block/component.d.ts +3 -0
  102. package/dist/esm/components/screens/temp-block/component.js +28 -0
  103. package/dist/{modern/components/overlimit → esm/components/screens/temp-block}/index.css +9 -31
  104. package/dist/esm/components/{sign-confirmation → screens/temp-block}/index.d.ts +0 -0
  105. package/dist/esm/components/screens/temp-block/index.js +5 -0
  106. package/dist/esm/context.d.ts +4 -0
  107. package/dist/esm/context.js +23 -0
  108. package/dist/esm/countdown-section-7f4accdc.d.ts +9 -0
  109. package/dist/esm/countdown-section-7f4accdc.js +33 -0
  110. package/dist/esm/index.css +7 -79
  111. package/dist/esm/index.d.ts +3 -0
  112. package/dist/esm/index.js +13 -11
  113. package/dist/esm/types.d.ts +130 -0
  114. package/dist/esm/types.js +19 -0
  115. package/dist/esm/utils.d.ts +30 -0
  116. package/dist/esm/utils.js +76 -0
  117. package/dist/index.css +7 -79
  118. package/dist/index.d.ts +3 -0
  119. package/dist/index.js +25 -16
  120. package/dist/modern/component.d.ts +4 -164
  121. package/dist/modern/component.js +75 -102
  122. package/dist/modern/components/countdown-loader/component.d.ts +1 -1
  123. package/dist/modern/components/countdown-loader/component.js +1 -1
  124. package/dist/modern/components/countdown-loader/index.css +2 -2
  125. package/dist/modern/components/index.d.ts +1 -3
  126. package/dist/modern/components/index.js +11 -10
  127. package/dist/modern/components/screens/fatal-error/component.d.ts +3 -0
  128. package/dist/modern/components/screens/fatal-error/component.js +17 -0
  129. package/dist/modern/components/screens/fatal-error/index.css +61 -0
  130. package/dist/modern/components/{code-input → screens/fatal-error}/index.d.ts +0 -0
  131. package/dist/modern/components/screens/fatal-error/index.js +5 -0
  132. package/dist/modern/components/screens/hint/component.d.ts +3 -0
  133. package/dist/modern/components/screens/hint/component.js +36 -0
  134. package/dist/modern/components/screens/hint/index.css +103 -0
  135. package/dist/modern/components/{countdown → screens/hint}/index.d.ts +0 -0
  136. package/dist/modern/components/screens/hint/index.js +7 -0
  137. package/dist/modern/components/screens/index.d.ts +4 -0
  138. package/dist/modern/components/screens/index.js +15 -0
  139. package/dist/modern/components/screens/initial/component.d.ts +3 -0
  140. package/dist/modern/components/screens/initial/component.js +86 -0
  141. package/dist/modern/components/screens/initial/countdown-section.d.ts +0 -0
  142. package/dist/modern/components/screens/initial/countdown-section.js +7 -0
  143. package/dist/modern/components/screens/initial/index.css +98 -0
  144. package/dist/modern/components/{overlimit → screens/initial}/index.d.ts +0 -0
  145. package/dist/modern/components/screens/initial/index.js +11 -0
  146. package/dist/modern/components/screens/temp-block/component.d.ts +3 -0
  147. package/dist/modern/components/screens/temp-block/component.js +28 -0
  148. package/dist/{esm/components/overlimit → modern/components/screens/temp-block}/index.css +9 -31
  149. package/dist/modern/components/{sign-confirmation → screens/temp-block}/index.d.ts +0 -0
  150. package/dist/modern/components/screens/temp-block/index.js +5 -0
  151. package/dist/modern/context.d.ts +4 -0
  152. package/dist/modern/context.js +23 -0
  153. package/dist/modern/countdown-section-2c8a29e0.d.ts +9 -0
  154. package/dist/modern/countdown-section-2c8a29e0.js +32 -0
  155. package/dist/modern/index.css +7 -79
  156. package/dist/modern/index.d.ts +3 -0
  157. package/dist/modern/index.js +12 -10
  158. package/dist/modern/types.d.ts +130 -0
  159. package/dist/modern/types.js +19 -0
  160. package/dist/modern/utils.d.ts +30 -0
  161. package/dist/modern/utils.js +74 -0
  162. package/dist/types.d.ts +130 -0
  163. package/dist/types.js +23 -0
  164. package/dist/utils.d.ts +30 -0
  165. package/dist/utils.js +84 -0
  166. package/package.json +4 -3
  167. package/dist/components/code-input/component.d.ts +0 -16
  168. package/dist/components/code-input/component.js +0 -160
  169. package/dist/components/code-input/index.css +0 -99
  170. package/dist/components/code-input/index.js +0 -13
  171. package/dist/components/code-input/utils.d.ts +0 -10
  172. package/dist/components/code-input/utils.js +0 -21
  173. package/dist/components/countdown/component.d.ts +0 -23
  174. package/dist/components/countdown/component.js +0 -117
  175. package/dist/components/countdown/index.css +0 -85
  176. package/dist/components/countdown/index.js +0 -16
  177. package/dist/components/overlimit/component.d.ts +0 -12
  178. package/dist/components/overlimit/component.js +0 -73
  179. package/dist/components/overlimit/index.js +0 -17
  180. package/dist/components/sign-confirmation/component.d.ts +0 -37
  181. package/dist/components/sign-confirmation/component.js +0 -62
  182. package/dist/components/sign-confirmation/index.css +0 -108
  183. package/dist/components/sign-confirmation/index.js +0 -20
  184. package/dist/cssm/components/code-input/component.d.ts +0 -16
  185. package/dist/cssm/components/code-input/component.js +0 -159
  186. package/dist/cssm/components/code-input/index.js +0 -14
  187. package/dist/cssm/components/code-input/index.module.css +0 -98
  188. package/dist/cssm/components/code-input/utils.d.ts +0 -10
  189. package/dist/cssm/components/code-input/utils.js +0 -21
  190. package/dist/cssm/components/countdown/component.d.ts +0 -23
  191. package/dist/cssm/components/countdown/component.js +0 -117
  192. package/dist/cssm/components/countdown/index.js +0 -18
  193. package/dist/cssm/components/countdown/index.module.css +0 -84
  194. package/dist/cssm/components/overlimit/component.d.ts +0 -12
  195. package/dist/cssm/components/overlimit/component.js +0 -74
  196. package/dist/cssm/components/overlimit/index.js +0 -20
  197. package/dist/cssm/components/sign-confirmation/component.d.ts +0 -37
  198. package/dist/cssm/components/sign-confirmation/component.js +0 -64
  199. package/dist/cssm/components/sign-confirmation/index.js +0 -24
  200. package/dist/esm/components/code-input/component.d.ts +0 -16
  201. package/dist/esm/components/code-input/component.js +0 -151
  202. package/dist/esm/components/code-input/index.css +0 -99
  203. package/dist/esm/components/code-input/index.js +0 -5
  204. package/dist/esm/components/code-input/utils.d.ts +0 -10
  205. package/dist/esm/components/code-input/utils.js +0 -17
  206. package/dist/esm/components/countdown/component.d.ts +0 -23
  207. package/dist/esm/components/countdown/component.js +0 -107
  208. package/dist/esm/components/countdown/index.css +0 -85
  209. package/dist/esm/components/countdown/index.js +0 -7
  210. package/dist/esm/components/overlimit/component.d.ts +0 -12
  211. package/dist/esm/components/overlimit/component.js +0 -65
  212. package/dist/esm/components/overlimit/index.js +0 -9
  213. package/dist/esm/components/sign-confirmation/component.d.ts +0 -37
  214. package/dist/esm/components/sign-confirmation/component.js +0 -53
  215. package/dist/esm/components/sign-confirmation/index.css +0 -108
  216. package/dist/esm/components/sign-confirmation/index.js +0 -12
  217. package/dist/modern/components/code-input/component.d.ts +0 -16
  218. package/dist/modern/components/code-input/component.js +0 -123
  219. package/dist/modern/components/code-input/index.css +0 -99
  220. package/dist/modern/components/code-input/index.js +0 -5
  221. package/dist/modern/components/code-input/utils.d.ts +0 -10
  222. package/dist/modern/components/code-input/utils.js +0 -16
  223. package/dist/modern/components/countdown/component.d.ts +0 -23
  224. package/dist/modern/components/countdown/component.js +0 -102
  225. package/dist/modern/components/countdown/index.css +0 -85
  226. package/dist/modern/components/countdown/index.js +0 -7
  227. package/dist/modern/components/overlimit/component.d.ts +0 -12
  228. package/dist/modern/components/overlimit/component.js +0 -64
  229. package/dist/modern/components/overlimit/index.js +0 -9
  230. package/dist/modern/components/sign-confirmation/component.d.ts +0 -37
  231. package/dist/modern/components/sign-confirmation/component.js +0 -51
  232. package/dist/modern/components/sign-confirmation/index.css +0 -108
  233. package/dist/modern/components/sign-confirmation/index.js +0 -12
@@ -1,65 +0,0 @@
1
- import React, { useRef, useState, useCallback, useEffect } from 'react';
2
- import 'classnames';
3
- import { Button } from '@alfalab/core-components-button/dist/esm';
4
- import '@alfalab/utils';
5
- import '@alfalab/hooks';
6
- import { CountdownLoader } from '../countdown-loader/component.js';
7
- import { formatMsAsMinutes } from '../countdown/component.js';
8
- import { CrossCircleMIcon } from '@alfalab/icons-glyph';
9
-
10
- var styles = {"component":"confirmation__component_1iqq7","title":"confirmation__title_1iqq7","description":"confirmation__description_1iqq7","countdown":"confirmation__countdown_1iqq7","loader":"confirmation__loader_1iqq7","timePassed":"confirmation__timePassed_1iqq7","getCodeButton":"confirmation__getCodeButton_1iqq7","alertIcon":"confirmation__alertIcon_1iqq7"};
11
- require('./index.css')
12
-
13
- var Overlimit = function (_a) {
14
- var _b = _a.duration, duration = _b === void 0 ? 60000 : _b, buttonRetryText = _a.buttonRetryText, hasFatalError = _a.hasFatalError, onOverlimitRepeatSms = _a.onOverlimitRepeatSms, onOverlimitCountdownFinished = _a.onOverlimitCountdownFinished, text = _a.text, title = _a.title;
15
- var timerId = useRef(0);
16
- var start = useRef(0);
17
- var _c = useState(false), isBlockingOver = _c[0], setIsBlockingOver = _c[1];
18
- var _d = useState(0), timePassed = _d[0], setTimePassed = _d[1];
19
- var stopTimer = useCallback(function () {
20
- window.clearInterval(timerId.current);
21
- }, []);
22
- var updateProgress = useCallback(function () {
23
- var passed = Date.now() - start.current;
24
- if (passed >= duration) {
25
- setIsBlockingOver(true);
26
- if (onOverlimitCountdownFinished) {
27
- onOverlimitCountdownFinished();
28
- }
29
- stopTimer();
30
- }
31
- else {
32
- setTimePassed(passed);
33
- }
34
- }, [duration, onOverlimitCountdownFinished, stopTimer]);
35
- var startTimer = useCallback(function () {
36
- start.current = Date.now();
37
- updateProgress();
38
- timerId.current = window.setInterval(updateProgress, 50);
39
- }, [updateProgress]);
40
- var handleRepeatSmsButtonClick = useCallback(function (event) {
41
- setIsBlockingOver(false);
42
- if (onOverlimitRepeatSms) {
43
- onOverlimitRepeatSms(event);
44
- }
45
- startTimer();
46
- }, [onOverlimitRepeatSms, startTimer]);
47
- useEffect(function () {
48
- startTimer();
49
- return function () {
50
- stopTimer();
51
- };
52
- }, [startTimer, stopTimer]);
53
- var progress = timePassed / duration;
54
- return (React.createElement("div", { className: styles.component },
55
- hasFatalError && (React.createElement("div", { className: styles.alertIcon },
56
- React.createElement(CrossCircleMIcon, { "data-test-id": 'alert-icon', width: 64, height: 64 }))),
57
- React.createElement("span", { className: styles.title }, title),
58
- React.createElement("div", { className: styles.description },
59
- React.createElement("div", null, text),
60
- isBlockingOver ? (React.createElement(Button, { size: 'xs', view: 'secondary', onClick: handleRepeatSmsButtonClick, className: styles.getCodeButton }, buttonRetryText)) : (React.createElement("div", { className: styles.countdown },
61
- React.createElement(CountdownLoader, { progress: progress, className: styles.loader }),
62
- React.createElement("div", { className: styles.timePassed }, formatMsAsMinutes(duration - timePassed)))))));
63
- };
64
-
65
- export { Overlimit };
@@ -1,9 +0,0 @@
1
- import 'react';
2
- import 'classnames';
3
- import '@alfalab/core-components-button/dist/esm';
4
- import '@alfalab/utils';
5
- import '@alfalab/hooks';
6
- import '../countdown-loader/component.js';
7
- import '../countdown/component.js';
8
- import '@alfalab/icons-glyph';
9
- export { Overlimit } from './component.js';
@@ -1,37 +0,0 @@
1
- /// <reference types="react" />
2
- import React from 'react';
3
- import { FC, MutableRefObject, ReactNode } from "react";
4
- import { ContentAlign } from "../../component";
5
- type SignConfirmationProps = {
6
- codeChecking: boolean;
7
- codeSending: boolean;
8
- smsHintVisible: boolean;
9
- requiredCharAmount: number;
10
- countdownDuration: number;
11
- additionalContent: React.ReactNode;
12
- hasPhoneMask: boolean;
13
- phone?: string;
14
- code: string;
15
- errorText: string;
16
- error: boolean;
17
- title: string | React.ReactNode;
18
- codeCheckingText: string;
19
- codeSendingText: string;
20
- hasSmsCountdown: boolean;
21
- inputRef: MutableRefObject<HTMLInputElement | null>;
22
- alignContent: ContentAlign;
23
- noAttemptsLeftMessage?: string;
24
- buttonRetryText: string;
25
- countdownContent?: ReactNode;
26
- onInputFinished: ({ code }: {
27
- code: string;
28
- }) => void;
29
- onInputChange: ({ code }: {
30
- code: string;
31
- }) => void;
32
- onSmsRetryClick: (event: React.MouseEvent) => void;
33
- onCountdownFinished: () => void;
34
- onSmsHintLinkClick: (event: React.MouseEvent) => void;
35
- };
36
- declare const SignConfirmation: FC<SignConfirmationProps>;
37
- export { SignConfirmationProps, SignConfirmation };
@@ -1,53 +0,0 @@
1
- import React, { useCallback } from 'react';
2
- import cn from 'classnames';
3
- import '@alfalab/core-components-button/dist/esm';
4
- import { Link } from '@alfalab/core-components-link/dist/esm';
5
- import '@alfalab/utils';
6
- import '@alfalab/hooks';
7
- import '../countdown-loader/component.js';
8
- import { Countdown } from '../countdown/component.js';
9
- import { Loader } from '@alfalab/core-components-loader/dist/esm';
10
- import { CodeInput } from '../code-input/component.js';
11
- import '../code-input/utils.js';
12
-
13
- var styles = {"component":"confirmation__component_srlhu","countdown":"confirmation__countdown_srlhu","hidden":"confirmation__hidden_srlhu","header":"confirmation__header_srlhu","inputContainer":"confirmation__inputContainer_srlhu","smsComeLinkWrap":"confirmation__smsComeLinkWrap_srlhu","smsComeLink":"confirmation__smsComeLink_srlhu","error":"confirmation__error_srlhu","loaderWrap":"confirmation__loaderWrap_srlhu","loaderText":"confirmation__loaderText_srlhu","center":"confirmation__center_srlhu","codeInput":"confirmation__codeInput_srlhu"};
14
- require('./index.css')
15
-
16
- var SignConfirmation = function (_a) {
17
- var _b;
18
- var codeChecking = _a.codeChecking, codeSending = _a.codeSending, smsHintVisible = _a.smsHintVisible, requiredCharAmount = _a.requiredCharAmount, countdownDuration = _a.countdownDuration, additionalContent = _a.additionalContent, hasPhoneMask = _a.hasPhoneMask, phone = _a.phone, inputValue = _a.code, error = _a.error, errorText = _a.errorText, title = _a.title, hasSmsCountdown = _a.hasSmsCountdown, inputRef = _a.inputRef, codeCheckingText = _a.codeCheckingText, codeSendingText = _a.codeSendingText, alignContent = _a.alignContent, noAttemptsLeftMessage = _a.noAttemptsLeftMessage, buttonRetryText = _a.buttonRetryText, countdownContent = _a.countdownContent, onInputFinished = _a.onInputFinished, onInputChange = _a.onInputChange, onSmsRetryClick = _a.onSmsRetryClick, onCountdownFinished = _a.onCountdownFinished, onSmsHintLinkClick = _a.onSmsHintLinkClick;
19
- var processing = codeChecking || codeSending;
20
- var displayedError = processing ? '' : errorText;
21
- var handleInputKeyDown = useCallback(function (event) {
22
- if (event.key === 'Enter') {
23
- onInputFinished({ code: event.target.value });
24
- }
25
- }, [onInputFinished]);
26
- var handleInputFinished = useCallback(function (code) {
27
- onInputFinished({ code: code });
28
- if (inputRef.current) {
29
- inputRef.current.blur();
30
- }
31
- }, [onInputFinished, inputRef]);
32
- var handleInputChange = useCallback(function (code) {
33
- if (code.length === requiredCharAmount) {
34
- handleInputFinished(code);
35
- }
36
- onInputChange({ code: code });
37
- }, [handleInputFinished, onInputChange, requiredCharAmount]);
38
- return (React.createElement("div", { className: cn(styles.component, styles[alignContent]) },
39
- typeof title === 'string' ? React.createElement("span", { className: styles.header }, title) : title,
40
- React.createElement("div", { className: styles.inputContainer },
41
- React.createElement(CodeInput, { processing: processing, error: error, value: inputValue, ref: inputRef, slotsCount: requiredCharAmount, className: styles.codeInput, alignContent: alignContent, handleChange: handleInputChange, handleInputKeyDown: handleInputKeyDown }),
42
- displayedError && (React.createElement("div", { className: styles.error, role: 'alert' }, displayedError))),
43
- processing && (React.createElement("div", { className: styles.loaderWrap },
44
- React.createElement(Loader, null),
45
- React.createElement("span", { className: styles.loaderText }, codeChecking ? codeCheckingText : codeSendingText))),
46
- hasSmsCountdown && (React.createElement("div", { className: cn('countdown', styles.countdown, (_b = {}, _b[styles.hidden] = processing, _b)) },
47
- React.createElement(Countdown, { duration: countdownDuration, phone: phone, hasPhoneMask: hasPhoneMask, alignContent: alignContent, noAttemptsLeftMessage: noAttemptsLeftMessage, hasError: Boolean(displayedError), buttonRetryText: buttonRetryText, content: countdownContent, onRepeatSms: onSmsRetryClick, onCountdownFinished: onCountdownFinished }))),
48
- smsHintVisible && (React.createElement("div", { className: styles.smsComeLinkWrap },
49
- React.createElement(Link, { onClick: onSmsHintLinkClick, className: styles.smsComeLink, view: 'secondary', pseudo: true }, "\u041D\u0435 \u043F\u0440\u0438\u0445\u043E\u0434\u0438\u0442 \u0441\u043E\u043E\u0431\u0449\u0435\u043D\u0438\u0435?"))),
50
- React.createElement("div", null, additionalContent)));
51
- };
52
-
53
- export { SignConfirmation };
@@ -1,108 +0,0 @@
1
- /* hash: u6g7x */
2
- :root {
3
- --color-light-text-negative: #d91d0b;
4
- --color-light-text-primary: #0b1f35;
5
- --color-light-text-secondary: #546272;
6
- }
7
- :root {
8
-
9
- /* Hard */
10
-
11
- /* Up */
12
-
13
- /* Hard up */
14
- }
15
- :root {
16
- --gap-xs: 8px;
17
- --gap-s: 12px;
18
- --gap-l: 20px;
19
- --gap-3xl: 40px;
20
- }
21
- :root {
22
- --font-family-system: system-ui, -apple-system, 'Segoe UI', Roboto, 'Helvetica Neue', Helvetica,
23
- sans-serif;
24
- }
25
- :root {
26
- /* title */
27
- --confirmation-title-font-size: 22px;
28
- --confirmation-title-line-height: 26px;
29
- --confirmation-title-font-weight: 700;
30
- --confirmation-title-font-family: var(--font-family-system);
31
- --confirmation-title-color: var(--color-light-text-primary);
32
- --confirmation-title-font-feature-settings: normal;
33
-
34
- /* text */
35
- --confirmation-text-font-size: 16px;
36
- --confirmation-text-line-height: 24px;
37
- --confirmation-text-font-weight: 400;
38
- --confirmation-text-font-family: var(--font-family-system);
39
- --confirmation-text-color: var(--color-light-text-secondary);
40
-
41
- /* error */
42
- --confirmation-error-color: var(--color-light-text-negative);
43
-
44
- /* input */
45
- }
46
- .confirmation__component_srlhu {
47
- display: flex;
48
- flex-direction: column;
49
- }
50
- .confirmation__countdown_srlhu {
51
- max-height: 300px;
52
- overflow: hidden;
53
- transition: max-height 0.15s ease;
54
- }
55
- .confirmation__hidden_srlhu {
56
- opacity: 0;
57
- max-height: 0;
58
- }
59
- .confirmation__header_srlhu {
60
- font-size: var(--confirmation-title-font-size);
61
- line-height: var(--confirmation-title-line-height);
62
- font-weight: var(--confirmation-title-font-weight);
63
- font-family: var(--confirmation-title-font-family);
64
- color: var(--confirmation-title-color);
65
- font-feature-settings: var(--confirmation-title-font-feature-settings);
66
-
67
- margin-bottom: var(--gap-3xl);
68
- color: var(--confirmation-title-color);
69
- }
70
- .confirmation__inputContainer_srlhu {
71
- display: flex;
72
- flex-direction: column;
73
- }
74
- .confirmation__smsComeLinkWrap_srlhu {
75
- margin-top: var(--gap-l);
76
- }
77
- .confirmation__smsComeLink_srlhu {
78
- font-size: 14px;
79
- line-height: 20px;
80
- font-weight: 400;
81
- }
82
- .confirmation__error_srlhu {
83
- font-size: 14px;
84
- line-height: 20px;
85
- font-weight: 400;
86
-
87
- margin-top: var(--gap-xs);
88
- color: var(--confirmation-error-color);
89
- }
90
- .confirmation__loaderWrap_srlhu {
91
- display: flex;
92
- align-items: center;
93
- margin: var(--gap-3xl) 0 var(--gap-xs);
94
- }
95
- .confirmation__loaderText_srlhu {
96
- font-size: var(--confirmation-text-font-size);
97
- line-height: var(--confirmation-text-line-height);
98
- font-weight: var(--confirmation-text-font-weight);
99
- font-family: var(--confirmation-text-font-family);
100
- color: var(--confirmation-text-color);
101
-
102
- margin-left: var(--gap-s);
103
- color: var(--confirmation-text-color);
104
- }
105
- .confirmation__center_srlhu .confirmation__codeInput_srlhu,
106
- .confirmation__center_srlhu .confirmation__loaderWrap_srlhu {
107
- justify-content: center;
108
- }
@@ -1,12 +0,0 @@
1
- import 'react';
2
- import 'classnames';
3
- import '@alfalab/core-components-button/dist/esm';
4
- import '@alfalab/core-components-link/dist/esm';
5
- import '@alfalab/utils';
6
- import '@alfalab/hooks';
7
- import '../countdown-loader/component.js';
8
- import '../countdown/component.js';
9
- import '@alfalab/core-components-loader/dist/esm';
10
- import '../code-input/component.js';
11
- import '../code-input/utils.js';
12
- export { SignConfirmation } from './component.js';
@@ -1,16 +0,0 @@
1
- /// <reference types="react" />
2
- import React from 'react';
3
- import { KeyboardEvent } from "react";
4
- import { ContentAlign } from "../../component";
5
- type CodeInputProps = {
6
- processing: boolean;
7
- value: string;
8
- slotsCount: number;
9
- error: boolean;
10
- className?: string;
11
- alignContent: ContentAlign;
12
- handleChange: (code: string) => void;
13
- handleInputKeyDown: (event: KeyboardEvent) => void;
14
- };
15
- declare const CodeInput: React.ForwardRefExoticComponent<CodeInputProps & React.RefAttributes<HTMLInputElement>>;
16
- export { CodeInput };
@@ -1,123 +0,0 @@
1
- import React, { forwardRef, useRef, useImperativeHandle, useCallback, useEffect } from 'react';
2
- import cn from 'classnames';
3
- import { usePrevious } from '@alfalab/hooks';
4
- import { mergeArrays } from './utils.js';
5
-
6
- var styles = {"component":"confirmation__component_1s527","input":"confirmation__input_1s527","hasError":"confirmation__hasError_1s527","center":"confirmation__center_1s527","disabled":"confirmation__disabled_1s527","compact":"confirmation__compact_1s527","shake":"confirmation__shake_1s527"};
7
- require('./index.css')
8
-
9
- const Input = ({ index, slotsCount, error, processing, value, alignContent, handleChange, handleInputKeyDown, setRef, focus, }) => {
10
- const splittedValue = value.split('');
11
- const inputRef = useRef(null);
12
- const onChange = (event) => {
13
- const { value: targetValue } = event.target;
14
- if (/^\d$/.test(targetValue)) {
15
- const newValues = [...splittedValue];
16
- newValues[index] = targetValue;
17
- handleChange(newValues.join(''));
18
- }
19
- else if (/^\d{1,}$/.test(targetValue) && index !== slotsCount - 1) {
20
- /*
21
- * если пользователь хочет ввести более 1 цифры в инпут,
22
- * то предполагаем, что это вставка кода (например, из смс)
23
- */
24
- const newValues = mergeArrays({
25
- sourceArray: splittedValue,
26
- targetArray: targetValue.split(''),
27
- startIndex: index,
28
- resultArrayLength: slotsCount,
29
- });
30
- handleChange(newValues.join(''));
31
- }
32
- };
33
- const onInputKeyDown = (event) => {
34
- const { key } = event;
35
- const newValues = [...splittedValue];
36
- switch (key) {
37
- case 'Backspace':
38
- case 'Delete':
39
- newValues[index] = '';
40
- handleChange(newValues.join('').trim());
41
- if (index !== 0) {
42
- focus(index - 1);
43
- }
44
- break;
45
- case 'ArrowRight':
46
- if (index !== slotsCount - 1) {
47
- focus(index + 1);
48
- }
49
- break;
50
- case 'ArrowLeft':
51
- if (index !== 0) {
52
- focus(index - 1);
53
- }
54
- break;
55
- case 'Home':
56
- focus(0);
57
- break;
58
- case 'End':
59
- focus(slotsCount - 1);
60
- break;
61
- }
62
- handleInputKeyDown(event);
63
- };
64
- const handleRef = (node) => {
65
- inputRef.current = node;
66
- setRef({ node, index });
67
- };
68
- return (React.createElement("input", { className: cn(styles.input, styles[alignContent], {
69
- [styles.hasError]: error,
70
- [styles.disabled]: processing,
71
- }), disabled: processing, value: splittedValue[index] || '', autoComplete: index === 0 ? 'one-time-code' : '', inputMode: 'numeric', pattern: '[0-9]*', onChange: onChange, onKeyDown: onInputKeyDown, ref: handleRef }));
72
- };
73
- const CodeInput = forwardRef(({ processing, value = '', slotsCount, error, handleInputKeyDown, handleChange, className, alignContent, }, ref) => {
74
- const inputs = useRef([]);
75
- useImperativeHandle(ref, () => inputs.current[0]);
76
- const prevValue = usePrevious(value) || '';
77
- const focus = useCallback((index) => {
78
- const input = inputs.current[index];
79
- if (input) {
80
- input.focus();
81
- input.setSelectionRange(1, 1);
82
- }
83
- }, []);
84
- const setRef = useCallback(({ node, index }) => {
85
- inputs.current[index] = node;
86
- }, []);
87
- /**
88
- * Устанавливаем фокус на инпуте:
89
- * 1) если код введен неверно
90
- * 2) по нажатию кнопки 'Запросить код'
91
- */
92
- useEffect(() => {
93
- const inputIndex = value.length === slotsCount ? value.length - 1 : value.length;
94
- const needFocus = !processing || error;
95
- if (needFocus && value.length === prevValue.length) {
96
- focus(inputIndex);
97
- }
98
- }, [focus, error, slotsCount, value.length, prevValue.length, processing]);
99
- useEffect(() => {
100
- if (value.length > prevValue.length && value.length < slotsCount) {
101
- /**
102
- * Если value.length увеличился - ставим фокус на следующем инпуте
103
- */
104
- const nextInputIndex = value.length;
105
- focus(nextInputIndex);
106
- }
107
- else if (value.length <= prevValue.length && value.length > 0) {
108
- /**
109
- * Если value.length уменьшился - ставим фокус на предыдущем инпуте
110
- */
111
- const nextInputIndex = value.length - 1;
112
- focus(nextInputIndex);
113
- }
114
- }, [value.length, prevValue.length, slotsCount, focus]);
115
- return (React.createElement("div", { className: cn(styles.component, className, {
116
- [styles.shake]: Boolean(error),
117
- [styles.compact]: slotsCount > 6,
118
- }) }, new Array(slotsCount).fill('').map((_, index) => (React.createElement(Input, { value: value, index: index, error: error, processing: processing, slotsCount: slotsCount, alignContent: alignContent, handleChange: handleChange, handleInputKeyDown: handleInputKeyDown, setRef: setRef, focus: focus,
119
- // eslint-disable-next-line react/no-array-index-key
120
- key: index })))));
121
- });
122
-
123
- export { CodeInput };
@@ -1,99 +0,0 @@
1
- /* hash: 19upi */
2
- :root {
3
- --color-light-bg-negative-muted: #feebea;
4
- --color-light-bg-secondary: #f3f4f5;
5
- --color-light-text-negative: #d91d0b;
6
- --color-light-text-primary: #0b1f35;
7
- --color-light-text-tertiary: #b6bcc3;
8
- }
9
- :root {
10
-
11
- /* Hard */
12
-
13
- /* Up */
14
-
15
- /* Hard up */
16
- }
17
- :root {
18
- --gap-2xs: 4px;
19
- --gap-xs: 8px;
20
- }
21
- :root {
22
- --font-family-system: system-ui, -apple-system, 'Segoe UI', Roboto, 'Helvetica Neue', Helvetica,
23
- sans-serif;
24
- }
25
- :root {
26
- --border-radius-s: 4px;
27
- }
28
- :root {
29
- /* title */
30
-
31
- /* text */
32
-
33
- /* error */
34
- --confirmation-error-color: var(--color-light-text-negative);
35
-
36
- /* input */
37
- --confirmation-input-font-size: 30px;
38
- --confirmation-input-font-weight: 700;
39
- --confirmation-input-font-family: var(--font-family-system);
40
- --confirmation-input-text-color: var(--color-light-text-primary);
41
- --confirmation-input-bg-color: var(--color-light-bg-secondary);
42
- --confirmation-input-error-bg-color: var(--color-light-bg-negative-muted);
43
- }
44
- .confirmation__component_1s527 {
45
- display: flex;
46
- }
47
- .confirmation__input_1s527 {
48
- flex-shrink: 0;
49
- width: 36px;
50
- height: 48px;
51
- margin-right: var(--gap-xs);
52
- padding: 0;
53
- background-color: var(--confirmation-input-bg-color);
54
- border: none;
55
- border-radius: var(--border-radius-s);
56
- box-sizing: border-box;
57
- outline: none;
58
- color: var(--confirmation-input-text-color);
59
- text-align: center;
60
- font-size: var(--confirmation-input-font-size);
61
- font-weight: var(--confirmation-input-font-weight);
62
- font-family: var(--confirmation-input-font-family)
63
- }
64
- .confirmation__input_1s527.confirmation__hasError_1s527 {
65
- color: var(--confirmation-error-color);
66
- caret-color: var(--confirmation-input-text-color);
67
- background-color: var(--confirmation-input-error-bg-color);
68
- }
69
- .confirmation__input_1s527.confirmation__center_1s527 {
70
- margin: 0 var(--gap-2xs);
71
- }
72
- .confirmation__input_1s527.confirmation__disabled_1s527 {
73
- color: var(--color-light-text-tertiary);
74
- opacity: 1;
75
- }
76
- .confirmation__compact_1s527 .confirmation__input_1s527 {
77
- width: 28px;
78
- height: 40px;
79
- }
80
- @keyframes confirmation__shake_1s527 {
81
- 0% {
82
- transform: translateX(0);
83
- }
84
-
85
- 25% {
86
- transform: translateX(-2px);
87
- }
88
-
89
- 75% {
90
- transform: translateX(2px);
91
- }
92
-
93
- 100% {
94
- transform: translateX(0);
95
- }
96
- }
97
- .confirmation__shake_1s527 {
98
- animation: confirmation__shake_1s527 0.15s linear 0s 3;
99
- }
@@ -1,5 +0,0 @@
1
- import 'react';
2
- import 'classnames';
3
- import '@alfalab/hooks';
4
- import './utils.js';
5
- export { CodeInput } from './component.js';
@@ -1,10 +0,0 @@
1
- /**
2
- * Начиная с указанного индекса, заменяет элементы исходного массива
3
- */
4
- declare const mergeArrays: ({ sourceArray, targetArray, startIndex, resultArrayLength, }: {
5
- sourceArray: string[];
6
- targetArray: string[];
7
- startIndex: number;
8
- resultArrayLength: number;
9
- }) => string[];
10
- export { mergeArrays };
@@ -1,16 +0,0 @@
1
- /**
2
- * Начиная с указанного индекса, заменяет элементы исходного массива
3
- */
4
- const mergeArrays = ({ sourceArray, targetArray, startIndex, resultArrayLength, }) => {
5
- let insertedElemIndex = 0;
6
- const result = new Array(resultArrayLength).fill('');
7
- return result.map((_, index) => {
8
- if (index < startIndex) {
9
- return sourceArray[index] || '';
10
- }
11
- // eslint-disable-next-line no-plusplus
12
- return targetArray[insertedElemIndex++] || sourceArray[index] || '';
13
- });
14
- };
15
-
16
- export { mergeArrays };
@@ -1,23 +0,0 @@
1
- import { MouseEvent, FC, ReactNode } from 'react';
2
- /**
3
- * TODO: Вынести это в utils
4
- * Форматирование миллисекунд в hh:mm:ss.
5
- *
6
- * @param {Number} ms миллисекунды
7
- * @returns {String} время в формате mm:ss
8
- */
9
- declare function formatMsAsMinutes(ms: number): string;
10
- type CountdownProps = {
11
- duration: number;
12
- hasPhoneMask: boolean;
13
- phone?: string;
14
- alignContent: string;
15
- buttonRetryText: string;
16
- noAttemptsLeftMessage?: string;
17
- hasError: boolean;
18
- content?: ReactNode;
19
- onCountdownFinished?: () => void;
20
- onRepeatSms: (event: MouseEvent) => void;
21
- };
22
- declare const Countdown: FC<CountdownProps>;
23
- export { formatMsAsMinutes, CountdownProps, Countdown };