@alfalab/core-components-confirmation 13.6.3 → 13.7.1
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/components/base-confirmation/component.js +1 -1
- package/components/base-confirmation/index.css +4 -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/screens/fatal-error/component.js +1 -1
- package/components/screens/fatal-error/index.css +6 -6
- package/components/screens/hint/component.js +1 -1
- package/components/screens/hint/index.css +15 -14
- package/components/screens/initial/component.js +1 -1
- package/components/screens/initial/countdown-section.js +1 -1
- package/components/screens/initial/index.css +20 -19
- package/components/screens/temp-block/component.js +1 -1
- package/components/screens/temp-block/index.css +7 -7
- package/{countdown-section-846c8aba.js → countdown-section-343aaa69.js} +1 -1
- package/cssm/components/base-confirmation/index.module.css +2 -1
- package/cssm/components/screens/hint/index.module.css +3 -2
- package/cssm/components/screens/initial/index.module.css +2 -1
- package/esm/components/base-confirmation/component.js +1 -1
- package/esm/components/base-confirmation/index.css +4 -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/screens/fatal-error/component.js +1 -1
- package/esm/components/screens/fatal-error/index.css +6 -6
- package/esm/components/screens/hint/component.js +1 -1
- package/esm/components/screens/hint/index.css +15 -14
- package/esm/components/screens/initial/component.js +1 -1
- package/esm/components/screens/initial/countdown-section.js +1 -1
- package/esm/components/screens/initial/index.css +20 -19
- package/esm/components/screens/temp-block/component.js +1 -1
- package/esm/components/screens/temp-block/index.css +7 -7
- package/esm/{countdown-section-56b1951d.js → countdown-section-e0c0af6b.js} +1 -1
- package/esm/mobile/component.mobile.js +1 -1
- package/esm/mobile/mobile.css +2 -2
- package/mobile/component.mobile.js +1 -1
- package/mobile/mobile.css +2 -2
- package/modern/components/base-confirmation/component.js +1 -1
- package/modern/components/base-confirmation/index.css +4 -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/screens/fatal-error/component.js +1 -1
- package/modern/components/screens/fatal-error/index.css +6 -6
- package/modern/components/screens/hint/component.js +1 -1
- package/modern/components/screens/hint/index.css +15 -14
- package/modern/components/screens/initial/component.js +1 -1
- package/modern/components/screens/initial/countdown-section.js +1 -1
- package/modern/components/screens/initial/index.css +20 -19
- package/modern/components/screens/temp-block/component.js +1 -1
- package/modern/components/screens/temp-block/index.css +7 -7
- package/modern/{countdown-section-904527f9.js → countdown-section-2b4a5603.js} +1 -1
- package/modern/mobile/component.mobile.js +1 -1
- package/modern/mobile/mobile.css +2 -2
- package/moderncssm/component.responsive.d.ts +15 -0
- package/moderncssm/component.responsive.js +11 -0
- package/moderncssm/components/base-confirmation/component.d.ts +4 -0
- package/moderncssm/components/base-confirmation/component.js +85 -0
- package/moderncssm/components/base-confirmation/index.d.ts +1 -0
- package/moderncssm/components/base-confirmation/index.js +1 -0
- package/moderncssm/components/base-confirmation/index.module.css +8 -0
- package/moderncssm/components/countdown-loader/component.d.ts +7 -0
- package/moderncssm/components/countdown-loader/component.js +18 -0
- package/moderncssm/components/countdown-loader/index.d.ts +1 -0
- package/moderncssm/components/countdown-loader/index.js +1 -0
- package/moderncssm/components/countdown-loader/index.module.css +7 -0
- package/moderncssm/components/header/component.d.ts +13 -0
- package/moderncssm/components/header/component.js +8 -0
- package/moderncssm/components/header/index.d.ts +1 -0
- package/moderncssm/components/header/index.js +1 -0
- package/moderncssm/components/header/index.module.css +40 -0
- package/moderncssm/components/index.d.ts +2 -0
- package/moderncssm/components/index.js +5 -0
- package/moderncssm/components/screens/fatal-error/component.d.ts +9 -0
- package/moderncssm/components/screens/fatal-error/component.js +17 -0
- package/moderncssm/components/screens/fatal-error/index.d.ts +1 -0
- package/moderncssm/components/screens/fatal-error/index.js +1 -0
- package/moderncssm/components/screens/fatal-error/index.module.css +42 -0
- package/moderncssm/components/screens/hint/component.d.ts +9 -0
- package/moderncssm/components/screens/hint/component.js +34 -0
- package/moderncssm/components/screens/hint/index.d.ts +1 -0
- package/moderncssm/components/screens/hint/index.js +1 -0
- package/moderncssm/components/screens/hint/index.module.css +72 -0
- package/moderncssm/components/screens/index.d.ts +4 -0
- package/moderncssm/components/screens/index.js +4 -0
- package/moderncssm/components/screens/initial/component.d.ts +9 -0
- package/moderncssm/components/screens/initial/component.js +102 -0
- package/moderncssm/components/screens/initial/countdown-section.d.ts +10 -0
- package/moderncssm/components/screens/initial/countdown-section.js +34 -0
- package/moderncssm/components/screens/initial/index.d.ts +1 -0
- package/moderncssm/components/screens/initial/index.js +1 -0
- package/moderncssm/components/screens/initial/index.module.css +97 -0
- package/moderncssm/components/screens/temp-block/component.d.ts +9 -0
- package/moderncssm/components/screens/temp-block/component.js +29 -0
- package/moderncssm/components/screens/temp-block/index.d.ts +1 -0
- package/moderncssm/components/screens/temp-block/index.js +1 -0
- package/moderncssm/components/screens/temp-block/index.module.css +47 -0
- package/moderncssm/context.d.ts +4 -0
- package/moderncssm/context.js +26 -0
- package/moderncssm/desktop/component.desktop.d.ts +5 -0
- package/moderncssm/desktop/component.desktop.js +6 -0
- package/moderncssm/desktop/index.d.ts +2 -0
- package/moderncssm/desktop/index.js +2 -0
- package/moderncssm/index.d.ts +2 -0
- package/moderncssm/index.js +2 -0
- package/moderncssm/mobile/component.mobile.d.ts +5 -0
- package/moderncssm/mobile/component.mobile.js +8 -0
- package/moderncssm/mobile/index.d.ts +2 -0
- package/moderncssm/mobile/index.js +2 -0
- package/moderncssm/mobile/mobile.module.css +3 -0
- package/moderncssm/shared/index.d.ts +4 -0
- package/moderncssm/shared/index.js +8 -0
- package/moderncssm/types.d.ts +167 -0
- package/moderncssm/types.js +19 -0
- package/moderncssm/utils.d.ts +30 -0
- package/moderncssm/utils.js +72 -0
- package/moderncssm/vars.css +11 -0
- package/package.json +8 -8
- package/src/components/base-confirmation/index.module.css +2 -2
- package/src/components/countdown-loader/index.module.css +1 -1
- package/src/components/screens/hint/index.module.css +2 -2
- package/src/components/screens/initial/index.module.css +1 -1
- package/src/vars.css +1 -1
- /package/{countdown-section-846c8aba.d.ts → countdown-section-343aaa69.d.ts} +0 -0
- /package/esm/{countdown-section-56b1951d.d.ts → countdown-section-e0c0af6b.d.ts} +0 -0
- /package/modern/{countdown-section-904527f9.d.ts → countdown-section-2b4a5603.d.ts} +0 -0
|
@@ -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: var(--gap-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: var(--gap-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,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: var(--gap-0);
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
.containerInput {
|
|
96
|
+
min-height: 80px;
|
|
97
|
+
}
|
|
@@ -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,26 @@
|
|
|
1
|
+
import { createContext } from 'react';
|
|
2
|
+
import { ONE_MINUTE, ONE_DAY } from './utils.js';
|
|
3
|
+
|
|
4
|
+
const mockFn = () => undefined;
|
|
5
|
+
const ConfirmationContext = createContext({
|
|
6
|
+
alignContent: 'left',
|
|
7
|
+
texts: {},
|
|
8
|
+
state: 'INITIAL',
|
|
9
|
+
screen: 'INITIAL',
|
|
10
|
+
requiredCharAmount: 5,
|
|
11
|
+
countdownDuration: ONE_MINUTE,
|
|
12
|
+
timeLeft: ONE_MINUTE,
|
|
13
|
+
tempBlockDuration: ONE_DAY,
|
|
14
|
+
phone: '',
|
|
15
|
+
hideCountdownSection: false,
|
|
16
|
+
breakpoint: 1024,
|
|
17
|
+
initialScreenHintSlot: null,
|
|
18
|
+
onTempBlockFinished: mockFn,
|
|
19
|
+
onInputFinished: mockFn,
|
|
20
|
+
onChangeState: mockFn,
|
|
21
|
+
onSmsRetryClick: mockFn,
|
|
22
|
+
onChangeScreen: mockFn,
|
|
23
|
+
onFatalErrorOkButtonClick: mockFn,
|
|
24
|
+
});
|
|
25
|
+
|
|
26
|
+
export { ConfirmationContext };
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { FC } from 'react';
|
|
2
|
+
import { ConfirmationProps } from "../types";
|
|
3
|
+
type DesktopConfirmationProps = Omit<ConfirmationProps, 'mobile' | 'breakpoint'>;
|
|
4
|
+
declare const ConfirmationDesktop: FC<DesktopConfirmationProps>;
|
|
5
|
+
export { DesktopConfirmationProps, ConfirmationDesktop };
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import cn from 'classnames';
|
|
3
|
+
import { BaseConfirmation } from '../components/base-confirmation/component.js';
|
|
4
|
+
import styles from './mobile.module.css';
|
|
5
|
+
|
|
6
|
+
const ConfirmationMobile = ({ className, ...resProps }) => (React.createElement(BaseConfirmation, { mobile: true, className: cn(className, styles.container), ...resProps }));
|
|
7
|
+
|
|
8
|
+
export { ConfirmationMobile };
|
|
@@ -0,0 +1,8 @@
|
|
|
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';
|