@alfalab/core-components-base-modal 3.0.1 → 3.2.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/CHANGELOG.md +34 -0
- package/dist/Component.d.ts +4 -0
- package/dist/Component.js +36 -27
- package/dist/cssm/Component.d.ts +4 -0
- package/dist/cssm/Component.js +35 -26
- package/dist/cssm/index.js +2 -0
- package/dist/cssm/index.module.css +1 -1
- package/dist/cssm/utils.d.ts +3 -2
- package/dist/cssm/utils.js +39 -14
- package/dist/esm/Component.d.ts +4 -0
- package/dist/esm/Component.js +38 -29
- package/dist/esm/index.css +14 -14
- package/dist/esm/index.js +2 -1
- package/dist/esm/utils.d.ts +3 -2
- package/dist/esm/utils.js +39 -15
- package/dist/index.css +14 -14
- package/dist/index.js +2 -0
- package/dist/modern/Component.d.ts +4 -0
- package/dist/modern/Component.js +32 -23
- package/dist/modern/index.css +14 -14
- package/dist/modern/index.js +2 -1
- package/dist/modern/utils.d.ts +3 -2
- package/dist/modern/utils.js +38 -14
- package/dist/utils.d.ts +3 -2
- package/dist/utils.js +39 -14
- package/package.json +3 -2
package/dist/modern/utils.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
declare function isScrolledToTop(target: HTMLElement): boolean;
|
|
2
2
|
declare function isScrolledToBottom(target: HTMLElement): boolean;
|
|
3
3
|
declare function hasScrollbar(target: HTMLElement): boolean;
|
|
4
|
-
declare const
|
|
5
|
-
|
|
4
|
+
declare const restoreContainerStyles: (container: HTMLElement) => void;
|
|
5
|
+
declare const handleContainer: (container?: HTMLElement | undefined) => void;
|
|
6
|
+
export { isScrolledToTop, isScrolledToBottom, hasScrollbar, restoreContainerStyles, handleContainer };
|
package/dist/modern/utils.js
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
import { getModalStore } from '@alfalab/core-components-global-store/dist/modern';
|
|
2
|
+
|
|
1
3
|
function isScrolledToTop(target) {
|
|
2
4
|
return target.scrollTop <= 0;
|
|
3
5
|
}
|
|
@@ -28,12 +30,39 @@ const isOverflowing = (container) => {
|
|
|
28
30
|
const getPaddingRight = (node) => {
|
|
29
31
|
return parseInt(window.getComputedStyle(node).paddingRight, 10) || 0;
|
|
30
32
|
};
|
|
33
|
+
const restoreContainerStyles = (container) => {
|
|
34
|
+
const modalRestoreStyles = getModalStore().getRestoreStyles();
|
|
35
|
+
const index = modalRestoreStyles.findIndex(s => s.container === container);
|
|
36
|
+
const existingStyles = modalRestoreStyles[index];
|
|
37
|
+
if (!existingStyles)
|
|
38
|
+
return;
|
|
39
|
+
existingStyles.modals -= 1;
|
|
40
|
+
if (existingStyles.modals <= 0) {
|
|
41
|
+
modalRestoreStyles.splice(index, 1);
|
|
42
|
+
existingStyles.styles.forEach(({ value, el, key }) => {
|
|
43
|
+
if (value) {
|
|
44
|
+
el.style.setProperty(key, value);
|
|
45
|
+
}
|
|
46
|
+
else {
|
|
47
|
+
el.style.removeProperty(key);
|
|
48
|
+
}
|
|
49
|
+
});
|
|
50
|
+
}
|
|
51
|
+
};
|
|
31
52
|
const handleContainer = (container) => {
|
|
32
|
-
|
|
53
|
+
if (!container)
|
|
54
|
+
return;
|
|
55
|
+
const modalRestoreStyles = getModalStore().getRestoreStyles();
|
|
56
|
+
const existingStyles = modalRestoreStyles.find(s => s.container === container);
|
|
57
|
+
if (existingStyles) {
|
|
58
|
+
existingStyles.modals += 1;
|
|
59
|
+
return;
|
|
60
|
+
}
|
|
61
|
+
const containerStyles = [];
|
|
33
62
|
if (isOverflowing(container)) {
|
|
34
63
|
// Вычисляет размер до применения `overflow hidden` для избежания скачков
|
|
35
64
|
const scrollbarSize = getScrollbarSize();
|
|
36
|
-
|
|
65
|
+
containerStyles.push({
|
|
37
66
|
value: container.style.paddingRight,
|
|
38
67
|
key: 'padding-right',
|
|
39
68
|
el: container,
|
|
@@ -52,23 +81,18 @@ const handleContainer = (container) => {
|
|
|
52
81
|
: container;
|
|
53
82
|
// Блокируем скролл даже если отсутствует скроллбар
|
|
54
83
|
if (scrollContainer.style.overflow !== 'hidden') {
|
|
55
|
-
|
|
84
|
+
containerStyles.push({
|
|
56
85
|
value: scrollContainer.style.overflow,
|
|
57
86
|
key: 'overflow',
|
|
58
87
|
el: scrollContainer,
|
|
59
88
|
});
|
|
60
89
|
}
|
|
61
90
|
scrollContainer.style.overflow = 'hidden';
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
else {
|
|
68
|
-
el.style.removeProperty(key);
|
|
69
|
-
}
|
|
70
|
-
});
|
|
71
|
-
};
|
|
91
|
+
modalRestoreStyles.push({
|
|
92
|
+
container,
|
|
93
|
+
modals: 1,
|
|
94
|
+
styles: containerStyles,
|
|
95
|
+
});
|
|
72
96
|
};
|
|
73
97
|
|
|
74
|
-
export { handleContainer, hasScrollbar, isScrolledToBottom, isScrolledToTop };
|
|
98
|
+
export { handleContainer, hasScrollbar, isScrolledToBottom, isScrolledToTop, restoreContainerStyles };
|
package/dist/utils.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
declare function isScrolledToTop(target: HTMLElement): boolean;
|
|
2
2
|
declare function isScrolledToBottom(target: HTMLElement): boolean;
|
|
3
3
|
declare function hasScrollbar(target: HTMLElement): boolean;
|
|
4
|
-
declare const
|
|
5
|
-
|
|
4
|
+
declare const restoreContainerStyles: (container: HTMLElement) => void;
|
|
5
|
+
declare const handleContainer: (container?: HTMLElement | undefined) => void;
|
|
6
|
+
export { isScrolledToTop, isScrolledToBottom, hasScrollbar, restoreContainerStyles, handleContainer };
|
package/dist/utils.js
CHANGED
|
@@ -2,6 +2,8 @@
|
|
|
2
2
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
|
+
var coreComponentsGlobalStore = require('@alfalab/core-components-global-store');
|
|
6
|
+
|
|
5
7
|
function isScrolledToTop(target) {
|
|
6
8
|
return target.scrollTop <= 0;
|
|
7
9
|
}
|
|
@@ -32,12 +34,40 @@ var isOverflowing = function (container) {
|
|
|
32
34
|
var getPaddingRight = function (node) {
|
|
33
35
|
return parseInt(window.getComputedStyle(node).paddingRight, 10) || 0;
|
|
34
36
|
};
|
|
37
|
+
var restoreContainerStyles = function (container) {
|
|
38
|
+
var modalRestoreStyles = coreComponentsGlobalStore.getModalStore().getRestoreStyles();
|
|
39
|
+
var index = modalRestoreStyles.findIndex(function (s) { return s.container === container; });
|
|
40
|
+
var existingStyles = modalRestoreStyles[index];
|
|
41
|
+
if (!existingStyles)
|
|
42
|
+
return;
|
|
43
|
+
existingStyles.modals -= 1;
|
|
44
|
+
if (existingStyles.modals <= 0) {
|
|
45
|
+
modalRestoreStyles.splice(index, 1);
|
|
46
|
+
existingStyles.styles.forEach(function (_a) {
|
|
47
|
+
var value = _a.value, el = _a.el, key = _a.key;
|
|
48
|
+
if (value) {
|
|
49
|
+
el.style.setProperty(key, value);
|
|
50
|
+
}
|
|
51
|
+
else {
|
|
52
|
+
el.style.removeProperty(key);
|
|
53
|
+
}
|
|
54
|
+
});
|
|
55
|
+
}
|
|
56
|
+
};
|
|
35
57
|
var handleContainer = function (container) {
|
|
36
|
-
|
|
58
|
+
if (!container)
|
|
59
|
+
return;
|
|
60
|
+
var modalRestoreStyles = coreComponentsGlobalStore.getModalStore().getRestoreStyles();
|
|
61
|
+
var existingStyles = modalRestoreStyles.find(function (s) { return s.container === container; });
|
|
62
|
+
if (existingStyles) {
|
|
63
|
+
existingStyles.modals += 1;
|
|
64
|
+
return;
|
|
65
|
+
}
|
|
66
|
+
var containerStyles = [];
|
|
37
67
|
if (isOverflowing(container)) {
|
|
38
68
|
// Вычисляет размер до применения `overflow hidden` для избежания скачков
|
|
39
69
|
var scrollbarSize = getScrollbarSize();
|
|
40
|
-
|
|
70
|
+
containerStyles.push({
|
|
41
71
|
value: container.style.paddingRight,
|
|
42
72
|
key: 'padding-right',
|
|
43
73
|
el: container,
|
|
@@ -56,27 +86,22 @@ var handleContainer = function (container) {
|
|
|
56
86
|
: container;
|
|
57
87
|
// Блокируем скролл даже если отсутствует скроллбар
|
|
58
88
|
if (scrollContainer.style.overflow !== 'hidden') {
|
|
59
|
-
|
|
89
|
+
containerStyles.push({
|
|
60
90
|
value: scrollContainer.style.overflow,
|
|
61
91
|
key: 'overflow',
|
|
62
92
|
el: scrollContainer,
|
|
63
93
|
});
|
|
64
94
|
}
|
|
65
95
|
scrollContainer.style.overflow = 'hidden';
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
}
|
|
72
|
-
else {
|
|
73
|
-
el.style.removeProperty(key);
|
|
74
|
-
}
|
|
75
|
-
});
|
|
76
|
-
};
|
|
96
|
+
modalRestoreStyles.push({
|
|
97
|
+
container: container,
|
|
98
|
+
modals: 1,
|
|
99
|
+
styles: containerStyles,
|
|
100
|
+
});
|
|
77
101
|
};
|
|
78
102
|
|
|
79
103
|
exports.handleContainer = handleContainer;
|
|
80
104
|
exports.hasScrollbar = hasScrollbar;
|
|
81
105
|
exports.isScrolledToBottom = isScrolledToBottom;
|
|
82
106
|
exports.isScrolledToTop = isScrolledToTop;
|
|
107
|
+
exports.restoreContainerStyles = restoreContainerStyles;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@alfalab/core-components-base-modal",
|
|
3
|
-
"version": "3.0
|
|
3
|
+
"version": "3.2.0",
|
|
4
4
|
"description": "BaseModal component",
|
|
5
5
|
"keywords": [],
|
|
6
6
|
"license": "MIT",
|
|
@@ -16,6 +16,7 @@
|
|
|
16
16
|
},
|
|
17
17
|
"dependencies": {
|
|
18
18
|
"@alfalab/core-components-backdrop": "^2.0.1",
|
|
19
|
+
"@alfalab/core-components-global-store": "^1.1.0",
|
|
19
20
|
"@alfalab/core-components-portal": "^2.0.1",
|
|
20
21
|
"@alfalab/core-components-stack": "^3.0.1",
|
|
21
22
|
"classnames": "^2.2.6",
|
|
@@ -30,5 +31,5 @@
|
|
|
30
31
|
"peerDependencies": {
|
|
31
32
|
"react": "^16.9.0 || ^17.0.1"
|
|
32
33
|
},
|
|
33
|
-
"gitHead": "
|
|
34
|
+
"gitHead": "ddf4fab6035139cf412e0acb7174ef388f23e4f2"
|
|
34
35
|
}
|