@alfalab/core-components-confirmation 12.5.2 → 13.0.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.
- package/component.desktop.d.ts +1 -1
- package/component.desktop.js +5 -3
- package/component.mobile.js +6 -4
- package/component.responsive.d.ts +2 -3
- package/component.responsive.js +9 -9
- package/components/base-confirmation/component.js +9 -6
- package/components/base-confirmation/index.css +2 -2
- package/components/base-confirmation/index.js +5 -3
- package/components/countdown-loader/component.js +1 -1
- package/components/countdown-loader/index.css +2 -2
- package/components/header/component.js +1 -1
- package/components/header/index.css +4 -4
- package/components/index.js +5 -3
- package/components/screens/fatal-error/component.js +3 -3
- package/components/screens/fatal-error/index.css +6 -6
- package/components/screens/hint/component.js +3 -3
- package/components/screens/hint/index.css +12 -12
- package/components/screens/index.js +5 -3
- package/components/screens/initial/component.js +12 -9
- package/components/screens/initial/countdown-section.js +1 -1
- package/components/screens/initial/index.css +17 -20
- package/components/screens/initial/index.js +5 -3
- package/components/screens/temp-block/component.js +1 -1
- package/components/screens/temp-block/index.css +7 -7
- package/context.js +1 -0
- package/{countdown-section-41f47745.js → countdown-section-fb6524aa.js} +3 -3
- package/cssm/component.desktop.d.ts +1 -1
- package/cssm/component.desktop.js +4 -2
- package/cssm/component.mobile.js +4 -2
- package/cssm/component.responsive.d.ts +2 -3
- package/cssm/component.responsive.js +8 -8
- package/cssm/components/base-confirmation/component.js +7 -4
- package/cssm/components/base-confirmation/index.js +4 -2
- package/cssm/components/index.js +4 -2
- package/cssm/components/screens/fatal-error/component.js +2 -2
- package/cssm/components/screens/hint/component.js +2 -2
- package/cssm/components/screens/index.js +4 -2
- package/cssm/components/screens/initial/component.js +11 -8
- package/cssm/components/screens/initial/countdown-section.js +2 -2
- package/cssm/components/screens/initial/index.js +4 -2
- package/cssm/components/screens/initial/index.module.css +0 -3
- package/cssm/context.js +1 -0
- package/cssm/desktop.d.ts +1 -1
- package/cssm/desktop.js +7 -3
- package/cssm/index.d.ts +2 -6
- package/cssm/index.js +18 -26
- package/cssm/mobile.d.ts +1 -1
- package/cssm/mobile.js +7 -3
- package/cssm/shared.d.ts +4 -0
- package/cssm/shared.js +43 -0
- package/cssm/types.d.ts +11 -0
- package/desktop.d.ts +1 -1
- package/desktop.js +8 -4
- package/esm/component.desktop.d.ts +1 -1
- package/esm/component.desktop.js +5 -3
- package/esm/component.mobile.js +6 -4
- package/esm/component.responsive.d.ts +2 -3
- package/esm/component.responsive.js +9 -9
- package/esm/components/base-confirmation/component.js +9 -6
- package/esm/components/base-confirmation/index.css +2 -2
- package/esm/components/base-confirmation/index.js +5 -3
- package/esm/components/countdown-loader/component.js +1 -1
- package/esm/components/countdown-loader/index.css +2 -2
- package/esm/components/header/component.js +1 -1
- package/esm/components/header/index.css +4 -4
- package/esm/components/index.js +5 -3
- package/esm/components/screens/fatal-error/component.js +3 -3
- package/esm/components/screens/fatal-error/index.css +6 -6
- package/esm/components/screens/hint/component.js +3 -3
- package/esm/components/screens/hint/index.css +12 -12
- package/esm/components/screens/index.js +5 -3
- package/esm/components/screens/initial/component.js +8 -5
- package/esm/components/screens/initial/countdown-section.js +1 -1
- package/esm/components/screens/initial/index.css +17 -20
- package/esm/components/screens/initial/index.js +5 -3
- package/esm/components/screens/temp-block/component.js +1 -1
- package/esm/components/screens/temp-block/index.css +7 -7
- package/esm/context.js +1 -0
- package/esm/{countdown-section-83bf5f20.js → countdown-section-c65cff2d.js} +3 -3
- package/esm/desktop.d.ts +1 -1
- package/esm/desktop.js +6 -4
- package/esm/index.d.ts +2 -6
- package/esm/index.js +17 -14
- package/esm/mobile.css +2 -2
- package/esm/mobile.d.ts +1 -1
- package/esm/mobile.js +6 -4
- package/esm/shared.d.ts +4 -0
- package/esm/shared.js +20 -0
- package/esm/types.d.ts +11 -0
- package/index.d.ts +2 -6
- package/index.js +16 -24
- package/mobile.css +2 -2
- package/mobile.d.ts +1 -1
- package/mobile.js +8 -4
- package/modern/component.desktop.d.ts +1 -1
- package/modern/component.desktop.js +5 -3
- package/modern/component.mobile.js +6 -4
- package/modern/component.responsive.d.ts +2 -3
- package/modern/component.responsive.js +9 -9
- package/modern/components/base-confirmation/component.js +8 -5
- package/modern/components/base-confirmation/index.css +2 -2
- package/modern/components/base-confirmation/index.js +5 -3
- package/modern/components/countdown-loader/component.js +1 -1
- package/modern/components/countdown-loader/index.css +2 -2
- package/modern/components/header/component.js +1 -1
- package/modern/components/header/index.css +4 -4
- package/modern/components/index.js +5 -3
- package/modern/components/screens/fatal-error/component.js +3 -3
- package/modern/components/screens/fatal-error/index.css +6 -6
- package/modern/components/screens/hint/component.js +3 -3
- package/modern/components/screens/hint/index.css +12 -12
- package/modern/components/screens/index.js +5 -3
- package/modern/components/screens/initial/component.js +8 -5
- package/modern/components/screens/initial/countdown-section.js +1 -1
- package/modern/components/screens/initial/index.css +17 -20
- package/modern/components/screens/initial/index.js +5 -3
- package/modern/components/screens/temp-block/component.js +1 -1
- package/modern/components/screens/temp-block/index.css +7 -7
- package/modern/context.js +1 -0
- package/modern/{countdown-section-a28d693c.js → countdown-section-dd4e5fe3.js} +3 -3
- package/modern/desktop.d.ts +1 -1
- package/modern/desktop.js +6 -4
- package/modern/index.d.ts +2 -6
- package/modern/index.js +17 -14
- package/modern/mobile.css +2 -2
- package/modern/mobile.d.ts +1 -1
- package/modern/mobile.js +6 -4
- package/modern/shared.d.ts +4 -0
- package/modern/shared.js +20 -0
- package/modern/types.d.ts +11 -0
- package/package.json +31 -6
- package/shared.d.ts +4 -0
- package/shared.js +37 -0
- package/src/component.desktop.tsx +10 -0
- package/src/component.mobile.tsx +13 -0
- package/src/component.responsive.tsx +31 -0
- package/src/components/base-confirmation/component.tsx +123 -0
- package/src/components/base-confirmation/index.module.css +8 -0
- package/src/components/base-confirmation/index.ts +1 -0
- package/src/components/countdown-loader/component.tsx +37 -0
- package/src/components/countdown-loader/index.module.css +7 -0
- package/src/components/countdown-loader/index.ts +1 -0
- package/src/components/header/component.tsx +28 -0
- package/src/components/header/index.module.css +21 -0
- package/src/components/header/index.ts +1 -0
- package/src/components/index.ts +2 -0
- package/src/components/screens/fatal-error/component.tsx +46 -0
- package/src/components/screens/fatal-error/index.module.css +23 -0
- package/src/components/screens/fatal-error/index.ts +1 -0
- package/src/components/screens/hint/component.tsx +94 -0
- package/src/components/screens/hint/index.module.css +51 -0
- package/src/components/screens/hint/index.ts +1 -0
- package/src/components/screens/index.ts +4 -0
- package/src/components/screens/initial/component.tsx +190 -0
- package/src/components/screens/initial/countdown-section.tsx +79 -0
- package/src/components/screens/initial/index.module.css +71 -0
- package/src/components/screens/initial/index.ts +1 -0
- package/src/components/screens/temp-block/component.tsx +58 -0
- package/src/components/screens/temp-block/index.module.css +28 -0
- package/src/components/screens/temp-block/index.ts +1 -0
- package/src/context.ts +26 -0
- package/src/desktop.ts +3 -0
- package/src/index.ts +6 -0
- package/src/mobile.module.css +3 -0
- package/src/mobile.ts +3 -0
- package/src/shared.ts +4 -0
- package/src/types.ts +219 -0
- package/src/utils.ts +107 -0
- package/src/vars.css +33 -0
- package/types.d.ts +11 -0
- package/cssm/responsive.d.ts +0 -2
- package/cssm/responsive.js +0 -39
- package/esm/responsive.d.ts +0 -2
- package/esm/responsive.js +0 -23
- package/modern/responsive.d.ts +0 -2
- package/modern/responsive.js +0 -22
- package/responsive.d.ts +0 -2
- package/responsive.js +0 -31
- /package/{countdown-section-41f47745.d.ts → countdown-section-fb6524aa.d.ts} +0 -0
- /package/esm/{countdown-section-83bf5f20.d.ts → countdown-section-c65cff2d.d.ts} +0 -0
- /package/modern/{countdown-section-a28d693c.d.ts → countdown-section-dd4e5fe3.d.ts} +0 -0
package/modern/desktop.js
CHANGED
|
@@ -1,18 +1,20 @@
|
|
|
1
1
|
export { ConfirmationDesktop } from './component.desktop.js';
|
|
2
|
+
export { useConfirmation, useCountdown } from './utils.js';
|
|
2
3
|
import 'react';
|
|
3
4
|
import './components/base-confirmation/component.js';
|
|
4
5
|
import 'classnames';
|
|
5
6
|
import '@alfalab/hooks';
|
|
6
7
|
import './context.js';
|
|
7
|
-
import './utils.js';
|
|
8
8
|
import './types.js';
|
|
9
9
|
import './components/screens/initial/component.js';
|
|
10
|
-
import '@alfalab/core-components-button/modern';
|
|
11
|
-
import '@alfalab/core-components-code-input/modern';
|
|
10
|
+
import '@alfalab/core-components-button/modern/mobile';
|
|
11
|
+
import '@alfalab/core-components-code-input/modern/desktop';
|
|
12
|
+
import '@alfalab/core-components-code-input/modern/mobile';
|
|
12
13
|
import '@alfalab/core-components-link/modern';
|
|
13
14
|
import '@alfalab/core-components-typography/modern';
|
|
14
15
|
import './components/header/component.js';
|
|
15
|
-
import './countdown-section-
|
|
16
|
+
import './countdown-section-dd4e5fe3.js';
|
|
17
|
+
import '@alfalab/core-components-button/modern';
|
|
16
18
|
import '@alfalab/core-components-loader/modern';
|
|
17
19
|
import './components/screens/hint/component.js';
|
|
18
20
|
import './components/screens/fatal-error/component.js';
|
package/modern/index.d.ts
CHANGED
|
@@ -1,6 +1,2 @@
|
|
|
1
|
-
export {
|
|
2
|
-
export
|
|
3
|
-
export * from "./components/index";
|
|
4
|
-
export * from "./context";
|
|
5
|
-
export * from "./types";
|
|
6
|
-
export * from "./utils";
|
|
1
|
+
export { ConfirmationResponsive as Confirmation, ResponsiveConfirmationProps as ConfirmationProps } from "./component.responsive";
|
|
2
|
+
export { useConfirmation, useCountdown } from "./utils";
|
package/modern/index.js
CHANGED
|
@@ -1,22 +1,25 @@
|
|
|
1
|
-
export {
|
|
2
|
-
export {
|
|
3
|
-
export { Initial } from './components/screens/initial/component.js';
|
|
4
|
-
export { Hint } from './components/screens/hint/component.js';
|
|
5
|
-
export { FatalError } from './components/screens/fatal-error/component.js';
|
|
6
|
-
export { TempBlock } from './components/screens/temp-block/component.js';
|
|
7
|
-
export { CountdownLoader } from './components/countdown-loader/component.js';
|
|
8
|
-
export { ConfirmationContext } from './context.js';
|
|
9
|
-
export { defaultTexts } from './types.js';
|
|
10
|
-
export { ONE_DAY, ONE_MINUTE, formatMsAsMinutes, useConfirmation, useCountdown } from './utils.js';
|
|
1
|
+
export { ConfirmationResponsive as Confirmation } from './component.responsive.js';
|
|
2
|
+
export { useConfirmation, useCountdown } from './utils.js';
|
|
11
3
|
import 'react';
|
|
4
|
+
import '@alfalab/core-components-mq/modern';
|
|
5
|
+
import './component.desktop.js';
|
|
12
6
|
import './components/base-confirmation/component.js';
|
|
13
7
|
import 'classnames';
|
|
14
8
|
import '@alfalab/hooks';
|
|
15
|
-
import './
|
|
16
|
-
import '
|
|
17
|
-
import '
|
|
9
|
+
import './context.js';
|
|
10
|
+
import './types.js';
|
|
11
|
+
import './components/screens/initial/component.js';
|
|
12
|
+
import '@alfalab/core-components-button/modern/mobile';
|
|
13
|
+
import '@alfalab/core-components-code-input/modern/desktop';
|
|
14
|
+
import '@alfalab/core-components-code-input/modern/mobile';
|
|
18
15
|
import '@alfalab/core-components-link/modern';
|
|
19
16
|
import '@alfalab/core-components-typography/modern';
|
|
20
17
|
import './components/header/component.js';
|
|
21
|
-
import './countdown-section-
|
|
18
|
+
import './countdown-section-dd4e5fe3.js';
|
|
19
|
+
import '@alfalab/core-components-button/modern';
|
|
22
20
|
import '@alfalab/core-components-loader/modern';
|
|
21
|
+
import './components/screens/hint/component.js';
|
|
22
|
+
import './components/screens/fatal-error/component.js';
|
|
23
|
+
import './components/screens/temp-block/component.js';
|
|
24
|
+
import './components/countdown-loader/component.js';
|
|
25
|
+
import './component.mobile.js';
|
package/modern/mobile.css
CHANGED
package/modern/mobile.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
export * from "./component.mobile";
|
|
2
|
-
export {};
|
|
2
|
+
export { useConfirmation, useCountdown } from "./utils";
|
package/modern/mobile.js
CHANGED
|
@@ -1,18 +1,20 @@
|
|
|
1
1
|
export { ConfirmationMobile } from './component.mobile.js';
|
|
2
|
+
export { useConfirmation, useCountdown } from './utils.js';
|
|
2
3
|
import 'react';
|
|
3
4
|
import 'classnames';
|
|
4
5
|
import './components/base-confirmation/component.js';
|
|
5
6
|
import '@alfalab/hooks';
|
|
6
7
|
import './context.js';
|
|
7
|
-
import './utils.js';
|
|
8
8
|
import './types.js';
|
|
9
9
|
import './components/screens/initial/component.js';
|
|
10
|
-
import '@alfalab/core-components-button/modern';
|
|
11
|
-
import '@alfalab/core-components-code-input/modern';
|
|
10
|
+
import '@alfalab/core-components-button/modern/mobile';
|
|
11
|
+
import '@alfalab/core-components-code-input/modern/desktop';
|
|
12
|
+
import '@alfalab/core-components-code-input/modern/mobile';
|
|
12
13
|
import '@alfalab/core-components-link/modern';
|
|
13
14
|
import '@alfalab/core-components-typography/modern';
|
|
14
15
|
import './components/header/component.js';
|
|
15
|
-
import './countdown-section-
|
|
16
|
+
import './countdown-section-dd4e5fe3.js';
|
|
17
|
+
import '@alfalab/core-components-button/modern';
|
|
16
18
|
import '@alfalab/core-components-loader/modern';
|
|
17
19
|
import './components/screens/hint/component.js';
|
|
18
20
|
import './components/screens/fatal-error/component.js';
|
package/modern/shared.js
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
export { Initial } from './components/screens/initial/component.js';
|
|
2
|
+
export { Hint } from './components/screens/hint/component.js';
|
|
3
|
+
export { FatalError } from './components/screens/fatal-error/component.js';
|
|
4
|
+
export { TempBlock } from './components/screens/temp-block/component.js';
|
|
5
|
+
export { CountdownLoader } from './components/countdown-loader/component.js';
|
|
6
|
+
export { ConfirmationContext } from './context.js';
|
|
7
|
+
export { defaultTexts } from './types.js';
|
|
8
|
+
export { ONE_DAY, ONE_MINUTE, formatMsAsMinutes } from './utils.js';
|
|
9
|
+
import 'react';
|
|
10
|
+
import 'classnames';
|
|
11
|
+
import '@alfalab/core-components-button/modern/mobile';
|
|
12
|
+
import '@alfalab/core-components-code-input/modern/desktop';
|
|
13
|
+
import '@alfalab/core-components-code-input/modern/mobile';
|
|
14
|
+
import '@alfalab/core-components-link/modern';
|
|
15
|
+
import '@alfalab/core-components-typography/modern';
|
|
16
|
+
import '@alfalab/hooks';
|
|
17
|
+
import './components/header/component.js';
|
|
18
|
+
import './countdown-section-dd4e5fe3.js';
|
|
19
|
+
import '@alfalab/core-components-button/modern';
|
|
20
|
+
import '@alfalab/core-components-loader/modern';
|
package/modern/types.d.ts
CHANGED
|
@@ -89,9 +89,20 @@ type ConfirmationProps = {
|
|
|
89
89
|
* @default false
|
|
90
90
|
*/
|
|
91
91
|
hideCountdownSection?: boolean;
|
|
92
|
+
/**
|
|
93
|
+
* Контрольная точка для кнопки, с нее начинается desktop версия
|
|
94
|
+
* @default 1024
|
|
95
|
+
*/
|
|
96
|
+
breakpoint?: number;
|
|
92
97
|
};
|
|
93
98
|
type TConfirmationContext = Required<Pick<ConfirmationProps, 'alignContent' | 'texts' | 'state' | 'screen' | 'requiredCharAmount' | 'onInputFinished' | 'countdownDuration' | 'onChangeState' | 'onSmsRetryClick' | 'onChangeScreen' | 'onFatalErrorOkButtonClick' | 'tempBlockDuration' | 'hideCountdownSection'>> & Pick<ConfirmationProps, 'phone' | 'blockSmsRetry' | 'onTempBlockFinished' | 'clearCodeOnError'> & {
|
|
94
99
|
timeLeft: number;
|
|
100
|
+
} & {
|
|
101
|
+
/**
|
|
102
|
+
* Контрольная точка для кнопки, с нее начинается desktop версия
|
|
103
|
+
* @default 1024
|
|
104
|
+
*/
|
|
105
|
+
breakpoint?: number;
|
|
95
106
|
};
|
|
96
107
|
type ConfirmationTexts = {
|
|
97
108
|
/**
|
package/package.json
CHANGED
|
@@ -1,21 +1,46 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@alfalab/core-components-confirmation",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "13.0.0",
|
|
4
4
|
"description": "Sms confirmation component",
|
|
5
5
|
"keywords": [],
|
|
6
6
|
"license": "MIT",
|
|
7
7
|
"main": "index.js",
|
|
8
8
|
"module": "./esm/index.js",
|
|
9
|
+
"exports": {
|
|
10
|
+
".": {
|
|
11
|
+
"import": "./esm/index.js",
|
|
12
|
+
"require": "./index.js"
|
|
13
|
+
},
|
|
14
|
+
"./mobile": {
|
|
15
|
+
"import": "./esm/mobile.js",
|
|
16
|
+
"require": "./mobile.js"
|
|
17
|
+
},
|
|
18
|
+
"./desktop": {
|
|
19
|
+
"import": "./esm/desktop.js",
|
|
20
|
+
"require": "./desktop.js"
|
|
21
|
+
},
|
|
22
|
+
"./shared": {
|
|
23
|
+
"import": "./esm/shared.js",
|
|
24
|
+
"require": "./shared.js"
|
|
25
|
+
},
|
|
26
|
+
"./esm": "./esm/index.js",
|
|
27
|
+
"./cssm": "./cssm/index.js",
|
|
28
|
+
"./modern": "./modern/index.js",
|
|
29
|
+
"./esm/*": "./esm/*",
|
|
30
|
+
"./cssm/*": "./cssm/*",
|
|
31
|
+
"./modern/*": "./modern/*"
|
|
32
|
+
},
|
|
9
33
|
"publishConfig": {
|
|
10
34
|
"access": "public",
|
|
11
35
|
"directory": "dist"
|
|
12
36
|
},
|
|
13
37
|
"dependencies": {
|
|
14
|
-
"@alfalab/core-components-button": "^
|
|
15
|
-
"@alfalab/core-components-code-input": "^
|
|
16
|
-
"@alfalab/core-components-link": "^5.0
|
|
17
|
-
"@alfalab/core-components-loader": "^3.0
|
|
18
|
-
"@alfalab/core-components-typography": "^
|
|
38
|
+
"@alfalab/core-components-button": "^9.0.0",
|
|
39
|
+
"@alfalab/core-components-code-input": "^3.0.0",
|
|
40
|
+
"@alfalab/core-components-link": "^5.1.0",
|
|
41
|
+
"@alfalab/core-components-loader": "^3.1.0",
|
|
42
|
+
"@alfalab/core-components-typography": "^4.0.0",
|
|
43
|
+
"@alfalab/core-components-mq": "^4.2.0",
|
|
19
44
|
"@alfalab/hooks": "^1.13.0",
|
|
20
45
|
"classnames": "^2.3.1",
|
|
21
46
|
"tslib": "^2.4.0"
|
package/shared.d.ts
ADDED
package/shared.js
ADDED
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
+
|
|
5
|
+
var components_screens_initial_component = require('./components/screens/initial/component.js');
|
|
6
|
+
var components_screens_hint_component = require('./components/screens/hint/component.js');
|
|
7
|
+
var components_screens_fatalError_component = require('./components/screens/fatal-error/component.js');
|
|
8
|
+
var components_screens_tempBlock_component = require('./components/screens/temp-block/component.js');
|
|
9
|
+
var components_countdownLoader_component = require('./components/countdown-loader/component.js');
|
|
10
|
+
var context = require('./context.js');
|
|
11
|
+
var types = require('./types.js');
|
|
12
|
+
var utils = require('./utils.js');
|
|
13
|
+
require('react');
|
|
14
|
+
require('classnames');
|
|
15
|
+
require('@alfalab/core-components-button/mobile');
|
|
16
|
+
require('@alfalab/core-components-code-input/desktop');
|
|
17
|
+
require('@alfalab/core-components-code-input/mobile');
|
|
18
|
+
require('@alfalab/core-components-link');
|
|
19
|
+
require('@alfalab/core-components-typography');
|
|
20
|
+
require('@alfalab/hooks');
|
|
21
|
+
require('./components/header/component.js');
|
|
22
|
+
require('./countdown-section-fb6524aa.js');
|
|
23
|
+
require('@alfalab/core-components-button');
|
|
24
|
+
require('@alfalab/core-components-loader');
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
exports.Initial = components_screens_initial_component.Initial;
|
|
29
|
+
exports.Hint = components_screens_hint_component.Hint;
|
|
30
|
+
exports.FatalError = components_screens_fatalError_component.FatalError;
|
|
31
|
+
exports.TempBlock = components_screens_tempBlock_component.TempBlock;
|
|
32
|
+
exports.CountdownLoader = components_countdownLoader_component.CountdownLoader;
|
|
33
|
+
exports.ConfirmationContext = context.ConfirmationContext;
|
|
34
|
+
exports.defaultTexts = types.defaultTexts;
|
|
35
|
+
exports.ONE_DAY = utils.ONE_DAY;
|
|
36
|
+
exports.ONE_MINUTE = utils.ONE_MINUTE;
|
|
37
|
+
exports.formatMsAsMinutes = utils.formatMsAsMinutes;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import React, { FC } from 'react';
|
|
2
|
+
|
|
3
|
+
import { BaseConfirmation } from './components/base-confirmation';
|
|
4
|
+
import { ConfirmationProps } from './types';
|
|
5
|
+
|
|
6
|
+
export type DesktopConfirmationProps = Omit<ConfirmationProps, 'mobile' | 'breakpoint'>;
|
|
7
|
+
|
|
8
|
+
export const ConfirmationDesktop: FC<DesktopConfirmationProps> = (props) => (
|
|
9
|
+
<BaseConfirmation {...props} />
|
|
10
|
+
);
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import React, { FC } from 'react';
|
|
2
|
+
import cn from 'classnames';
|
|
3
|
+
|
|
4
|
+
import { BaseConfirmation } from './components/base-confirmation';
|
|
5
|
+
import { ConfirmationProps } from './types';
|
|
6
|
+
|
|
7
|
+
import styles from './mobile.module.css';
|
|
8
|
+
|
|
9
|
+
export type MobileConfirmationProps = Omit<ConfirmationProps, 'mobile'>;
|
|
10
|
+
|
|
11
|
+
export const ConfirmationMobile: FC<MobileConfirmationProps> = ({ className, ...resProps }) => (
|
|
12
|
+
<BaseConfirmation mobile={true} className={cn(className, styles.container)} {...resProps} />
|
|
13
|
+
);
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import React, { FC } from 'react';
|
|
2
|
+
|
|
3
|
+
import { useMatchMedia } from '@alfalab/core-components-mq';
|
|
4
|
+
|
|
5
|
+
import { ConfirmationDesktop } from './component.desktop';
|
|
6
|
+
import { ConfirmationMobile } from './component.mobile';
|
|
7
|
+
import { ConfirmationProps } from './types';
|
|
8
|
+
|
|
9
|
+
export type ResponsiveConfirmationProps = Omit<
|
|
10
|
+
ConfirmationProps,
|
|
11
|
+
'confirmationScreens' | 'breakpoint'
|
|
12
|
+
> & {
|
|
13
|
+
/**
|
|
14
|
+
* Контрольная точка, с нее начинается desktop версия
|
|
15
|
+
* @default 1024
|
|
16
|
+
*/
|
|
17
|
+
breakpoint?: number;
|
|
18
|
+
};
|
|
19
|
+
|
|
20
|
+
export const ConfirmationResponsive: FC<ResponsiveConfirmationProps> = ({
|
|
21
|
+
breakpoint = 1024,
|
|
22
|
+
...restProps
|
|
23
|
+
}) => {
|
|
24
|
+
const [isDesktop] = useMatchMedia(`(min-width: ${breakpoint}px)`, true);
|
|
25
|
+
|
|
26
|
+
return isDesktop ? (
|
|
27
|
+
<ConfirmationDesktop {...restProps} />
|
|
28
|
+
) : (
|
|
29
|
+
<ConfirmationMobile breakpoint={breakpoint} {...restProps} />
|
|
30
|
+
);
|
|
31
|
+
};
|
|
@@ -0,0 +1,123 @@
|
|
|
1
|
+
import React, { ComponentType, FC, useEffect } from 'react';
|
|
2
|
+
import cn from 'classnames';
|
|
3
|
+
|
|
4
|
+
import { usePrevious } from '@alfalab/hooks';
|
|
5
|
+
|
|
6
|
+
import { ConfirmationContext } from '../../context';
|
|
7
|
+
import { ConfirmationProps, defaultTexts, TConfirmationContext } from '../../types';
|
|
8
|
+
import { ONE_DAY, ONE_MINUTE, useCountdown } from '../../utils';
|
|
9
|
+
import { FatalError, Hint, Initial, TempBlock } from '../screens';
|
|
10
|
+
|
|
11
|
+
import styles from './index.module.css';
|
|
12
|
+
|
|
13
|
+
const confirmationScreens: { [key: string]: ComponentType<{ mobile?: boolean }> } = {
|
|
14
|
+
INITIAL: Initial,
|
|
15
|
+
HINT: Hint,
|
|
16
|
+
FATAL_ERROR: FatalError,
|
|
17
|
+
TEMP_BLOCK: TempBlock,
|
|
18
|
+
};
|
|
19
|
+
|
|
20
|
+
export const BaseConfirmation: FC<ConfirmationProps> = ({
|
|
21
|
+
state,
|
|
22
|
+
screen,
|
|
23
|
+
alignContent = 'left',
|
|
24
|
+
children,
|
|
25
|
+
requiredCharAmount = 5,
|
|
26
|
+
countdownDuration = ONE_MINUTE,
|
|
27
|
+
tempBlockDuration = ONE_DAY,
|
|
28
|
+
phone,
|
|
29
|
+
blockSmsRetry,
|
|
30
|
+
dataTestId,
|
|
31
|
+
className,
|
|
32
|
+
getScreensMap,
|
|
33
|
+
onInputFinished,
|
|
34
|
+
onChangeState,
|
|
35
|
+
onSmsRetryClick,
|
|
36
|
+
onChangeScreen,
|
|
37
|
+
onFatalErrorOkButtonClick,
|
|
38
|
+
onTempBlockFinished,
|
|
39
|
+
mobile,
|
|
40
|
+
clearCodeOnError = true,
|
|
41
|
+
hideCountdownSection = false,
|
|
42
|
+
breakpoint = 1024,
|
|
43
|
+
...restProps
|
|
44
|
+
}) => {
|
|
45
|
+
const [timeLeft, startTimer, stopTimer] = useCountdown(countdownDuration);
|
|
46
|
+
|
|
47
|
+
const prevState = usePrevious(state);
|
|
48
|
+
|
|
49
|
+
useEffect(() => {
|
|
50
|
+
startTimer();
|
|
51
|
+
}, [startTimer]);
|
|
52
|
+
|
|
53
|
+
useEffect(() => {
|
|
54
|
+
/**
|
|
55
|
+
* Перезапускаем таймер после повторного запроса кода
|
|
56
|
+
*/
|
|
57
|
+
if (state === 'INITIAL' && prevState === 'CODE_SENDING') {
|
|
58
|
+
startTimer();
|
|
59
|
+
}
|
|
60
|
+
}, [state, prevState, startTimer]);
|
|
61
|
+
|
|
62
|
+
useEffect(() => {
|
|
63
|
+
/**
|
|
64
|
+
* Останавливаем таймер, если новый экран/состояние не содержит таймер
|
|
65
|
+
*/
|
|
66
|
+
if (!['INITIAL', 'HINT', 'TEMP_BLOCK'].includes(screen) || blockSmsRetry) {
|
|
67
|
+
stopTimer();
|
|
68
|
+
}
|
|
69
|
+
}, [state, screen, blockSmsRetry, stopTimer]);
|
|
70
|
+
|
|
71
|
+
const handleSmsRetry = () => {
|
|
72
|
+
onChangeState('CODE_SENDING');
|
|
73
|
+
|
|
74
|
+
onSmsRetryClick();
|
|
75
|
+
};
|
|
76
|
+
|
|
77
|
+
const handleInputFinished = (code: string) => {
|
|
78
|
+
onChangeState('CODE_CHECKING');
|
|
79
|
+
|
|
80
|
+
onInputFinished(code);
|
|
81
|
+
};
|
|
82
|
+
|
|
83
|
+
const handleFatalErrorOkButtonClick = () => {
|
|
84
|
+
if (onFatalErrorOkButtonClick) {
|
|
85
|
+
onFatalErrorOkButtonClick();
|
|
86
|
+
}
|
|
87
|
+
};
|
|
88
|
+
|
|
89
|
+
// eslint-disable-next-line react/jsx-no-constructed-context-values
|
|
90
|
+
const contextValue: TConfirmationContext = {
|
|
91
|
+
hideCountdownSection,
|
|
92
|
+
alignContent,
|
|
93
|
+
texts: { ...defaultTexts, ...restProps.texts },
|
|
94
|
+
state,
|
|
95
|
+
screen,
|
|
96
|
+
requiredCharAmount,
|
|
97
|
+
countdownDuration,
|
|
98
|
+
timeLeft,
|
|
99
|
+
tempBlockDuration,
|
|
100
|
+
phone,
|
|
101
|
+
blockSmsRetry,
|
|
102
|
+
breakpoint,
|
|
103
|
+
onTempBlockFinished,
|
|
104
|
+
onChangeState,
|
|
105
|
+
onChangeScreen,
|
|
106
|
+
clearCodeOnError,
|
|
107
|
+
onInputFinished: handleInputFinished,
|
|
108
|
+
onSmsRetryClick: handleSmsRetry,
|
|
109
|
+
onFatalErrorOkButtonClick: handleFatalErrorOkButtonClick,
|
|
110
|
+
};
|
|
111
|
+
|
|
112
|
+
const screensMap = getScreensMap ? getScreensMap(confirmationScreens) : confirmationScreens;
|
|
113
|
+
|
|
114
|
+
const CurrentScreen = screensMap[screen];
|
|
115
|
+
|
|
116
|
+
return (
|
|
117
|
+
<ConfirmationContext.Provider value={contextValue}>
|
|
118
|
+
<div className={cn(styles.component, className)} data-test-id={dataTestId}>
|
|
119
|
+
{CurrentScreen && <CurrentScreen mobile={mobile} />}
|
|
120
|
+
</div>
|
|
121
|
+
</ConfirmationContext.Provider>
|
|
122
|
+
);
|
|
123
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './component';
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import React, { FC } from 'react';
|
|
2
|
+
|
|
3
|
+
import styles from './index.module.css';
|
|
4
|
+
|
|
5
|
+
type Props = {
|
|
6
|
+
progress: number; // 0-1
|
|
7
|
+
className?: string;
|
|
8
|
+
};
|
|
9
|
+
|
|
10
|
+
const SIZE = 16;
|
|
11
|
+
const STROKE_WIDTH = 2;
|
|
12
|
+
|
|
13
|
+
const CENTER = SIZE / 2;
|
|
14
|
+
const RADIUS = CENTER - STROKE_WIDTH / 2;
|
|
15
|
+
/** Длина окружности */
|
|
16
|
+
const CIRCUMFERENCE = Math.PI * RADIUS * 2;
|
|
17
|
+
|
|
18
|
+
export const CountdownLoader: FC<Props> = ({ progress, className }) => {
|
|
19
|
+
const value = Math.min(progress, 1);
|
|
20
|
+
|
|
21
|
+
const strokeDasharray = CIRCUMFERENCE.toFixed(2);
|
|
22
|
+
const strokeDashoffset = (value * CIRCUMFERENCE).toFixed(2);
|
|
23
|
+
|
|
24
|
+
return (
|
|
25
|
+
<svg width={SIZE} height={SIZE} viewBox={`0 0 ${SIZE} ${SIZE}`} className={className}>
|
|
26
|
+
<circle
|
|
27
|
+
cx={CENTER}
|
|
28
|
+
cy={CENTER}
|
|
29
|
+
r={RADIUS}
|
|
30
|
+
strokeDasharray={strokeDasharray}
|
|
31
|
+
strokeDashoffset={strokeDashoffset}
|
|
32
|
+
transform={`rotate(-90 ${CENTER} ${CENTER})`}
|
|
33
|
+
className={styles.circle}
|
|
34
|
+
/>
|
|
35
|
+
</svg>
|
|
36
|
+
);
|
|
37
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './component';
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import React, { FC, ReactNode } from 'react';
|
|
2
|
+
import cn from 'classnames';
|
|
3
|
+
|
|
4
|
+
import { Typography } from '@alfalab/core-components-typography';
|
|
5
|
+
|
|
6
|
+
import styles from './index.module.css';
|
|
7
|
+
|
|
8
|
+
export type HeaderProps = {
|
|
9
|
+
/**
|
|
10
|
+
* Контент шапки
|
|
11
|
+
*/
|
|
12
|
+
children?: ReactNode;
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* Отображать в мобильной версии экран компонента
|
|
16
|
+
*/
|
|
17
|
+
mobile?: boolean;
|
|
18
|
+
};
|
|
19
|
+
|
|
20
|
+
export const Header: FC<HeaderProps> = ({ mobile, children }) => (
|
|
21
|
+
<Typography.Title
|
|
22
|
+
className={cn(styles.header, styles.typography, { [styles.typographyMobile]: mobile })}
|
|
23
|
+
tag='h3'
|
|
24
|
+
color='primary'
|
|
25
|
+
>
|
|
26
|
+
{children}
|
|
27
|
+
</Typography.Title>
|
|
28
|
+
);
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
@import '../../vars.css';
|
|
2
|
+
|
|
3
|
+
.header.header {
|
|
4
|
+
margin-bottom: var(--gap-xl);
|
|
5
|
+
}
|
|
6
|
+
|
|
7
|
+
.typography.typography.typography {
|
|
8
|
+
font-feature-settings: var(--confirmation-header-font-feature-settings);
|
|
9
|
+
font-size: var(--confirmation-header-desktop-font-size);
|
|
10
|
+
line-height: var(--confirmation-header-desktop-line-height);
|
|
11
|
+
font-weight: var(--confirmation-header-desktop-font-weight);
|
|
12
|
+
font-family: var(--confirmation-header-desktop-font-family);
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
.typographyMobile.typographyMobile.typographyMobile {
|
|
16
|
+
font-feature-settings: var(--confirmation-header-font-feature-settings);
|
|
17
|
+
font-size: var(--confirmation-header-mobile-font-size);
|
|
18
|
+
line-height: var(--confirmation-header-mobile-line-height);
|
|
19
|
+
font-weight: var(--confirmation-header-mobile-font-weight);
|
|
20
|
+
font-family: var(--confirmation-header-mobile-font-family);
|
|
21
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './component';
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import React, { FC, useContext } from 'react';
|
|
2
|
+
import cn from 'classnames';
|
|
3
|
+
|
|
4
|
+
import { Button } from '@alfalab/core-components-button';
|
|
5
|
+
import { Typography } from '@alfalab/core-components-typography';
|
|
6
|
+
|
|
7
|
+
import { ConfirmationContext } from '../../../context';
|
|
8
|
+
import { Header } from '../../header';
|
|
9
|
+
|
|
10
|
+
import styles from './index.module.css';
|
|
11
|
+
|
|
12
|
+
export type FatalErrorProps = {
|
|
13
|
+
/**
|
|
14
|
+
* Отображать в мобильной версии экран компонента
|
|
15
|
+
*/
|
|
16
|
+
mobile?: boolean;
|
|
17
|
+
};
|
|
18
|
+
|
|
19
|
+
export const FatalError: FC<FatalErrorProps> = ({ mobile }) => {
|
|
20
|
+
const { alignContent, texts, onFatalErrorOkButtonClick, breakpoint } =
|
|
21
|
+
useContext(ConfirmationContext);
|
|
22
|
+
|
|
23
|
+
return (
|
|
24
|
+
<div className={cn(styles.component, styles[alignContent])}>
|
|
25
|
+
<Header mobile={mobile}>{texts.fatalErrorTitle}</Header>
|
|
26
|
+
|
|
27
|
+
<Typography.Text
|
|
28
|
+
view='primary-medium'
|
|
29
|
+
color='primary'
|
|
30
|
+
className={cn({ [styles.typographyTheme]: !mobile })}
|
|
31
|
+
>
|
|
32
|
+
{texts.fatalErrorDescription}
|
|
33
|
+
</Typography.Text>
|
|
34
|
+
|
|
35
|
+
<Button
|
|
36
|
+
size={mobile ? 'xs' : 's'}
|
|
37
|
+
view='secondary'
|
|
38
|
+
onClick={onFatalErrorOkButtonClick}
|
|
39
|
+
className={styles.button}
|
|
40
|
+
breakpoint={breakpoint}
|
|
41
|
+
>
|
|
42
|
+
{texts.fatalErrorButton}
|
|
43
|
+
</Button>
|
|
44
|
+
</div>
|
|
45
|
+
);
|
|
46
|
+
};
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
@import '../../../vars.css';
|
|
2
|
+
|
|
3
|
+
.component {
|
|
4
|
+
display: flex;
|
|
5
|
+
flex-direction: column;
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
.typographyTheme.typographyTheme {
|
|
9
|
+
@mixin _confirmation-text;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
.left {
|
|
13
|
+
align-items: flex-start;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
.center {
|
|
17
|
+
align-items: center;
|
|
18
|
+
text-align: center;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
.button {
|
|
22
|
+
margin-top: var(--gap-2xl);
|
|
23
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './component';
|