@smart-react-components/ui 2.0.0-alpha-128 → 2.0.0-alpha-130
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/Grid/Container.js +1 -9
- package/Overlay/index.js +5 -1
- package/package.json +1 -1
- package/util/dom.d.ts +4 -0
- package/util/dom.js +10 -3
package/Grid/Container.js
CHANGED
|
@@ -5,14 +5,6 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
const Div_1 = __importDefault(require("@smart-react-components/core/Element/Div"));
|
|
7
7
|
const styled_components_1 = __importDefault(require("styled-components"));
|
|
8
|
-
exports.default = (0, styled_components_1.default)(Div_1.default).attrs(({ marginHorizontal = 'auto', paddingHorizontal = '$length.grid.space' }) => ({
|
|
9
|
-
marginHorizontal,
|
|
10
|
-
paddingHorizontal,
|
|
11
|
-
maxWidth: '100%',
|
|
12
|
-
maxWidthSm: '{length.grid.containerWidth.small}px',
|
|
13
|
-
maxWidthMd: '{length.grid.containerWidth.medium}px',
|
|
14
|
-
maxWidthLg: '{length.grid.containerWidth.large}px',
|
|
15
|
-
maxWidthXl: '{length.grid.containerWidth.xlarge}px',
|
|
16
|
-
})) `
|
|
8
|
+
exports.default = (0, styled_components_1.default)(Div_1.default).attrs(({ marginHorizontal = 'auto', paddingHorizontal = '$length.grid.space', maxWidth = '100%', maxWidthSm = '{length.grid.containerWidth.small}px', maxWidthMd = '{length.grid.containerWidth.medium}px', maxWidthLg = '{length.grid.containerWidth.large}px', maxWidthXl = '{length.grid.containerWidth.xlarge}px', }) => ({ marginHorizontal, paddingHorizontal, maxWidth, maxWidthSm, maxWidthMd, maxWidthLg, maxWidthXl })) `
|
|
17
9
|
box-sizing: border-box;
|
|
18
10
|
`;
|
package/Overlay/index.js
CHANGED
|
@@ -30,11 +30,15 @@ const Overlay = react_1.default.forwardRef((props, forwardRef) => {
|
|
|
30
30
|
const [isFront, setFront] = react_1.default.useState(() => getFront());
|
|
31
31
|
const handleResize = () => setActive(getActive());
|
|
32
32
|
const handleMouseWheel = (e) => {
|
|
33
|
+
const activeOverlayEls = document.querySelectorAll('body > *[data-src-overlay="visible"]');
|
|
34
|
+
if (activeOverlayEls[activeOverlayEls.length - 1] !== ref.current) {
|
|
35
|
+
return;
|
|
36
|
+
}
|
|
33
37
|
const container = ref.current;
|
|
34
38
|
const delta = ((e.deltaY || -e.wheelDelta || e.detail) >> 10) || 1;
|
|
35
39
|
const up = delta < 0;
|
|
36
40
|
const el = e.target;
|
|
37
|
-
let scrollEl = (0, dom_2.getScrollParent)(el);
|
|
41
|
+
let scrollEl = (0, dom_2.isElementScrollable)(el) ? el : (0, dom_2.getScrollParent)(el);
|
|
38
42
|
while (scrollEl && (scrollEl === container || container.contains(scrollEl))) {
|
|
39
43
|
if ((up && scrollEl.scrollTop > 0)
|
|
40
44
|
|| (!up && scrollEl.scrollHeight > scrollEl.scrollTop)) {
|
package/package.json
CHANGED
package/util/dom.d.ts
CHANGED
|
@@ -19,6 +19,10 @@ export declare const canBeRenderedInPortal: () => boolean;
|
|
|
19
19
|
* @param el
|
|
20
20
|
*/
|
|
21
21
|
export declare const getScrollParent: (el: HTMLElement) => HTMLElement;
|
|
22
|
+
/**
|
|
23
|
+
* Checks if the given element is scrollable.
|
|
24
|
+
*/
|
|
25
|
+
export declare const isElementScrollable: (el: HTMLElement) => boolean;
|
|
22
26
|
/**
|
|
23
27
|
* Checks if target is a clickable element.
|
|
24
28
|
*/
|
package/util/dom.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.isTargetClickable = exports.getScrollParent = exports.canBeRenderedInPortal = exports.calculateShownPart = exports.placeholder = exports.mouseWheel = void 0;
|
|
3
|
+
exports.isTargetClickable = exports.isElementScrollable = exports.getScrollParent = exports.canBeRenderedInPortal = exports.calculateShownPart = exports.placeholder = exports.mouseWheel = void 0;
|
|
4
4
|
const dom_1 = require("@smart-react-components/core/util/dom");
|
|
5
5
|
exports.mouseWheel = ['wheel', 'mousewheel', 'DOMMouseScroll'];
|
|
6
6
|
exports.placeholder = ['::-webkit-input-placeholder', '::-moz-placeholder', ':-moz-placeholder', ':-ms-input-placeholder', '::placeholder'];
|
|
@@ -62,14 +62,21 @@ exports.canBeRenderedInPortal = canBeRenderedInPortal;
|
|
|
62
62
|
*/
|
|
63
63
|
const getScrollParent = (el) => {
|
|
64
64
|
for (let parent = el; (parent = parent.parentElement);) {
|
|
65
|
-
|
|
66
|
-
if (/(auto|scroll|hidden)/.test(style.overflow + style.overflowX + style.overflowY)) {
|
|
65
|
+
if ((0, exports.isElementScrollable)(parent)) {
|
|
67
66
|
return parent;
|
|
68
67
|
}
|
|
69
68
|
}
|
|
70
69
|
return null;
|
|
71
70
|
};
|
|
72
71
|
exports.getScrollParent = getScrollParent;
|
|
72
|
+
/**
|
|
73
|
+
* Checks if the given element is scrollable.
|
|
74
|
+
*/
|
|
75
|
+
const isElementScrollable = (el) => {
|
|
76
|
+
const style = window.getComputedStyle(el, null);
|
|
77
|
+
return /(auto|scroll|hidden)/.test(style.overflow + style.overflowX + style.overflowY);
|
|
78
|
+
};
|
|
79
|
+
exports.isElementScrollable = isElementScrollable;
|
|
73
80
|
/**
|
|
74
81
|
* Checks if target is a clickable element.
|
|
75
82
|
*/
|