@alfalab/core-components-confirmation 13.6.3 → 13.7.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/components/base-confirmation/component.js +1 -1
- package/components/base-confirmation/index.css +2 -2
- 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 +12 -12
- package/components/screens/initial/component.js +1 -1
- package/components/screens/initial/countdown-section.js +1 -1
- package/components/screens/initial/index.css +18 -18
- 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-17d446a6.js} +1 -1
- package/esm/components/base-confirmation/component.js +1 -1
- package/esm/components/base-confirmation/index.css +2 -2
- 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 +12 -12
- 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 +18 -18
- 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-c5b45e8c.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 +2 -2
- 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 +12 -12
- 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 +18 -18
- 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-b9145aea.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 +1 -1
- package/src/components/countdown-loader/index.module.css +1 -1
- package/src/vars.css +1 -1
- /package/{countdown-section-846c8aba.d.ts → countdown-section-17d446a6.d.ts} +0 -0
- /package/esm/{countdown-section-56b1951d.d.ts → countdown-section-c5b45e8c.d.ts} +0 -0
- /package/modern/{countdown-section-904527f9.d.ts → countdown-section-b9145aea.d.ts} +0 -0
|
@@ -0,0 +1,85 @@
|
|
|
1
|
+
import React, { useEffect, useMemo } from 'react';
|
|
2
|
+
import cn from 'classnames';
|
|
3
|
+
import { usePrevious } from '@alfalab/hooks';
|
|
4
|
+
import { ConfirmationContext } from '../../context.js';
|
|
5
|
+
import { defaultTexts } from '../../types.js';
|
|
6
|
+
import { useCountdown, ONE_MINUTE, ONE_DAY } from '../../utils.js';
|
|
7
|
+
import { Initial } from '../screens/initial/component.js';
|
|
8
|
+
import { Hint } from '../screens/hint/component.js';
|
|
9
|
+
import { FatalError } from '../screens/fatal-error/component.js';
|
|
10
|
+
import { TempBlock } from '../screens/temp-block/component.js';
|
|
11
|
+
import styles from './index.module.css';
|
|
12
|
+
|
|
13
|
+
const confirmationScreens = {
|
|
14
|
+
INITIAL: Initial,
|
|
15
|
+
HINT: Hint,
|
|
16
|
+
FATAL_ERROR: FatalError,
|
|
17
|
+
TEMP_BLOCK: TempBlock,
|
|
18
|
+
};
|
|
19
|
+
const BaseConfirmation = ({ state, screen, alignContent = 'left', children, requiredCharAmount = 5, countdownDuration = ONE_MINUTE, tempBlockDuration = ONE_DAY, phone, blockSmsRetry, dataTestId, className, getScreensMap, onInputFinished, onChangeState, onSmsRetryClick, onChangeScreen, onFatalErrorOkButtonClick, onTempBlockFinished, mobile, clearCodeOnError = true, hideCountdownSection = false, breakpoint = 1024, initialScreenHintSlot, errorVisibleDuration, ...restProps }) => {
|
|
20
|
+
const [timeLeft, startTimer, stopTimer] = useCountdown(countdownDuration);
|
|
21
|
+
const prevState = usePrevious(state);
|
|
22
|
+
useEffect(() => {
|
|
23
|
+
startTimer();
|
|
24
|
+
}, [startTimer]);
|
|
25
|
+
useEffect(() => {
|
|
26
|
+
/**
|
|
27
|
+
* Перезапускаем таймер после повторного запроса кода
|
|
28
|
+
*/
|
|
29
|
+
if (state === 'INITIAL' && prevState === 'CODE_SENDING') {
|
|
30
|
+
startTimer();
|
|
31
|
+
}
|
|
32
|
+
}, [state, prevState, startTimer]);
|
|
33
|
+
useEffect(() => {
|
|
34
|
+
/**
|
|
35
|
+
* Останавливаем таймер, если новый экран/состояние не содержит таймер
|
|
36
|
+
*/
|
|
37
|
+
if (!['INITIAL', 'HINT', 'TEMP_BLOCK'].includes(screen) || blockSmsRetry) {
|
|
38
|
+
stopTimer();
|
|
39
|
+
}
|
|
40
|
+
}, [state, screen, blockSmsRetry, stopTimer]);
|
|
41
|
+
const handleSmsRetry = () => {
|
|
42
|
+
onChangeState('CODE_SENDING');
|
|
43
|
+
onSmsRetryClick();
|
|
44
|
+
};
|
|
45
|
+
const handleInputFinished = (code) => {
|
|
46
|
+
onChangeState('CODE_CHECKING');
|
|
47
|
+
onInputFinished(code);
|
|
48
|
+
};
|
|
49
|
+
const handleFatalErrorOkButtonClick = () => {
|
|
50
|
+
if (onFatalErrorOkButtonClick) {
|
|
51
|
+
onFatalErrorOkButtonClick();
|
|
52
|
+
}
|
|
53
|
+
};
|
|
54
|
+
// eslint-disable-next-line react/jsx-no-constructed-context-values
|
|
55
|
+
const contextValue = {
|
|
56
|
+
hideCountdownSection,
|
|
57
|
+
alignContent,
|
|
58
|
+
texts: { ...defaultTexts, ...restProps.texts },
|
|
59
|
+
state,
|
|
60
|
+
screen,
|
|
61
|
+
requiredCharAmount,
|
|
62
|
+
countdownDuration,
|
|
63
|
+
timeLeft,
|
|
64
|
+
tempBlockDuration,
|
|
65
|
+
phone,
|
|
66
|
+
blockSmsRetry,
|
|
67
|
+
breakpoint,
|
|
68
|
+
onTempBlockFinished,
|
|
69
|
+
onChangeState,
|
|
70
|
+
onChangeScreen,
|
|
71
|
+
clearCodeOnError,
|
|
72
|
+
errorVisibleDuration,
|
|
73
|
+
initialScreenHintSlot,
|
|
74
|
+
onInputFinished: handleInputFinished,
|
|
75
|
+
onSmsRetryClick: handleSmsRetry,
|
|
76
|
+
onFatalErrorOkButtonClick: handleFatalErrorOkButtonClick,
|
|
77
|
+
};
|
|
78
|
+
const customScreen = useMemo(() => getScreensMap && getScreensMap(confirmationScreens), [getScreensMap]);
|
|
79
|
+
const screensMap = customScreen || confirmationScreens;
|
|
80
|
+
const CurrentScreen = screensMap[screen];
|
|
81
|
+
return (React.createElement(ConfirmationContext.Provider, { value: contextValue },
|
|
82
|
+
React.createElement("div", { className: cn(styles.component, className), "data-test-id": dataTestId }, CurrentScreen && React.createElement(CurrentScreen, { mobile: mobile }))));
|
|
83
|
+
};
|
|
84
|
+
|
|
85
|
+
export { BaseConfirmation };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./component";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { BaseConfirmation } from './component.js';
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import styles from './index.module.css';
|
|
3
|
+
|
|
4
|
+
const SIZE = 16;
|
|
5
|
+
const STROKE_WIDTH = 2;
|
|
6
|
+
const CENTER = SIZE / 2;
|
|
7
|
+
const RADIUS = CENTER - STROKE_WIDTH / 2;
|
|
8
|
+
/** Длина окружности */
|
|
9
|
+
const CIRCUMFERENCE = Math.PI * RADIUS * 2;
|
|
10
|
+
const CountdownLoader = ({ progress, className }) => {
|
|
11
|
+
const value = Math.min(progress, 1);
|
|
12
|
+
const strokeDasharray = CIRCUMFERENCE.toFixed(2);
|
|
13
|
+
const strokeDashoffset = (value * CIRCUMFERENCE).toFixed(2);
|
|
14
|
+
return (React.createElement("svg", { width: SIZE, height: SIZE, viewBox: `0 0 ${SIZE} ${SIZE}`, className: className },
|
|
15
|
+
React.createElement("circle", { cx: CENTER, cy: CENTER, r: RADIUS, strokeDasharray: strokeDasharray, strokeDashoffset: strokeDashoffset, transform: `rotate(-90 ${CENTER} ${CENTER})`, className: styles.circle })));
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
export { CountdownLoader };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./component";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { CountdownLoader } from './component.js';
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { FC, ReactNode } from 'react';
|
|
2
|
+
type HeaderProps = {
|
|
3
|
+
/**
|
|
4
|
+
* Контент шапки
|
|
5
|
+
*/
|
|
6
|
+
children?: ReactNode;
|
|
7
|
+
/**
|
|
8
|
+
* Отображать в мобильной версии экран компонента
|
|
9
|
+
*/
|
|
10
|
+
mobile?: boolean;
|
|
11
|
+
};
|
|
12
|
+
declare const Header: FC<HeaderProps>;
|
|
13
|
+
export { HeaderProps, Header };
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import cn from 'classnames';
|
|
3
|
+
import { Typography } from '@alfalab/core-components-typography/moderncssm';
|
|
4
|
+
import styles from './index.module.css';
|
|
5
|
+
|
|
6
|
+
const Header = ({ mobile, children }) => (React.createElement(Typography.Title, { className: cn(styles.header, styles.typography, { [styles.typographyMobile]: mobile }), tag: 'h3', color: 'primary' }, children));
|
|
7
|
+
|
|
8
|
+
export { Header };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./component";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { Header } from './component.js';
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
/* */
|
|
2
|
+
|
|
3
|
+
:root {
|
|
4
|
+
/* desktop */
|
|
5
|
+
--confirmation-header-desktop-font-size: 22px;
|
|
6
|
+
--confirmation-header-desktop-line-height: 26px;
|
|
7
|
+
--confirmation-header-desktop-font-weight: bold;
|
|
8
|
+
--confirmation-header-desktop-font-family: var(--font-family-system);
|
|
9
|
+
|
|
10
|
+
/* mobile */
|
|
11
|
+
--confirmation-header-mobile-font-size: 20px;
|
|
12
|
+
--confirmation-header-mobile-line-height: 28px;
|
|
13
|
+
--confirmation-header-mobile-font-weight: 600;
|
|
14
|
+
--confirmation-header-mobile-font-family: var(--font-family-system);
|
|
15
|
+
|
|
16
|
+
/* text */
|
|
17
|
+
|
|
18
|
+
/* header */
|
|
19
|
+
--confirmation-header-font-feature-settings: normal
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
.header.header {
|
|
23
|
+
margin-bottom: var(--gap-24);
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
.typography.typography.typography {
|
|
27
|
+
font-feature-settings: var(--confirmation-header-font-feature-settings);
|
|
28
|
+
font-size: var(--confirmation-header-desktop-font-size);
|
|
29
|
+
line-height: var(--confirmation-header-desktop-line-height);
|
|
30
|
+
font-weight: var(--confirmation-header-desktop-font-weight);
|
|
31
|
+
font-family: var(--confirmation-header-desktop-font-family);
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
.typographyMobile.typographyMobile.typographyMobile {
|
|
35
|
+
font-feature-settings: var(--confirmation-header-font-feature-settings);
|
|
36
|
+
font-size: var(--confirmation-header-mobile-font-size);
|
|
37
|
+
line-height: var(--confirmation-header-mobile-line-height);
|
|
38
|
+
font-weight: var(--confirmation-header-mobile-font-weight);
|
|
39
|
+
font-family: var(--confirmation-header-mobile-font-family);
|
|
40
|
+
}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
export { Initial } from './screens/initial/component.js';
|
|
2
|
+
export { Hint } from './screens/hint/component.js';
|
|
3
|
+
export { FatalError } from './screens/fatal-error/component.js';
|
|
4
|
+
export { TempBlock } from './screens/temp-block/component.js';
|
|
5
|
+
export { CountdownLoader } from './countdown-loader/component.js';
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import React, { useContext } from 'react';
|
|
2
|
+
import cn from 'classnames';
|
|
3
|
+
import { Button } from '@alfalab/core-components-button/moderncssm';
|
|
4
|
+
import { Typography } from '@alfalab/core-components-typography/moderncssm';
|
|
5
|
+
import { ConfirmationContext } from '../../../context.js';
|
|
6
|
+
import { Header } from '../../header/component.js';
|
|
7
|
+
import styles from './index.module.css';
|
|
8
|
+
|
|
9
|
+
const FatalError = ({ mobile }) => {
|
|
10
|
+
const { alignContent, texts, onFatalErrorOkButtonClick, breakpoint } = useContext(ConfirmationContext);
|
|
11
|
+
return (React.createElement("div", { className: cn(styles.component, styles[alignContent]) },
|
|
12
|
+
React.createElement(Header, { mobile: mobile }, texts.fatalErrorTitle),
|
|
13
|
+
React.createElement(Typography.Text, { view: 'primary-medium', color: 'primary', className: cn({ [styles.typographyTheme]: !mobile }) }, texts.fatalErrorDescription),
|
|
14
|
+
React.createElement(Button, { size: mobile ? 'xs' : 's', view: 'secondary', onClick: onFatalErrorOkButtonClick, className: styles.button, breakpoint: breakpoint }, texts.fatalErrorButton)));
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
export { FatalError };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./component";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { FatalError } from './component.js';
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
/* */
|
|
2
|
+
|
|
3
|
+
:root {
|
|
4
|
+
/* desktop */
|
|
5
|
+
|
|
6
|
+
/* mobile */
|
|
7
|
+
|
|
8
|
+
/* text */
|
|
9
|
+
--confirmation-text-font-size: 16px;
|
|
10
|
+
--confirmation-text-line-height: 24px;
|
|
11
|
+
--confirmation-text-font-weight: 400;
|
|
12
|
+
--confirmation-text-font-family: var(--font-family-system);
|
|
13
|
+
--confirmation-text-color: var(--color-light-text-primary)
|
|
14
|
+
|
|
15
|
+
/* header */
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
.component {
|
|
19
|
+
display: flex;
|
|
20
|
+
flex-direction: column;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
.typographyTheme.typographyTheme {
|
|
24
|
+
font-size: var(--confirmation-text-font-size);
|
|
25
|
+
line-height: var(--confirmation-text-line-height);
|
|
26
|
+
font-weight: var(--confirmation-text-font-weight);
|
|
27
|
+
font-family: var(--confirmation-text-font-family);
|
|
28
|
+
color: var(--confirmation-text-color);
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
.left {
|
|
32
|
+
align-items: flex-start;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
.center {
|
|
36
|
+
align-items: center;
|
|
37
|
+
text-align: center;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
.button.button {
|
|
41
|
+
margin-top: var(--gap-32);
|
|
42
|
+
}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import React, { useContext } from 'react';
|
|
2
|
+
import cn from 'classnames';
|
|
3
|
+
import { Button } from '@alfalab/core-components-button/moderncssm';
|
|
4
|
+
import { Link } from '@alfalab/core-components-link/moderncssm';
|
|
5
|
+
import { Typography } from '@alfalab/core-components-typography/moderncssm';
|
|
6
|
+
import { ConfirmationContext } from '../../../context.js';
|
|
7
|
+
import { Header } from '../../header/component.js';
|
|
8
|
+
import styles from './index.module.css';
|
|
9
|
+
|
|
10
|
+
const Hint = ({ mobile }) => {
|
|
11
|
+
const { alignContent, texts, onChangeScreen, onChangeState, breakpoint } = useContext(ConfirmationContext);
|
|
12
|
+
const handleReturnButtonClick = () => {
|
|
13
|
+
onChangeScreen('INITIAL');
|
|
14
|
+
onChangeState('INITIAL');
|
|
15
|
+
};
|
|
16
|
+
return (React.createElement("div", { className: cn(styles.component, styles[alignContent]) },
|
|
17
|
+
React.createElement(Header, { mobile: mobile }, "\u041D\u0435\u00A0\u043F\u0440\u0438\u0445\u043E\u0434\u0438\u0442 \u0441\u043E\u043E\u0431\u0449\u0435\u043D\u0438\u0435?"),
|
|
18
|
+
React.createElement(Typography.Text, { view: 'primary-medium', color: 'primary', className: cn(styles.text, { [styles.typographyTheme]: !mobile }) }, "\u0415\u0441\u043B\u0438 \u0443\u00A0\u0432\u0430\u0441 \u0438\u0437\u043C\u0435\u043D\u0438\u043B\u0441\u044F \u043D\u043E\u043C\u0435\u0440 \u0442\u0435\u043B\u0435\u0444\u043E\u043D\u0430, \u043F\u043E\u0437\u0432\u043E\u043D\u0438\u0442\u0435 \u043D\u0430\u043C \u0438\u043B\u0438 \u043E\u0431\u0440\u0430\u0442\u0438\u0442\u0435\u0441\u044C \u0432\u00A0\u043B\u044E\u0431\u043E\u0435 \u043E\u0442\u0434\u0435\u043B\u0435\u043D\u0438\u0435 \u0431\u0430\u043D\u043A\u0430."),
|
|
19
|
+
React.createElement("div", { className: styles.phonesWrap },
|
|
20
|
+
React.createElement("div", { className: cn(styles.phoneWrap, { [styles.phoneContentMobile]: mobile }) },
|
|
21
|
+
React.createElement(Link, { href: 'tel:+78002000000', underline: false, className: styles.phoneLink }, "8 800 200 00 00"),
|
|
22
|
+
React.createElement(Typography.Text, { view: 'primary-medium', color: 'primary', className: cn(styles.text, { [styles.typographyTheme]: !mobile }) }, mobile
|
|
23
|
+
? 'Для\u00A0звонков по\u00A0России'
|
|
24
|
+
: ' \u2014\u00A0для звонков по\u00A0России')),
|
|
25
|
+
React.createElement("div", { className: cn(styles.phoneWrap, { [styles.phoneContentMobile]: mobile }) },
|
|
26
|
+
React.createElement(Link, { href: 'tel:+74957888878', underline: false, className: styles.phoneLink }, "+7 495 78 888 78"),
|
|
27
|
+
React.createElement(Typography.Text, { view: 'primary-medium', color: 'primary', className: cn(styles.text, { [styles.typographyTheme]: !mobile }) }, mobile
|
|
28
|
+
? 'В\u00A0Москве и\u00A0за\u00A0границей'
|
|
29
|
+
: ' \u2014\u00A0в\u00A0Москве и\u00A0за\u00A0границей'))),
|
|
30
|
+
React.createElement(Typography.Text, { view: 'primary-medium', color: 'primary', className: cn(styles.text, { [styles.typographyTheme]: !mobile }) }, "\u0415\u0441\u043B\u0438 \u043D\u043E\u043C\u0435\u0440 \u043D\u0435\u00A0\u043C\u0435\u043D\u044F\u043B\u0441\u044F, \u0432\u043E\u0437\u043C\u043E\u0436\u043D\u043E, \u043F\u0435\u0440\u0435\u0433\u0440\u0443\u0436\u0435\u043D \u0441\u0435\u0440\u0432\u0438\u0441 \u043E\u0442\u043F\u0440\u0430\u0432\u043A\u0438 \u0441\u043E\u043E\u0431\u0449\u0435\u043D\u0438\u0439. \u041F\u043E\u043F\u0440\u043E\u0431\u0443\u0439\u0442\u0435 \u043F\u043E\u0432\u0442\u043E\u0440\u0438\u0442\u044C \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u0435 \u0447\u0435\u0440\u0435\u0437 \u043D\u0435\u0441\u043A\u043E\u043B\u044C\u043A\u043E \u043C\u0438\u043D\u0443\u0442."),
|
|
31
|
+
React.createElement(Button, { size: mobile ? 'xs' : 's', view: 'secondary', onClick: handleReturnButtonClick, className: styles.hintButton, breakpoint: breakpoint }, texts.hintButton)));
|
|
32
|
+
};
|
|
33
|
+
|
|
34
|
+
export { Hint };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./component";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export { Hint } from './component.js';
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
/* */
|
|
2
|
+
|
|
3
|
+
:root {
|
|
4
|
+
/* desktop */
|
|
5
|
+
|
|
6
|
+
/* mobile */
|
|
7
|
+
|
|
8
|
+
/* text */
|
|
9
|
+
--confirmation-text-font-size: 16px;
|
|
10
|
+
--confirmation-text-line-height: 24px;
|
|
11
|
+
--confirmation-text-font-weight: 400;
|
|
12
|
+
--confirmation-text-font-family: var(--font-family-system);
|
|
13
|
+
--confirmation-text-color: var(--color-light-text-primary)
|
|
14
|
+
|
|
15
|
+
/* header */
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
.component {
|
|
19
|
+
display: flex;
|
|
20
|
+
flex-direction: column;
|
|
21
|
+
align-items: flex-start
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
.component span:last-of-type {
|
|
25
|
+
margin-bottom: 0;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
.center {
|
|
29
|
+
align-items: center;
|
|
30
|
+
text-align: center;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
.text.text {
|
|
34
|
+
margin-bottom: var(--gap-24);
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
.typographyTheme.typographyTheme {
|
|
38
|
+
font-size: var(--confirmation-text-font-size);
|
|
39
|
+
line-height: var(--confirmation-text-line-height);
|
|
40
|
+
font-weight: var(--confirmation-text-font-weight);
|
|
41
|
+
font-family: var(--confirmation-text-font-family);
|
|
42
|
+
color: var(--confirmation-text-color);
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
.phonesWrap {
|
|
46
|
+
display: flex;
|
|
47
|
+
flex-direction: column;
|
|
48
|
+
margin-bottom: var(--gap-24);
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
.phoneWrap {
|
|
52
|
+
margin-bottom: var(--gap-8)
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
.phoneWrap:last-child {
|
|
56
|
+
margin-bottom: 0;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
.phoneLink.phoneLink {
|
|
60
|
+
font-size: 16px;
|
|
61
|
+
line-height: 24px;
|
|
62
|
+
font-weight: 500;
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
.hintButton {
|
|
66
|
+
margin-top: var(--gap-32);
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
.phoneContentMobile {
|
|
70
|
+
display: flex;
|
|
71
|
+
flex-direction: column;
|
|
72
|
+
}
|
|
@@ -0,0 +1,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';
|