@alfalab/core-components-confirmation 13.8.3 → 13.9.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.
Files changed (83) hide show
  1. package/components/base-confirmation/component.js +1 -1
  2. package/components/base-confirmation/index.css +2 -2
  3. package/components/countdown-loader/component.js +1 -1
  4. package/components/countdown-loader/index.css +2 -2
  5. package/components/header/component.js +1 -1
  6. package/components/header/index.css +4 -4
  7. package/components/screens/fatal-error/component.js +1 -1
  8. package/components/screens/fatal-error/index.css +7 -7
  9. package/components/screens/hint/component.js +6 -4
  10. package/components/screens/hint/index.css +13 -13
  11. package/components/screens/initial/component.js +1 -1
  12. package/components/screens/initial/countdown-section.js +1 -1
  13. package/components/screens/initial/index.css +19 -19
  14. package/components/screens/temp-block/component.js +1 -1
  15. package/components/screens/temp-block/index.css +8 -8
  16. package/{countdown-section-0f785844.js → countdown-section-d7a44cd1.js} +1 -1
  17. package/cssm/components/screens/hint/component.js +5 -3
  18. package/cssm/types.d.ts +6 -20
  19. package/cssm/types.js +2 -0
  20. package/cssm/utils.d.ts +5 -1
  21. package/cssm/utils.js +8 -0
  22. package/esm/components/base-confirmation/component.js +1 -1
  23. package/esm/components/base-confirmation/index.css +2 -2
  24. package/esm/components/countdown-loader/component.js +1 -1
  25. package/esm/components/countdown-loader/index.css +2 -2
  26. package/esm/components/header/component.js +1 -1
  27. package/esm/components/header/index.css +4 -4
  28. package/esm/components/screens/fatal-error/component.js +1 -1
  29. package/esm/components/screens/fatal-error/index.css +7 -7
  30. package/esm/components/screens/hint/component.js +6 -4
  31. package/esm/components/screens/hint/index.css +13 -13
  32. package/esm/components/screens/initial/component.js +1 -1
  33. package/esm/components/screens/initial/countdown-section.js +1 -1
  34. package/esm/components/screens/initial/index.css +19 -19
  35. package/esm/components/screens/temp-block/component.js +1 -1
  36. package/esm/components/screens/temp-block/index.css +8 -8
  37. package/esm/{countdown-section-3516a8a6.js → countdown-section-25714e1f.js} +1 -1
  38. package/esm/mobile/component.mobile.js +1 -1
  39. package/esm/mobile/mobile.css +2 -2
  40. package/esm/types.d.ts +6 -20
  41. package/esm/types.js +2 -0
  42. package/esm/utils.d.ts +5 -1
  43. package/esm/utils.js +8 -1
  44. package/mobile/component.mobile.js +1 -1
  45. package/mobile/mobile.css +2 -2
  46. package/modern/components/base-confirmation/component.js +1 -1
  47. package/modern/components/base-confirmation/index.css +2 -2
  48. package/modern/components/countdown-loader/component.js +1 -1
  49. package/modern/components/countdown-loader/index.css +2 -2
  50. package/modern/components/header/component.js +1 -1
  51. package/modern/components/header/index.css +4 -4
  52. package/modern/components/screens/fatal-error/component.js +1 -1
  53. package/modern/components/screens/fatal-error/index.css +7 -7
  54. package/modern/components/screens/hint/component.js +6 -4
  55. package/modern/components/screens/hint/index.css +13 -13
  56. package/modern/components/screens/initial/component.js +1 -1
  57. package/modern/components/screens/initial/countdown-section.js +1 -1
  58. package/modern/components/screens/initial/index.css +19 -19
  59. package/modern/components/screens/temp-block/component.js +1 -1
  60. package/modern/components/screens/temp-block/index.css +8 -8
  61. package/modern/{countdown-section-7563320f.js → countdown-section-cdcdc727.js} +1 -1
  62. package/modern/mobile/component.mobile.js +1 -1
  63. package/modern/mobile/mobile.css +2 -2
  64. package/modern/types.d.ts +6 -20
  65. package/modern/types.js +2 -0
  66. package/modern/utils.d.ts +5 -1
  67. package/modern/utils.js +8 -1
  68. package/moderncssm/components/screens/hint/component.js +5 -3
  69. package/moderncssm/types.d.ts +6 -20
  70. package/moderncssm/types.js +2 -0
  71. package/moderncssm/utils.d.ts +5 -1
  72. package/moderncssm/utils.js +8 -1
  73. package/package.json +1 -1
  74. package/src/components/screens/hint/component.tsx +8 -5
  75. package/src/types.ts +8 -5
  76. package/src/utils.ts +9 -0
  77. package/types.d.ts +6 -20
  78. package/types.js +2 -0
  79. package/utils.d.ts +5 -1
  80. package/utils.js +8 -0
  81. /package/{countdown-section-0f785844.d.ts → countdown-section-d7a44cd1.d.ts} +0 -0
  82. /package/esm/{countdown-section-3516a8a6.d.ts → countdown-section-25714e1f.d.ts} +0 -0
  83. /package/modern/{countdown-section-7563320f.d.ts → countdown-section-cdcdc727.d.ts} +0 -0
@@ -1,4 +1,4 @@
1
- /* hash: 1aigo */
1
+ /* hash: 16l97 */
2
2
  :root { /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */ /* deprecated */
3
3
  } /* deprecated */ :root {
4
4
  --color-light-text-primary: rgba(3, 3, 6, 0.88);
@@ -37,25 +37,25 @@
37
37
  --confirmation-text-color: var(--color-light-text-primary)
38
38
 
39
39
  /* header */
40
- } .confirmation__component_gfnyn {
40
+ } .confirmation__component_bvit8 {
41
41
  display: flex;
42
42
  flex-direction: column;
43
- } .confirmation__center_gfnyn {
43
+ } .confirmation__center_bvit8 {
44
44
  align-items: center;
45
45
  text-align: center;
46
- } .confirmation__typographyTheme_gfnyn.confirmation__typographyTheme_gfnyn {
46
+ } .confirmation__typographyTheme_bvit8.confirmation__typographyTheme_bvit8 {
47
47
  font-size: var(--confirmation-text-font-size);
48
48
  line-height: var(--confirmation-text-line-height);
49
49
  font-weight: var(--confirmation-text-font-weight);
50
50
  font-family: var(--confirmation-text-font-family);
51
51
  color: var(--confirmation-text-color);
52
- } .confirmation__typographyThemeMobile_gfnyn.confirmation__typographyThemeMobile_gfnyn {
52
+ } .confirmation__typographyThemeMobile_bvit8.confirmation__typographyThemeMobile_bvit8 {
53
53
  color: var(--color-light-text-secondary);
54
- } .confirmation__description_gfnyn.confirmation__description_gfnyn {
54
+ } .confirmation__description_bvit8.confirmation__description_bvit8 {
55
55
  margin-bottom: var(--gap-8);
56
- } .confirmation__countdownWrap_gfnyn {
56
+ } .confirmation__countdownWrap_bvit8 {
57
57
  display: flex;
58
58
  align-items: center;
59
- } .confirmation__loader_gfnyn {
59
+ } .confirmation__loader_bvit8 {
60
60
  margin-right: var(--gap-8);
61
61
  }
@@ -6,7 +6,7 @@ import { Typography } from '@alfalab/core-components-typography/modern';
6
6
  import { ConfirmationContext } from './context.js';
7
7
  import { formatMsAsMinutes } from './utils.js';
8
8
 
9
- const styles = {"component":"confirmation__component_6ytgy","phone":"confirmation__phone_6ytgy","typographyTheme":"confirmation__typographyTheme_6ytgy","typographyThemeMobile":"confirmation__typographyThemeMobile_6ytgy","compact":"confirmation__compact_6ytgy","loaderWrap":"confirmation__loaderWrap_6ytgy","left":"confirmation__left_6ytgy","center":"confirmation__center_6ytgy","codeInput":"confirmation__codeInput_6ytgy","smsBtn":"confirmation__smsBtn_6ytgy","smsComeLink":"confirmation__smsComeLink_6ytgy","countdownContainer":"confirmation__countdownContainer_6ytgy","countdownMobile":"confirmation__countdownMobile_6ytgy","countdownLoaderMobile":"confirmation__countdownLoaderMobile_6ytgy","getCodeButton":"confirmation__getCodeButton_6ytgy","getCodeButtonMobile":"confirmation__getCodeButtonMobile_6ytgy","containerInput":"confirmation__containerInput_6ytgy"};
9
+ const styles = {"component":"confirmation__component_ztfvp","phone":"confirmation__phone_ztfvp","typographyTheme":"confirmation__typographyTheme_ztfvp","typographyThemeMobile":"confirmation__typographyThemeMobile_ztfvp","compact":"confirmation__compact_ztfvp","loaderWrap":"confirmation__loaderWrap_ztfvp","left":"confirmation__left_ztfvp","center":"confirmation__center_ztfvp","codeInput":"confirmation__codeInput_ztfvp","smsBtn":"confirmation__smsBtn_ztfvp","smsComeLink":"confirmation__smsComeLink_ztfvp","countdownContainer":"confirmation__countdownContainer_ztfvp","countdownMobile":"confirmation__countdownMobile_ztfvp","countdownLoaderMobile":"confirmation__countdownLoaderMobile_ztfvp","getCodeButton":"confirmation__getCodeButton_ztfvp","getCodeButtonMobile":"confirmation__getCodeButtonMobile_ztfvp","containerInput":"confirmation__containerInput_ztfvp"};
10
10
  require('./components/screens/initial/index.css')
11
11
 
12
12
  const CountdownSection = ({ codeSendHintVisible, timePassed, processing, mobile, handleSmsRetryClick, }) => {
@@ -2,7 +2,7 @@ import React from 'react';
2
2
  import cn from 'classnames';
3
3
  import { BaseConfirmation } from '../components/base-confirmation/component.js';
4
4
 
5
- const styles = {"container":"confirmation__container_n9l9d"};
5
+ const styles = {"container":"confirmation__container_1lmp3"};
6
6
  require('./mobile.css')
7
7
 
8
8
  const ConfirmationMobile = ({ className, ...resProps }) => (React.createElement(BaseConfirmation, { mobile: true, className: cn(className, styles.container), ...resProps }));
@@ -1,4 +1,4 @@
1
- /* hash: 1t5ts */
2
- .confirmation__container_n9l9d {
1
+ /* hash: 10vh3 */
2
+ .confirmation__container_1lmp3 {
3
3
  max-width: 288px;
4
4
  }
package/modern/types.d.ts CHANGED
@@ -77,11 +77,11 @@ type ConfirmationProps = {
77
77
  */
78
78
  onTempBlockFinished?: () => void;
79
79
  /**
80
- * Возввращает объект, где ключ - название экрана (screen), значение - компонент для экрана
80
+ * Возвращает объект, где ключ - название экрана (screen), значение - компонент для экрана
81
81
  */
82
- getScreensMap?: (defaulScreensMap: ScreensMap) => ScreensMap;
82
+ getScreensMap?: (defaultScreensMap: ScreensMap) => ScreensMap;
83
83
  /**
84
- * Дочерние элементы.
84
+ * Дочерние элементы
85
85
  */
86
86
  children?: ReactNode;
87
87
  /**
@@ -128,6 +128,8 @@ type ConfirmationTexts = {
128
128
  * Экран HINT
129
129
  */
130
130
  hintButton?: string;
131
+ domesticPhone?: string;
132
+ internationalPhone?: string;
131
133
  /**
132
134
  * Экран FATAL_ERROR
133
135
  */
@@ -145,21 +147,5 @@ type ConfirmationState = 'INITIAL' | 'CODE_CHECKING' | 'CODE_SENDING' | 'CODE_ER
145
147
  type ScreensMap = {
146
148
  [key: string]: ComponentType;
147
149
  };
148
- declare const defaultTexts: {
149
- title: string;
150
- codeError: string;
151
- codeChecking: string;
152
- codeSending: string;
153
- buttonRetry: string;
154
- linkToHint: string;
155
- hintButton: string;
156
- noAttemptsLeft: string;
157
- fatalErrorTitle: string;
158
- fatalErrorDescription: string;
159
- fatalErrorButton: string;
160
- tempBlockTitle: string;
161
- tempBlockDescription: string;
162
- codeSended: string;
163
- countdown: string;
164
- };
150
+ declare const defaultTexts: ConfirmationTexts;
165
151
  export { ConfirmationProps, TConfirmationContext, ConfirmationTexts, ConfirmationScreen, ConfirmationState, ScreensMap, defaultTexts };
package/modern/types.js CHANGED
@@ -14,6 +14,8 @@ const defaultTexts = {
14
14
  tempBlockDescription: 'Повторное подтверждение кодом будет возможно через 24\xa0часа',
15
15
  codeSended: 'Код выслан',
16
16
  countdown: 'Запросить повторно можно через',
17
+ domesticPhone: '8 800 200 00 00',
18
+ internationalPhone: '+7 495 78 888 78',
17
19
  };
18
20
 
19
21
  export { defaultTexts };
package/modern/utils.d.ts CHANGED
@@ -27,4 +27,8 @@ declare const useConfirmation: ({ state, screen, blockSmsRetry }?: UseConfirmati
27
27
  setConfirmationScreen: import("react").Dispatch<import("react").SetStateAction<string>>;
28
28
  setConfirmationBlockSmsRetry: import("react").Dispatch<import("react").SetStateAction<boolean>>;
29
29
  };
30
- export { formatMsAsMinutes, useCountdown, ONE_DAY, ONE_MINUTE, useConfirmation };
30
+ /**
31
+ * @returns ссылку для набора номера
32
+ */
33
+ declare function getPhoneHref(phone: string): string;
34
+ export { formatMsAsMinutes, useCountdown, ONE_DAY, ONE_MINUTE, useConfirmation, getPhoneHref };
package/modern/utils.js CHANGED
@@ -68,5 +68,12 @@ const useConfirmation = ({ state, screen, blockSmsRetry } = {}) => {
68
68
  setConfirmationBlockSmsRetry,
69
69
  };
70
70
  };
71
+ const NON_NUMBER_OR_PLUS_REGEXP = new RegExp(/[^\d+]/g);
72
+ /**
73
+ * @returns ссылку для набора номера
74
+ */
75
+ function getPhoneHref(phone) {
76
+ return `tel:${phone.replace(NON_NUMBER_OR_PLUS_REGEXP, '')}`;
77
+ }
71
78
 
72
- export { ONE_DAY, ONE_MINUTE, formatMsAsMinutes, useConfirmation, useCountdown };
79
+ export { ONE_DAY, ONE_MINUTE, formatMsAsMinutes, getPhoneHref, useConfirmation, useCountdown };
@@ -4,11 +4,13 @@ import { Button } from '@alfalab/core-components-button/moderncssm';
4
4
  import { Link } from '@alfalab/core-components-link/moderncssm';
5
5
  import { Typography } from '@alfalab/core-components-typography/moderncssm';
6
6
  import { ConfirmationContext } from '../../../context.js';
7
+ import { getPhoneHref } from '../../../utils.js';
7
8
  import { Header } from '../../header/component.js';
8
9
  import styles from './index.module.css';
9
10
 
10
11
  const Hint = ({ mobile }) => {
11
12
  const { alignContent, texts, onChangeScreen, onChangeState, breakpoint, client } = useContext(ConfirmationContext);
13
+ const { domesticPhone = '', internationalPhone = '', hintButton } = texts;
12
14
  const handleReturnButtonClick = () => {
13
15
  onChangeScreen('INITIAL');
14
16
  onChangeState('INITIAL');
@@ -23,7 +25,7 @@ const Hint = ({ mobile }) => {
23
25
  [styles.phonesWrapMobile]: mobile,
24
26
  }) },
25
27
  React.createElement("div", { className: cn(styles.phoneWrap, { [styles.phoneContentMobile]: mobile }) },
26
- React.createElement(Link, { href: 'tel:+78002000000', underline: false, className: cn(styles.phoneLink, { [styles.typographyThemeMobile]: mobile }) }, "8 800 200 00 00"),
28
+ React.createElement(Link, { href: getPhoneHref(domesticPhone), underline: false, className: cn(styles.phoneLink, { [styles.typographyThemeMobile]: mobile }) }, domesticPhone),
27
29
  React.createElement(Typography.Text, { view: 'primary-medium', color: 'primary', className: cn(styles.text, {
28
30
  [styles.typographyTheme]: !mobile,
29
31
  [styles.typographyThemeMobile]: mobile,
@@ -31,7 +33,7 @@ const Hint = ({ mobile }) => {
31
33
  ? 'Для\u00A0звонков по\u00A0России'
32
34
  : ' \u2014\u00A0для звонков по\u00A0России')),
33
35
  React.createElement("div", { className: cn(styles.phoneWrap, { [styles.phoneContentMobile]: mobile }) },
34
- React.createElement(Link, { href: 'tel:+74957888878', underline: false, className: cn(styles.phoneLink, { [styles.typographyThemeMobile]: mobile }) }, "+7 495 78 888 78"),
36
+ React.createElement(Link, { href: getPhoneHref(internationalPhone), underline: false, className: cn(styles.phoneLink, { [styles.typographyThemeMobile]: mobile }) }, internationalPhone),
35
37
  React.createElement(Typography.Text, { view: 'primary-medium', color: 'primary', className: cn(styles.text, {
36
38
  [styles.typographyTheme]: !mobile,
37
39
  [styles.typographyThemeMobile]: mobile,
@@ -42,7 +44,7 @@ const Hint = ({ mobile }) => {
42
44
  [styles.typographyTheme]: !mobile,
43
45
  [styles.typographyThemeMobile]: mobile,
44
46
  }) }, "\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."),
45
- React.createElement(Button, { size: mobile ? 'xs' : 's', view: 'secondary', onClick: handleReturnButtonClick, className: styles.hintButton, breakpoint: breakpoint, client: client }, texts.hintButton)));
47
+ React.createElement(Button, { size: mobile ? 'xs' : 's', view: 'secondary', onClick: handleReturnButtonClick, className: styles.hintButton, breakpoint: breakpoint, client: client }, hintButton)));
46
48
  };
47
49
 
48
50
  export { Hint };
@@ -77,11 +77,11 @@ type ConfirmationProps = {
77
77
  */
78
78
  onTempBlockFinished?: () => void;
79
79
  /**
80
- * Возввращает объект, где ключ - название экрана (screen), значение - компонент для экрана
80
+ * Возвращает объект, где ключ - название экрана (screen), значение - компонент для экрана
81
81
  */
82
- getScreensMap?: (defaulScreensMap: ScreensMap) => ScreensMap;
82
+ getScreensMap?: (defaultScreensMap: ScreensMap) => ScreensMap;
83
83
  /**
84
- * Дочерние элементы.
84
+ * Дочерние элементы
85
85
  */
86
86
  children?: ReactNode;
87
87
  /**
@@ -128,6 +128,8 @@ type ConfirmationTexts = {
128
128
  * Экран HINT
129
129
  */
130
130
  hintButton?: string;
131
+ domesticPhone?: string;
132
+ internationalPhone?: string;
131
133
  /**
132
134
  * Экран FATAL_ERROR
133
135
  */
@@ -145,21 +147,5 @@ type ConfirmationState = 'INITIAL' | 'CODE_CHECKING' | 'CODE_SENDING' | 'CODE_ER
145
147
  type ScreensMap = {
146
148
  [key: string]: ComponentType;
147
149
  };
148
- declare const defaultTexts: {
149
- title: string;
150
- codeError: string;
151
- codeChecking: string;
152
- codeSending: string;
153
- buttonRetry: string;
154
- linkToHint: string;
155
- hintButton: string;
156
- noAttemptsLeft: string;
157
- fatalErrorTitle: string;
158
- fatalErrorDescription: string;
159
- fatalErrorButton: string;
160
- tempBlockTitle: string;
161
- tempBlockDescription: string;
162
- codeSended: string;
163
- countdown: string;
164
- };
150
+ declare const defaultTexts: ConfirmationTexts;
165
151
  export { ConfirmationProps, TConfirmationContext, ConfirmationTexts, ConfirmationScreen, ConfirmationState, ScreensMap, defaultTexts };
@@ -14,6 +14,8 @@ const defaultTexts = {
14
14
  tempBlockDescription: 'Повторное подтверждение кодом будет возможно через 24\xa0часа',
15
15
  codeSended: 'Код выслан',
16
16
  countdown: 'Запросить повторно можно через',
17
+ domesticPhone: '8 800 200 00 00',
18
+ internationalPhone: '+7 495 78 888 78',
17
19
  };
18
20
 
19
21
  export { defaultTexts };
@@ -27,4 +27,8 @@ declare const useConfirmation: ({ state, screen, blockSmsRetry }?: UseConfirmati
27
27
  setConfirmationScreen: import("react").Dispatch<import("react").SetStateAction<string>>;
28
28
  setConfirmationBlockSmsRetry: import("react").Dispatch<import("react").SetStateAction<boolean>>;
29
29
  };
30
- export { formatMsAsMinutes, useCountdown, ONE_DAY, ONE_MINUTE, useConfirmation };
30
+ /**
31
+ * @returns ссылку для набора номера
32
+ */
33
+ declare function getPhoneHref(phone: string): string;
34
+ export { formatMsAsMinutes, useCountdown, ONE_DAY, ONE_MINUTE, useConfirmation, getPhoneHref };
@@ -68,5 +68,12 @@ const useConfirmation = ({ state, screen, blockSmsRetry } = {}) => {
68
68
  setConfirmationBlockSmsRetry,
69
69
  };
70
70
  };
71
+ const NON_NUMBER_OR_PLUS_REGEXP = new RegExp(/[^\d+]/g);
72
+ /**
73
+ * @returns ссылку для набора номера
74
+ */
75
+ function getPhoneHref(phone) {
76
+ return `tel:${phone.replace(NON_NUMBER_OR_PLUS_REGEXP, '')}`;
77
+ }
71
78
 
72
- export { ONE_DAY, ONE_MINUTE, formatMsAsMinutes, useConfirmation, useCountdown };
79
+ export { ONE_DAY, ONE_MINUTE, formatMsAsMinutes, getPhoneHref, useConfirmation, useCountdown };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@alfalab/core-components-confirmation",
3
- "version": "13.8.3",
3
+ "version": "13.9.0",
4
4
  "description": "Sms confirmation component",
5
5
  "keywords": [],
6
6
  "license": "MIT",
@@ -6,6 +6,7 @@ import { Link } from '@alfalab/core-components-link';
6
6
  import { Typography } from '@alfalab/core-components-typography';
7
7
 
8
8
  import { ConfirmationContext } from '../../../context';
9
+ import { getPhoneHref } from '../../../utils';
9
10
  import { Header } from '../../header';
10
11
 
11
12
  import styles from './index.module.css';
@@ -21,6 +22,8 @@ export const Hint: FC<HintProps> = ({ mobile }) => {
21
22
  const { alignContent, texts, onChangeScreen, onChangeState, breakpoint, client } =
22
23
  useContext(ConfirmationContext);
23
24
 
25
+ const { domesticPhone = '', internationalPhone = '', hintButton } = texts;
26
+
24
27
  const handleReturnButtonClick = () => {
25
28
  onChangeScreen('INITIAL');
26
29
  onChangeState('INITIAL');
@@ -49,11 +52,11 @@ export const Hint: FC<HintProps> = ({ mobile }) => {
49
52
  >
50
53
  <div className={cn(styles.phoneWrap, { [styles.phoneContentMobile]: mobile })}>
51
54
  <Link
52
- href='tel:+78002000000'
55
+ href={getPhoneHref(domesticPhone)}
53
56
  underline={false}
54
57
  className={cn(styles.phoneLink, { [styles.typographyThemeMobile]: mobile })}
55
58
  >
56
- 8 800 200 00 00
59
+ {domesticPhone}
57
60
  </Link>
58
61
  <Typography.Text
59
62
  view='primary-medium'
@@ -71,11 +74,11 @@ export const Hint: FC<HintProps> = ({ mobile }) => {
71
74
 
72
75
  <div className={cn(styles.phoneWrap, { [styles.phoneContentMobile]: mobile })}>
73
76
  <Link
74
- href='tel:+74957888878'
77
+ href={getPhoneHref(internationalPhone)}
75
78
  underline={false}
76
79
  className={cn(styles.phoneLink, { [styles.typographyThemeMobile]: mobile })}
77
80
  >
78
- +7 495 78 888 78
81
+ {internationalPhone}
79
82
  </Link>
80
83
  <Typography.Text
81
84
  view='primary-medium'
@@ -112,7 +115,7 @@ export const Hint: FC<HintProps> = ({ mobile }) => {
112
115
  breakpoint={breakpoint}
113
116
  client={client}
114
117
  >
115
- {texts.hintButton}
118
+ {hintButton}
116
119
  </Button>
117
120
  </div>
118
121
  );
package/src/types.ts CHANGED
@@ -97,12 +97,12 @@ export type ConfirmationProps = {
97
97
  onTempBlockFinished?: () => void;
98
98
 
99
99
  /**
100
- * Возввращает объект, где ключ - название экрана (screen), значение - компонент для экрана
100
+ * Возвращает объект, где ключ - название экрана (screen), значение - компонент для экрана
101
101
  */
102
- getScreensMap?: (defaulScreensMap: ScreensMap) => ScreensMap;
102
+ getScreensMap?: (defaultScreensMap: ScreensMap) => ScreensMap;
103
103
 
104
104
  /**
105
- * Дочерние элементы.
105
+ * Дочерние элементы
106
106
  */
107
107
  children?: ReactNode;
108
108
 
@@ -185,7 +185,8 @@ export type ConfirmationTexts = {
185
185
  * Экран HINT
186
186
  */
187
187
  hintButton?: string; // кнопка 'Вернуться'
188
-
188
+ domesticPhone?: string; // номер телефона для звонков по России
189
+ internationalPhone?: string; // номер телефона для звонков из-за границы
189
190
  /**
190
191
  * Экран FATAL_ERROR
191
192
  */
@@ -216,7 +217,7 @@ export type ScreensMap = {
216
217
  [key: string]: ComponentType;
217
218
  };
218
219
 
219
- export const defaultTexts = {
220
+ export const defaultTexts: ConfirmationTexts = {
220
221
  title: 'Введите код из\xa0сообщения',
221
222
  codeError: 'Код введён неверно',
222
223
  codeChecking: '',
@@ -233,4 +234,6 @@ export const defaultTexts = {
233
234
  tempBlockDescription: 'Повторное подтверждение кодом будет возможно через 24\xa0часа',
234
235
  codeSended: 'Код выслан',
235
236
  countdown: 'Запросить повторно можно через',
237
+ domesticPhone: '8 800 200 00 00',
238
+ internationalPhone: '+7 495 78 888 78',
236
239
  };
package/src/utils.ts CHANGED
@@ -105,3 +105,12 @@ export const useConfirmation = ({ state, screen, blockSmsRetry }: UseConfirmatio
105
105
  setConfirmationBlockSmsRetry,
106
106
  };
107
107
  };
108
+
109
+ const NON_NUMBER_OR_PLUS_REGEXP = new RegExp(/[^\d+]/g);
110
+
111
+ /**
112
+ * @returns ссылку для набора номера
113
+ */
114
+ export function getPhoneHref(phone: string): string {
115
+ return `tel:${phone.replace(NON_NUMBER_OR_PLUS_REGEXP, '')}`;
116
+ }
package/types.d.ts CHANGED
@@ -77,11 +77,11 @@ type ConfirmationProps = {
77
77
  */
78
78
  onTempBlockFinished?: () => void;
79
79
  /**
80
- * Возввращает объект, где ключ - название экрана (screen), значение - компонент для экрана
80
+ * Возвращает объект, где ключ - название экрана (screen), значение - компонент для экрана
81
81
  */
82
- getScreensMap?: (defaulScreensMap: ScreensMap) => ScreensMap;
82
+ getScreensMap?: (defaultScreensMap: ScreensMap) => ScreensMap;
83
83
  /**
84
- * Дочерние элементы.
84
+ * Дочерние элементы
85
85
  */
86
86
  children?: ReactNode;
87
87
  /**
@@ -128,6 +128,8 @@ type ConfirmationTexts = {
128
128
  * Экран HINT
129
129
  */
130
130
  hintButton?: string;
131
+ domesticPhone?: string;
132
+ internationalPhone?: string;
131
133
  /**
132
134
  * Экран FATAL_ERROR
133
135
  */
@@ -145,21 +147,5 @@ type ConfirmationState = 'INITIAL' | 'CODE_CHECKING' | 'CODE_SENDING' | 'CODE_ER
145
147
  type ScreensMap = {
146
148
  [key: string]: ComponentType;
147
149
  };
148
- declare const defaultTexts: {
149
- title: string;
150
- codeError: string;
151
- codeChecking: string;
152
- codeSending: string;
153
- buttonRetry: string;
154
- linkToHint: string;
155
- hintButton: string;
156
- noAttemptsLeft: string;
157
- fatalErrorTitle: string;
158
- fatalErrorDescription: string;
159
- fatalErrorButton: string;
160
- tempBlockTitle: string;
161
- tempBlockDescription: string;
162
- codeSended: string;
163
- countdown: string;
164
- };
150
+ declare const defaultTexts: ConfirmationTexts;
165
151
  export { ConfirmationProps, TConfirmationContext, ConfirmationTexts, ConfirmationScreen, ConfirmationState, ScreensMap, defaultTexts };
package/types.js CHANGED
@@ -18,6 +18,8 @@ var defaultTexts = {
18
18
  tempBlockDescription: 'Повторное подтверждение кодом будет возможно через 24\xa0часа',
19
19
  codeSended: 'Код выслан',
20
20
  countdown: 'Запросить повторно можно через',
21
+ domesticPhone: '8 800 200 00 00',
22
+ internationalPhone: '+7 495 78 888 78',
21
23
  };
22
24
 
23
25
  exports.defaultTexts = defaultTexts;
package/utils.d.ts CHANGED
@@ -27,4 +27,8 @@ declare const useConfirmation: ({ state, screen, blockSmsRetry }?: UseConfirmati
27
27
  setConfirmationScreen: import("react").Dispatch<import("react").SetStateAction<string>>;
28
28
  setConfirmationBlockSmsRetry: import("react").Dispatch<import("react").SetStateAction<boolean>>;
29
29
  };
30
- export { formatMsAsMinutes, useCountdown, ONE_DAY, ONE_MINUTE, useConfirmation };
30
+ /**
31
+ * @returns ссылку для набора номера
32
+ */
33
+ declare function getPhoneHref(phone: string): string;
34
+ export { formatMsAsMinutes, useCountdown, ONE_DAY, ONE_MINUTE, useConfirmation, getPhoneHref };
package/utils.js CHANGED
@@ -74,9 +74,17 @@ var useConfirmation = function (_a) {
74
74
  setConfirmationBlockSmsRetry: setConfirmationBlockSmsRetry,
75
75
  };
76
76
  };
77
+ var NON_NUMBER_OR_PLUS_REGEXP = new RegExp(/[^\d+]/g);
78
+ /**
79
+ * @returns ссылку для набора номера
80
+ */
81
+ function getPhoneHref(phone) {
82
+ return "tel:".concat(phone.replace(NON_NUMBER_OR_PLUS_REGEXP, ''));
83
+ }
77
84
 
78
85
  exports.ONE_DAY = ONE_DAY;
79
86
  exports.ONE_MINUTE = ONE_MINUTE;
80
87
  exports.formatMsAsMinutes = formatMsAsMinutes;
88
+ exports.getPhoneHref = getPhoneHref;
81
89
  exports.useConfirmation = useConfirmation;
82
90
  exports.useCountdown = useCountdown;