@alfalab/core-components-confirmation 12.4.6 → 12.4.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 (109) hide show
  1. package/component.desktop.js +4 -3
  2. package/component.mobile.js +6 -5
  3. package/component.responsive.js +5 -4
  4. package/components/base-confirmation/component.d.ts +4 -0
  5. package/components/base-confirmation/component.js +87 -13
  6. package/components/base-confirmation/index.css +2 -2
  7. package/components/base-confirmation/index.d.ts +1 -1
  8. package/components/base-confirmation/index.js +3 -2
  9. package/components/countdown-loader/component.js +1 -1
  10. package/components/countdown-loader/index.css +2 -2
  11. package/components/header/component.js +1 -1
  12. package/components/header/index.css +4 -4
  13. package/components/index.js +1 -1
  14. package/components/screens/fatal-error/component.js +1 -1
  15. package/components/screens/fatal-error/index.css +6 -6
  16. package/components/screens/hint/component.js +1 -1
  17. package/components/screens/hint/index.css +12 -12
  18. package/components/screens/index.js +1 -1
  19. package/components/screens/initial/component.js +1 -1
  20. package/components/screens/initial/countdown-section.js +1 -1
  21. package/components/screens/initial/index.css +18 -18
  22. package/components/screens/initial/index.js +1 -1
  23. package/components/screens/temp-block/component.js +1 -1
  24. package/components/screens/temp-block/index.css +7 -7
  25. package/{countdown-section-c2e9f183.d.ts → countdown-section-bda43975.d.ts} +0 -0
  26. package/{countdown-section-c2e9f183.js → countdown-section-bda43975.js} +1 -1
  27. package/cssm/component.desktop.js +3 -2
  28. package/cssm/component.mobile.js +4 -3
  29. package/cssm/component.responsive.js +4 -3
  30. package/cssm/components/base-confirmation/component.d.ts +4 -0
  31. package/cssm/components/base-confirmation/component.js +85 -13
  32. package/cssm/components/base-confirmation/index.d.ts +1 -1
  33. package/cssm/components/base-confirmation/index.js +2 -1
  34. package/cssm/desktop.js +2 -1
  35. package/cssm/index.js +2 -1
  36. package/cssm/mobile.js +2 -1
  37. package/cssm/responsive.js +4 -3
  38. package/desktop.js +3 -2
  39. package/esm/component.desktop.js +3 -2
  40. package/esm/component.mobile.js +4 -3
  41. package/esm/component.responsive.js +3 -2
  42. package/esm/components/base-confirmation/component.d.ts +4 -0
  43. package/esm/components/base-confirmation/component.js +85 -12
  44. package/esm/components/base-confirmation/index.css +2 -2
  45. package/esm/components/base-confirmation/index.d.ts +1 -1
  46. package/esm/components/base-confirmation/index.js +3 -2
  47. package/esm/components/countdown-loader/component.js +1 -1
  48. package/esm/components/countdown-loader/index.css +2 -2
  49. package/esm/components/header/component.js +1 -1
  50. package/esm/components/header/index.css +4 -4
  51. package/esm/components/index.js +1 -1
  52. package/esm/components/screens/fatal-error/component.js +1 -1
  53. package/esm/components/screens/fatal-error/index.css +6 -6
  54. package/esm/components/screens/hint/component.js +1 -1
  55. package/esm/components/screens/hint/index.css +12 -12
  56. package/esm/components/screens/index.js +1 -1
  57. package/esm/components/screens/initial/component.js +1 -1
  58. package/esm/components/screens/initial/countdown-section.js +1 -1
  59. package/esm/components/screens/initial/index.css +18 -18
  60. package/esm/components/screens/initial/index.js +1 -1
  61. package/esm/components/screens/temp-block/component.js +1 -1
  62. package/esm/components/screens/temp-block/index.css +7 -7
  63. package/esm/{countdown-section-55873048.d.ts → countdown-section-6eb66678.d.ts} +0 -0
  64. package/esm/{countdown-section-55873048.js → countdown-section-6eb66678.js} +1 -1
  65. package/esm/desktop.js +3 -2
  66. package/esm/index.js +3 -2
  67. package/esm/mobile.css +2 -2
  68. package/esm/mobile.js +3 -2
  69. package/esm/responsive.js +5 -4
  70. package/index.js +3 -2
  71. package/mobile.css +2 -2
  72. package/mobile.js +3 -2
  73. package/modern/component.desktop.js +1 -1
  74. package/modern/component.mobile.js +2 -2
  75. package/modern/component.responsive.js +1 -1
  76. package/modern/components/base-confirmation/component.js +2 -2
  77. package/modern/components/base-confirmation/index.css +2 -2
  78. package/modern/components/base-confirmation/index.js +1 -1
  79. package/modern/components/countdown-loader/component.js +1 -1
  80. package/modern/components/countdown-loader/index.css +2 -2
  81. package/modern/components/header/component.js +1 -1
  82. package/modern/components/header/index.css +4 -4
  83. package/modern/components/index.js +1 -1
  84. package/modern/components/screens/fatal-error/component.js +1 -1
  85. package/modern/components/screens/fatal-error/index.css +6 -6
  86. package/modern/components/screens/hint/component.js +1 -1
  87. package/modern/components/screens/hint/index.css +12 -12
  88. package/modern/components/screens/index.js +1 -1
  89. package/modern/components/screens/initial/component.js +1 -1
  90. package/modern/components/screens/initial/countdown-section.js +1 -1
  91. package/modern/components/screens/initial/index.css +18 -18
  92. package/modern/components/screens/initial/index.js +1 -1
  93. package/modern/components/screens/temp-block/component.js +1 -1
  94. package/modern/components/screens/temp-block/index.css +7 -7
  95. package/modern/{countdown-section-51959e53.d.ts → countdown-section-f17bf1df.d.ts} +0 -0
  96. package/modern/{countdown-section-51959e53.js → countdown-section-f17bf1df.js} +1 -1
  97. package/modern/desktop.js +1 -1
  98. package/modern/index.js +1 -1
  99. package/modern/mobile.css +2 -2
  100. package/modern/mobile.js +1 -1
  101. package/modern/responsive.js +1 -1
  102. package/package.json +8 -7
  103. package/responsive.js +5 -4
  104. package/component-8284a164.d.ts +0 -37
  105. package/component-8284a164.js +0 -130
  106. package/cssm/component-3c591970.d.ts +0 -37
  107. package/cssm/component-3c591970.js +0 -129
  108. package/esm/component-d3c86aea.d.ts +0 -37
  109. package/esm/component-d3c86aea.js +0 -122
@@ -1,7 +1,8 @@
1
1
  'use strict';
2
2
 
3
- var components_baseConfirmation_component = require('./component-3c591970.js');
3
+ var tslib = require('tslib');
4
4
  var React = require('react');
5
+ var components_baseConfirmation_component = require('./components/base-confirmation/component.js');
5
6
  require('classnames');
6
7
  require('@alfalab/hooks');
7
8
  require('./context.js');
@@ -31,6 +32,6 @@ function _interopDefaultCompat (e) { return e && typeof e === 'object' && 'defau
31
32
 
32
33
  var React__default = /*#__PURE__*/_interopDefaultCompat(React);
33
34
 
34
- var ConfirmationDesktop = function (props) { return (React__default.default.createElement(components_baseConfirmation_component.BaseConfirmation, components_baseConfirmation_component.__assign({}, props))); };
35
+ var ConfirmationDesktop = function (props) { return (React__default.default.createElement(components_baseConfirmation_component.BaseConfirmation, tslib.__assign({}, props))); };
35
36
 
36
37
  exports.ConfirmationDesktop = ConfirmationDesktop;
@@ -1,8 +1,9 @@
1
1
  'use strict';
2
2
 
3
- var components_baseConfirmation_component = require('./component-3c591970.js');
3
+ var tslib = require('tslib');
4
4
  var React = require('react');
5
5
  var cn = require('classnames');
6
+ var components_baseConfirmation_component = require('./components/base-confirmation/component.js');
6
7
  var styles = require('./mobile.module.css');
7
8
  require('@alfalab/hooks');
8
9
  require('./context.js');
@@ -35,8 +36,8 @@ var cn__default = /*#__PURE__*/_interopDefaultCompat(cn);
35
36
  var styles__default = /*#__PURE__*/_interopDefaultCompat(styles);
36
37
 
37
38
  var ConfirmationMobile = function (_a) {
38
- var className = _a.className, resProps = components_baseConfirmation_component.__rest(_a, ["className"]);
39
- return (React__default.default.createElement(components_baseConfirmation_component.BaseConfirmation, components_baseConfirmation_component.__assign({ mobile: true, className: cn__default.default(className, styles__default.default.container) }, resProps)));
39
+ var className = _a.className, resProps = tslib.__rest(_a, ["className"]);
40
+ return (React__default.default.createElement(components_baseConfirmation_component.BaseConfirmation, tslib.__assign({ mobile: true, className: cn__default.default(className, styles__default.default.container) }, resProps)));
40
41
  };
41
42
 
42
43
  exports.ConfirmationMobile = ConfirmationMobile;
@@ -1,10 +1,11 @@
1
1
  'use strict';
2
2
 
3
- var components_baseConfirmation_component = require('./component-3c591970.js');
3
+ var tslib = require('tslib');
4
4
  var React = require('react');
5
5
  var hooks = require('@alfalab/hooks');
6
6
  var component_desktop = require('./component.desktop.js');
7
7
  var component_mobile = require('./component.mobile.js');
8
+ require('./components/base-confirmation/component.js');
8
9
  require('classnames');
9
10
  require('./context.js');
10
11
  require('./utils.js');
@@ -35,12 +36,12 @@ function _interopDefaultCompat (e) { return e && typeof e === 'object' && 'defau
35
36
  var React__default = /*#__PURE__*/_interopDefaultCompat(React);
36
37
 
37
38
  var ConfirmationResponsive = function (_a) {
38
- var _b = _a.breakpoint, breakpoint = _b === void 0 ? 1024 : _b, restProps = components_baseConfirmation_component.__rest(_a, ["breakpoint"]);
39
+ var _b = _a.breakpoint, breakpoint = _b === void 0 ? 1024 : _b, restProps = tslib.__rest(_a, ["breakpoint"]);
39
40
  var view = hooks.useMedia([
40
41
  ['mobile', "(max-width: ".concat(breakpoint - 1, "px)")],
41
42
  ['desktop', "(min-width: ".concat(breakpoint, "px)")],
42
43
  ], 'desktop')[0];
43
- return view === 'desktop' ? (React__default.default.createElement(component_desktop.ConfirmationDesktop, components_baseConfirmation_component.__assign({}, restProps))) : (React__default.default.createElement(component_mobile.ConfirmationMobile, components_baseConfirmation_component.__assign({}, restProps)));
44
+ return view === 'desktop' ? (React__default.default.createElement(component_desktop.ConfirmationDesktop, tslib.__assign({}, restProps))) : (React__default.default.createElement(component_mobile.ConfirmationMobile, tslib.__assign({}, restProps)));
44
45
  };
45
46
 
46
47
  exports.ConfirmationResponsive = ConfirmationResponsive;
@@ -0,0 +1,4 @@
1
+ import { FC } from 'react';
2
+ import { ConfirmationProps } from "../../types";
3
+ declare const BaseConfirmation: FC<ConfirmationProps>;
4
+ export { BaseConfirmation };
@@ -1,17 +1,17 @@
1
1
  'use strict';
2
2
 
3
- var components_baseConfirmation_component = require('../../component-3c591970.js');
4
- require('react');
5
- require('classnames');
6
- require('@alfalab/hooks');
7
- require('../../context.js');
8
- require('../../types.js');
9
- require('../../utils.js');
10
- require('../screens/initial/component.js');
11
- require('../screens/hint/component.js');
12
- require('../screens/fatal-error/component.js');
13
- require('../screens/temp-block/component.js');
14
- require('./index.module.css');
3
+ var tslib = require('tslib');
4
+ var React = require('react');
5
+ var cn = require('classnames');
6
+ var hooks = require('@alfalab/hooks');
7
+ var context = require('../../context.js');
8
+ var types = require('../../types.js');
9
+ var utils = require('../../utils.js');
10
+ var components_screens_initial_component = require('../screens/initial/component.js');
11
+ var components_screens_hint_component = require('../screens/hint/component.js');
12
+ var components_screens_fatalError_component = require('../screens/fatal-error/component.js');
13
+ var components_screens_tempBlock_component = require('../screens/temp-block/component.js');
14
+ var styles = require('./index.module.css');
15
15
  require('@alfalab/core-components-button/cssm');
16
16
  require('@alfalab/core-components-code-input/cssm');
17
17
  require('@alfalab/core-components-link/cssm');
@@ -27,6 +27,78 @@ require('../countdown-loader/component.js');
27
27
  require('../countdown-loader/index.module.css');
28
28
  require('../screens/temp-block/index.module.css');
29
29
 
30
+ function _interopDefaultCompat (e) { return e && typeof e === 'object' && 'default' in e ? e : { default: e }; }
30
31
 
32
+ var React__default = /*#__PURE__*/_interopDefaultCompat(React);
33
+ var cn__default = /*#__PURE__*/_interopDefaultCompat(cn);
34
+ var styles__default = /*#__PURE__*/_interopDefaultCompat(styles);
31
35
 
32
- exports.BaseConfirmation = components_baseConfirmation_component.BaseConfirmation;
36
+ var confirmationScreens = {
37
+ INITIAL: components_screens_initial_component.Initial,
38
+ HINT: components_screens_hint_component.Hint,
39
+ FATAL_ERROR: components_screens_fatalError_component.FatalError,
40
+ TEMP_BLOCK: components_screens_tempBlock_component.TempBlock,
41
+ };
42
+ var BaseConfirmation = function (_a) {
43
+ var state = _a.state, screen = _a.screen, _b = _a.alignContent, alignContent = _b === void 0 ? 'left' : _b; _a.children; var _c = _a.requiredCharAmount, requiredCharAmount = _c === void 0 ? 5 : _c, _d = _a.countdownDuration, countdownDuration = _d === void 0 ? utils.ONE_MINUTE : _d, _e = _a.tempBlockDuration, tempBlockDuration = _e === void 0 ? utils.ONE_DAY : _e, phone = _a.phone, blockSmsRetry = _a.blockSmsRetry, dataTestId = _a.dataTestId, className = _a.className, getScreensMap = _a.getScreensMap, onInputFinished = _a.onInputFinished, onChangeState = _a.onChangeState, onSmsRetryClick = _a.onSmsRetryClick, onChangeScreen = _a.onChangeScreen, onFatalErrorOkButtonClick = _a.onFatalErrorOkButtonClick, onTempBlockFinished = _a.onTempBlockFinished, mobile = _a.mobile, _f = _a.clearCodeOnError, clearCodeOnError = _f === void 0 ? true : _f, restProps = tslib.__rest(_a, ["state", "screen", "alignContent", "children", "requiredCharAmount", "countdownDuration", "tempBlockDuration", "phone", "blockSmsRetry", "dataTestId", "className", "getScreensMap", "onInputFinished", "onChangeState", "onSmsRetryClick", "onChangeScreen", "onFatalErrorOkButtonClick", "onTempBlockFinished", "mobile", "clearCodeOnError"]);
44
+ var _g = utils.useCountdown(countdownDuration), timeLeft = _g[0], startTimer = _g[1], stopTimer = _g[2];
45
+ var prevState = hooks.usePrevious(state);
46
+ React.useEffect(function () {
47
+ startTimer();
48
+ }, [startTimer]);
49
+ React.useEffect(function () {
50
+ /**
51
+ * Перезапускаем таймер после повторного запроса кода
52
+ */
53
+ if (state === 'INITIAL' && prevState === 'CODE_SENDING') {
54
+ startTimer();
55
+ }
56
+ }, [state, prevState, startTimer]);
57
+ React.useEffect(function () {
58
+ /**
59
+ * Останавливаем таймер, если новый экран/состояние не содержит таймер
60
+ */
61
+ if (!['INITIAL', 'HINT', 'TEMP_BLOCK'].includes(screen) || blockSmsRetry) {
62
+ stopTimer();
63
+ }
64
+ }, [state, screen, blockSmsRetry, stopTimer]);
65
+ var handleSmsRetry = function () {
66
+ onChangeState('CODE_SENDING');
67
+ onSmsRetryClick();
68
+ };
69
+ var handleInputFinished = function (code) {
70
+ onChangeState('CODE_CHECKING');
71
+ onInputFinished(code);
72
+ };
73
+ var handleFatalErrorOkButtonClick = function () {
74
+ if (onFatalErrorOkButtonClick) {
75
+ onFatalErrorOkButtonClick();
76
+ }
77
+ };
78
+ // eslint-disable-next-line react/jsx-no-constructed-context-values
79
+ var contextValue = {
80
+ alignContent: alignContent,
81
+ texts: tslib.__assign(tslib.__assign({}, types.defaultTexts), restProps.texts),
82
+ state: state,
83
+ screen: screen,
84
+ requiredCharAmount: requiredCharAmount,
85
+ countdownDuration: countdownDuration,
86
+ timeLeft: timeLeft,
87
+ tempBlockDuration: tempBlockDuration,
88
+ phone: phone,
89
+ blockSmsRetry: blockSmsRetry,
90
+ onTempBlockFinished: onTempBlockFinished,
91
+ onChangeState: onChangeState,
92
+ onChangeScreen: onChangeScreen,
93
+ clearCodeOnError: clearCodeOnError,
94
+ onInputFinished: handleInputFinished,
95
+ onSmsRetryClick: handleSmsRetry,
96
+ onFatalErrorOkButtonClick: handleFatalErrorOkButtonClick,
97
+ };
98
+ var screensMap = getScreensMap ? getScreensMap(confirmationScreens) : confirmationScreens;
99
+ var CurrentScreen = screensMap[screen];
100
+ return (React__default.default.createElement(context.ConfirmationContext.Provider, { value: contextValue },
101
+ React__default.default.createElement("div", { className: cn__default.default(styles__default.default.component, className), "data-test-id": dataTestId }, CurrentScreen && React__default.default.createElement(CurrentScreen, { mobile: mobile }))));
102
+ };
103
+
104
+ exports.BaseConfirmation = BaseConfirmation;
@@ -1 +1 @@
1
- export * from "../../component-3c591970";
1
+ export * from "./component";
@@ -1,6 +1,7 @@
1
1
  'use strict';
2
2
 
3
- var components_baseConfirmation_component = require('../../component-3c591970.js');
3
+ var components_baseConfirmation_component = require('./component.js');
4
+ require('tslib');
4
5
  require('react');
5
6
  require('classnames');
6
7
  require('@alfalab/hooks');
package/cssm/desktop.js CHANGED
@@ -1,8 +1,9 @@
1
1
  'use strict';
2
2
 
3
3
  var component_desktop = require('./component.desktop.js');
4
- require('./component-3c591970.js');
4
+ require('tslib');
5
5
  require('react');
6
+ require('./components/base-confirmation/component.js');
6
7
  require('classnames');
7
8
  require('@alfalab/hooks');
8
9
  require('./context.js');
package/cssm/index.js CHANGED
@@ -10,8 +10,9 @@ var components_countdownLoader_component = require('./components/countdown-loade
10
10
  var context = require('./context.js');
11
11
  var types = require('./types.js');
12
12
  var utils = require('./utils.js');
13
- require('./component-3c591970.js');
13
+ require('tslib');
14
14
  require('react');
15
+ require('./components/base-confirmation/component.js');
15
16
  require('classnames');
16
17
  require('@alfalab/hooks');
17
18
  require('./components/base-confirmation/index.module.css');
package/cssm/mobile.js CHANGED
@@ -1,9 +1,10 @@
1
1
  'use strict';
2
2
 
3
3
  var component_mobile = require('./component.mobile.js');
4
- require('./component-3c591970.js');
4
+ require('tslib');
5
5
  require('react');
6
6
  require('classnames');
7
+ require('./components/base-confirmation/component.js');
7
8
  require('@alfalab/hooks');
8
9
  require('./context.js');
9
10
  require('./utils.js');
@@ -1,10 +1,12 @@
1
1
  'use strict';
2
2
 
3
3
  var component_responsive = require('./component.responsive.js');
4
- require('./component-3c591970.js');
4
+ require('tslib');
5
5
  require('react');
6
- require('classnames');
7
6
  require('@alfalab/hooks');
7
+ require('./component.desktop.js');
8
+ require('./components/base-confirmation/component.js');
9
+ require('classnames');
8
10
  require('./context.js');
9
11
  require('./utils.js');
10
12
  require('./types.js');
@@ -27,7 +29,6 @@ require('./components/countdown-loader/component.js');
27
29
  require('./components/countdown-loader/index.module.css');
28
30
  require('./components/screens/temp-block/index.module.css');
29
31
  require('./components/base-confirmation/index.module.css');
30
- require('./component.desktop.js');
31
32
  require('./component.mobile.js');
32
33
  require('./mobile.module.css');
33
34
 
package/desktop.js CHANGED
@@ -1,8 +1,9 @@
1
1
  'use strict';
2
2
 
3
3
  var component_desktop = require('./component.desktop.js');
4
- require('./component-8284a164.js');
4
+ require('tslib');
5
5
  require('react');
6
+ require('./components/base-confirmation/component.js');
6
7
  require('classnames');
7
8
  require('@alfalab/hooks');
8
9
  require('./context.js');
@@ -14,7 +15,7 @@ require('@alfalab/core-components-code-input');
14
15
  require('@alfalab/core-components-link');
15
16
  require('@alfalab/core-components-typography');
16
17
  require('./components/header/component.js');
17
- require('./countdown-section-c2e9f183.js');
18
+ require('./countdown-section-bda43975.js');
18
19
  require('@alfalab/core-components-loader');
19
20
  require('./components/screens/hint/component.js');
20
21
  require('./components/screens/fatal-error/component.js');
@@ -1,5 +1,6 @@
1
- import { B as BaseConfirmation, _ as __assign } from './component-d3c86aea.js';
1
+ import { __assign } from 'tslib';
2
2
  import React from 'react';
3
+ import { BaseConfirmation } from './components/base-confirmation/component.js';
3
4
  import 'classnames';
4
5
  import '@alfalab/hooks';
5
6
  import './context.js';
@@ -11,7 +12,7 @@ import '@alfalab/core-components-code-input/esm';
11
12
  import '@alfalab/core-components-link/esm';
12
13
  import '@alfalab/core-components-typography/esm';
13
14
  import './components/header/component.js';
14
- import './countdown-section-55873048.js';
15
+ import './countdown-section-6eb66678.js';
15
16
  import '@alfalab/core-components-loader/esm';
16
17
  import './components/screens/hint/component.js';
17
18
  import './components/screens/fatal-error/component.js';
@@ -1,6 +1,7 @@
1
- import { a as __rest, B as BaseConfirmation, _ as __assign } from './component-d3c86aea.js';
1
+ import { __rest, __assign } from 'tslib';
2
2
  import React from 'react';
3
3
  import cn from 'classnames';
4
+ import { BaseConfirmation } from './components/base-confirmation/component.js';
4
5
  import '@alfalab/hooks';
5
6
  import './context.js';
6
7
  import './utils.js';
@@ -11,14 +12,14 @@ import '@alfalab/core-components-code-input/esm';
11
12
  import '@alfalab/core-components-link/esm';
12
13
  import '@alfalab/core-components-typography/esm';
13
14
  import './components/header/component.js';
14
- import './countdown-section-55873048.js';
15
+ import './countdown-section-6eb66678.js';
15
16
  import '@alfalab/core-components-loader/esm';
16
17
  import './components/screens/hint/component.js';
17
18
  import './components/screens/fatal-error/component.js';
18
19
  import './components/screens/temp-block/component.js';
19
20
  import './components/countdown-loader/component.js';
20
21
 
21
- var styles = {"container":"confirmation__container_1il9u"};
22
+ var styles = {"container":"confirmation__container_16npl"};
22
23
  require('./mobile.css')
23
24
 
24
25
  var ConfirmationMobile = function (_a) {
@@ -1,8 +1,9 @@
1
- import { a as __rest, _ as __assign } from './component-d3c86aea.js';
1
+ import { __rest, __assign } from 'tslib';
2
2
  import React from 'react';
3
3
  import { useMedia } from '@alfalab/hooks';
4
4
  import { ConfirmationDesktop } from './component.desktop.js';
5
5
  import { ConfirmationMobile } from './component.mobile.js';
6
+ import './components/base-confirmation/component.js';
6
7
  import 'classnames';
7
8
  import './context.js';
8
9
  import './utils.js';
@@ -13,7 +14,7 @@ import '@alfalab/core-components-code-input/esm';
13
14
  import '@alfalab/core-components-link/esm';
14
15
  import '@alfalab/core-components-typography/esm';
15
16
  import './components/header/component.js';
16
- import './countdown-section-55873048.js';
17
+ import './countdown-section-6eb66678.js';
17
18
  import '@alfalab/core-components-loader/esm';
18
19
  import './components/screens/hint/component.js';
19
20
  import './components/screens/fatal-error/component.js';
@@ -0,0 +1,4 @@
1
+ import { FC } from 'react';
2
+ import { ConfirmationProps } from "../../types";
3
+ declare const BaseConfirmation: FC<ConfirmationProps>;
4
+ export { BaseConfirmation };
@@ -1,19 +1,92 @@
1
- export { B as BaseConfirmation } from '../../component-d3c86aea.js';
2
- import 'react';
3
- import 'classnames';
4
- import '@alfalab/hooks';
5
- import '../../context.js';
6
- import '../../types.js';
7
- import '../../utils.js';
8
- import '../screens/initial/component.js';
9
- import '../screens/hint/component.js';
10
- import '../screens/fatal-error/component.js';
11
- import '../screens/temp-block/component.js';
1
+ import { __rest, __assign } from 'tslib';
2
+ import React, { useEffect } from 'react';
3
+ import cn from 'classnames';
4
+ import { usePrevious } from '@alfalab/hooks';
5
+ import { ConfirmationContext } from '../../context.js';
6
+ import { defaultTexts } from '../../types.js';
7
+ import { useCountdown, ONE_MINUTE, ONE_DAY } from '../../utils.js';
8
+ import { Initial } from '../screens/initial/component.js';
9
+ import { Hint } from '../screens/hint/component.js';
10
+ import { FatalError } from '../screens/fatal-error/component.js';
11
+ import { TempBlock } from '../screens/temp-block/component.js';
12
12
  import '@alfalab/core-components-button/esm';
13
13
  import '@alfalab/core-components-code-input/esm';
14
14
  import '@alfalab/core-components-link/esm';
15
15
  import '@alfalab/core-components-typography/esm';
16
16
  import '../header/component.js';
17
- import '../../countdown-section-55873048.js';
17
+ import '../../countdown-section-6eb66678.js';
18
18
  import '@alfalab/core-components-loader/esm';
19
19
  import '../countdown-loader/component.js';
20
+
21
+ var styles = {"component":"confirmation__component_y3i6g"};
22
+ require('./index.css')
23
+
24
+ var confirmationScreens = {
25
+ INITIAL: Initial,
26
+ HINT: Hint,
27
+ FATAL_ERROR: FatalError,
28
+ TEMP_BLOCK: TempBlock,
29
+ };
30
+ var BaseConfirmation = function (_a) {
31
+ var state = _a.state, screen = _a.screen, _b = _a.alignContent, alignContent = _b === void 0 ? 'left' : _b; _a.children; var _c = _a.requiredCharAmount, requiredCharAmount = _c === void 0 ? 5 : _c, _d = _a.countdownDuration, countdownDuration = _d === void 0 ? ONE_MINUTE : _d, _e = _a.tempBlockDuration, tempBlockDuration = _e === void 0 ? ONE_DAY : _e, phone = _a.phone, blockSmsRetry = _a.blockSmsRetry, dataTestId = _a.dataTestId, className = _a.className, getScreensMap = _a.getScreensMap, onInputFinished = _a.onInputFinished, onChangeState = _a.onChangeState, onSmsRetryClick = _a.onSmsRetryClick, onChangeScreen = _a.onChangeScreen, onFatalErrorOkButtonClick = _a.onFatalErrorOkButtonClick, onTempBlockFinished = _a.onTempBlockFinished, mobile = _a.mobile, _f = _a.clearCodeOnError, clearCodeOnError = _f === void 0 ? true : _f, restProps = __rest(_a, ["state", "screen", "alignContent", "children", "requiredCharAmount", "countdownDuration", "tempBlockDuration", "phone", "blockSmsRetry", "dataTestId", "className", "getScreensMap", "onInputFinished", "onChangeState", "onSmsRetryClick", "onChangeScreen", "onFatalErrorOkButtonClick", "onTempBlockFinished", "mobile", "clearCodeOnError"]);
32
+ var _g = useCountdown(countdownDuration), timeLeft = _g[0], startTimer = _g[1], stopTimer = _g[2];
33
+ var prevState = usePrevious(state);
34
+ useEffect(function () {
35
+ startTimer();
36
+ }, [startTimer]);
37
+ useEffect(function () {
38
+ /**
39
+ * Перезапускаем таймер после повторного запроса кода
40
+ */
41
+ if (state === 'INITIAL' && prevState === 'CODE_SENDING') {
42
+ startTimer();
43
+ }
44
+ }, [state, prevState, startTimer]);
45
+ useEffect(function () {
46
+ /**
47
+ * Останавливаем таймер, если новый экран/состояние не содержит таймер
48
+ */
49
+ if (!['INITIAL', 'HINT', 'TEMP_BLOCK'].includes(screen) || blockSmsRetry) {
50
+ stopTimer();
51
+ }
52
+ }, [state, screen, blockSmsRetry, stopTimer]);
53
+ var handleSmsRetry = function () {
54
+ onChangeState('CODE_SENDING');
55
+ onSmsRetryClick();
56
+ };
57
+ var handleInputFinished = function (code) {
58
+ onChangeState('CODE_CHECKING');
59
+ onInputFinished(code);
60
+ };
61
+ var handleFatalErrorOkButtonClick = function () {
62
+ if (onFatalErrorOkButtonClick) {
63
+ onFatalErrorOkButtonClick();
64
+ }
65
+ };
66
+ // eslint-disable-next-line react/jsx-no-constructed-context-values
67
+ var contextValue = {
68
+ alignContent: alignContent,
69
+ texts: __assign(__assign({}, defaultTexts), restProps.texts),
70
+ state: state,
71
+ screen: screen,
72
+ requiredCharAmount: requiredCharAmount,
73
+ countdownDuration: countdownDuration,
74
+ timeLeft: timeLeft,
75
+ tempBlockDuration: tempBlockDuration,
76
+ phone: phone,
77
+ blockSmsRetry: blockSmsRetry,
78
+ onTempBlockFinished: onTempBlockFinished,
79
+ onChangeState: onChangeState,
80
+ onChangeScreen: onChangeScreen,
81
+ clearCodeOnError: clearCodeOnError,
82
+ onInputFinished: handleInputFinished,
83
+ onSmsRetryClick: handleSmsRetry,
84
+ onFatalErrorOkButtonClick: handleFatalErrorOkButtonClick,
85
+ };
86
+ var screensMap = getScreensMap ? getScreensMap(confirmationScreens) : confirmationScreens;
87
+ var CurrentScreen = screensMap[screen];
88
+ return (React.createElement(ConfirmationContext.Provider, { value: contextValue },
89
+ React.createElement("div", { className: cn(styles.component, className), "data-test-id": dataTestId }, CurrentScreen && React.createElement(CurrentScreen, { mobile: mobile }))));
90
+ };
91
+
92
+ export { BaseConfirmation };
@@ -1,4 +1,4 @@
1
- /* hash: 1j1lx */
1
+ /* hash: 37onl */
2
2
  :root {
3
3
  } /* deprecated */ :root {
4
4
  --color-light-text-secondary: rgba(11, 31, 53, 0.7);
@@ -15,7 +15,7 @@
15
15
  } :root {
16
16
  } :root {
17
17
  } :root {
18
- } .confirmation__component_twbrc {
18
+ } .confirmation__component_y3i6g {
19
19
  width: 100%;
20
20
  max-width: 388px;
21
21
  margin: 0 auto;
@@ -1 +1 @@
1
- export * from "../../component-d3c86aea";
1
+ export * from "./component";
@@ -1,4 +1,5 @@
1
- export { B as BaseConfirmation } from '../../component-d3c86aea.js';
1
+ export { BaseConfirmation } from './component.js';
2
+ import 'tslib';
2
3
  import 'react';
3
4
  import 'classnames';
4
5
  import '@alfalab/hooks';
@@ -11,7 +12,7 @@ import '@alfalab/core-components-code-input/esm';
11
12
  import '@alfalab/core-components-link/esm';
12
13
  import '@alfalab/core-components-typography/esm';
13
14
  import '../header/component.js';
14
- import '../../countdown-section-55873048.js';
15
+ import '../../countdown-section-6eb66678.js';
15
16
  import '@alfalab/core-components-loader/esm';
16
17
  import '../screens/hint/component.js';
17
18
  import '../screens/fatal-error/component.js';
@@ -1,6 +1,6 @@
1
1
  import React from 'react';
2
2
 
3
- var styles = {"circle":"confirmation__circle_j09yr"};
3
+ var styles = {"circle":"confirmation__circle_1q6wg"};
4
4
  require('./index.css')
5
5
 
6
6
  var SIZE = 16;
@@ -1,4 +1,4 @@
1
- /* hash: 1i799 */
1
+ /* hash: 1e5nj */
2
2
  :root {
3
3
  } /* deprecated */ :root {
4
4
  --color-light-graphic-tertiary: #b6bcc3;
@@ -15,7 +15,7 @@
15
15
  } :root {
16
16
  } :root {
17
17
  } :root {
18
- } .confirmation__circle_j09yr {
18
+ } .confirmation__circle_1q6wg {
19
19
  fill: transparent;
20
20
  stroke: var(--color-light-graphic-tertiary);
21
21
  stroke-width: 2px;
@@ -2,7 +2,7 @@ import React from 'react';
2
2
  import cn from 'classnames';
3
3
  import { Typography } from '@alfalab/core-components-typography/esm';
4
4
 
5
- var styles = {"header":"confirmation__header_b93vi","typography":"confirmation__typography_b93vi","typographyMobile":"confirmation__typographyMobile_b93vi"};
5
+ var styles = {"header":"confirmation__header_k1gli","typography":"confirmation__typography_k1gli","typographyMobile":"confirmation__typographyMobile_k1gli"};
6
6
  require('./index.css')
7
7
 
8
8
  var Header = function (_a) {
@@ -1,4 +1,4 @@
1
- /* hash: 1eq76 */
1
+ /* hash: 4uqfp */
2
2
  :root {
3
3
  } /* deprecated */ :root {
4
4
  } :root {
@@ -34,15 +34,15 @@
34
34
 
35
35
  /* header */
36
36
  --confirmation-header-font-feature-settings: normal
37
- } .confirmation__header_b93vi.confirmation__header_b93vi {
37
+ } .confirmation__header_k1gli.confirmation__header_k1gli {
38
38
  margin-bottom: var(--gap-xl);
39
- } .confirmation__typography_b93vi.confirmation__typography_b93vi {
39
+ } .confirmation__typography_k1gli.confirmation__typography_k1gli {
40
40
  font-feature-settings: var(--confirmation-header-font-feature-settings);
41
41
  font-size: var(--confirmation-header-desktop-font-size);
42
42
  line-height: var(--confirmation-header-desktop-line-height);
43
43
  font-weight: var(--confirmation-header-desktop-font-weight);
44
44
  font-family: var(--confirmation-header-desktop-font-family);
45
- } .confirmation__typographyMobile_b93vi.confirmation__typographyMobile_b93vi {
45
+ } .confirmation__typographyMobile_k1gli.confirmation__typographyMobile_k1gli {
46
46
  font-feature-settings: var(--confirmation-header-font-feature-settings);
47
47
  font-size: var(--confirmation-header-mobile-font-size);
48
48
  line-height: var(--confirmation-header-mobile-line-height);
@@ -13,5 +13,5 @@ import '@alfalab/hooks';
13
13
  import '../context.js';
14
14
  import '../utils.js';
15
15
  import './header/component.js';
16
- import '../countdown-section-55873048.js';
16
+ import '../countdown-section-6eb66678.js';
17
17
  import '@alfalab/core-components-loader/esm';
@@ -6,7 +6,7 @@ import { ConfirmationContext } from '../../../context.js';
6
6
  import { Header } from '../../header/component.js';
7
7
  import '../../../utils.js';
8
8
 
9
- var styles = {"component":"confirmation__component_8kuou","typographyTheme":"confirmation__typographyTheme_8kuou","left":"confirmation__left_8kuou","center":"confirmation__center_8kuou","button":"confirmation__button_8kuou"};
9
+ var styles = {"component":"confirmation__component_1751l","typographyTheme":"confirmation__typographyTheme_1751l","left":"confirmation__left_1751l","center":"confirmation__center_1751l","button":"confirmation__button_1751l"};
10
10
  require('./index.css')
11
11
 
12
12
  var FatalError = function (_a) {
@@ -1,4 +1,4 @@
1
- /* hash: xmkb0 */
1
+ /* hash: 112kj */
2
2
  :root {
3
3
  } /* deprecated */ :root {
4
4
  --color-light-text-primary: #0b1f35;
@@ -31,20 +31,20 @@
31
31
  --confirmation-text-color: var(--color-light-text-primary)
32
32
 
33
33
  /* header */
34
- } .confirmation__component_8kuou {
34
+ } .confirmation__component_1751l {
35
35
  display: flex;
36
36
  flex-direction: column;
37
- } .confirmation__typographyTheme_8kuou.confirmation__typographyTheme_8kuou {
37
+ } .confirmation__typographyTheme_1751l.confirmation__typographyTheme_1751l {
38
38
  font-size: var(--confirmation-text-font-size);
39
39
  line-height: var(--confirmation-text-line-height);
40
40
  font-weight: var(--confirmation-text-font-weight);
41
41
  font-family: var(--confirmation-text-font-family);
42
42
  color: var(--confirmation-text-color);
43
- } .confirmation__left_8kuou {
43
+ } .confirmation__left_1751l {
44
44
  align-items: flex-start;
45
- } .confirmation__center_8kuou {
45
+ } .confirmation__center_1751l {
46
46
  align-items: center;
47
47
  text-align: center;
48
- } .confirmation__button_8kuou {
48
+ } .confirmation__button_1751l {
49
49
  margin-top: var(--gap-2xl);
50
50
  }
@@ -7,7 +7,7 @@ import { ConfirmationContext } from '../../../context.js';
7
7
  import { Header } from '../../header/component.js';
8
8
  import '../../../utils.js';
9
9
 
10
- var styles = {"component":"confirmation__component_w9xpd","center":"confirmation__center_w9xpd","text":"confirmation__text_w9xpd","typographyTheme":"confirmation__typographyTheme_w9xpd","phonesWrap":"confirmation__phonesWrap_w9xpd","phoneWrap":"confirmation__phoneWrap_w9xpd","phoneLink":"confirmation__phoneLink_w9xpd","hintButton":"confirmation__hintButton_w9xpd","phoneContentMobile":"confirmation__phoneContentMobile_w9xpd"};
10
+ var styles = {"component":"confirmation__component_r22t9","center":"confirmation__center_r22t9","text":"confirmation__text_r22t9","typographyTheme":"confirmation__typographyTheme_r22t9","phonesWrap":"confirmation__phonesWrap_r22t9","phoneWrap":"confirmation__phoneWrap_r22t9","phoneLink":"confirmation__phoneLink_r22t9","hintButton":"confirmation__hintButton_r22t9","phoneContentMobile":"confirmation__phoneContentMobile_r22t9"};
11
11
  require('./index.css')
12
12
 
13
13
  var Hint = function (_a) {