@alfalab/core-components-pattern-lock-v1 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (142) hide show
  1. package/@alfalab/core-components-shared/package.json +23 -0
  2. package/Component.responsive.d.ts +10 -0
  3. package/Component.responsive.js +27 -0
  4. package/components/base-pattern-lock/Component.d.ts +6 -0
  5. package/components/base-pattern-lock/Component.js +68 -0
  6. package/components/base-pattern-lock/index.css +45 -0
  7. package/components/base-pattern-lock/index.d.ts +1 -0
  8. package/components/base-pattern-lock/index.js +9 -0
  9. package/consts.d.ts +11 -0
  10. package/consts.js +34 -0
  11. package/cssm/Component.responsive.d.ts +10 -0
  12. package/cssm/Component.responsive.js +27 -0
  13. package/cssm/components/base-pattern-lock/Component.d.ts +6 -0
  14. package/cssm/components/base-pattern-lock/Component.js +67 -0
  15. package/cssm/components/base-pattern-lock/index.d.ts +1 -0
  16. package/cssm/components/base-pattern-lock/index.js +9 -0
  17. package/cssm/components/base-pattern-lock/index.module.css +44 -0
  18. package/cssm/consts.d.ts +11 -0
  19. package/cssm/consts.js +34 -0
  20. package/cssm/desktop/Component.desktop.d.ts +6 -0
  21. package/cssm/desktop/Component.desktop.js +17 -0
  22. package/cssm/desktop/desktop.module.css +27 -0
  23. package/cssm/desktop/index.d.ts +2 -0
  24. package/cssm/desktop/index.js +9 -0
  25. package/cssm/hooks/use-pattern-lock-cleanup.d.ts +6 -0
  26. package/cssm/hooks/use-pattern-lock-cleanup.js +18 -0
  27. package/cssm/index.d.ts +3 -0
  28. package/cssm/index.js +11 -0
  29. package/cssm/mobile/Component.mobile.d.ts +6 -0
  30. package/cssm/mobile/Component.mobile.js +17 -0
  31. package/cssm/mobile/index.d.ts +2 -0
  32. package/cssm/mobile/index.js +9 -0
  33. package/cssm/mobile/mobile.module.css +47 -0
  34. package/cssm/shared/index.d.ts +2 -0
  35. package/cssm/shared/index.js +11 -0
  36. package/cssm/typings.d.ts +91 -0
  37. package/cssm/typings.js +2 -0
  38. package/cssm/utils.d.ts +16 -0
  39. package/cssm/utils.js +96 -0
  40. package/cssm/vars.css +0 -0
  41. package/desktop/Component.desktop.d.ts +6 -0
  42. package/desktop/Component.desktop.js +18 -0
  43. package/desktop/desktop.css +28 -0
  44. package/desktop/index.d.ts +2 -0
  45. package/desktop/index.js +9 -0
  46. package/desktop/package.json +3 -0
  47. package/esm/Component.responsive.d.ts +10 -0
  48. package/esm/Component.responsive.js +19 -0
  49. package/esm/components/base-pattern-lock/Component.d.ts +6 -0
  50. package/esm/components/base-pattern-lock/Component.js +59 -0
  51. package/esm/components/base-pattern-lock/index.css +45 -0
  52. package/esm/components/base-pattern-lock/index.d.ts +1 -0
  53. package/esm/components/base-pattern-lock/index.js +1 -0
  54. package/esm/consts.d.ts +11 -0
  55. package/esm/consts.js +27 -0
  56. package/esm/desktop/Component.desktop.d.ts +6 -0
  57. package/esm/desktop/Component.desktop.js +10 -0
  58. package/esm/desktop/desktop.css +28 -0
  59. package/esm/desktop/index.d.ts +2 -0
  60. package/esm/desktop/index.js +1 -0
  61. package/esm/hooks/use-pattern-lock-cleanup.d.ts +6 -0
  62. package/esm/hooks/use-pattern-lock-cleanup.js +14 -0
  63. package/esm/index.d.ts +3 -0
  64. package/esm/index.js +2 -0
  65. package/esm/mobile/Component.mobile.d.ts +6 -0
  66. package/esm/mobile/Component.mobile.js +10 -0
  67. package/esm/mobile/index.d.ts +2 -0
  68. package/esm/mobile/index.js +1 -0
  69. package/esm/mobile/mobile.css +48 -0
  70. package/esm/shared/index.d.ts +2 -0
  71. package/esm/shared/index.js +2 -0
  72. package/esm/typings.d.ts +91 -0
  73. package/esm/typings.js +1 -0
  74. package/esm/utils.d.ts +16 -0
  75. package/esm/utils.js +88 -0
  76. package/hooks/use-pattern-lock-cleanup.d.ts +6 -0
  77. package/hooks/use-pattern-lock-cleanup.js +18 -0
  78. package/index.d.ts +3 -0
  79. package/index.js +11 -0
  80. package/mobile/Component.mobile.d.ts +6 -0
  81. package/mobile/Component.mobile.js +18 -0
  82. package/mobile/index.d.ts +2 -0
  83. package/mobile/index.js +9 -0
  84. package/mobile/mobile.css +48 -0
  85. package/mobile/package.json +3 -0
  86. package/modern/Component.responsive.d.ts +10 -0
  87. package/modern/Component.responsive.js +17 -0
  88. package/modern/components/base-pattern-lock/Component.d.ts +6 -0
  89. package/modern/components/base-pattern-lock/Component.js +54 -0
  90. package/modern/components/base-pattern-lock/index.css +45 -0
  91. package/modern/components/base-pattern-lock/index.d.ts +1 -0
  92. package/modern/components/base-pattern-lock/index.js +1 -0
  93. package/modern/consts.d.ts +11 -0
  94. package/modern/consts.js +27 -0
  95. package/modern/desktop/Component.desktop.d.ts +6 -0
  96. package/modern/desktop/Component.desktop.js +9 -0
  97. package/modern/desktop/desktop.css +28 -0
  98. package/modern/desktop/index.d.ts +2 -0
  99. package/modern/desktop/index.js +1 -0
  100. package/modern/hooks/use-pattern-lock-cleanup.d.ts +6 -0
  101. package/modern/hooks/use-pattern-lock-cleanup.js +14 -0
  102. package/modern/index.d.ts +3 -0
  103. package/modern/index.js +2 -0
  104. package/modern/mobile/Component.mobile.d.ts +6 -0
  105. package/modern/mobile/Component.mobile.js +9 -0
  106. package/modern/mobile/index.d.ts +2 -0
  107. package/modern/mobile/index.js +1 -0
  108. package/modern/mobile/mobile.css +48 -0
  109. package/modern/shared/index.d.ts +2 -0
  110. package/modern/shared/index.js +2 -0
  111. package/modern/typings.d.ts +91 -0
  112. package/modern/typings.js +1 -0
  113. package/modern/utils.d.ts +16 -0
  114. package/modern/utils.js +98 -0
  115. package/package.json +25 -0
  116. package/shared/index.d.ts +2 -0
  117. package/shared/index.js +11 -0
  118. package/shared/package.json +3 -0
  119. package/src/Component.responsive.tsx +24 -0
  120. package/src/components/base-pattern-lock/Component.tsx +146 -0
  121. package/src/components/base-pattern-lock/index.module.css +34 -0
  122. package/src/components/base-pattern-lock/index.ts +1 -0
  123. package/src/consts.ts +32 -0
  124. package/src/desktop/Component.desktop.tsx +11 -0
  125. package/src/desktop/desktop.module.css +15 -0
  126. package/src/desktop/index.ts +2 -0
  127. package/src/desktop/package.json +3 -0
  128. package/src/hooks/use-pattern-lock-cleanup.tsx +16 -0
  129. package/src/index.ts +3 -0
  130. package/src/mobile/Component.mobile.tsx +11 -0
  131. package/src/mobile/index.ts +2 -0
  132. package/src/mobile/mobile.module.css +32 -0
  133. package/src/mobile/package.json +3 -0
  134. package/src/shared/index.ts +2 -0
  135. package/src/shared/package.json +3 -0
  136. package/src/typings.ts +103 -0
  137. package/src/utils.ts +105 -0
  138. package/src/vars.css +4 -0
  139. package/typings.d.ts +91 -0
  140. package/typings.js +2 -0
  141. package/utils.d.ts +16 -0
  142. package/utils.js +96 -0
@@ -0,0 +1,16 @@
1
+ import { useMemo } from 'react';
2
+ import type { TPatternLockInstance } from 'react-canvas-pattern-lock';
3
+
4
+ export const usePatternLockCleanup = (
5
+ patternLockRef: React.MutableRefObject<TPatternLockInstance | null>,
6
+ ) => {
7
+ const clear = useMemo(() => {
8
+ if (patternLockRef.current) {
9
+ patternLockRef.current.setInitialState();
10
+ }
11
+ }, [patternLockRef]);
12
+
13
+ return {
14
+ clear,
15
+ };
16
+ };
package/src/index.ts ADDED
@@ -0,0 +1,3 @@
1
+ export type { PatternLockProps } from './typings';
2
+ export * from './Component.responsive';
3
+ export { THEME_STATE } from './consts';
@@ -0,0 +1,11 @@
1
+ import React, { forwardRef } from 'react';
2
+ import type { TPatternLockInstance } from 'react-canvas-pattern-lock';
3
+
4
+ import { BasePatternLock } from '../components/base-pattern-lock';
5
+ import { CommonPatternLockProps } from '../typings';
6
+
7
+ import styles from './mobile.module.css';
8
+
9
+ export const PatternLockMobileV1 = forwardRef<TPatternLockInstance, CommonPatternLockProps>(
10
+ (restProps, ref) => <BasePatternLock {...restProps} ref={ref} styles={styles} />,
11
+ );
@@ -0,0 +1,2 @@
1
+ export { PatternLockMobileV1 } from './Component.mobile';
2
+ export type { CommonPatternLockProps as PatternLockMobileProps } from '../typings';
@@ -0,0 +1,32 @@
1
+ @import '@alfalab/core-components-themes/src/default.css';
2
+ @import '../vars.css';
3
+
4
+ .component {
5
+ max-width: var(--pattern-lock-v1-max-width);
6
+ margin: var(--gap-xs) 0 var(--gap-xl) 0;
7
+ }
8
+
9
+ .forgotBtn {
10
+ margin: var(--gap-xl) auto 0;
11
+ }
12
+
13
+ @media screen and (min-width: 360px) {
14
+ .forgotBtn {
15
+ margin-top: var(--gap-2xl);
16
+ min-height: var(--size-s-height);
17
+ }
18
+
19
+ .component {
20
+ margin-bottom: var(--gap-s);
21
+ }
22
+ }
23
+
24
+ @media screen and (min-width: 390px) {
25
+ .forgotBtn {
26
+ min-height: var(--size-m-height);
27
+ }
28
+
29
+ .component {
30
+ margin-bottom: var(--gap-l);
31
+ }
32
+ }
@@ -0,0 +1,3 @@
1
+ {
2
+ "module": "../esm/mobile/index.js"
3
+ }
@@ -0,0 +1,2 @@
1
+ export { getPatternLockTestIds } from '../utils';
2
+ export { usePatternLockCleanup } from '../hooks/use-pattern-lock-cleanup';
@@ -0,0 +1,3 @@
1
+ {
2
+ "module": "../esm/shared/index.js"
3
+ }
package/src/typings.ts ADDED
@@ -0,0 +1,103 @@
1
+ import { MouseEvent, ReactNode } from 'react';
2
+ import { ReactPatternLockProps } from 'react-canvas-pattern-lock';
3
+
4
+ type ConditionalProps =
5
+ | {
6
+ /**
7
+ * Показать кнопку "забыли код"
8
+ * @default "Забыли код?"
9
+ */
10
+ showForgotCodeBtn: true;
11
+
12
+ /**
13
+ * Текст кнопки "забыли код"
14
+ * @default "Забыли код?"
15
+ */
16
+ forgotCodeBtnText?: string;
17
+
18
+ /**
19
+ * Коллбэк, вызываемый при клике на кнопку "Забыли код"
20
+ */
21
+ onForgotBtnClick: (event: MouseEvent<HTMLButtonElement>) => void;
22
+ }
23
+ | {
24
+ showForgotCodeBtn?: false;
25
+ onForgotBtnClick?: never;
26
+ forgotCodeBtnText?: never;
27
+ };
28
+
29
+ export type CommonPatternLockProps = {
30
+ /**
31
+ * Дополнительный класс
32
+ */
33
+ className?: string;
34
+
35
+ /**
36
+ * Сообщение об ошибке
37
+ */
38
+ error?: ReactNode;
39
+
40
+ /**
41
+ * Сообщение над графическим ключом
42
+ */
43
+ message?: ReactNode;
44
+
45
+ /**
46
+ * Идентификатор для систем автоматизированного тестирования.
47
+ * Для сообщения используется модификатор -message, ошибки -error,
48
+ * кнопки "забыли код" -forgot-code-btn
49
+ */
50
+ dataTestId?: string;
51
+
52
+ /**
53
+ * Следить ли за изменениями значений цветовых токенов
54
+ * @default false
55
+ */
56
+ observeTokens?: boolean;
57
+
58
+ /**
59
+ * Параметры MutationObserver для наблюдения за изменениями режима(css custom properties)
60
+ */
61
+ observerParams?: {
62
+ getTarget?: () => Node;
63
+ options?: MutationObserverInit;
64
+ };
65
+
66
+ /**
67
+ * Дополнительный класс для message/errorMessage
68
+ */
69
+ messageClassName?: string;
70
+ } & Omit<ReactPatternLockProps, 'theme' | 'width' | 'height' | 'rows' | 'cols' | 'hover'> &
71
+ ConditionalProps;
72
+
73
+ export type PrivatePatternLockProps = {
74
+ /**
75
+ * Включает ховер-эффект
76
+ */
77
+ hover?: boolean;
78
+ /**
79
+ * Стили компонента
80
+ */
81
+ styles: { [key: string]: string };
82
+ };
83
+
84
+ export type PatternLockProps = CommonPatternLockProps & {
85
+ /**
86
+ * Контрольная точка, с нее начинается desktop версия
87
+ * @default 1024
88
+ */
89
+ breakpoint?: number;
90
+ };
91
+ export type ObservableTokens = {
92
+ ACCENT_INITIAL: string;
93
+ ACCENT_SUCCESS: string;
94
+ ACCENT_FAILURE: string;
95
+ RING_BG_INITIAL: string;
96
+ SELECTED_RING_BG_INITIAL: string;
97
+ SELECTED_RING_BG_SUCCESS: string;
98
+ SELECTED_RING_BG_FAILURE: string;
99
+ PRIMARY: string;
100
+ BG: string;
101
+ HOVER_INNER: string;
102
+ HOVER_OUTER: string;
103
+ };
package/src/utils.ts ADDED
@@ -0,0 +1,105 @@
1
+ import { Theme, ThemeParams } from 'react-canvas-pattern-lock';
2
+
3
+ import { getDataTestId } from '@alfalab/core-components-shared';
4
+
5
+ import { OBSERVABLE_TOKENS, THEME_STATE } from './consts';
6
+
7
+ export function getDefaultObserveTarget() {
8
+ return document.head;
9
+ }
10
+
11
+ export function getColorByToken(token: string) {
12
+ return getComputedStyle(document.documentElement).getPropertyValue(token);
13
+ }
14
+
15
+ export const getSizes = (() => {
16
+ const COMMON_SIZES = {
17
+ lineWidth: 6,
18
+ nodeRing: 0,
19
+ nodeCore: 12,
20
+ };
21
+
22
+ let cachedSize: { elementSizes: ThemeParams['dimens']; width: number; height: number };
23
+
24
+ return () => {
25
+ if (cachedSize) {
26
+ return cachedSize;
27
+ }
28
+
29
+ if (window.matchMedia('(min-width: 600px)').matches) {
30
+ cachedSize = {
31
+ elementSizes: { ...COMMON_SIZES, nodeRadius: 32 },
32
+ width: 240,
33
+ height: 240,
34
+ };
35
+ } else if (window.matchMedia('(min-width: 390px)').matches) {
36
+ cachedSize = {
37
+ elementSizes: { ...COMMON_SIZES, nodeRadius: 43 },
38
+ width: 322,
39
+ height: 322,
40
+ };
41
+ } else if (window.matchMedia('(min-width: 360px)').matches) {
42
+ cachedSize = {
43
+ elementSizes: { ...COMMON_SIZES, nodeRadius: 38 },
44
+ width: 292,
45
+ height: 292,
46
+ };
47
+ } else {
48
+ cachedSize = {
49
+ elementSizes: { ...COMMON_SIZES, nodeRadius: 32 },
50
+ width: 240,
51
+ height: 240,
52
+ };
53
+ }
54
+
55
+ return cachedSize;
56
+ };
57
+ })();
58
+
59
+ export function getTheme(dimens: ThemeParams['dimens']): Theme {
60
+ const baseColors = {
61
+ primary: getColorByToken(OBSERVABLE_TOKENS.PRIMARY),
62
+ bg: getColorByToken(OBSERVABLE_TOKENS.BG),
63
+ ringBg: getColorByToken(OBSERVABLE_TOKENS.RING_BG_INITIAL),
64
+ hover: {
65
+ inner: getColorByToken(OBSERVABLE_TOKENS.HOVER_INNER),
66
+ outer: getColorByToken(OBSERVABLE_TOKENS.HOVER_OUTER),
67
+ },
68
+ };
69
+
70
+ return {
71
+ [THEME_STATE.INITIAL]: {
72
+ colors: {
73
+ ...baseColors,
74
+ accent: getColorByToken(OBSERVABLE_TOKENS.ACCENT_INITIAL),
75
+ selectedRingBg: getColorByToken(OBSERVABLE_TOKENS.SELECTED_RING_BG_INITIAL),
76
+ },
77
+ dimens,
78
+ },
79
+ [THEME_STATE.SUCCESS]: {
80
+ colors: {
81
+ ...baseColors,
82
+ accent: getColorByToken(OBSERVABLE_TOKENS.ACCENT_SUCCESS),
83
+ selectedRingBg: getColorByToken(OBSERVABLE_TOKENS.SELECTED_RING_BG_SUCCESS),
84
+ },
85
+ dimens,
86
+ },
87
+ [THEME_STATE.FAILURE]: {
88
+ colors: {
89
+ ...baseColors,
90
+ accent: getColorByToken(OBSERVABLE_TOKENS.ACCENT_FAILURE),
91
+ selectedRingBg: getColorByToken(OBSERVABLE_TOKENS.SELECTED_RING_BG_FAILURE),
92
+ },
93
+ dimens,
94
+ },
95
+ };
96
+ }
97
+
98
+ export function getPatternLockTestIds(dataTestId: string) {
99
+ return {
100
+ patternLock: dataTestId,
101
+ forgotCodeBtn: getDataTestId(dataTestId, 'forgot-code-btn'),
102
+ error: getDataTestId(dataTestId, 'error'),
103
+ message: getDataTestId(dataTestId, 'message'),
104
+ };
105
+ }
package/src/vars.css ADDED
@@ -0,0 +1,4 @@
1
+ :root {
2
+ --pattern-lock-v1-max-width: 500px;
3
+ --pattern-lock-v1-desktop-max-width: 240px;
4
+ }
package/typings.d.ts ADDED
@@ -0,0 +1,91 @@
1
+ import { MouseEvent, ReactNode } from 'react';
2
+ import { ReactPatternLockProps } from 'react-canvas-pattern-lock';
3
+ type ConditionalProps = {
4
+ /**
5
+ * Показать кнопку "забыли код"
6
+ * @default "Забыли код?"
7
+ */
8
+ showForgotCodeBtn: true;
9
+ /**
10
+ * Текст кнопки "забыли код"
11
+ * @default "Забыли код?"
12
+ */
13
+ forgotCodeBtnText?: string;
14
+ /**
15
+ * Коллбэк, вызываемый при клике на кнопку "Забыли код"
16
+ */
17
+ onForgotBtnClick: (event: MouseEvent<HTMLButtonElement>) => void;
18
+ } | {
19
+ showForgotCodeBtn?: false;
20
+ onForgotBtnClick?: never;
21
+ forgotCodeBtnText?: never;
22
+ };
23
+ type CommonPatternLockProps = {
24
+ /**
25
+ * Дополнительный класс
26
+ */
27
+ className?: string;
28
+ /**
29
+ * Сообщение об ошибке
30
+ */
31
+ error?: ReactNode;
32
+ /**
33
+ * Сообщение над графическим ключом
34
+ */
35
+ message?: ReactNode;
36
+ /**
37
+ * Идентификатор для систем автоматизированного тестирования.
38
+ * Для сообщения используется модификатор -message, ошибки -error,
39
+ * кнопки "забыли код" -forgot-code-btn
40
+ */
41
+ dataTestId?: string;
42
+ /**
43
+ * Следить ли за изменениями значений цветовых токенов
44
+ * @default false
45
+ */
46
+ observeTokens?: boolean;
47
+ /**
48
+ * Параметры MutationObserver для наблюдения за изменениями режима(css custom properties)
49
+ */
50
+ observerParams?: {
51
+ getTarget?: () => Node;
52
+ options?: MutationObserverInit;
53
+ };
54
+ /**
55
+ * Дополнительный класс для message/errorMessage
56
+ */
57
+ messageClassName?: string;
58
+ } & Omit<ReactPatternLockProps, 'theme' | 'width' | 'height' | 'rows' | 'cols' | 'hover'> & ConditionalProps;
59
+ type PrivatePatternLockProps = {
60
+ /**
61
+ * Включает ховер-эффект
62
+ */
63
+ hover?: boolean;
64
+ /**
65
+ * Стили компонента
66
+ */
67
+ styles: {
68
+ [key: string]: string;
69
+ };
70
+ };
71
+ type PatternLockProps = CommonPatternLockProps & {
72
+ /**
73
+ * Контрольная точка, с нее начинается desktop версия
74
+ * @default 1024
75
+ */
76
+ breakpoint?: number;
77
+ };
78
+ type ObservableTokens = {
79
+ ACCENT_INITIAL: string;
80
+ ACCENT_SUCCESS: string;
81
+ ACCENT_FAILURE: string;
82
+ RING_BG_INITIAL: string;
83
+ SELECTED_RING_BG_INITIAL: string;
84
+ SELECTED_RING_BG_SUCCESS: string;
85
+ SELECTED_RING_BG_FAILURE: string;
86
+ PRIMARY: string;
87
+ BG: string;
88
+ HOVER_INNER: string;
89
+ HOVER_OUTER: string;
90
+ };
91
+ export { CommonPatternLockProps, PrivatePatternLockProps, PatternLockProps, ObservableTokens };
package/typings.js ADDED
@@ -0,0 +1,2 @@
1
+ 'use strict';
2
+
package/utils.d.ts ADDED
@@ -0,0 +1,16 @@
1
+ import { Theme, ThemeParams } from 'react-canvas-pattern-lock';
2
+ declare function getDefaultObserveTarget(): HTMLHeadElement;
3
+ declare function getColorByToken(token: string): string;
4
+ declare const getSizes: () => {
5
+ elementSizes: ThemeParams['dimens'];
6
+ width: number;
7
+ height: number;
8
+ };
9
+ declare function getTheme(dimens: ThemeParams['dimens']): Theme;
10
+ declare function getPatternLockTestIds(dataTestId: string): {
11
+ patternLock: string;
12
+ forgotCodeBtn: string;
13
+ error: string;
14
+ message: string;
15
+ };
16
+ export { getDefaultObserveTarget, getColorByToken, getSizes, getTheme, getPatternLockTestIds };
package/utils.js ADDED
@@ -0,0 +1,96 @@
1
+ 'use strict';
2
+
3
+ Object.defineProperty(exports, '__esModule', { value: true });
4
+
5
+ var tslib = require('tslib');
6
+ var coreComponentsShared = require('@alfalab/core-components-shared');
7
+ var consts = require('./consts.js');
8
+
9
+ function getDefaultObserveTarget() {
10
+ return document.head;
11
+ }
12
+ function getColorByToken(token) {
13
+ return getComputedStyle(document.documentElement).getPropertyValue(token);
14
+ }
15
+ var getSizes = (function () {
16
+ var COMMON_SIZES = {
17
+ lineWidth: 6,
18
+ nodeRing: 0,
19
+ nodeCore: 12,
20
+ };
21
+ var cachedSize;
22
+ return function () {
23
+ if (cachedSize) {
24
+ return cachedSize;
25
+ }
26
+ if (window.matchMedia('(min-width: 600px)').matches) {
27
+ cachedSize = {
28
+ elementSizes: tslib.__assign(tslib.__assign({}, COMMON_SIZES), { nodeRadius: 32 }),
29
+ width: 240,
30
+ height: 240,
31
+ };
32
+ }
33
+ else if (window.matchMedia('(min-width: 390px)').matches) {
34
+ cachedSize = {
35
+ elementSizes: tslib.__assign(tslib.__assign({}, COMMON_SIZES), { nodeRadius: 43 }),
36
+ width: 322,
37
+ height: 322,
38
+ };
39
+ }
40
+ else if (window.matchMedia('(min-width: 360px)').matches) {
41
+ cachedSize = {
42
+ elementSizes: tslib.__assign(tslib.__assign({}, COMMON_SIZES), { nodeRadius: 38 }),
43
+ width: 292,
44
+ height: 292,
45
+ };
46
+ }
47
+ else {
48
+ cachedSize = {
49
+ elementSizes: tslib.__assign(tslib.__assign({}, COMMON_SIZES), { nodeRadius: 32 }),
50
+ width: 240,
51
+ height: 240,
52
+ };
53
+ }
54
+ return cachedSize;
55
+ };
56
+ })();
57
+ function getTheme(dimens) {
58
+ var _a;
59
+ var baseColors = {
60
+ primary: getColorByToken(consts.OBSERVABLE_TOKENS.PRIMARY),
61
+ bg: getColorByToken(consts.OBSERVABLE_TOKENS.BG),
62
+ ringBg: getColorByToken(consts.OBSERVABLE_TOKENS.RING_BG_INITIAL),
63
+ hover: {
64
+ inner: getColorByToken(consts.OBSERVABLE_TOKENS.HOVER_INNER),
65
+ outer: getColorByToken(consts.OBSERVABLE_TOKENS.HOVER_OUTER),
66
+ },
67
+ };
68
+ return _a = {},
69
+ _a[consts.THEME_STATE.INITIAL] = {
70
+ colors: tslib.__assign(tslib.__assign({}, baseColors), { accent: getColorByToken(consts.OBSERVABLE_TOKENS.ACCENT_INITIAL), selectedRingBg: getColorByToken(consts.OBSERVABLE_TOKENS.SELECTED_RING_BG_INITIAL) }),
71
+ dimens: dimens,
72
+ },
73
+ _a[consts.THEME_STATE.SUCCESS] = {
74
+ colors: tslib.__assign(tslib.__assign({}, baseColors), { accent: getColorByToken(consts.OBSERVABLE_TOKENS.ACCENT_SUCCESS), selectedRingBg: getColorByToken(consts.OBSERVABLE_TOKENS.SELECTED_RING_BG_SUCCESS) }),
75
+ dimens: dimens,
76
+ },
77
+ _a[consts.THEME_STATE.FAILURE] = {
78
+ colors: tslib.__assign(tslib.__assign({}, baseColors), { accent: getColorByToken(consts.OBSERVABLE_TOKENS.ACCENT_FAILURE), selectedRingBg: getColorByToken(consts.OBSERVABLE_TOKENS.SELECTED_RING_BG_FAILURE) }),
79
+ dimens: dimens,
80
+ },
81
+ _a;
82
+ }
83
+ function getPatternLockTestIds(dataTestId) {
84
+ return {
85
+ patternLock: dataTestId,
86
+ forgotCodeBtn: coreComponentsShared.getDataTestId(dataTestId, 'forgot-code-btn'),
87
+ error: coreComponentsShared.getDataTestId(dataTestId, 'error'),
88
+ message: coreComponentsShared.getDataTestId(dataTestId, 'message'),
89
+ };
90
+ }
91
+
92
+ exports.getColorByToken = getColorByToken;
93
+ exports.getDefaultObserveTarget = getDefaultObserveTarget;
94
+ exports.getPatternLockTestIds = getPatternLockTestIds;
95
+ exports.getSizes = getSizes;
96
+ exports.getTheme = getTheme;