@alfalab/core-components-confirmation 14.0.1 → 14.1.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.responsive.d.ts +2 -2
- package/component.responsive.js.map +1 -1
- package/components/base-confirmation/component.d.ts +2 -2
- package/components/base-confirmation/component.js +4 -3
- package/components/base-confirmation/component.js.map +1 -1
- package/components/base-confirmation/index.css +3 -3
- package/components/base-confirmation/index.module.css.js +1 -1
- package/components/base-confirmation/index.module.css.js.map +1 -1
- package/components/countdown-loader/component.d.ts +1 -1
- package/components/countdown-loader/component.js.map +1 -1
- package/components/countdown-loader/index.css +1 -1
- package/components/countdown-loader/index.module.css.js +1 -1
- package/components/countdown-loader/index.module.css.js.map +1 -1
- package/components/header/component.d.ts +6 -1
- package/components/header/component.js +2 -2
- package/components/header/component.js.map +1 -1
- package/components/header/index.css +5 -5
- package/components/header/index.module.css.js +1 -1
- package/components/screens/fatal-error/component.d.ts +1 -1
- package/components/screens/fatal-error/component.js +2 -2
- package/components/screens/fatal-error/component.js.map +1 -1
- package/components/screens/fatal-error/index.css +8 -10
- package/components/screens/fatal-error/index.module.css.js +1 -1
- package/components/screens/hint/component.d.ts +1 -1
- package/components/screens/hint/component.js +2 -2
- package/components/screens/hint/component.js.map +1 -1
- package/components/screens/hint/index.css +16 -18
- package/components/screens/hint/index.module.css.js +1 -1
- package/components/screens/initial/component.d.ts +1 -1
- package/components/screens/initial/component.js +2 -2
- package/components/screens/initial/component.js.map +1 -1
- package/components/screens/initial/countdown-section.d.ts +1 -1
- package/components/screens/initial/countdown-section.js.map +1 -1
- package/components/screens/initial/index.css +22 -24
- package/components/screens/initial/index.module.css.js +1 -1
- package/components/screens/temp-block/component.d.ts +1 -1
- package/components/screens/temp-block/component.js +2 -2
- package/components/screens/temp-block/component.js.map +1 -1
- package/components/screens/temp-block/index.css +10 -12
- package/components/screens/temp-block/index.module.css.js +1 -1
- package/components/screens/temp-block-over/component.d.ts +1 -1
- package/components/screens/temp-block-over/component.js +2 -2
- package/components/screens/temp-block-over/component.js.map +1 -1
- package/components/screens/temp-block-over/index.css +7 -9
- package/components/screens/temp-block-over/index.module.css.js +1 -1
- package/context.d.ts +1 -1
- package/context.js +1 -0
- package/context.js.map +1 -1
- package/cssm/component.responsive.d.ts +2 -2
- package/cssm/component.responsive.js.map +1 -1
- package/cssm/components/base-confirmation/component.d.ts +2 -2
- package/cssm/components/base-confirmation/component.js +4 -3
- package/cssm/components/base-confirmation/component.js.map +1 -1
- package/cssm/components/base-confirmation/index.module.css +1 -1
- package/cssm/components/countdown-loader/component.d.ts +1 -1
- package/cssm/components/countdown-loader/component.js.map +1 -1
- package/cssm/components/header/component.d.ts +6 -1
- package/cssm/components/header/component.js +2 -2
- package/cssm/components/header/component.js.map +1 -1
- package/cssm/components/header/index.module.css +2 -2
- package/cssm/components/screens/fatal-error/component.d.ts +1 -1
- package/cssm/components/screens/fatal-error/component.js +2 -2
- package/cssm/components/screens/fatal-error/component.js.map +1 -1
- package/cssm/components/screens/fatal-error/index.module.css +2 -4
- package/cssm/components/screens/hint/component.d.ts +1 -1
- package/cssm/components/screens/hint/component.js +2 -2
- package/cssm/components/screens/hint/component.js.map +1 -1
- package/cssm/components/screens/hint/index.module.css +4 -6
- package/cssm/components/screens/initial/component.d.ts +1 -1
- package/cssm/components/screens/initial/component.js +2 -2
- package/cssm/components/screens/initial/component.js.map +1 -1
- package/cssm/components/screens/initial/countdown-section.d.ts +1 -1
- package/cssm/components/screens/initial/countdown-section.js.map +1 -1
- package/cssm/components/screens/initial/index.module.css +3 -5
- package/cssm/components/screens/temp-block/component.d.ts +1 -1
- package/cssm/components/screens/temp-block/component.js +2 -2
- package/cssm/components/screens/temp-block/component.js.map +1 -1
- package/cssm/components/screens/temp-block/index.module.css +2 -4
- package/cssm/components/screens/temp-block-over/component.d.ts +1 -1
- package/cssm/components/screens/temp-block-over/component.js +2 -2
- package/cssm/components/screens/temp-block-over/component.js.map +1 -1
- package/cssm/components/screens/temp-block-over/index.module.css +2 -4
- package/cssm/context.d.ts +1 -1
- package/cssm/context.js +1 -0
- package/cssm/context.js.map +1 -1
- package/cssm/desktop/component.desktop.d.ts +2 -2
- package/cssm/desktop/component.desktop.js.map +1 -1
- package/cssm/mobile/component.mobile.d.ts +2 -2
- package/cssm/mobile/component.mobile.js.map +1 -1
- package/cssm/types.d.ts +13 -8
- package/cssm/types.js.map +1 -1
- package/cssm/utils.d.ts +1 -1
- package/cssm/utils.js.map +1 -1
- package/desktop/component.desktop.d.ts +2 -2
- package/desktop/component.desktop.js.map +1 -1
- package/esm/component.responsive.d.ts +2 -2
- package/esm/component.responsive.js.map +1 -1
- package/esm/components/base-confirmation/component.d.ts +2 -2
- package/esm/components/base-confirmation/component.js +4 -3
- package/esm/components/base-confirmation/component.js.map +1 -1
- package/esm/components/base-confirmation/index.css +3 -3
- package/esm/components/base-confirmation/index.module.css.js +1 -1
- package/esm/components/base-confirmation/index.module.css.js.map +1 -1
- package/esm/components/countdown-loader/component.d.ts +1 -1
- package/esm/components/countdown-loader/component.js.map +1 -1
- package/esm/components/countdown-loader/index.css +1 -1
- package/esm/components/countdown-loader/index.module.css.js +1 -1
- package/esm/components/countdown-loader/index.module.css.js.map +1 -1
- package/esm/components/header/component.d.ts +6 -1
- package/esm/components/header/component.js +2 -2
- package/esm/components/header/component.js.map +1 -1
- package/esm/components/header/index.css +5 -5
- package/esm/components/header/index.module.css.js +1 -1
- package/esm/components/screens/fatal-error/component.d.ts +1 -1
- package/esm/components/screens/fatal-error/component.js +2 -2
- package/esm/components/screens/fatal-error/component.js.map +1 -1
- package/esm/components/screens/fatal-error/index.css +8 -10
- package/esm/components/screens/fatal-error/index.module.css.js +1 -1
- package/esm/components/screens/hint/component.d.ts +1 -1
- package/esm/components/screens/hint/component.js +2 -2
- package/esm/components/screens/hint/component.js.map +1 -1
- package/esm/components/screens/hint/index.css +16 -18
- package/esm/components/screens/hint/index.module.css.js +1 -1
- package/esm/components/screens/initial/component.d.ts +1 -1
- package/esm/components/screens/initial/component.js +2 -2
- package/esm/components/screens/initial/component.js.map +1 -1
- package/esm/components/screens/initial/countdown-section.d.ts +1 -1
- package/esm/components/screens/initial/countdown-section.js.map +1 -1
- package/esm/components/screens/initial/index.css +22 -24
- package/esm/components/screens/initial/index.module.css.js +1 -1
- package/esm/components/screens/temp-block/component.d.ts +1 -1
- package/esm/components/screens/temp-block/component.js +2 -2
- package/esm/components/screens/temp-block/component.js.map +1 -1
- package/esm/components/screens/temp-block/index.css +10 -12
- package/esm/components/screens/temp-block/index.module.css.js +1 -1
- package/esm/components/screens/temp-block-over/component.d.ts +1 -1
- package/esm/components/screens/temp-block-over/component.js +2 -2
- package/esm/components/screens/temp-block-over/component.js.map +1 -1
- package/esm/components/screens/temp-block-over/index.css +7 -9
- package/esm/components/screens/temp-block-over/index.module.css.js +1 -1
- package/esm/context.d.ts +1 -1
- package/esm/context.js +1 -0
- package/esm/context.js.map +1 -1
- package/esm/desktop/component.desktop.d.ts +2 -2
- package/esm/desktop/component.desktop.js.map +1 -1
- package/esm/mobile/component.mobile.d.ts +2 -2
- package/esm/mobile/component.mobile.js.map +1 -1
- package/esm/mobile/mobile.css +1 -1
- package/esm/mobile/mobile.module.css.js +1 -1
- package/esm/types.d.ts +13 -8
- package/esm/types.js.map +1 -1
- package/esm/utils.d.ts +1 -1
- package/esm/utils.js.map +1 -1
- package/mobile/component.mobile.d.ts +2 -2
- package/mobile/component.mobile.js.map +1 -1
- package/mobile/mobile.css +1 -1
- package/mobile/mobile.module.css.js +1 -1
- package/modern/component.responsive.d.ts +2 -2
- package/modern/component.responsive.js.map +1 -1
- package/modern/components/base-confirmation/component.d.ts +2 -2
- package/modern/components/base-confirmation/component.js +3 -2
- package/modern/components/base-confirmation/component.js.map +1 -1
- package/modern/components/base-confirmation/index.css +3 -3
- package/modern/components/base-confirmation/index.module.css.js +1 -1
- package/modern/components/base-confirmation/index.module.css.js.map +1 -1
- package/modern/components/countdown-loader/component.d.ts +1 -1
- package/modern/components/countdown-loader/component.js.map +1 -1
- package/modern/components/countdown-loader/index.css +1 -1
- package/modern/components/countdown-loader/index.module.css.js +1 -1
- package/modern/components/countdown-loader/index.module.css.js.map +1 -1
- package/modern/components/header/component.d.ts +6 -1
- package/modern/components/header/component.js +1 -1
- package/modern/components/header/component.js.map +1 -1
- package/modern/components/header/index.css +5 -5
- package/modern/components/header/index.module.css.js +1 -1
- package/modern/components/screens/fatal-error/component.d.ts +1 -1
- package/modern/components/screens/fatal-error/component.js +2 -2
- package/modern/components/screens/fatal-error/component.js.map +1 -1
- package/modern/components/screens/fatal-error/index.css +8 -10
- package/modern/components/screens/fatal-error/index.module.css.js +1 -1
- package/modern/components/screens/hint/component.d.ts +1 -1
- package/modern/components/screens/hint/component.js +2 -2
- package/modern/components/screens/hint/component.js.map +1 -1
- package/modern/components/screens/hint/index.css +16 -18
- package/modern/components/screens/hint/index.module.css.js +1 -1
- package/modern/components/screens/initial/component.d.ts +1 -1
- package/modern/components/screens/initial/component.js +2 -2
- package/modern/components/screens/initial/component.js.map +1 -1
- package/modern/components/screens/initial/countdown-section.d.ts +1 -1
- package/modern/components/screens/initial/countdown-section.js.map +1 -1
- package/modern/components/screens/initial/index.css +22 -24
- package/modern/components/screens/initial/index.module.css.js +1 -1
- package/modern/components/screens/temp-block/component.d.ts +1 -1
- package/modern/components/screens/temp-block/component.js +2 -2
- package/modern/components/screens/temp-block/component.js.map +1 -1
- package/modern/components/screens/temp-block/index.css +10 -12
- package/modern/components/screens/temp-block/index.module.css.js +1 -1
- package/modern/components/screens/temp-block-over/component.d.ts +1 -1
- package/modern/components/screens/temp-block-over/component.js +2 -2
- package/modern/components/screens/temp-block-over/component.js.map +1 -1
- package/modern/components/screens/temp-block-over/index.css +7 -9
- package/modern/components/screens/temp-block-over/index.module.css.js +1 -1
- package/modern/context.d.ts +1 -1
- package/modern/context.js +1 -0
- package/modern/context.js.map +1 -1
- package/modern/desktop/component.desktop.d.ts +2 -2
- package/modern/desktop/component.desktop.js.map +1 -1
- package/modern/mobile/component.mobile.d.ts +2 -2
- package/modern/mobile/component.mobile.js.map +1 -1
- package/modern/mobile/mobile.css +1 -1
- package/modern/mobile/mobile.module.css.js +1 -1
- package/modern/types.d.ts +13 -8
- package/modern/types.js.map +1 -1
- package/modern/utils.d.ts +1 -1
- package/modern/utils.js.map +1 -1
- package/moderncssm/component.responsive.d.ts +2 -2
- package/moderncssm/component.responsive.js.map +1 -1
- package/moderncssm/components/base-confirmation/component.d.ts +2 -2
- package/moderncssm/components/base-confirmation/component.js +3 -2
- package/moderncssm/components/base-confirmation/component.js.map +1 -1
- package/moderncssm/components/base-confirmation/index.module.css +3 -2
- package/moderncssm/components/countdown-loader/component.d.ts +1 -1
- package/moderncssm/components/countdown-loader/component.js.map +1 -1
- package/moderncssm/components/countdown-loader/index.module.css +2 -0
- package/moderncssm/components/header/component.d.ts +6 -1
- package/moderncssm/components/header/component.js +1 -1
- package/moderncssm/components/header/component.js.map +1 -1
- package/moderncssm/components/header/index.module.css +2 -0
- package/moderncssm/components/screens/fatal-error/component.d.ts +1 -1
- package/moderncssm/components/screens/fatal-error/component.js +2 -2
- package/moderncssm/components/screens/fatal-error/component.js.map +1 -1
- package/moderncssm/components/screens/fatal-error/index.module.css +2 -2
- package/moderncssm/components/screens/hint/component.d.ts +1 -1
- package/moderncssm/components/screens/hint/component.js +2 -2
- package/moderncssm/components/screens/hint/component.js.map +1 -1
- package/moderncssm/components/screens/hint/index.module.css +4 -4
- package/moderncssm/components/screens/initial/component.d.ts +1 -1
- package/moderncssm/components/screens/initial/component.js +2 -2
- package/moderncssm/components/screens/initial/component.js.map +1 -1
- package/moderncssm/components/screens/initial/countdown-section.d.ts +1 -1
- package/moderncssm/components/screens/initial/countdown-section.js.map +1 -1
- package/moderncssm/components/screens/initial/index.module.css +3 -3
- package/moderncssm/components/screens/temp-block/component.d.ts +1 -1
- package/moderncssm/components/screens/temp-block/component.js +2 -2
- package/moderncssm/components/screens/temp-block/component.js.map +1 -1
- package/moderncssm/components/screens/temp-block/index.module.css +2 -2
- package/moderncssm/components/screens/temp-block-over/component.d.ts +1 -1
- package/moderncssm/components/screens/temp-block-over/component.js +2 -2
- package/moderncssm/components/screens/temp-block-over/component.js.map +1 -1
- package/moderncssm/components/screens/temp-block-over/index.module.css +2 -2
- package/moderncssm/context.d.ts +1 -1
- package/moderncssm/context.js +1 -0
- package/moderncssm/context.js.map +1 -1
- package/moderncssm/desktop/component.desktop.d.ts +2 -2
- package/moderncssm/desktop/component.desktop.js.map +1 -1
- package/moderncssm/mobile/component.mobile.d.ts +2 -2
- package/moderncssm/mobile/component.mobile.js.map +1 -1
- package/moderncssm/types.d.ts +13 -8
- package/moderncssm/types.js.map +1 -1
- package/moderncssm/utils.d.ts +1 -1
- package/moderncssm/utils.js.map +1 -1
- package/package.json +3 -3
- package/src/component.responsive.tsx +2 -2
- package/src/components/base-confirmation/component.tsx +5 -6
- package/src/components/base-confirmation/index.module.css +1 -1
- package/src/components/countdown-loader/component.tsx +1 -1
- package/src/components/countdown-loader/index.module.css +1 -1
- package/src/components/header/component.tsx +9 -3
- package/src/components/screens/fatal-error/component.tsx +5 -3
- package/src/components/screens/hint/component.tsx +5 -3
- package/src/components/screens/initial/component.tsx +9 -3
- package/src/components/screens/initial/countdown-section.tsx +1 -1
- package/src/components/screens/temp-block/component.tsx +12 -4
- package/src/components/screens/temp-block-over/component.tsx +5 -3
- package/src/context.ts +2 -1
- package/src/desktop/component.desktop.tsx +2 -2
- package/src/mobile/component.mobile.tsx +2 -2
- package/src/types.ts +14 -7
- package/src/utils.ts +1 -1
- package/src/vars.css +1 -1
- package/types.d.ts +13 -8
- package/types.js.map +1 -1
- package/utils.d.ts +1 -1
- package/utils.js.map +1 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import React, { FC, useContext } from 'react';
|
|
1
|
+
import React, { type FC, useContext } from 'react';
|
|
2
2
|
import cn from 'classnames';
|
|
3
3
|
|
|
4
4
|
import { Button } from '@alfalab/core-components-button';
|
|
@@ -17,7 +17,7 @@ export type TempBlockOverProps = {
|
|
|
17
17
|
};
|
|
18
18
|
|
|
19
19
|
export const TempBlockOver: FC<TempBlockOverProps> = ({ mobile }) => {
|
|
20
|
-
const { alignContent, texts, breakpoint, client, onChangeScreen, onChangeState } =
|
|
20
|
+
const { alignContent, titleTag, texts, breakpoint, client, onChangeScreen, onChangeState } =
|
|
21
21
|
useContext(ConfirmationContext);
|
|
22
22
|
|
|
23
23
|
const handleReturnButtonClick = () => {
|
|
@@ -27,7 +27,9 @@ export const TempBlockOver: FC<TempBlockOverProps> = ({ mobile }) => {
|
|
|
27
27
|
|
|
28
28
|
return (
|
|
29
29
|
<div className={cn(styles.component, styles[alignContent])}>
|
|
30
|
-
<Header mobile={mobile}
|
|
30
|
+
<Header mobile={mobile} titleTag={titleTag}>
|
|
31
|
+
{texts.tempBlockOverTitle}
|
|
32
|
+
</Header>
|
|
31
33
|
|
|
32
34
|
<Text
|
|
33
35
|
view='primary-medium'
|
package/src/context.ts
CHANGED
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
import { createContext } from 'react';
|
|
2
2
|
|
|
3
|
-
import { TConfirmationContext } from './types';
|
|
3
|
+
import { type TConfirmationContext } from './types';
|
|
4
4
|
import { ONE_DAY, ONE_MINUTE } from './utils';
|
|
5
5
|
|
|
6
6
|
const mockFn = () => undefined;
|
|
7
7
|
|
|
8
8
|
export const ConfirmationContext = createContext<TConfirmationContext>({
|
|
9
9
|
alignContent: 'left',
|
|
10
|
+
titleTag: 'h3',
|
|
10
11
|
texts: {},
|
|
11
12
|
state: 'INITIAL',
|
|
12
13
|
screen: 'INITIAL',
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import React, { FC } from 'react';
|
|
1
|
+
import React, { type FC } from 'react';
|
|
2
2
|
|
|
3
3
|
import { BaseConfirmation } from '../components/base-confirmation';
|
|
4
|
-
import { ConfirmationProps } from '../types';
|
|
4
|
+
import { type ConfirmationProps } from '../types';
|
|
5
5
|
|
|
6
6
|
export type DesktopConfirmationProps = Omit<ConfirmationProps, 'mobile' | 'breakpoint'>;
|
|
7
7
|
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import React, { FC } from 'react';
|
|
1
|
+
import React, { type FC } from 'react';
|
|
2
2
|
import cn from 'classnames';
|
|
3
3
|
|
|
4
4
|
import { BaseConfirmation } from '../components/base-confirmation';
|
|
5
|
-
import { ConfirmationProps } from '../types';
|
|
5
|
+
import { type ConfirmationProps } from '../types';
|
|
6
6
|
|
|
7
7
|
import styles from './mobile.module.css';
|
|
8
8
|
|
package/src/types.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { ComponentType, ReactNode } from 'react';
|
|
1
|
+
import { type ComponentType, type ReactNode } from 'react';
|
|
2
2
|
|
|
3
|
-
export
|
|
3
|
+
export interface ConfirmationProps {
|
|
4
4
|
/**
|
|
5
5
|
* Экран компонента
|
|
6
6
|
*/
|
|
@@ -21,6 +21,12 @@ export type ConfirmationProps = {
|
|
|
21
21
|
*/
|
|
22
22
|
alignContent?: 'left' | 'center';
|
|
23
23
|
|
|
24
|
+
/**
|
|
25
|
+
* HTML тег для заголовка
|
|
26
|
+
* @default 'h3'
|
|
27
|
+
*/
|
|
28
|
+
titleTag?: 'h1' | 'h2' | 'h3' | 'h4' | 'h5' | 'h6';
|
|
29
|
+
|
|
24
30
|
/**
|
|
25
31
|
* Объект с текстами
|
|
26
32
|
*/
|
|
@@ -133,12 +139,13 @@ export type ConfirmationProps = {
|
|
|
133
139
|
* @default 1300
|
|
134
140
|
*/
|
|
135
141
|
errorVisibleDuration?: number;
|
|
136
|
-
}
|
|
142
|
+
}
|
|
137
143
|
|
|
138
144
|
export type TConfirmationContext = Required<
|
|
139
145
|
Pick<
|
|
140
146
|
ConfirmationProps,
|
|
141
147
|
| 'alignContent'
|
|
148
|
+
| 'titleTag'
|
|
142
149
|
| 'texts'
|
|
143
150
|
| 'state'
|
|
144
151
|
| 'screen'
|
|
@@ -167,7 +174,7 @@ export type TConfirmationContext = Required<
|
|
|
167
174
|
timeLeft: number;
|
|
168
175
|
};
|
|
169
176
|
|
|
170
|
-
export
|
|
177
|
+
export interface ConfirmationTexts {
|
|
171
178
|
/**
|
|
172
179
|
* Экран INITIAL
|
|
173
180
|
*/
|
|
@@ -212,7 +219,7 @@ export type ConfirmationTexts = {
|
|
|
212
219
|
tempBlockOverTitle?: ReactNode; // заголовок
|
|
213
220
|
tempBlockOverDescription?: ReactNode; // описание
|
|
214
221
|
tempBlockOverButton?: string; // кнопка
|
|
215
|
-
}
|
|
222
|
+
}
|
|
216
223
|
|
|
217
224
|
export type ConfirmationScreen =
|
|
218
225
|
| 'INITIAL' // начальный экран
|
|
@@ -229,9 +236,9 @@ export type ConfirmationState =
|
|
|
229
236
|
| 'CODE_EXPIRED' // ошибка, когда код устарел, но можно запросить новый
|
|
230
237
|
| 'CODE_EXPIRED_ENDED'; // ошибка, когда код устарел
|
|
231
238
|
|
|
232
|
-
export
|
|
239
|
+
export interface ScreensMap {
|
|
233
240
|
[key: string]: ComponentType;
|
|
234
|
-
}
|
|
241
|
+
}
|
|
235
242
|
|
|
236
243
|
export const defaultTexts: ConfirmationTexts = {
|
|
237
244
|
title: 'Введите код из\xa0уведомления',
|
package/src/utils.ts
CHANGED
package/src/vars.css
CHANGED
package/types.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { ComponentType, ReactNode } from 'react';
|
|
2
|
-
export
|
|
1
|
+
import { type ComponentType, type ReactNode } from 'react';
|
|
2
|
+
export interface ConfirmationProps {
|
|
3
3
|
/**
|
|
4
4
|
* Экран компонента
|
|
5
5
|
*/
|
|
@@ -16,6 +16,11 @@ export declare type ConfirmationProps = {
|
|
|
16
16
|
* Позиционирование контента
|
|
17
17
|
*/
|
|
18
18
|
alignContent?: 'left' | 'center';
|
|
19
|
+
/**
|
|
20
|
+
* HTML тег для заголовка
|
|
21
|
+
* @default 'h3'
|
|
22
|
+
*/
|
|
23
|
+
titleTag?: 'h1' | 'h2' | 'h3' | 'h4' | 'h5' | 'h6';
|
|
19
24
|
/**
|
|
20
25
|
* Объект с текстами
|
|
21
26
|
*/
|
|
@@ -107,11 +112,11 @@ export declare type ConfirmationProps = {
|
|
|
107
112
|
* @default 1300
|
|
108
113
|
*/
|
|
109
114
|
errorVisibleDuration?: number;
|
|
110
|
-
}
|
|
111
|
-
export declare type TConfirmationContext = Required<Pick<ConfirmationProps, 'alignContent' | 'texts' | 'state' | 'screen' | 'requiredCharAmount' | 'onInputFinished' | 'countdownDuration' | 'onChangeState' | 'onSmsRetryClick' | 'onChangeScreen' | 'onFatalErrorOkButtonClick' | 'tempBlockDuration' | 'hideCountdownSection'>> & Pick<ConfirmationProps, 'phone' | 'blockSmsRetry' | 'onTempBlockFinished' | 'clearCodeOnError' | 'initialScreenHintSlot' | 'errorVisibleDuration' | 'breakpoint' | 'client'> & {
|
|
115
|
+
}
|
|
116
|
+
export declare type TConfirmationContext = Required<Pick<ConfirmationProps, 'alignContent' | 'titleTag' | 'texts' | 'state' | 'screen' | 'requiredCharAmount' | 'onInputFinished' | 'countdownDuration' | 'onChangeState' | 'onSmsRetryClick' | 'onChangeScreen' | 'onFatalErrorOkButtonClick' | 'tempBlockDuration' | 'hideCountdownSection'>> & Pick<ConfirmationProps, 'phone' | 'blockSmsRetry' | 'onTempBlockFinished' | 'clearCodeOnError' | 'initialScreenHintSlot' | 'errorVisibleDuration' | 'breakpoint' | 'client'> & {
|
|
112
117
|
timeLeft: number;
|
|
113
118
|
};
|
|
114
|
-
export
|
|
119
|
+
export interface ConfirmationTexts {
|
|
115
120
|
/**
|
|
116
121
|
* Экран INITIAL
|
|
117
122
|
*/
|
|
@@ -152,10 +157,10 @@ export declare type ConfirmationTexts = {
|
|
|
152
157
|
tempBlockOverTitle?: ReactNode;
|
|
153
158
|
tempBlockOverDescription?: ReactNode;
|
|
154
159
|
tempBlockOverButton?: string;
|
|
155
|
-
}
|
|
160
|
+
}
|
|
156
161
|
export declare type ConfirmationScreen = 'INITIAL' | 'HINT' | 'FATAL_ERROR' | 'TEMP_BLOCK' | 'TEMP_BLOCK_OVER';
|
|
157
162
|
export declare type ConfirmationState = 'INITIAL' | 'CODE_CHECKING' | 'CODE_SENDING' | 'CODE_ERROR' | 'CODE_EXPIRED' | 'CODE_EXPIRED_ENDED';
|
|
158
|
-
export
|
|
163
|
+
export interface ScreensMap {
|
|
159
164
|
[key: string]: ComponentType;
|
|
160
|
-
}
|
|
165
|
+
}
|
|
161
166
|
export declare const defaultTexts: ConfirmationTexts;
|
package/types.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.js","sources":["src/types.ts"],"sourcesContent":["import { ComponentType, ReactNode } from 'react';\n\nexport
|
|
1
|
+
{"version":3,"file":"types.js","sources":["src/types.ts"],"sourcesContent":["import { type ComponentType, type ReactNode } from 'react';\n\nexport interface ConfirmationProps {\n /**\n * Экран компонента\n */\n screen: ConfirmationScreen | string;\n\n /**\n * Состояние компонента\n */\n state: ConfirmationState | string;\n\n /**\n * Мобильная версия компонента для экрана\n */\n mobile?: boolean;\n\n /**\n * Позиционирование контента\n */\n alignContent?: 'left' | 'center';\n\n /**\n * HTML тег для заголовка\n * @default 'h3'\n */\n titleTag?: 'h1' | 'h2' | 'h3' | 'h4' | 'h5' | 'h6';\n\n /**\n * Объект с текстами\n */\n texts?: ConfirmationTexts;\n\n /**\n * Количество символов, которое можно ввести в поле ввода подписания до того, как произойдет автоотправка\n */\n requiredCharAmount?: number;\n\n /**\n * Длительность обратного отсчета на кнопке повторного запроса сообщения, в милисекундах\n */\n countdownDuration?: number;\n\n /**\n * Продолжительность блокировки формы (ms)\n */\n tempBlockDuration?: number;\n\n /**\n * Номер телефона, на который отправлен код\n */\n phone?: string;\n\n /**\n * Не осталось попыток ввода кода\n */\n blockSmsRetry?: boolean;\n\n /**\n * Идентификатор для систем автоматизированного тестирования\n */\n dataTestId?: string;\n\n /**\n * Сss класс для стилизации общей обёртки\n */\n className?: string;\n\n /**\n * Флаг - нужно ли очищать код при возникновении ошибки\n */\n clearCodeOnError?: boolean;\n\n /**\n * Функция обновления состояния компонента\n */\n onChangeState: (state: ConfirmationState | string) => void;\n\n /**\n * Функция обновления состояния компонента\n */\n onChangeScreen: (state: ConfirmationScreen | string) => void;\n\n /**\n * Обработчик события завершения ввода кода подписания\n */\n onInputFinished: (code: string) => void;\n\n /**\n * Обработчик события нажатия на кнопку \"Запросить код\"\n */\n onSmsRetryClick: () => void;\n\n /**\n * Клик по кнопке \"Понятно\" на экране фатальной ошибки\n */\n onFatalErrorOkButtonClick?: () => void;\n\n /**\n * Временная блокировка формы закончилась\n */\n onTempBlockFinished?: () => void;\n\n /**\n * Возвращает объект, где ключ - название экрана (screen), значение - компонент для экрана\n */\n getScreensMap?: (defaultScreensMap: ScreensMap) => ScreensMap;\n\n /**\n * Дочерние элементы\n */\n children?: ReactNode;\n\n /**\n * Скрыть секцию с повторной отправкой кода\n * @default false\n */\n hideCountdownSection?: boolean;\n\n /**\n * Слот для контента с подсказкой на главном экране\n */\n initialScreenHintSlot?: ReactNode;\n\n /**\n * Контрольная точка для кнопки, с нее начинается desktop версия\n * @default 1024\n */\n breakpoint?: number;\n\n /**\n * Версия, которая будет использоваться при серверном рендеринге\n */\n client?: 'desktop' | 'mobile';\n\n /**\n * Продолжительность отображения ошибки\n * @default 1300\n */\n errorVisibleDuration?: number;\n}\n\nexport type TConfirmationContext = Required<\n Pick<\n ConfirmationProps,\n | 'alignContent'\n | 'titleTag'\n | 'texts'\n | 'state'\n | 'screen'\n | 'requiredCharAmount'\n | 'onInputFinished'\n | 'countdownDuration'\n | 'onChangeState'\n | 'onSmsRetryClick'\n | 'onChangeScreen'\n | 'onFatalErrorOkButtonClick'\n | 'tempBlockDuration'\n | 'hideCountdownSection'\n >\n> &\n Pick<\n ConfirmationProps,\n | 'phone'\n | 'blockSmsRetry'\n | 'onTempBlockFinished'\n | 'clearCodeOnError'\n | 'initialScreenHintSlot'\n | 'errorVisibleDuration'\n | 'breakpoint'\n | 'client'\n > & {\n timeLeft: number;\n };\n\nexport interface ConfirmationTexts {\n /**\n * Экран INITIAL\n */\n title?: ReactNode; // заголовок\n codeError?: string; // ошибка проверки кода\n codeErrorExpired?: string; // код устарел, запросите новый\n codeErrorExpiredEnded?: string; // код устарел\n codeChecking?: string; // код проверяется\n codeSending?: string; // код отправляется\n codeSended?: string; // код отправлен\n buttonRetry?: string; // кнопка повторной отправки кода\n linkToHint?: string; // ссылка на экран HINT\n noAttemptsLeft?: string; // не осталось попыток запроса кода\n countdown?: string; // 'запросить повторно можно через'\n\n /**\n * Экран HINT\n */\n hintTitle?: string; // заголовок\n hintDescription?: string; // описание\n hintNotification?: string; // уведомление\n hintButton?: string; // кнопка 'Вернуться'\n domesticPhone?: string; // номер телефона для звонков по России\n internationalPhone?: string; // номер телефона для звонков из-за границы\n\n /**\n * Экран FATAL_ERROR\n */\n fatalErrorTitle?: ReactNode; // заголовок\n fatalErrorDescription?: ReactNode; // описание\n fatalErrorButton?: string; // кнопка\n\n /**\n * Экран TEMP_BLOCK\n */\n tempBlockTitle?: ReactNode; // заголовок\n tempBlockDescription?: ReactNode; // описание\n\n /**\n * Экран TEMP_BLOCK_OVER\n */\n tempBlockOverTitle?: ReactNode; // заголовок\n tempBlockOverDescription?: ReactNode; // описание\n tempBlockOverButton?: string; // кнопка\n}\n\nexport type ConfirmationScreen =\n | 'INITIAL' // начальный экран\n | 'HINT' // экран \"Не приходит смс?\"\n | 'FATAL_ERROR' // экран критической ошибки\n | 'TEMP_BLOCK' // экран временной блокировки\n | 'TEMP_BLOCK_OVER'; // экран todo\n\nexport type ConfirmationState =\n | 'INITIAL' // начальное состояние\n | 'CODE_CHECKING' // проверка кода\n | 'CODE_SENDING' // повторная отправка кода\n | 'CODE_ERROR' // ошибка, когда ввели неверный код\n | 'CODE_EXPIRED' // ошибка, когда код устарел, но можно запросить новый\n | 'CODE_EXPIRED_ENDED'; // ошибка, когда код устарел\n\nexport interface ScreensMap {\n [key: string]: ComponentType;\n}\n\nexport const defaultTexts: ConfirmationTexts = {\n title: 'Введите код из\\xa0уведомления',\n codeError: 'Код не подходит, проверьте его',\n codeErrorExpired: 'Код устарел, запросите новый',\n codeErrorExpiredEnded: 'Код устарел',\n codeChecking: '',\n codeSending: '',\n buttonRetry: 'Запросить код',\n hintTitle: 'Не\\xa0приходит код?',\n hintDescription: 'Если\\xa0сменили номер, позвоните нам или обратитесь в\\xa0любой офис банка.',\n hintNotification:\n 'Если номер не\\xa0меняли, попробуйте запросить код позже — возможно, перегружен сервис отправки уведомлений.',\n linkToHint: 'Не\\xa0приходит код?',\n hintButton: 'Вернуться к\\xa0вводу кода',\n noAttemptsLeft: 'Не\\xa0осталось попыток запроса кода',\n fatalErrorTitle: 'Ввести код больше нельзя',\n fatalErrorDescription:\n 'Мы ограничили следующие попытки ввода, потому\\xa0что код был введён неверно больше 5 раз.',\n fatalErrorButton: 'Понятно',\n tempBlockTitle: 'Ввести код пока нельзя',\n tempBlockDescription: 'Слишком много неверных попыток. Запросите новый позже',\n tempBlockOverTitle: 'Ввод разблокирован',\n tempBlockOverDescription: 'Теперь можно запросить новый код',\n tempBlockOverButton: 'Запросить новый код',\n codeSended: 'Код отправлен',\n countdown: 'Запросить новый можно через',\n domesticPhone: '8 800 200 00 00',\n internationalPhone: '+7 495 78 888 78',\n};\n"],"names":[],"mappings":";;;;AAkPa,IAAA,YAAY,GAAsB;AAC3C,IAAA,KAAK,EAAE,+BAA+B;AACtC,IAAA,SAAS,EAAE,gCAAgC;AAC3C,IAAA,gBAAgB,EAAE,8BAA8B;AAChD,IAAA,qBAAqB,EAAE,aAAa;AACpC,IAAA,YAAY,EAAE,EAAE;AAChB,IAAA,WAAW,EAAE,EAAE;AACf,IAAA,WAAW,EAAE,eAAe;AAC5B,IAAA,SAAS,EAAE,qBAAqB;AAChC,IAAA,eAAe,EAAE,4EAA4E;AAC7F,IAAA,gBAAgB,EACZ,6GAA6G;AACjH,IAAA,UAAU,EAAE,qBAAqB;AACjC,IAAA,UAAU,EAAE,2BAA2B;AACvC,IAAA,cAAc,EAAE,qCAAqC;AACrD,IAAA,eAAe,EAAE,0BAA0B;AAC3C,IAAA,qBAAqB,EACjB,2FAA2F;AAC/F,IAAA,gBAAgB,EAAE,SAAS;AAC3B,IAAA,cAAc,EAAE,wBAAwB;AACxC,IAAA,oBAAoB,EAAE,uDAAuD;AAC7E,IAAA,kBAAkB,EAAE,oBAAoB;AACxC,IAAA,wBAAwB,EAAE,kCAAkC;AAC5D,IAAA,mBAAmB,EAAE,qBAAqB;AAC1C,IAAA,UAAU,EAAE,eAAe;AAC3B,IAAA,SAAS,EAAE,6BAA6B;AACxC,IAAA,aAAa,EAAE,iBAAiB;AAChC,IAAA,kBAAkB,EAAE,kBAAkB;;;;;"}
|
package/utils.d.ts
CHANGED
package/utils.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils.js","sources":["src/utils.ts"],"sourcesContent":["import { useCallback, useEffect, useRef, useState } from 'react';\n\nimport { ConfirmationProps } from './types';\n\n/**\n * Форматирование миллисекунд в hh:mm:ss.\n *\n * @param {Number} ms миллисекунды\n * @returns {String} время в формате mm:ss\n */\nexport function formatMsAsMinutes(ms: number) {\n const totalSeconds = Math.ceil(ms / 1000);\n const totalMinutes = Math.floor(totalSeconds / 60);\n const totalHours = Math.floor(totalMinutes / 60);\n\n const seconds = totalSeconds % 60;\n const paddedSeconds = `00${seconds}`.slice(-2);\n\n if (totalHours > 0) {\n const minutes = totalMinutes % 60;\n\n const paddedMinutes = `00${minutes}`.slice(-2);\n const paddedHours = `00${totalHours}`.slice(-2);\n\n return `${paddedHours}:${paddedMinutes}:${paddedSeconds}`;\n }\n\n const paddedMinutes = `00${totalMinutes}`.slice(-2);\n\n return `${paddedMinutes}:${paddedSeconds}`;\n}\n\ntype UseCountdown = (countdownDuration: number, tick?: number) => [number, () => void, () => void];\n\n/**\n * Возвращает время, которое осталось до истечения таймера в ms\n */\nexport const useCountdown: UseCountdown = (countdownDuration, tick = 1000) => {\n const timerId = useRef(0);\n\n const start = useRef(0);\n\n const [timePassed, setTimePassed] = useState(0);\n\n const stopTimer = useCallback(() => {\n window.clearInterval(timerId.current);\n }, []);\n\n const updateProgress = useCallback(() => {\n const passed = Date.now() - start.current;\n\n if (passed >= countdownDuration) {\n stopTimer();\n\n setTimePassed(countdownDuration);\n } else {\n setTimePassed(passed);\n }\n }, [countdownDuration, stopTimer]);\n\n const startTimer = useCallback(() => {\n stopTimer();\n\n start.current = Date.now();\n\n updateProgress();\n\n timerId.current = window.setInterval(updateProgress, tick);\n }, [stopTimer, updateProgress, tick]);\n\n const timeLeft = countdownDuration - timePassed;\n\n useEffect(\n () => () => {\n stopTimer();\n },\n [stopTimer],\n );\n\n return [timeLeft, startTimer, stopTimer];\n};\n\nexport const ONE_DAY = 24 * 60 * 60 * 1000;\nexport const ONE_MINUTE = 60 * 1000;\n\ntype UseConfirmationParams = {\n state?: ConfirmationProps['state'];\n screen?: ConfirmationProps['screen'];\n blockSmsRetry?: ConfirmationProps['blockSmsRetry'];\n};\n\nexport const useConfirmation = ({ state, screen, blockSmsRetry }: UseConfirmationParams = {}) => {\n const [confirmationState, setConfirmationState] = useState(state ?? 'INITIAL');\n const [confirmationScreen, setConfirmationScreen] = useState(screen ?? 'INITIAL');\n const [confirmationBlockSmsRetry, setConfirmationBlockSmsRetry] = useState(\n blockSmsRetry ?? false,\n );\n\n return {\n confirmationState,\n confirmationScreen,\n confirmationBlockSmsRetry,\n setConfirmationState,\n setConfirmationScreen,\n setConfirmationBlockSmsRetry,\n };\n};\n\nconst NON_NUMBER_OR_PLUS_REGEXP = new RegExp(/[^\\d+]/g);\n\n/**\n * @returns ссылку для набора номера\n */\nexport function getPhoneHref(phone: string): string {\n return `tel:${phone.replace(NON_NUMBER_OR_PLUS_REGEXP, '')}`;\n}\n"],"names":["useRef","useState","useCallback","useEffect"],"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ConfirmationProps } from './types';\n\n/**\n * Форматирование миллисекунд в hh:mm:ss.\n *\n * @param {Number} ms миллисекунды\n * @returns {String} время в формате mm:ss\n */\nexport function formatMsAsMinutes(ms: number) {\n const totalSeconds = Math.ceil(ms / 1000);\n const totalMinutes = Math.floor(totalSeconds / 60);\n const totalHours = Math.floor(totalMinutes / 60);\n\n const seconds = totalSeconds % 60;\n const paddedSeconds = `00${seconds}`.slice(-2);\n\n if (totalHours > 0) {\n const minutes = totalMinutes % 60;\n\n const paddedMinutes = `00${minutes}`.slice(-2);\n const paddedHours = `00${totalHours}`.slice(-2);\n\n return `${paddedHours}:${paddedMinutes}:${paddedSeconds}`;\n }\n\n const paddedMinutes = `00${totalMinutes}`.slice(-2);\n\n return `${paddedMinutes}:${paddedSeconds}`;\n}\n\ntype UseCountdown = (countdownDuration: number, tick?: number) => [number, () => void, () => void];\n\n/**\n * Возвращает время, которое осталось до истечения таймера в ms\n */\nexport const useCountdown: UseCountdown = (countdownDuration, tick = 1000) => {\n const timerId = useRef(0);\n\n const start = useRef(0);\n\n const [timePassed, setTimePassed] = useState(0);\n\n const stopTimer = useCallback(() => {\n window.clearInterval(timerId.current);\n }, []);\n\n const updateProgress = useCallback(() => {\n const passed = Date.now() - start.current;\n\n if (passed >= countdownDuration) {\n stopTimer();\n\n setTimePassed(countdownDuration);\n } else {\n setTimePassed(passed);\n }\n }, [countdownDuration, stopTimer]);\n\n const startTimer = useCallback(() => {\n stopTimer();\n\n start.current = Date.now();\n\n updateProgress();\n\n timerId.current = window.setInterval(updateProgress, tick);\n }, [stopTimer, updateProgress, tick]);\n\n const timeLeft = countdownDuration - timePassed;\n\n useEffect(\n () => () => {\n stopTimer();\n },\n [stopTimer],\n );\n\n return [timeLeft, startTimer, stopTimer];\n};\n\nexport const ONE_DAY = 24 * 60 * 60 * 1000;\nexport const ONE_MINUTE = 60 * 1000;\n\ntype UseConfirmationParams = {\n state?: ConfirmationProps['state'];\n screen?: ConfirmationProps['screen'];\n blockSmsRetry?: ConfirmationProps['blockSmsRetry'];\n};\n\nexport const useConfirmation = ({ state, screen, blockSmsRetry }: UseConfirmationParams = {}) => {\n const [confirmationState, setConfirmationState] = useState(state ?? 'INITIAL');\n const [confirmationScreen, setConfirmationScreen] = useState(screen ?? 'INITIAL');\n const [confirmationBlockSmsRetry, setConfirmationBlockSmsRetry] = useState(\n blockSmsRetry ?? false,\n );\n\n return {\n confirmationState,\n confirmationScreen,\n confirmationBlockSmsRetry,\n setConfirmationState,\n setConfirmationScreen,\n setConfirmationBlockSmsRetry,\n };\n};\n\nconst NON_NUMBER_OR_PLUS_REGEXP = new RegExp(/[^\\d+]/g);\n\n/**\n * @returns ссылку для набора номера\n */\nexport function getPhoneHref(phone: string): string {\n return `tel:${phone.replace(NON_NUMBER_OR_PLUS_REGEXP, '')}`;\n}\n"],"names":["useRef","useState","useCallback","useEffect"],"mappings":";;;;;;AAIA;;;;;AAKG;AACG,SAAU,iBAAiB,CAAC,EAAU,EAAA;IACxC,IAAM,YAAY,GAAG,IAAI,CAAC,IAAI,CAAC,EAAE,GAAG,IAAI,CAAC;IACzC,IAAM,YAAY,GAAG,IAAI,CAAC,KAAK,CAAC,YAAY,GAAG,EAAE,CAAC;IAClD,IAAM,UAAU,GAAG,IAAI,CAAC,KAAK,CAAC,YAAY,GAAG,EAAE,CAAC;AAEhD,IAAA,IAAM,OAAO,GAAG,YAAY,GAAG,EAAE;IACjC,IAAM,aAAa,GAAG,IAAA,CAAA,MAAA,CAAK,OAAO,CAAE,CAAC,KAAK,CAAC,EAAE,CAAC;IAE9C,IAAI,UAAU,GAAG,CAAC,EAAE;AAChB,QAAA,IAAM,OAAO,GAAG,YAAY,GAAG,EAAE;QAEjC,IAAM,eAAa,GAAG,IAAA,CAAA,MAAA,CAAK,OAAO,CAAE,CAAC,KAAK,CAAC,EAAE,CAAC;QAC9C,IAAM,WAAW,GAAG,IAAA,CAAA,MAAA,CAAK,UAAU,CAAE,CAAC,KAAK,CAAC,EAAE,CAA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