@smart-react-components/ui 2.0.0-alpha-127 → 2.0.0-alpha-129
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/Overlay/index.js +5 -1
- package/Pagination/PaginationLink.d.ts +1 -0
- package/Pagination/PaginationLink.js +2 -1
- package/package.json +1 -1
- package/util/dom.d.ts +4 -0
- package/util/dom.js +10 -3
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)) {
|
|
@@ -9,6 +9,7 @@ const react_1 = __importDefault(require("react"));
|
|
|
9
9
|
const WaveEffect_1 = __importDefault(require("../WaveEffect"));
|
|
10
10
|
const PaginationItemElement_1 = __importDefault(require("../components/Pagination/PaginationItemElement"));
|
|
11
11
|
const PaginationLink = (props) => {
|
|
12
|
+
var _a;
|
|
12
13
|
const { children, handleOnClick, isActive } = (0, useLink_1.default)({
|
|
13
14
|
children: props.children,
|
|
14
15
|
isDisabled: props.isDisabled,
|
|
@@ -19,7 +20,7 @@ const PaginationLink = (props) => {
|
|
|
19
20
|
});
|
|
20
21
|
const AnchorEl = (react_1.default.createElement(A_1.default, Object.assign({}, props.elementProps, { href: props.to, onClick: handleOnClick }), children));
|
|
21
22
|
const El = props.hasWaveEffect ? react_1.default.createElement(WaveEffect_1.default, { palette: props.waveEffectPalette }, AnchorEl) : AnchorEl;
|
|
22
|
-
return (react_1.default.createElement(PaginationItemElement_1.default, { isActive: isActive, isDisabled: props.isDisabled, isFixedSize: props.isFixedSize, isOutline: props.isOutline, isSoft: props.isSoft, palette: props.palette, shape: props.shape }, El));
|
|
23
|
+
return (react_1.default.createElement(PaginationItemElement_1.default, { isActive: (_a = props.isActive) !== null && _a !== void 0 ? _a : isActive, isDisabled: props.isDisabled, isFixedSize: props.isFixedSize, isOutline: props.isOutline, isSoft: props.isSoft, palette: props.palette, shape: props.shape }, El));
|
|
23
24
|
};
|
|
24
25
|
PaginationLink.defaultProps = {
|
|
25
26
|
isExact: true,
|
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
|
*/
|