@alfalab/core-components-confirmation 13.6.2 → 13.7.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 (134) hide show
  1. package/components/base-confirmation/component.js +1 -1
  2. package/components/base-confirmation/index.css +2 -2
  3. package/components/countdown-loader/component.js +1 -1
  4. package/components/countdown-loader/index.css +2 -2
  5. package/components/header/component.js +1 -1
  6. package/components/header/index.css +6 -5
  7. package/components/screens/fatal-error/component.js +1 -1
  8. package/components/screens/fatal-error/index.css +8 -7
  9. package/components/screens/hint/component.js +1 -1
  10. package/components/screens/hint/index.css +19 -16
  11. package/components/screens/initial/component.js +1 -1
  12. package/components/screens/initial/countdown-section.js +1 -1
  13. package/components/screens/initial/index.css +32 -26
  14. package/components/screens/temp-block/component.js +1 -1
  15. package/components/screens/temp-block/index.css +10 -9
  16. package/{countdown-section-f20056ef.js → countdown-section-17d446a6.js} +1 -1
  17. package/cssm/components/header/index.module.css +2 -1
  18. package/cssm/components/screens/fatal-error/index.module.css +2 -1
  19. package/cssm/components/screens/hint/index.module.css +7 -4
  20. package/cssm/components/screens/initial/index.module.css +14 -8
  21. package/cssm/components/screens/temp-block/index.module.css +3 -2
  22. package/esm/components/base-confirmation/component.js +1 -1
  23. package/esm/components/base-confirmation/index.css +2 -2
  24. package/esm/components/countdown-loader/component.js +1 -1
  25. package/esm/components/countdown-loader/index.css +2 -2
  26. package/esm/components/header/component.js +1 -1
  27. package/esm/components/header/index.css +6 -5
  28. package/esm/components/screens/fatal-error/component.js +1 -1
  29. package/esm/components/screens/fatal-error/index.css +8 -7
  30. package/esm/components/screens/hint/component.js +1 -1
  31. package/esm/components/screens/hint/index.css +19 -16
  32. package/esm/components/screens/initial/component.js +1 -1
  33. package/esm/components/screens/initial/countdown-section.js +1 -1
  34. package/esm/components/screens/initial/index.css +32 -26
  35. package/esm/components/screens/temp-block/component.js +1 -1
  36. package/esm/components/screens/temp-block/index.css +10 -9
  37. package/esm/{countdown-section-7164d11c.js → countdown-section-c5b45e8c.js} +1 -1
  38. package/esm/mobile/component.mobile.js +1 -1
  39. package/esm/mobile/mobile.css +2 -2
  40. package/mobile/component.mobile.js +1 -1
  41. package/mobile/mobile.css +2 -2
  42. package/modern/components/base-confirmation/component.js +1 -1
  43. package/modern/components/base-confirmation/index.css +2 -2
  44. package/modern/components/countdown-loader/component.js +1 -1
  45. package/modern/components/countdown-loader/index.css +2 -2
  46. package/modern/components/header/component.js +1 -1
  47. package/modern/components/header/index.css +6 -5
  48. package/modern/components/screens/fatal-error/component.js +1 -1
  49. package/modern/components/screens/fatal-error/index.css +8 -7
  50. package/modern/components/screens/hint/component.js +1 -1
  51. package/modern/components/screens/hint/index.css +19 -16
  52. package/modern/components/screens/initial/component.js +1 -1
  53. package/modern/components/screens/initial/countdown-section.js +1 -1
  54. package/modern/components/screens/initial/index.css +32 -26
  55. package/modern/components/screens/temp-block/component.js +1 -1
  56. package/modern/components/screens/temp-block/index.css +10 -9
  57. package/modern/{countdown-section-37a6acf8.js → countdown-section-b9145aea.js} +1 -1
  58. package/modern/mobile/component.mobile.js +1 -1
  59. package/modern/mobile/mobile.css +2 -2
  60. package/moderncssm/component.responsive.d.ts +15 -0
  61. package/moderncssm/component.responsive.js +11 -0
  62. package/moderncssm/components/base-confirmation/component.d.ts +4 -0
  63. package/moderncssm/components/base-confirmation/component.js +85 -0
  64. package/moderncssm/components/base-confirmation/index.d.ts +1 -0
  65. package/moderncssm/components/base-confirmation/index.js +1 -0
  66. package/moderncssm/components/base-confirmation/index.module.css +8 -0
  67. package/moderncssm/components/countdown-loader/component.d.ts +7 -0
  68. package/moderncssm/components/countdown-loader/component.js +18 -0
  69. package/moderncssm/components/countdown-loader/index.d.ts +1 -0
  70. package/moderncssm/components/countdown-loader/index.js +1 -0
  71. package/moderncssm/components/countdown-loader/index.module.css +7 -0
  72. package/moderncssm/components/header/component.d.ts +13 -0
  73. package/moderncssm/components/header/component.js +8 -0
  74. package/moderncssm/components/header/index.d.ts +1 -0
  75. package/moderncssm/components/header/index.js +1 -0
  76. package/moderncssm/components/header/index.module.css +40 -0
  77. package/moderncssm/components/index.d.ts +2 -0
  78. package/moderncssm/components/index.js +5 -0
  79. package/moderncssm/components/screens/fatal-error/component.d.ts +9 -0
  80. package/moderncssm/components/screens/fatal-error/component.js +17 -0
  81. package/moderncssm/components/screens/fatal-error/index.d.ts +1 -0
  82. package/moderncssm/components/screens/fatal-error/index.js +1 -0
  83. package/moderncssm/components/screens/fatal-error/index.module.css +42 -0
  84. package/moderncssm/components/screens/hint/component.d.ts +9 -0
  85. package/moderncssm/components/screens/hint/component.js +34 -0
  86. package/moderncssm/components/screens/hint/index.d.ts +1 -0
  87. package/moderncssm/components/screens/hint/index.js +1 -0
  88. package/moderncssm/components/screens/hint/index.module.css +72 -0
  89. package/moderncssm/components/screens/index.d.ts +4 -0
  90. package/moderncssm/components/screens/index.js +4 -0
  91. package/moderncssm/components/screens/initial/component.d.ts +9 -0
  92. package/moderncssm/components/screens/initial/component.js +102 -0
  93. package/moderncssm/components/screens/initial/countdown-section.d.ts +10 -0
  94. package/moderncssm/components/screens/initial/countdown-section.js +34 -0
  95. package/moderncssm/components/screens/initial/index.d.ts +1 -0
  96. package/moderncssm/components/screens/initial/index.js +1 -0
  97. package/moderncssm/components/screens/initial/index.module.css +97 -0
  98. package/moderncssm/components/screens/temp-block/component.d.ts +9 -0
  99. package/moderncssm/components/screens/temp-block/component.js +29 -0
  100. package/moderncssm/components/screens/temp-block/index.d.ts +1 -0
  101. package/moderncssm/components/screens/temp-block/index.js +1 -0
  102. package/moderncssm/components/screens/temp-block/index.module.css +47 -0
  103. package/moderncssm/context.d.ts +4 -0
  104. package/moderncssm/context.js +26 -0
  105. package/moderncssm/desktop/component.desktop.d.ts +5 -0
  106. package/moderncssm/desktop/component.desktop.js +6 -0
  107. package/moderncssm/desktop/index.d.ts +2 -0
  108. package/moderncssm/desktop/index.js +2 -0
  109. package/moderncssm/index.d.ts +2 -0
  110. package/moderncssm/index.js +2 -0
  111. package/moderncssm/mobile/component.mobile.d.ts +5 -0
  112. package/moderncssm/mobile/component.mobile.js +8 -0
  113. package/moderncssm/mobile/index.d.ts +2 -0
  114. package/moderncssm/mobile/index.js +2 -0
  115. package/moderncssm/mobile/mobile.module.css +3 -0
  116. package/moderncssm/shared/index.d.ts +4 -0
  117. package/moderncssm/shared/index.js +8 -0
  118. package/moderncssm/types.d.ts +167 -0
  119. package/moderncssm/types.js +19 -0
  120. package/moderncssm/utils.d.ts +30 -0
  121. package/moderncssm/utils.js +72 -0
  122. package/moderncssm/vars.css +11 -0
  123. package/package.json +8 -8
  124. package/src/components/base-confirmation/index.module.css +1 -1
  125. package/src/components/countdown-loader/index.module.css +1 -1
  126. package/src/components/header/index.module.css +1 -1
  127. package/src/components/screens/fatal-error/index.module.css +1 -1
  128. package/src/components/screens/hint/index.module.css +4 -4
  129. package/src/components/screens/initial/index.module.css +8 -8
  130. package/src/components/screens/temp-block/index.module.css +2 -2
  131. package/src/vars.css +1 -1
  132. /package/{countdown-section-f20056ef.d.ts → countdown-section-17d446a6.d.ts} +0 -0
  133. /package/esm/{countdown-section-7164d11c.d.ts → countdown-section-c5b45e8c.d.ts} +0 -0
  134. /package/modern/{countdown-section-37a6acf8.d.ts → countdown-section-b9145aea.d.ts} +0 -0
@@ -0,0 +1,8 @@
1
+ import React from 'react';
2
+ import cn from 'classnames';
3
+ import { Typography } from '@alfalab/core-components-typography/moderncssm';
4
+ import styles from './index.module.css';
5
+
6
+ const Header = ({ mobile, children }) => (React.createElement(Typography.Title, { className: cn(styles.header, styles.typography, { [styles.typographyMobile]: mobile }), tag: 'h3', color: 'primary' }, children));
7
+
8
+ export { Header };
@@ -0,0 +1 @@
1
+ export * from "./component";
@@ -0,0 +1 @@
1
+ export { Header } from './component.js';
@@ -0,0 +1,40 @@
1
+ /* */
2
+
3
+ :root {
4
+ /* desktop */
5
+ --confirmation-header-desktop-font-size: 22px;
6
+ --confirmation-header-desktop-line-height: 26px;
7
+ --confirmation-header-desktop-font-weight: bold;
8
+ --confirmation-header-desktop-font-family: var(--font-family-system);
9
+
10
+ /* mobile */
11
+ --confirmation-header-mobile-font-size: 20px;
12
+ --confirmation-header-mobile-line-height: 28px;
13
+ --confirmation-header-mobile-font-weight: 600;
14
+ --confirmation-header-mobile-font-family: var(--font-family-system);
15
+
16
+ /* text */
17
+
18
+ /* header */
19
+ --confirmation-header-font-feature-settings: normal
20
+ }
21
+
22
+ .header.header {
23
+ margin-bottom: var(--gap-24);
24
+ }
25
+
26
+ .typography.typography.typography {
27
+ font-feature-settings: var(--confirmation-header-font-feature-settings);
28
+ font-size: var(--confirmation-header-desktop-font-size);
29
+ line-height: var(--confirmation-header-desktop-line-height);
30
+ font-weight: var(--confirmation-header-desktop-font-weight);
31
+ font-family: var(--confirmation-header-desktop-font-family);
32
+ }
33
+
34
+ .typographyMobile.typographyMobile.typographyMobile {
35
+ font-feature-settings: var(--confirmation-header-font-feature-settings);
36
+ font-size: var(--confirmation-header-mobile-font-size);
37
+ line-height: var(--confirmation-header-mobile-line-height);
38
+ font-weight: var(--confirmation-header-mobile-font-weight);
39
+ font-family: var(--confirmation-header-mobile-font-family);
40
+ }
@@ -0,0 +1,2 @@
1
+ export * from "./screens/index";
2
+ export * from "./countdown-loader/index";
@@ -0,0 +1,5 @@
1
+ export { Initial } from './screens/initial/component.js';
2
+ export { Hint } from './screens/hint/component.js';
3
+ export { FatalError } from './screens/fatal-error/component.js';
4
+ export { TempBlock } from './screens/temp-block/component.js';
5
+ export { CountdownLoader } from './countdown-loader/component.js';
@@ -0,0 +1,9 @@
1
+ import { FC } from 'react';
2
+ type FatalErrorProps = {
3
+ /**
4
+ * Отображать в мобильной версии экран компонента
5
+ */
6
+ mobile?: boolean;
7
+ };
8
+ declare const FatalError: FC<FatalErrorProps>;
9
+ export { FatalErrorProps, FatalError };
@@ -0,0 +1,17 @@
1
+ import React, { useContext } from 'react';
2
+ import cn from 'classnames';
3
+ import { Button } from '@alfalab/core-components-button/moderncssm';
4
+ import { Typography } from '@alfalab/core-components-typography/moderncssm';
5
+ import { ConfirmationContext } from '../../../context.js';
6
+ import { Header } from '../../header/component.js';
7
+ import styles from './index.module.css';
8
+
9
+ const FatalError = ({ mobile }) => {
10
+ const { alignContent, texts, onFatalErrorOkButtonClick, breakpoint } = useContext(ConfirmationContext);
11
+ return (React.createElement("div", { className: cn(styles.component, styles[alignContent]) },
12
+ React.createElement(Header, { mobile: mobile }, texts.fatalErrorTitle),
13
+ React.createElement(Typography.Text, { view: 'primary-medium', color: 'primary', className: cn({ [styles.typographyTheme]: !mobile }) }, texts.fatalErrorDescription),
14
+ React.createElement(Button, { size: mobile ? 'xs' : 's', view: 'secondary', onClick: onFatalErrorOkButtonClick, className: styles.button, breakpoint: breakpoint }, texts.fatalErrorButton)));
15
+ };
16
+
17
+ export { FatalError };
@@ -0,0 +1 @@
1
+ export * from "./component";
@@ -0,0 +1 @@
1
+ export { FatalError } from './component.js';
@@ -0,0 +1,42 @@
1
+ /* */
2
+
3
+ :root {
4
+ /* desktop */
5
+
6
+ /* mobile */
7
+
8
+ /* text */
9
+ --confirmation-text-font-size: 16px;
10
+ --confirmation-text-line-height: 24px;
11
+ --confirmation-text-font-weight: 400;
12
+ --confirmation-text-font-family: var(--font-family-system);
13
+ --confirmation-text-color: var(--color-light-text-primary)
14
+
15
+ /* header */
16
+ }
17
+
18
+ .component {
19
+ display: flex;
20
+ flex-direction: column;
21
+ }
22
+
23
+ .typographyTheme.typographyTheme {
24
+ font-size: var(--confirmation-text-font-size);
25
+ line-height: var(--confirmation-text-line-height);
26
+ font-weight: var(--confirmation-text-font-weight);
27
+ font-family: var(--confirmation-text-font-family);
28
+ color: var(--confirmation-text-color);
29
+ }
30
+
31
+ .left {
32
+ align-items: flex-start;
33
+ }
34
+
35
+ .center {
36
+ align-items: center;
37
+ text-align: center;
38
+ }
39
+
40
+ .button.button {
41
+ margin-top: var(--gap-32);
42
+ }
@@ -0,0 +1,9 @@
1
+ import { FC } from 'react';
2
+ type HintProps = {
3
+ /**
4
+ * Отображать в мобильной версии экран компонента
5
+ */
6
+ mobile?: boolean;
7
+ };
8
+ declare const Hint: FC<HintProps>;
9
+ export { HintProps, Hint };
@@ -0,0 +1,34 @@
1
+ import React, { useContext } from 'react';
2
+ import cn from 'classnames';
3
+ import { Button } from '@alfalab/core-components-button/moderncssm';
4
+ import { Link } from '@alfalab/core-components-link/moderncssm';
5
+ import { Typography } from '@alfalab/core-components-typography/moderncssm';
6
+ import { ConfirmationContext } from '../../../context.js';
7
+ import { Header } from '../../header/component.js';
8
+ import styles from './index.module.css';
9
+
10
+ const Hint = ({ mobile }) => {
11
+ const { alignContent, texts, onChangeScreen, onChangeState, breakpoint } = useContext(ConfirmationContext);
12
+ const handleReturnButtonClick = () => {
13
+ onChangeScreen('INITIAL');
14
+ onChangeState('INITIAL');
15
+ };
16
+ return (React.createElement("div", { className: cn(styles.component, styles[alignContent]) },
17
+ React.createElement(Header, { mobile: mobile }, "\u041D\u0435\u00A0\u043F\u0440\u0438\u0445\u043E\u0434\u0438\u0442 \u0441\u043E\u043E\u0431\u0449\u0435\u043D\u0438\u0435?"),
18
+ React.createElement(Typography.Text, { view: 'primary-medium', color: 'primary', className: cn(styles.text, { [styles.typographyTheme]: !mobile }) }, "\u0415\u0441\u043B\u0438 \u0443\u00A0\u0432\u0430\u0441 \u0438\u0437\u043C\u0435\u043D\u0438\u043B\u0441\u044F \u043D\u043E\u043C\u0435\u0440 \u0442\u0435\u043B\u0435\u0444\u043E\u043D\u0430, \u043F\u043E\u0437\u0432\u043E\u043D\u0438\u0442\u0435 \u043D\u0430\u043C \u0438\u043B\u0438 \u043E\u0431\u0440\u0430\u0442\u0438\u0442\u0435\u0441\u044C \u0432\u00A0\u043B\u044E\u0431\u043E\u0435 \u043E\u0442\u0434\u0435\u043B\u0435\u043D\u0438\u0435 \u0431\u0430\u043D\u043A\u0430."),
19
+ React.createElement("div", { className: styles.phonesWrap },
20
+ React.createElement("div", { className: cn(styles.phoneWrap, { [styles.phoneContentMobile]: mobile }) },
21
+ React.createElement(Link, { href: 'tel:+78002000000', underline: false, className: styles.phoneLink }, "8 800 200 00 00"),
22
+ React.createElement(Typography.Text, { view: 'primary-medium', color: 'primary', className: cn(styles.text, { [styles.typographyTheme]: !mobile }) }, mobile
23
+ ? 'Для\u00A0звонков по\u00A0России'
24
+ : ' \u2014\u00A0для звонков по\u00A0России')),
25
+ React.createElement("div", { className: cn(styles.phoneWrap, { [styles.phoneContentMobile]: mobile }) },
26
+ React.createElement(Link, { href: 'tel:+74957888878', underline: false, className: styles.phoneLink }, "+7 495 78 888 78"),
27
+ React.createElement(Typography.Text, { view: 'primary-medium', color: 'primary', className: cn(styles.text, { [styles.typographyTheme]: !mobile }) }, mobile
28
+ ? 'В\u00A0Москве и\u00A0за\u00A0границей'
29
+ : ' \u2014\u00A0в\u00A0Москве и\u00A0за\u00A0границей'))),
30
+ React.createElement(Typography.Text, { view: 'primary-medium', color: 'primary', className: cn(styles.text, { [styles.typographyTheme]: !mobile }) }, "\u0415\u0441\u043B\u0438 \u043D\u043E\u043C\u0435\u0440 \u043D\u0435\u00A0\u043C\u0435\u043D\u044F\u043B\u0441\u044F, \u0432\u043E\u0437\u043C\u043E\u0436\u043D\u043E, \u043F\u0435\u0440\u0435\u0433\u0440\u0443\u0436\u0435\u043D \u0441\u0435\u0440\u0432\u0438\u0441 \u043E\u0442\u043F\u0440\u0430\u0432\u043A\u0438 \u0441\u043E\u043E\u0431\u0449\u0435\u043D\u0438\u0439. \u041F\u043E\u043F\u0440\u043E\u0431\u0443\u0439\u0442\u0435 \u043F\u043E\u0432\u0442\u043E\u0440\u0438\u0442\u044C \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u0435 \u0447\u0435\u0440\u0435\u0437 \u043D\u0435\u0441\u043A\u043E\u043B\u044C\u043A\u043E \u043C\u0438\u043D\u0443\u0442."),
31
+ React.createElement(Button, { size: mobile ? 'xs' : 's', view: 'secondary', onClick: handleReturnButtonClick, className: styles.hintButton, breakpoint: breakpoint }, texts.hintButton)));
32
+ };
33
+
34
+ export { Hint };
@@ -0,0 +1 @@
1
+ export * from "./component";
@@ -0,0 +1 @@
1
+ export { Hint } from './component.js';
@@ -0,0 +1,72 @@
1
+ /* */
2
+
3
+ :root {
4
+ /* desktop */
5
+
6
+ /* mobile */
7
+
8
+ /* text */
9
+ --confirmation-text-font-size: 16px;
10
+ --confirmation-text-line-height: 24px;
11
+ --confirmation-text-font-weight: 400;
12
+ --confirmation-text-font-family: var(--font-family-system);
13
+ --confirmation-text-color: var(--color-light-text-primary)
14
+
15
+ /* header */
16
+ }
17
+
18
+ .component {
19
+ display: flex;
20
+ flex-direction: column;
21
+ align-items: flex-start
22
+ }
23
+
24
+ .component span:last-of-type {
25
+ margin-bottom: 0;
26
+ }
27
+
28
+ .center {
29
+ align-items: center;
30
+ text-align: center;
31
+ }
32
+
33
+ .text.text {
34
+ margin-bottom: var(--gap-24);
35
+ }
36
+
37
+ .typographyTheme.typographyTheme {
38
+ font-size: var(--confirmation-text-font-size);
39
+ line-height: var(--confirmation-text-line-height);
40
+ font-weight: var(--confirmation-text-font-weight);
41
+ font-family: var(--confirmation-text-font-family);
42
+ color: var(--confirmation-text-color);
43
+ }
44
+
45
+ .phonesWrap {
46
+ display: flex;
47
+ flex-direction: column;
48
+ margin-bottom: var(--gap-24);
49
+ }
50
+
51
+ .phoneWrap {
52
+ margin-bottom: var(--gap-8)
53
+ }
54
+
55
+ .phoneWrap:last-child {
56
+ margin-bottom: 0;
57
+ }
58
+
59
+ .phoneLink.phoneLink {
60
+ font-size: 16px;
61
+ line-height: 24px;
62
+ font-weight: 500;
63
+ }
64
+
65
+ .hintButton {
66
+ margin-top: var(--gap-32);
67
+ }
68
+
69
+ .phoneContentMobile {
70
+ display: flex;
71
+ flex-direction: column;
72
+ }
@@ -0,0 +1,4 @@
1
+ export * from "./initial/index";
2
+ export * from "./hint/index";
3
+ export * from "./fatal-error/index";
4
+ export * from "./temp-block/index";
@@ -0,0 +1,4 @@
1
+ export { Initial } from './initial/component.js';
2
+ export { Hint } from './hint/component.js';
3
+ export { FatalError } from './fatal-error/component.js';
4
+ export { TempBlock } from './temp-block/component.js';
@@ -0,0 +1,9 @@
1
+ import { FC } from 'react';
2
+ type InitialProps = {
3
+ /**
4
+ * Отображать в мобильной версии экран компонента
5
+ */
6
+ mobile?: boolean;
7
+ };
8
+ declare const Initial: FC<InitialProps>;
9
+ export { InitialProps, Initial };
@@ -0,0 +1,102 @@
1
+ import React, { useContext, useRef, useState, useCallback, useEffect } from 'react';
2
+ import cn from 'classnames';
3
+ import { ButtonMobile } from '@alfalab/core-components-button/moderncssm/mobile';
4
+ import { CodeInputDesktop } from '@alfalab/core-components-code-input/moderncssm/desktop';
5
+ import { CodeInputMobile } from '@alfalab/core-components-code-input/moderncssm/mobile';
6
+ import { Link } from '@alfalab/core-components-link/moderncssm';
7
+ import { Typography } from '@alfalab/core-components-typography/moderncssm';
8
+ import { usePrevious, useLayoutEffect_SAFE_FOR_SSR } from '@alfalab/hooks';
9
+ import { ConfirmationContext } from '../../../context.js';
10
+ import { Header } from '../../header/component.js';
11
+ import { CountdownSection } from './countdown-section.js';
12
+ import styles from './index.module.css';
13
+
14
+ const CODE_SEND_HINT_VISIBLE_DURATION = 2000;
15
+ const Initial = ({ mobile }) => {
16
+ const { state, alignContent, texts, requiredCharAmount, timeLeft, phone, clearCodeOnError, hideCountdownSection, initialScreenHintSlot, errorVisibleDuration, onChangeState, onInputFinished, onChangeScreen, onSmsRetryClick, } = useContext(ConfirmationContext);
17
+ const prevState = usePrevious(state);
18
+ const inputRef = useRef(null);
19
+ const [codeSendHintVisible, setCodeSendHintVisible] = useState(false);
20
+ const timerId = useRef(0);
21
+ const handleInputComplete = (code) => {
22
+ onInputFinished(code);
23
+ };
24
+ const handleSmsHintLinkClick = () => {
25
+ onChangeScreen('HINT');
26
+ };
27
+ const handleInputChange = () => {
28
+ if (state === 'CODE_ERROR') {
29
+ onChangeState('INITIAL');
30
+ }
31
+ };
32
+ const handleSmsRetryClick = () => {
33
+ if (inputRef.current) {
34
+ inputRef.current.reset();
35
+ }
36
+ onSmsRetryClick();
37
+ };
38
+ const handleErrorAnimationEnd = () => {
39
+ if (clearCodeOnError && state !== 'INITIAL') {
40
+ onChangeState('INITIAL');
41
+ }
42
+ };
43
+ const clearTimer = useCallback(() => {
44
+ window.clearTimeout(timerId.current);
45
+ }, []);
46
+ useEffect(() => {
47
+ if (inputRef.current) {
48
+ inputRef.current.focus();
49
+ }
50
+ return () => {
51
+ clearTimer();
52
+ };
53
+ }, [clearTimer]);
54
+ useEffect(() => {
55
+ if (!inputRef.current) {
56
+ return;
57
+ }
58
+ if (state === 'CODE_ERROR' && prevState !== 'CODE_ERROR') {
59
+ inputRef.current.focus(requiredCharAmount - 1);
60
+ }
61
+ if (prevState === 'CODE_SENDING' && state !== 'CODE_SENDING') {
62
+ inputRef.current.focus();
63
+ }
64
+ }, [prevState, state, requiredCharAmount]);
65
+ useLayoutEffect_SAFE_FOR_SSR(() => {
66
+ if (prevState === 'CODE_SENDING' && state !== 'CODE_SENDING') {
67
+ setCodeSendHintVisible(true);
68
+ clearTimer();
69
+ timerId.current = window.setTimeout(() => {
70
+ setCodeSendHintVisible(false);
71
+ }, CODE_SEND_HINT_VISIBLE_DURATION);
72
+ }
73
+ }, [prevState, state, clearTimer]);
74
+ const getCodeInputError = () => {
75
+ if (state === 'CODE_ERROR') {
76
+ return texts.codeError || true;
77
+ }
78
+ return false;
79
+ };
80
+ const renderHintButton = () => {
81
+ if (initialScreenHintSlot) {
82
+ return initialScreenHintSlot;
83
+ }
84
+ if (mobile) {
85
+ return (React.createElement(ButtonMobile, { onClick: handleSmsHintLinkClick, className: styles.smsBtn, view: 'text', size: 'xs' }, texts.linkToHint));
86
+ }
87
+ return (React.createElement(Link, { onClick: handleSmsHintLinkClick, className: styles.smsComeLink, view: mobile ? 'primary' : 'secondary', pseudo: true }, texts.linkToHint));
88
+ };
89
+ const processing = ['CODE_CHECKING', 'CODE_SENDING'].includes(state);
90
+ const timePassed = timeLeft === 0;
91
+ const ComponentCodeInput = mobile ? CodeInputMobile : CodeInputDesktop;
92
+ return (React.createElement("div", { className: cn(styles.component, styles[alignContent]) },
93
+ React.createElement(Header, { mobile: mobile }, texts.title),
94
+ phone ? (React.createElement(Typography.Text, { view: 'primary-medium', color: 'primary', className: cn(styles.phone, { [styles.typographyTheme]: !mobile }) },
95
+ "\u041A\u043E\u0434 \u043E\u0442\u043F\u0440\u0430\u0432\u043B\u0435\u043D \u043D\u0430 ",
96
+ phone)) : null,
97
+ React.createElement(ComponentCodeInput, { disabled: processing, error: getCodeInputError(), ref: inputRef, fields: requiredCharAmount, className: cn(styles.containerInput, styles.codeInput), onComplete: handleInputComplete, onChange: handleInputChange, clearCodeOnError: clearCodeOnError, errorVisibleDuration: errorVisibleDuration, onErrorAnimationEnd: handleErrorAnimationEnd }),
98
+ !hideCountdownSection && (React.createElement(CountdownSection, { processing: processing, timePassed: timePassed, codeSendHintVisible: codeSendHintVisible, handleSmsRetryClick: handleSmsRetryClick, mobile: mobile })),
99
+ renderHintButton()));
100
+ };
101
+
102
+ export { Initial };
@@ -0,0 +1,10 @@
1
+ import { FC } from 'react';
2
+ type CountdownSectionProps = {
3
+ codeSendHintVisible: boolean;
4
+ timePassed: boolean;
5
+ processing: boolean;
6
+ mobile?: boolean;
7
+ handleSmsRetryClick: () => void;
8
+ };
9
+ declare const CountdownSection: FC<CountdownSectionProps>;
10
+ export { CountdownSection };
@@ -0,0 +1,34 @@
1
+ import React, { useContext } from 'react';
2
+ import cn from 'classnames';
3
+ import { Button } from '@alfalab/core-components-button/moderncssm';
4
+ import { Spinner } from '@alfalab/core-components-spinner/moderncssm';
5
+ import { Typography } from '@alfalab/core-components-typography/moderncssm';
6
+ import { ConfirmationContext } from '../../../context.js';
7
+ import { formatMsAsMinutes } from '../../../utils.js';
8
+ import styles from './index.module.css';
9
+
10
+ const CountdownSection = ({ codeSendHintVisible, timePassed, processing, mobile, handleSmsRetryClick, }) => {
11
+ const { state, texts, timeLeft, blockSmsRetry, breakpoint } = useContext(ConfirmationContext);
12
+ const renderText = (text) => (React.createElement(Typography.Text, { className: cn(styles.countdownContainer, {
13
+ [styles.countdownMobile]: mobile,
14
+ [styles.typographyTheme]: !mobile,
15
+ }), view: mobile ? 'primary-small' : 'primary-medium', tag: 'div' }, text));
16
+ if (codeSendHintVisible)
17
+ return renderText(texts.codeSended);
18
+ if (processing) {
19
+ return (React.createElement("div", { className: cn(styles.loaderWrap, styles.countdownContainer, {
20
+ [styles.countdownLoaderMobile]: mobile,
21
+ [styles.typographyTheme]: !mobile,
22
+ }) },
23
+ React.createElement(Spinner, { visible: true }),
24
+ React.createElement("span", { className: styles.loaderText }, state === 'CODE_CHECKING' ? texts.codeChecking : texts.codeSending)));
25
+ }
26
+ if (blockSmsRetry)
27
+ return renderText(texts.noAttemptsLeft);
28
+ if (timePassed) {
29
+ return (React.createElement(Button, { size: mobile ? 'xs' : 'xxs', view: 'secondary', onClick: handleSmsRetryClick, className: cn(styles.getCodeButton, { [styles.getCodeButtonMobile]: mobile }), breakpoint: breakpoint }, texts.buttonRetry));
30
+ }
31
+ return renderText(`${texts.countdown} ${formatMsAsMinutes(timeLeft)}`);
32
+ };
33
+
34
+ export { CountdownSection };
@@ -0,0 +1 @@
1
+ export * from "./component";
@@ -0,0 +1 @@
1
+ export { Initial } from './component.js';
@@ -0,0 +1,97 @@
1
+ /* */
2
+
3
+ :root {
4
+ /* desktop */
5
+
6
+ /* mobile */
7
+
8
+ /* text */
9
+ --confirmation-text-font-size: 16px;
10
+ --confirmation-text-line-height: 24px;
11
+ --confirmation-text-font-weight: 400;
12
+ --confirmation-text-font-family: var(--font-family-system);
13
+ --confirmation-text-color: var(--color-light-text-primary)
14
+
15
+ /* header */
16
+ }
17
+
18
+ .component {
19
+ display: flex;
20
+ flex-direction: column;
21
+ }
22
+
23
+ .typographyTheme.typographyTheme {
24
+ font-size: var(--confirmation-text-font-size);
25
+ line-height: var(--confirmation-text-line-height);
26
+ font-weight: var(--confirmation-text-font-weight);
27
+ font-family: var(--confirmation-text-font-family);
28
+ color: var(--confirmation-text-color);
29
+ }
30
+
31
+ .phone.phone {
32
+ color: var(--color-light-text-primary);
33
+ margin-bottom: var(--gap-32);
34
+ }
35
+
36
+ .compact {
37
+ margin-bottom: var(--gap-24);
38
+ }
39
+
40
+ .loaderWrap {
41
+ display: flex;
42
+ align-items: center;
43
+ }
44
+
45
+ .left {
46
+ align-items: flex-start;
47
+ }
48
+
49
+ .center {
50
+ align-items: center;
51
+ text-align: center
52
+ }
53
+
54
+ .center .loaderWrap {
55
+ justify-content: center;
56
+ }
57
+
58
+ .codeInput {
59
+ margin-bottom: var(--gap-12);
60
+ }
61
+
62
+ .smsBtn.smsBtn {
63
+ min-height: var(--size-xs-height);
64
+ }
65
+
66
+ .smsComeLink.smsComeLink {
67
+ font-size: 14px;
68
+ line-height: 20px;
69
+ font-weight: 500;
70
+ }
71
+
72
+ .countdownContainer.countdownContainer {
73
+ color: var(--color-light-text-secondary);
74
+ margin-bottom: var(--gap-24);
75
+ }
76
+
77
+ .countdownMobile.countdownMobile {
78
+ margin-bottom: var(--gap-20);
79
+ }
80
+
81
+ .countdownLoaderMobile.countdownLoaderMobile {
82
+ margin-bottom: var(--gap-16);
83
+ }
84
+
85
+ .getCodeButton {
86
+ position: relative;
87
+ top: var(--gap-4-neg);
88
+ margin-bottom: var(--gap-16);
89
+ }
90
+
91
+ .getCodeButtonMobile {
92
+ margin-bottom: 0;
93
+ }
94
+
95
+ .containerInput {
96
+ min-height: 80px;
97
+ }
@@ -0,0 +1,9 @@
1
+ import { FC } from 'react';
2
+ type TempBlockProps = {
3
+ /**
4
+ * Отображать в мобильной версии экран компонента
5
+ */
6
+ mobile?: boolean;
7
+ };
8
+ declare const TempBlock: FC<TempBlockProps>;
9
+ export { TempBlockProps, TempBlock };
@@ -0,0 +1,29 @@
1
+ import React, { useContext, useEffect } from 'react';
2
+ import cn from 'classnames';
3
+ import { Typography } from '@alfalab/core-components-typography/moderncssm';
4
+ import { ConfirmationContext } from '../../../context.js';
5
+ import { useCountdown, formatMsAsMinutes } from '../../../utils.js';
6
+ import { CountdownLoader } from '../../countdown-loader/component.js';
7
+ import { Header } from '../../header/component.js';
8
+ import styles from './index.module.css';
9
+
10
+ const TempBlock = ({ mobile }) => {
11
+ const { alignContent, texts, tempBlockDuration, onChangeScreen, onTempBlockFinished } = useContext(ConfirmationContext);
12
+ const [timeLeft, startTimer] = useCountdown(tempBlockDuration);
13
+ useEffect(() => {
14
+ startTimer();
15
+ }, [startTimer]);
16
+ useEffect(() => {
17
+ if (timeLeft === 0 && onTempBlockFinished) {
18
+ onTempBlockFinished();
19
+ }
20
+ }, [timeLeft, onChangeScreen, onTempBlockFinished]);
21
+ return (React.createElement("div", { className: cn(styles.component, styles[alignContent]) },
22
+ React.createElement(Header, { mobile: mobile }, texts.tempBlockTitle),
23
+ React.createElement(Typography.Text, { view: 'primary-medium', color: 'primary', className: cn(styles.description, { [styles.typographyTheme]: !mobile }) }, texts.tempBlockDescription),
24
+ React.createElement("div", { className: cn(styles.countdownWrap, { [styles.typographyTheme]: !mobile }) },
25
+ React.createElement(CountdownLoader, { progress: 1 - timeLeft / tempBlockDuration, className: styles.loader }),
26
+ formatMsAsMinutes(timeLeft))));
27
+ };
28
+
29
+ export { TempBlock };
@@ -0,0 +1 @@
1
+ export * from "./component";
@@ -0,0 +1 @@
1
+ export { TempBlock } from './component.js';
@@ -0,0 +1,47 @@
1
+ /* */
2
+
3
+ :root {
4
+ /* desktop */
5
+
6
+ /* mobile */
7
+
8
+ /* text */
9
+ --confirmation-text-font-size: 16px;
10
+ --confirmation-text-line-height: 24px;
11
+ --confirmation-text-font-weight: 400;
12
+ --confirmation-text-font-family: var(--font-family-system);
13
+ --confirmation-text-color: var(--color-light-text-primary)
14
+
15
+ /* header */
16
+ }
17
+
18
+ .component {
19
+ display: flex;
20
+ flex-direction: column;
21
+ }
22
+
23
+ .center {
24
+ align-items: center;
25
+ text-align: center;
26
+ }
27
+
28
+ .typographyTheme.typographyTheme {
29
+ font-size: var(--confirmation-text-font-size);
30
+ line-height: var(--confirmation-text-line-height);
31
+ font-weight: var(--confirmation-text-font-weight);
32
+ font-family: var(--confirmation-text-font-family);
33
+ color: var(--confirmation-text-color);
34
+ }
35
+
36
+ .description.description {
37
+ margin-bottom: var(--gap-8);
38
+ }
39
+
40
+ .countdownWrap {
41
+ display: flex;
42
+ align-items: center;
43
+ }
44
+
45
+ .loader {
46
+ margin-right: var(--gap-8);
47
+ }
@@ -0,0 +1,4 @@
1
+ /// <reference types="react" />
2
+ import { TConfirmationContext } from "./types";
3
+ declare const ConfirmationContext: import("react").Context<TConfirmationContext>;
4
+ export { ConfirmationContext };