@alfalab/core-components-pattern-lock 1.5.1 → 1.6.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/Component.responsive.js +23 -0
- package/components/base-pattern-lock/Component.d.ts +6 -0
- package/{Component.js → components/base-pattern-lock/Component.js} +17 -16
- package/{esm → components/base-pattern-lock}/index.css +8 -36
- package/components/base-pattern-lock/index.d.ts +1 -0
- package/components/base-pattern-lock/index.js +9 -0
- package/consts.js +2 -0
- package/cssm/Component.responsive.js +23 -0
- package/cssm/components/base-pattern-lock/Component.d.ts +6 -0
- package/cssm/{Component.js → components/base-pattern-lock/Component.js} +18 -17
- package/cssm/components/base-pattern-lock/index.d.ts +1 -0
- package/cssm/components/base-pattern-lock/index.js +9 -0
- package/cssm/{index.module.css → components/base-pattern-lock/index.module.css} +2 -30
- package/cssm/consts.js +2 -0
- package/cssm/desktop/Component.desktop.d.ts +6 -0
- package/cssm/desktop/Component.desktop.js +17 -0
- package/cssm/desktop/desktop.module.css +27 -0
- package/cssm/desktop/index.d.ts +2 -0
- package/cssm/desktop/index.js +9 -0
- package/cssm/hooks/use-pattern-lock-cleanup.d.ts +6 -0
- package/cssm/hooks/use-pattern-lock-cleanup.js +18 -0
- package/cssm/index.d.ts +1 -1
- package/cssm/index.js +2 -2
- package/cssm/mobile/Component.mobile.d.ts +6 -0
- package/cssm/mobile/Component.mobile.js +17 -0
- package/cssm/mobile/index.d.ts +2 -0
- package/cssm/mobile/index.js +9 -0
- package/cssm/mobile/mobile.module.css +47 -0
- package/cssm/shared/index.d.ts +1 -0
- package/cssm/shared/index.js +2 -0
- package/cssm/typings.d.ts +29 -4
- package/cssm/utils.js +12 -1
- package/desktop/Component.desktop.d.ts +6 -0
- package/desktop/Component.desktop.js +18 -0
- package/desktop/desktop.css +28 -0
- package/desktop/index.d.ts +2 -0
- package/desktop/index.js +9 -0
- package/desktop/package.json +3 -0
- package/esm/Component.responsive.js +15 -0
- package/esm/components/base-pattern-lock/Component.d.ts +6 -0
- package/esm/{Component.js → components/base-pattern-lock/Component.js} +17 -16
- package/{modern → esm/components/base-pattern-lock}/index.css +8 -36
- package/esm/components/base-pattern-lock/index.d.ts +1 -0
- package/esm/components/base-pattern-lock/index.js +1 -0
- package/esm/consts.js +2 -0
- package/esm/desktop/Component.desktop.d.ts +6 -0
- package/esm/desktop/Component.desktop.js +10 -0
- package/esm/desktop/desktop.css +28 -0
- package/esm/desktop/index.d.ts +2 -0
- package/esm/desktop/index.js +1 -0
- package/esm/hooks/use-pattern-lock-cleanup.d.ts +6 -0
- package/esm/hooks/use-pattern-lock-cleanup.js +14 -0
- package/esm/index.d.ts +1 -1
- package/esm/index.js +1 -1
- package/esm/mobile/Component.mobile.d.ts +6 -0
- package/esm/mobile/Component.mobile.js +10 -0
- package/esm/mobile/index.d.ts +2 -0
- package/esm/mobile/index.js +1 -0
- package/esm/mobile/mobile.css +48 -0
- package/esm/shared/index.d.ts +1 -0
- package/esm/shared/index.js +1 -0
- package/esm/typings.d.ts +29 -4
- package/esm/utils.js +12 -1
- package/hooks/use-pattern-lock-cleanup.d.ts +6 -0
- package/hooks/use-pattern-lock-cleanup.js +18 -0
- package/index.d.ts +1 -1
- package/index.js +2 -2
- package/mobile/Component.mobile.d.ts +6 -0
- package/mobile/Component.mobile.js +18 -0
- package/mobile/index.d.ts +2 -0
- package/mobile/index.js +9 -0
- package/mobile/mobile.css +48 -0
- package/mobile/package.json +3 -0
- package/modern/Component.responsive.js +13 -0
- package/modern/components/base-pattern-lock/Component.d.ts +6 -0
- package/modern/{Component.js → components/base-pattern-lock/Component.js} +14 -13
- package/{index.css → modern/components/base-pattern-lock/index.css} +8 -36
- package/modern/components/base-pattern-lock/index.d.ts +1 -0
- package/modern/components/base-pattern-lock/index.js +1 -0
- package/modern/consts.js +2 -0
- package/modern/desktop/Component.desktop.d.ts +6 -0
- package/modern/desktop/Component.desktop.js +9 -0
- package/modern/desktop/desktop.css +28 -0
- package/modern/desktop/index.d.ts +2 -0
- package/modern/desktop/index.js +1 -0
- package/modern/hooks/use-pattern-lock-cleanup.d.ts +6 -0
- package/modern/hooks/use-pattern-lock-cleanup.js +14 -0
- package/modern/index.d.ts +1 -1
- package/modern/index.js +1 -1
- package/modern/mobile/Component.mobile.d.ts +6 -0
- package/modern/mobile/Component.mobile.js +9 -0
- package/modern/mobile/index.d.ts +2 -0
- package/modern/mobile/index.js +1 -0
- package/modern/mobile/mobile.css +48 -0
- package/modern/shared/index.d.ts +1 -0
- package/modern/shared/index.js +1 -0
- package/modern/typings.d.ts +29 -4
- package/modern/utils.js +12 -1
- package/package.json +4 -4
- package/shared/index.d.ts +1 -0
- package/shared/index.js +2 -0
- package/src/Component.responsive.tsx +20 -0
- package/src/{Component.tsx → components/base-pattern-lock/Component.tsx} +34 -18
- package/src/components/base-pattern-lock/index.module.css +34 -0
- package/src/components/base-pattern-lock/index.ts +1 -0
- package/src/consts.ts +2 -0
- package/src/desktop/Component.desktop.tsx +11 -0
- package/src/desktop/desktop.module.css +15 -0
- package/src/desktop/index.ts +2 -0
- package/src/desktop/package.json +3 -0
- package/src/hooks/use-pattern-lock-cleanup.tsx +16 -0
- package/src/index.ts +1 -1
- package/src/mobile/Component.mobile.tsx +11 -0
- package/src/mobile/index.ts +2 -0
- package/src/{index.module.css → mobile/mobile.module.css} +1 -28
- package/src/mobile/package.json +3 -0
- package/src/shared/index.ts +1 -0
- package/src/typings.ts +28 -3
- package/src/utils.ts +11 -1
- package/src/vars.css +1 -0
- package/typings.d.ts +29 -4
- package/utils.js +12 -1
- /package/{Component.d.ts → Component.responsive.d.ts} +0 -0
- /package/cssm/{Component.d.ts → Component.responsive.d.ts} +0 -0
- /package/esm/{Component.d.ts → Component.responsive.d.ts} +0 -0
- /package/modern/{Component.d.ts → Component.responsive.d.ts} +0 -0
|
@@ -4,16 +4,23 @@ import { ReactCanvasPatternLock } from 'react-canvas-pattern-lock';
|
|
|
4
4
|
import cn from 'classnames';
|
|
5
5
|
|
|
6
6
|
import { ButtonMobile } from '@alfalab/core-components-button/mobile';
|
|
7
|
-
import { Gap } from '@alfalab/core-components-gap';
|
|
8
7
|
import { getDataTestId } from '@alfalab/core-components-shared';
|
|
9
8
|
|
|
10
|
-
import {
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
9
|
+
import {
|
|
10
|
+
DEFAULT_EXTRA_BOUNDS,
|
|
11
|
+
OBSERVABLE_TOKENS,
|
|
12
|
+
OBSERVE_OPTIONS,
|
|
13
|
+
THEME_STATE,
|
|
14
|
+
} from '../../consts';
|
|
15
|
+
import type { CommonPatternLockProps, PrivatePatternLockProps } from '../../typings';
|
|
16
|
+
import { getColorByToken, getDefaultObserveTarget, getSizes, getTheme } from '../../utils';
|
|
17
|
+
|
|
18
|
+
import commonStyles from './index.module.css';
|
|
19
|
+
|
|
20
|
+
export const BasePatternLock = forwardRef<
|
|
21
|
+
TPatternLockInstance,
|
|
22
|
+
CommonPatternLockProps & PrivatePatternLockProps
|
|
23
|
+
>(
|
|
17
24
|
(
|
|
18
25
|
{
|
|
19
26
|
observeTokens = false,
|
|
@@ -27,6 +34,9 @@ export const PatternLock = forwardRef<TPatternLockInstance, PatternLockProps>(
|
|
|
27
34
|
onForgotBtnClick,
|
|
28
35
|
extraBounds = DEFAULT_EXTRA_BOUNDS,
|
|
29
36
|
message,
|
|
37
|
+
messageClassName,
|
|
38
|
+
hover,
|
|
39
|
+
styles = {},
|
|
30
40
|
...restProps
|
|
31
41
|
},
|
|
32
42
|
ref,
|
|
@@ -77,14 +87,17 @@ export const PatternLock = forwardRef<TPatternLockInstance, PatternLockProps>(
|
|
|
77
87
|
}, [observeTokens]);
|
|
78
88
|
|
|
79
89
|
const renderMessage = () => (
|
|
80
|
-
<div
|
|
90
|
+
<div
|
|
91
|
+
className={cn(commonStyles.message, messageClassName)}
|
|
92
|
+
data-test-id={getDataTestId(dataTestId, 'message')}
|
|
93
|
+
>
|
|
81
94
|
{message}
|
|
82
95
|
</div>
|
|
83
96
|
);
|
|
84
97
|
|
|
85
98
|
const renderError = () => (
|
|
86
99
|
<div
|
|
87
|
-
className={cn(
|
|
100
|
+
className={cn(commonStyles.message, commonStyles.error, messageClassName)}
|
|
88
101
|
data-test-id={getDataTestId(dataTestId, 'error')}
|
|
89
102
|
>
|
|
90
103
|
{error}
|
|
@@ -93,15 +106,13 @@ export const PatternLock = forwardRef<TPatternLockInstance, PatternLockProps>(
|
|
|
93
106
|
|
|
94
107
|
return (
|
|
95
108
|
<div
|
|
96
|
-
className={cn(styles.component, className, {
|
|
109
|
+
className={cn(commonStyles.component, styles.component, className, {
|
|
110
|
+
[commonStyles.hidden]: !params,
|
|
111
|
+
})}
|
|
97
112
|
data-test-id={dataTestId}
|
|
98
113
|
>
|
|
99
|
-
<Gap size='xs' />
|
|
100
|
-
|
|
101
114
|
{error ? renderError() : renderMessage()}
|
|
102
115
|
|
|
103
|
-
<Gap size='3xl' />
|
|
104
|
-
|
|
105
116
|
<ReactCanvasPatternLock
|
|
106
117
|
{...restProps}
|
|
107
118
|
{...params}
|
|
@@ -110,19 +121,24 @@ export const PatternLock = forwardRef<TPatternLockInstance, PatternLockProps>(
|
|
|
110
121
|
cols={3}
|
|
111
122
|
justifyNodes={justifyNodes}
|
|
112
123
|
extraBounds={extraBounds}
|
|
124
|
+
hover={hover}
|
|
113
125
|
/>
|
|
114
126
|
|
|
115
127
|
{showForgotCodeBtn ? (
|
|
116
128
|
<ButtonMobile
|
|
117
|
-
view='
|
|
118
|
-
className={styles.forgotBtn}
|
|
129
|
+
view='transparent'
|
|
130
|
+
className={cn(commonStyles.forgotBtn, styles.forgotBtn)}
|
|
119
131
|
onClick={onForgotBtnClick}
|
|
120
132
|
dataTestId={getDataTestId(dataTestId, 'forgot-code-btn')}
|
|
121
133
|
>
|
|
122
134
|
{forgotCodeBtnText}
|
|
123
135
|
</ButtonMobile>
|
|
124
136
|
) : (
|
|
125
|
-
<div
|
|
137
|
+
<div
|
|
138
|
+
className={cn(commonStyles.forgotBtn, styles.forgotBtn, {
|
|
139
|
+
[styles.hiddenBtn]: Boolean(styles.hiddenBtn),
|
|
140
|
+
})}
|
|
141
|
+
/>
|
|
126
142
|
)}
|
|
127
143
|
</div>
|
|
128
144
|
);
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
@import '@alfalab/core-components-themes/src/default.css';
|
|
2
|
+
@import '../../vars.css';
|
|
3
|
+
|
|
4
|
+
.component {
|
|
5
|
+
& canvas {
|
|
6
|
+
display: block;
|
|
7
|
+
margin: 0 auto;
|
|
8
|
+
}
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
.hidden {
|
|
12
|
+
visibility: hidden;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
.message {
|
|
16
|
+
@mixin paragraph_primary_medium;
|
|
17
|
+
|
|
18
|
+
text-align: center;
|
|
19
|
+
padding: 0 var(--gap-m) var(--gap-3xl);
|
|
20
|
+
min-height: 24px;
|
|
21
|
+
overflow: hidden;
|
|
22
|
+
text-overflow: ellipsis;
|
|
23
|
+
white-space: nowrap;
|
|
24
|
+
color: var(--color-light-text-primary);
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
.error {
|
|
28
|
+
color: var(--color-light-text-negative);
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
.forgotBtn {
|
|
32
|
+
display: block;
|
|
33
|
+
min-height: var(--size-xs-height);
|
|
34
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './Component';
|
package/src/consts.ts
CHANGED
|
@@ -21,6 +21,8 @@ export const OBSERVABLE_TOKENS: ObservableTokens = {
|
|
|
21
21
|
SELECTED_RING_BG_INITIAL: '--color-light-specialbg-tertiary-transparent',
|
|
22
22
|
SELECTED_RING_BG_SUCCESS: '--color-light-graphic-positive-alpha-10',
|
|
23
23
|
SELECTED_RING_BG_FAILURE: '--color-light-graphic-negative-alpha-10',
|
|
24
|
+
HOVER_INNER: '--color-light-neutral-500-hover',
|
|
25
|
+
HOVER_OUTER: '--color-light-neutral-translucent-200-hover',
|
|
24
26
|
};
|
|
25
27
|
|
|
26
28
|
export const THEME_STATE = {
|
|
@@ -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 './desktop.module.css';
|
|
8
|
+
|
|
9
|
+
export const PatternLockDesktop = forwardRef<TPatternLockInstance, CommonPatternLockProps>(
|
|
10
|
+
(restProps, ref) => <BasePatternLock {...restProps} hover={true} ref={ref} styles={styles} />,
|
|
11
|
+
);
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
@import '@alfalab/core-components-themes/src/default.css';
|
|
2
|
+
@import '../vars.css';
|
|
3
|
+
|
|
4
|
+
.component {
|
|
5
|
+
max-width: var(--pattern-lock-desktop-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
|
+
.hiddenBtn {
|
|
14
|
+
display: none;
|
|
15
|
+
}
|
|
@@ -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
CHANGED
|
@@ -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 PatternLockMobile = forwardRef<TPatternLockInstance, CommonPatternLockProps>(
|
|
10
|
+
(restProps, ref) => <BasePatternLock {...restProps} ref={ref} styles={styles} />,
|
|
11
|
+
);
|
|
@@ -1,39 +1,12 @@
|
|
|
1
1
|
@import '@alfalab/core-components-themes/src/default.css';
|
|
2
|
-
@import '
|
|
2
|
+
@import '../vars.css';
|
|
3
3
|
|
|
4
4
|
.component {
|
|
5
5
|
max-width: var(--pattern-lock-max-width);
|
|
6
6
|
margin: var(--gap-xs) 0 var(--gap-xl) 0;
|
|
7
|
-
|
|
8
|
-
& canvas {
|
|
9
|
-
display: block;
|
|
10
|
-
margin: 0 auto;
|
|
11
|
-
}
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
.hidden {
|
|
15
|
-
visibility: hidden;
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
.message {
|
|
19
|
-
@mixin paragraph_primary_medium;
|
|
20
|
-
|
|
21
|
-
text-align: center;
|
|
22
|
-
padding: 0 var(--gap-m);
|
|
23
|
-
min-height: 24px;
|
|
24
|
-
overflow: hidden;
|
|
25
|
-
text-overflow: ellipsis;
|
|
26
|
-
white-space: nowrap;
|
|
27
|
-
color: var(--color-light-text-primary);
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
.error {
|
|
31
|
-
color: var(--color-light-text-negative);
|
|
32
7
|
}
|
|
33
8
|
|
|
34
9
|
.forgotBtn {
|
|
35
|
-
display: block;
|
|
36
|
-
min-height: var(--size-xs-height);
|
|
37
10
|
margin: var(--gap-xl) auto 0;
|
|
38
11
|
}
|
|
39
12
|
|
package/src/shared/index.ts
CHANGED
package/src/typings.ts
CHANGED
|
@@ -4,7 +4,7 @@ import { ReactPatternLockProps } from 'react-canvas-pattern-lock';
|
|
|
4
4
|
type ConditionalProps =
|
|
5
5
|
| {
|
|
6
6
|
/**
|
|
7
|
-
*
|
|
7
|
+
* Показать кнопку "забыли код"
|
|
8
8
|
* @default "Забыли код?"
|
|
9
9
|
*/
|
|
10
10
|
showForgotCodeBtn: true;
|
|
@@ -26,7 +26,7 @@ type ConditionalProps =
|
|
|
26
26
|
forgotCodeBtnText?: never;
|
|
27
27
|
};
|
|
28
28
|
|
|
29
|
-
export type
|
|
29
|
+
export type CommonPatternLockProps = {
|
|
30
30
|
/**
|
|
31
31
|
* Дополнительный класс.
|
|
32
32
|
*/
|
|
@@ -62,9 +62,32 @@ export type PatternLockProps = {
|
|
|
62
62
|
getTarget?: () => Node;
|
|
63
63
|
options?: MutationObserverInit;
|
|
64
64
|
};
|
|
65
|
-
|
|
65
|
+
|
|
66
|
+
/**
|
|
67
|
+
* Дополнительный класс для message/errorMessage
|
|
68
|
+
*/
|
|
69
|
+
messageClassName?: string;
|
|
70
|
+
} & Omit<ReactPatternLockProps, 'theme' | 'width' | 'height' | 'rows' | 'cols' | 'hover'> &
|
|
66
71
|
ConditionalProps;
|
|
67
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
|
+
};
|
|
68
91
|
export type ObservableTokens = {
|
|
69
92
|
ACCENT_INITIAL: string;
|
|
70
93
|
ACCENT_SUCCESS: string;
|
|
@@ -75,4 +98,6 @@ export type ObservableTokens = {
|
|
|
75
98
|
SELECTED_RING_BG_FAILURE: string;
|
|
76
99
|
PRIMARY: string;
|
|
77
100
|
BG: string;
|
|
101
|
+
HOVER_INNER: string;
|
|
102
|
+
HOVER_OUTER: string;
|
|
78
103
|
};
|
package/src/utils.ts
CHANGED
|
@@ -26,7 +26,13 @@ export const getSizes = (() => {
|
|
|
26
26
|
return cachedSize;
|
|
27
27
|
}
|
|
28
28
|
|
|
29
|
-
if (window.matchMedia('(min-width:
|
|
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) {
|
|
30
36
|
cachedSize = {
|
|
31
37
|
elementSizes: { ...COMMON_SIZES, nodeRadius: 43 },
|
|
32
38
|
width: 322,
|
|
@@ -55,6 +61,10 @@ export function getTheme(dimens: ThemeParams['dimens']): Theme {
|
|
|
55
61
|
primary: getColorByToken(OBSERVABLE_TOKENS.PRIMARY),
|
|
56
62
|
bg: getColorByToken(OBSERVABLE_TOKENS.BG),
|
|
57
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
|
+
},
|
|
58
68
|
};
|
|
59
69
|
|
|
60
70
|
return {
|
package/src/vars.css
CHANGED
package/typings.d.ts
CHANGED
|
@@ -2,7 +2,7 @@ import { MouseEvent, ReactNode } from 'react';
|
|
|
2
2
|
import { ReactPatternLockProps } from 'react-canvas-pattern-lock';
|
|
3
3
|
type ConditionalProps = {
|
|
4
4
|
/**
|
|
5
|
-
*
|
|
5
|
+
* Показать кнопку "забыли код"
|
|
6
6
|
* @default "Забыли код?"
|
|
7
7
|
*/
|
|
8
8
|
showForgotCodeBtn: true;
|
|
@@ -20,7 +20,7 @@ type ConditionalProps = {
|
|
|
20
20
|
onForgotBtnClick?: never;
|
|
21
21
|
forgotCodeBtnText?: never;
|
|
22
22
|
};
|
|
23
|
-
type
|
|
23
|
+
type CommonPatternLockProps = {
|
|
24
24
|
/**
|
|
25
25
|
* Дополнительный класс.
|
|
26
26
|
*/
|
|
@@ -51,7 +51,30 @@ type PatternLockProps = {
|
|
|
51
51
|
getTarget?: () => Node;
|
|
52
52
|
options?: MutationObserverInit;
|
|
53
53
|
};
|
|
54
|
-
|
|
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
|
+
};
|
|
55
78
|
type ObservableTokens = {
|
|
56
79
|
ACCENT_INITIAL: string;
|
|
57
80
|
ACCENT_SUCCESS: string;
|
|
@@ -62,5 +85,7 @@ type ObservableTokens = {
|
|
|
62
85
|
SELECTED_RING_BG_FAILURE: string;
|
|
63
86
|
PRIMARY: string;
|
|
64
87
|
BG: string;
|
|
88
|
+
HOVER_INNER: string;
|
|
89
|
+
HOVER_OUTER: string;
|
|
65
90
|
};
|
|
66
|
-
export { PatternLockProps, ObservableTokens };
|
|
91
|
+
export { CommonPatternLockProps, PrivatePatternLockProps, PatternLockProps, ObservableTokens };
|
package/utils.js
CHANGED
|
@@ -23,7 +23,14 @@ var getSizes = (function () {
|
|
|
23
23
|
if (cachedSize) {
|
|
24
24
|
return cachedSize;
|
|
25
25
|
}
|
|
26
|
-
if (window.matchMedia('(min-width:
|
|
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) {
|
|
27
34
|
cachedSize = {
|
|
28
35
|
elementSizes: tslib.__assign(tslib.__assign({}, COMMON_SIZES), { nodeRadius: 43 }),
|
|
29
36
|
width: 322,
|
|
@@ -53,6 +60,10 @@ function getTheme(dimens) {
|
|
|
53
60
|
primary: getColorByToken(consts.OBSERVABLE_TOKENS.PRIMARY),
|
|
54
61
|
bg: getColorByToken(consts.OBSERVABLE_TOKENS.BG),
|
|
55
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
|
+
},
|
|
56
67
|
};
|
|
57
68
|
return _a = {},
|
|
58
69
|
_a[consts.THEME_STATE.INITIAL] = {
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|