@alfalab/core-components-pattern-lock 2.3.0 → 2.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/components/base-pattern-lock/Component.js +1 -1
- package/components/base-pattern-lock/index.css +11 -10
- package/cssm/components/base-pattern-lock/index.module.css +3 -2
- package/cssm/desktop/desktop.module.css +2 -1
- package/cssm/mobile/mobile.module.css +2 -1
- package/desktop/Component.desktop.js +1 -1
- package/desktop/desktop.css +6 -5
- package/esm/components/base-pattern-lock/Component.js +1 -1
- package/esm/components/base-pattern-lock/index.css +11 -10
- package/esm/desktop/Component.desktop.js +1 -1
- package/esm/desktop/desktop.css +6 -5
- package/esm/mobile/Component.mobile.js +1 -1
- package/esm/mobile/mobile.css +5 -4
- package/mobile/Component.mobile.js +1 -1
- package/mobile/mobile.css +5 -4
- package/modern/components/base-pattern-lock/Component.js +1 -1
- package/modern/components/base-pattern-lock/index.css +11 -10
- package/modern/desktop/Component.desktop.js +1 -1
- package/modern/desktop/desktop.css +6 -5
- package/modern/mobile/Component.mobile.js +1 -1
- package/modern/mobile/mobile.css +5 -4
- package/moderncssm/Component.responsive.d.ts +6 -0
- package/moderncssm/Component.responsive.js +14 -0
- package/moderncssm/components/base-pattern-lock/Component.d.ts +6 -0
- package/moderncssm/components/base-pattern-lock/Component.js +53 -0
- package/moderncssm/components/base-pattern-lock/index.d.ts +1 -0
- package/moderncssm/components/base-pattern-lock/index.js +1 -0
- package/moderncssm/components/base-pattern-lock/index.module.css +38 -0
- package/moderncssm/consts.d.ts +11 -0
- package/moderncssm/consts.js +26 -0
- package/moderncssm/desktop/Component.desktop.d.ts +6 -0
- package/moderncssm/desktop/Component.desktop.js +8 -0
- package/moderncssm/desktop/desktop.module.css +14 -0
- package/moderncssm/desktop/index.d.ts +2 -0
- package/moderncssm/desktop/index.js +1 -0
- package/moderncssm/hooks/use-pattern-lock-cleanup.d.ts +6 -0
- package/moderncssm/hooks/use-pattern-lock-cleanup.js +14 -0
- package/moderncssm/index.d.ts +3 -0
- package/moderncssm/index.js +2 -0
- package/moderncssm/mobile/Component.mobile.d.ts +6 -0
- package/moderncssm/mobile/Component.mobile.js +8 -0
- package/moderncssm/mobile/index.d.ts +2 -0
- package/moderncssm/mobile/index.js +1 -0
- package/moderncssm/mobile/mobile.module.css +11 -0
- package/moderncssm/shared/index.d.ts +2 -0
- package/moderncssm/shared/index.js +2 -0
- package/moderncssm/typings.d.ts +91 -0
- package/moderncssm/typings.js +1 -0
- package/moderncssm/utils.d.ts +14 -0
- package/moderncssm/utils.js +73 -0
- package/moderncssm/vars.css +0 -0
- package/package.json +4 -4
- package/src/components/base-pattern-lock/index.module.css +3 -3
- package/src/desktop/desktop.module.css +2 -2
- package/src/mobile/mobile.module.css +2 -2
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
import { MouseEvent } from 'react';
|
|
2
|
+
import { ReactPatternLockProps } from '@alfalab/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
|
+
* Для сообщения используется модификатор -message, ошибки -error,
|
|
31
|
+
* кнопки "забыли код" -forgot-code-btn
|
|
32
|
+
*/
|
|
33
|
+
dataTestId?: string;
|
|
34
|
+
/**
|
|
35
|
+
* Следить ли за изменениями значений цветовых токенов
|
|
36
|
+
* @default false
|
|
37
|
+
*/
|
|
38
|
+
observeTokens?: boolean;
|
|
39
|
+
/**
|
|
40
|
+
* Параметры MutationObserver для наблюдения за изменениями режима(css custom properties)
|
|
41
|
+
*/
|
|
42
|
+
observerParams?: {
|
|
43
|
+
getTarget?: () => Node;
|
|
44
|
+
options?: MutationObserverInit;
|
|
45
|
+
};
|
|
46
|
+
/**
|
|
47
|
+
* Дополнительный класс для message/errorMessage
|
|
48
|
+
*/
|
|
49
|
+
messageClassName?: string;
|
|
50
|
+
/**
|
|
51
|
+
* Отключает ввод паттерна
|
|
52
|
+
* @default false
|
|
53
|
+
*/
|
|
54
|
+
disabled?: boolean;
|
|
55
|
+
} & Omit<ReactPatternLockProps, 'theme' | 'width' | 'height' | 'rows' | 'cols' | 'hover' | 'justifyNodes'> & ConditionalProps;
|
|
56
|
+
type PrivatePatternLockProps = {
|
|
57
|
+
/**
|
|
58
|
+
* Включает ховер-эффект
|
|
59
|
+
*/
|
|
60
|
+
hover?: boolean;
|
|
61
|
+
/**
|
|
62
|
+
* Стили компонента
|
|
63
|
+
*/
|
|
64
|
+
styles: {
|
|
65
|
+
[key: string]: string;
|
|
66
|
+
};
|
|
67
|
+
};
|
|
68
|
+
type PatternLockProps = CommonPatternLockProps & {
|
|
69
|
+
/**
|
|
70
|
+
* Контрольная точка, с нее начинается desktop версия
|
|
71
|
+
* @default 1024
|
|
72
|
+
*/
|
|
73
|
+
breakpoint?: number;
|
|
74
|
+
/**
|
|
75
|
+
* Значение по-умолчанию для хука useMatchMedia
|
|
76
|
+
*/
|
|
77
|
+
defaultMatchMediaValue?: boolean | (() => boolean);
|
|
78
|
+
};
|
|
79
|
+
type ObservableTokens = {
|
|
80
|
+
ACCENT_INITIAL: string;
|
|
81
|
+
ACCENT_SUCCESS: string;
|
|
82
|
+
ACCENT_FAILURE: string;
|
|
83
|
+
RING_BG_INITIAL: string;
|
|
84
|
+
SELECTED_RING_BG_INITIAL: string;
|
|
85
|
+
SELECTED_RING_BG_SUCCESS: string;
|
|
86
|
+
SELECTED_RING_BG_FAILURE: string;
|
|
87
|
+
PRIMARY: string;
|
|
88
|
+
HOVER_INNER: string;
|
|
89
|
+
HOVER_OUTER: string;
|
|
90
|
+
};
|
|
91
|
+
export { CommonPatternLockProps, PrivatePatternLockProps, PatternLockProps, ObservableTokens };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { Theme, ThemeParams } from '@alfalab/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
|
+
};
|
|
14
|
+
export { getDefaultObserveTarget, getColorByToken, getSizes, getTheme, getPatternLockTestIds };
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
import { getDataTestId } from '@alfalab/core-components-shared/moderncssm';
|
|
2
|
+
import { OBSERVABLE_TOKENS, THEME_STATE } from './consts.js';
|
|
3
|
+
|
|
4
|
+
function getDefaultObserveTarget() {
|
|
5
|
+
return document.head;
|
|
6
|
+
}
|
|
7
|
+
function getColorByToken(token) {
|
|
8
|
+
return getComputedStyle(document.documentElement).getPropertyValue(token);
|
|
9
|
+
}
|
|
10
|
+
const getSizes = (() => {
|
|
11
|
+
const COMMON_SIZES = {
|
|
12
|
+
lineWidth: 6,
|
|
13
|
+
nodeRing: 0,
|
|
14
|
+
nodeCore: 12,
|
|
15
|
+
};
|
|
16
|
+
let cachedSize;
|
|
17
|
+
return () => {
|
|
18
|
+
if (cachedSize) {
|
|
19
|
+
return cachedSize;
|
|
20
|
+
}
|
|
21
|
+
cachedSize = {
|
|
22
|
+
elementSizes: { ...COMMON_SIZES, nodeRadius: 32 },
|
|
23
|
+
width: 240,
|
|
24
|
+
height: 240,
|
|
25
|
+
};
|
|
26
|
+
return cachedSize;
|
|
27
|
+
};
|
|
28
|
+
})();
|
|
29
|
+
function getTheme(dimens) {
|
|
30
|
+
const baseColors = {
|
|
31
|
+
primary: getColorByToken(OBSERVABLE_TOKENS.PRIMARY),
|
|
32
|
+
bg: 'transparent',
|
|
33
|
+
ringBg: getColorByToken(OBSERVABLE_TOKENS.RING_BG_INITIAL),
|
|
34
|
+
hover: {
|
|
35
|
+
inner: getColorByToken(OBSERVABLE_TOKENS.HOVER_INNER),
|
|
36
|
+
outer: getColorByToken(OBSERVABLE_TOKENS.HOVER_OUTER),
|
|
37
|
+
},
|
|
38
|
+
};
|
|
39
|
+
return {
|
|
40
|
+
[THEME_STATE.INITIAL]: {
|
|
41
|
+
colors: {
|
|
42
|
+
...baseColors,
|
|
43
|
+
accent: getColorByToken(OBSERVABLE_TOKENS.ACCENT_INITIAL),
|
|
44
|
+
selectedRingBg: getColorByToken(OBSERVABLE_TOKENS.SELECTED_RING_BG_INITIAL),
|
|
45
|
+
},
|
|
46
|
+
dimens,
|
|
47
|
+
},
|
|
48
|
+
[THEME_STATE.SUCCESS]: {
|
|
49
|
+
colors: {
|
|
50
|
+
...baseColors,
|
|
51
|
+
accent: getColorByToken(OBSERVABLE_TOKENS.ACCENT_SUCCESS),
|
|
52
|
+
selectedRingBg: getColorByToken(OBSERVABLE_TOKENS.SELECTED_RING_BG_SUCCESS),
|
|
53
|
+
},
|
|
54
|
+
dimens,
|
|
55
|
+
},
|
|
56
|
+
[THEME_STATE.FAILURE]: {
|
|
57
|
+
colors: {
|
|
58
|
+
...baseColors,
|
|
59
|
+
accent: getColorByToken(OBSERVABLE_TOKENS.ACCENT_FAILURE),
|
|
60
|
+
selectedRingBg: getColorByToken(OBSERVABLE_TOKENS.SELECTED_RING_BG_FAILURE),
|
|
61
|
+
},
|
|
62
|
+
dimens,
|
|
63
|
+
},
|
|
64
|
+
};
|
|
65
|
+
}
|
|
66
|
+
function getPatternLockTestIds(dataTestId) {
|
|
67
|
+
return {
|
|
68
|
+
patternLock: dataTestId,
|
|
69
|
+
forgotCodeBtn: getDataTestId(dataTestId, 'forgot-code-btn'),
|
|
70
|
+
};
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
export { getColorByToken, getDefaultObserveTarget, getPatternLockTestIds, getSizes, getTheme };
|
|
File without changes
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@alfalab/core-components-pattern-lock",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.4.0",
|
|
4
4
|
"description": "Pattern lock",
|
|
5
5
|
"keywords": [],
|
|
6
6
|
"license": "MIT",
|
|
@@ -15,13 +15,13 @@
|
|
|
15
15
|
"react-dom": "^16.9.0 || ^17.0.1 || ^18.0.0"
|
|
16
16
|
},
|
|
17
17
|
"dependencies": {
|
|
18
|
-
"@alfalab/core-components-button": "^11.
|
|
18
|
+
"@alfalab/core-components-button": "^11.6.0",
|
|
19
19
|
"@alfalab/core-components-shared": "^0.12.0",
|
|
20
20
|
"@alfalab/core-components-mq": "^4.3.0",
|
|
21
21
|
"@alfalab/react-canvas-pattern-lock": "^2.0.7",
|
|
22
22
|
"classnames": "^2.3.1",
|
|
23
23
|
"tslib": "^2.4.0"
|
|
24
24
|
},
|
|
25
|
-
"themesVersion": "13.0
|
|
26
|
-
"varsVersion": "9.
|
|
25
|
+
"themesVersion": "13.1.0",
|
|
26
|
+
"varsVersion": "9.12.0"
|
|
27
27
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
@import '@alfalab/core-components-
|
|
1
|
+
@import '@alfalab/core-components-vars/src/index.css';
|
|
2
2
|
@import '../../vars.css';
|
|
3
3
|
|
|
4
4
|
.component {
|
|
@@ -15,13 +15,13 @@
|
|
|
15
15
|
|
|
16
16
|
& .canvasContainer {
|
|
17
17
|
box-sizing: border-box;
|
|
18
|
-
padding: var(--gap-
|
|
18
|
+
padding: var(--gap-16) var(--gap-16);
|
|
19
19
|
min-width: var(--pattern-lock-min-width);
|
|
20
20
|
min-height: var(--pattern-lock-min-height);
|
|
21
21
|
|
|
22
22
|
& .canvasInner {
|
|
23
23
|
box-sizing: border-box;
|
|
24
|
-
padding: 0 var(--gap-
|
|
24
|
+
padding: 0 var(--gap-16);
|
|
25
25
|
min-width: var(--pattern-lock-min-height);
|
|
26
26
|
}
|
|
27
27
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
@import '@alfalab/core-components-
|
|
1
|
+
@import '@alfalab/core-components-vars/src/index.css';
|
|
2
2
|
@import '../vars.css';
|
|
3
3
|
|
|
4
4
|
.component {
|
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
}
|
|
8
8
|
|
|
9
9
|
.forgotBtn {
|
|
10
|
-
margin: var(--gap-
|
|
10
|
+
margin: var(--gap-8) auto 0;
|
|
11
11
|
}
|
|
12
12
|
|
|
13
13
|
.hiddenBtn {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
@import '@alfalab/core-components-
|
|
1
|
+
@import '@alfalab/core-components-vars/src/index.css';
|
|
2
2
|
@import '../vars.css';
|
|
3
3
|
|
|
4
4
|
.component {
|
|
@@ -7,5 +7,5 @@
|
|
|
7
7
|
}
|
|
8
8
|
|
|
9
9
|
.forgotBtn {
|
|
10
|
-
margin: var(--gap-
|
|
10
|
+
margin: var(--gap-8) auto 0;
|
|
11
11
|
}
|