@prom-ui/core 1.7.0-alpha.1 → 1.7.0-alpha.2
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/Avatar/package.json +1 -1
- package/Backdrop/package.json +1 -1
- package/Body/package.json +1 -1
- package/BodyContext/package.json +1 -1
- package/BodyProvider/package.json +1 -1
- package/BodyScrollLock/cjs/index.development.js +37 -0
- package/BodyScrollLock/cjs/index.development.v2.js +37 -0
- package/BodyScrollLock/cjs/index.production.js +1 -0
- package/BodyScrollLock/cjs/index.production.v2.js +1 -0
- package/BodyScrollLock/index.d.ts +5 -0
- package/{ScrollLock → BodyScrollLock}/package.json +2 -2
- package/Box/package.json +1 -1
- package/Button/package.json +1 -1
- package/ButtonPageUp/package.json +1 -1
- package/Checkbox/package.json +1 -1
- package/Flex/package.json +1 -1
- package/Grid/package.json +1 -1
- package/Icon/package.json +1 -1
- package/Image/package.json +1 -1
- package/ImageEmoji/package.json +1 -1
- package/Input/package.json +1 -1
- package/InputField/package.json +1 -1
- package/KeyPress/package.json +1 -1
- package/Line/package.json +1 -1
- package/Link/package.json +1 -1
- package/List/package.json +1 -1
- package/Media/package.json +1 -1
- package/OutsideClick/package.json +1 -1
- package/Overlay/cjs/index.development.js +2 -2
- package/Overlay/cjs/index.development.v2.js +2 -2
- package/Overlay/cjs/index.production.js +1 -1
- package/Overlay/cjs/index.production.v2.js +1 -1
- package/Overlay/package.json +1 -1
- package/Picture/package.json +1 -1
- package/Portal/package.json +1 -1
- package/QRCode/package.json +1 -1
- package/Rating/package.json +1 -1
- package/RatingSelect/package.json +1 -1
- package/SafeQuery/package.json +1 -1
- package/Scroll/package.json +1 -1
- package/ScrollControls/package.json +1 -1
- package/SimpleSlider/package.json +1 -1
- package/Skeleton/package.json +1 -1
- package/Spinner/package.json +1 -1
- package/Text/package.json +1 -1
- package/TextEmoji/package.json +1 -1
- package/Tooltip/package.json +1 -1
- package/Tumbler/package.json +1 -1
- package/package.json +2 -3
- package/useBodyScrollLock/cjs/index.development.js +163 -0
- package/useBodyScrollLock/cjs/index.development.v2.js +163 -0
- package/useBodyScrollLock/cjs/index.production.js +1 -0
- package/useBodyScrollLock/cjs/index.production.v2.js +1 -0
- package/useBodyScrollLock/index.d.ts +5 -0
- package/useBodyScrollLock/index.js +7 -0
- package/useBodyScrollLock/index.v2.js +7 -0
- package/useBodyScrollLock/package.json +9 -0
- package/useBodyScrollLock/preventScrollMobileSafari.d.ts +1 -0
- package/useBodyScrollLock/preventScrollStandard.d.ts +1 -0
- package/useBodyScrollLock/utils.d.ts +16 -0
- package/useBodyTTag/package.json +1 -1
- package/useDebounce/package.json +1 -1
- package/useId/package.json +1 -1
- package/useIsMounted/package.json +1 -1
- package/useKeyPress/package.json +1 -1
- package/useMedia/package.json +1 -1
- package/useOutsideClick/package.json +1 -1
- package/usePortal/package.json +1 -1
- package/useScrollPosition/package.json +1 -1
- package/ScrollLock/cjs/index.development.js +0 -464
- package/ScrollLock/cjs/index.development.v2.js +0 -464
- package/ScrollLock/cjs/index.production.js +0 -1
- package/ScrollLock/cjs/index.production.v2.js +0 -1
- package/ScrollLock/index.d.ts +0 -5
- /package/{ScrollLock → BodyScrollLock}/index.js +0 -0
- /package/{ScrollLock → BodyScrollLock}/index.v2.js +0 -0
package/Tumbler/package.json
CHANGED
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@prom-ui/core",
|
|
3
3
|
"author": "e.marchenko",
|
|
4
|
-
"version": "1.7.0-alpha.
|
|
4
|
+
"version": "1.7.0-alpha.2",
|
|
5
5
|
"description": "core ui blocks",
|
|
6
6
|
"scripts": {
|
|
7
7
|
"ts-types": "tsc --project tsconfig.build.json --declaration --emitDeclarationOnly",
|
|
@@ -52,7 +52,6 @@
|
|
|
52
52
|
"evokit-picture": "^3.2.0",
|
|
53
53
|
"evokit-text": "^3.2.0",
|
|
54
54
|
"qrcode.react": "^3.1.0",
|
|
55
|
-
"react-aria": "^3.28.0",
|
|
56
55
|
"react-easy-swipe": "^0.0.22",
|
|
57
56
|
"react-popper-tooltip": "^4.4.2",
|
|
58
57
|
"react-responsive": "^9.0.2",
|
|
@@ -71,5 +70,5 @@
|
|
|
71
70
|
"optional": true
|
|
72
71
|
}
|
|
73
72
|
},
|
|
74
|
-
"gitHead": "
|
|
73
|
+
"gitHead": "abdbcabde09a57cb21407f696127a7fc4bf96598"
|
|
75
74
|
}
|
|
@@ -0,0 +1,163 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
+
|
|
5
|
+
var React = require('react');
|
|
6
|
+
|
|
7
|
+
function _interopDefaultCompat (e) { return e && typeof e === 'object' && 'default' in e ? e : { default: e }; }
|
|
8
|
+
|
|
9
|
+
var React__default = /*#__PURE__*/_interopDefaultCompat(React);
|
|
10
|
+
|
|
11
|
+
var listenerOptions = {
|
|
12
|
+
capture: false,
|
|
13
|
+
passive: false
|
|
14
|
+
};
|
|
15
|
+
function testPlatform(re) {
|
|
16
|
+
var _window$navigator$use;
|
|
17
|
+
return typeof window !== 'undefined' && window.navigator != null ?
|
|
18
|
+
// @ts-ignore
|
|
19
|
+
re.test(((_window$navigator$use = window.navigator['userAgentData']) === null || _window$navigator$use === void 0 ? void 0 : _window$navigator$use.platform) || window.navigator.platform) : false;
|
|
20
|
+
}
|
|
21
|
+
function isMac() {
|
|
22
|
+
return testPlatform(/^Mac/i);
|
|
23
|
+
}
|
|
24
|
+
function isIPhone() {
|
|
25
|
+
return testPlatform(/^iPhone/i);
|
|
26
|
+
}
|
|
27
|
+
function isIPad() {
|
|
28
|
+
return testPlatform(/^iPad/i) ||
|
|
29
|
+
// iPadOS 13 lies and says it's a Mac, but we can distinguish by detecting touch support.
|
|
30
|
+
isMac() && navigator.maxTouchPoints > 1;
|
|
31
|
+
}
|
|
32
|
+
var useLayoutEffect = typeof document !== 'undefined' ? React__default.default.useLayoutEffect : function () {};
|
|
33
|
+
function isIOS() {
|
|
34
|
+
return isIPhone() || isIPad();
|
|
35
|
+
}
|
|
36
|
+
function setStyle(element, style, value) {
|
|
37
|
+
// @ts-ignore
|
|
38
|
+
var cur = element.style[style];
|
|
39
|
+
// @ts-ignore
|
|
40
|
+
element.style[style] = value;
|
|
41
|
+
return function () {
|
|
42
|
+
// @ts-ignore
|
|
43
|
+
element.style[style] = cur;
|
|
44
|
+
};
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
/**
|
|
48
|
+
* Calls all functions in the order they were chained with the same arguments.
|
|
49
|
+
*/
|
|
50
|
+
function chain() {
|
|
51
|
+
for (var _len = arguments.length, callbacks = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
52
|
+
callbacks[_key] = arguments[_key];
|
|
53
|
+
}
|
|
54
|
+
return function () {
|
|
55
|
+
for (var _i = 0, _callbacks = callbacks; _i < _callbacks.length; _i++) {
|
|
56
|
+
var callback = _callbacks[_i];
|
|
57
|
+
if (typeof callback === 'function') {
|
|
58
|
+
callback.apply(void 0, arguments);
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
};
|
|
62
|
+
}
|
|
63
|
+
var preventTouchMove = function preventTouchMove(e) {
|
|
64
|
+
e.preventDefault();
|
|
65
|
+
return false;
|
|
66
|
+
};
|
|
67
|
+
var allowTouchMove = function allowTouchMove(e) {
|
|
68
|
+
var target = e.currentTarget;
|
|
69
|
+
if (target.scrollHeight > target.clientHeight || target.scrollWidth > target.clientWidth) {
|
|
70
|
+
e.stopPropagation();
|
|
71
|
+
return true;
|
|
72
|
+
}
|
|
73
|
+
e.preventDefault();
|
|
74
|
+
return false;
|
|
75
|
+
};
|
|
76
|
+
function preventInertiaScroll(target) {
|
|
77
|
+
var top = target.scrollTop;
|
|
78
|
+
var totalScroll = target.scrollHeight;
|
|
79
|
+
var currentScroll = top + target.offsetHeight;
|
|
80
|
+
if (top === 0) {
|
|
81
|
+
target.scrollTop = 1;
|
|
82
|
+
} else if (currentScroll === totalScroll) {
|
|
83
|
+
target.scrollTop = top - 1;
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
function isScrollable(node) {
|
|
87
|
+
var style = window.getComputedStyle(node);
|
|
88
|
+
return /(auto|scroll)/.test(style.overflow + style.overflowX + style.overflowY);
|
|
89
|
+
}
|
|
90
|
+
function getScrollParent(node) {
|
|
91
|
+
if (isScrollable(node)) {
|
|
92
|
+
// @ts-ignore
|
|
93
|
+
node = node.parentElement;
|
|
94
|
+
}
|
|
95
|
+
while (node && !isScrollable(node)) {
|
|
96
|
+
// @ts-ignore
|
|
97
|
+
node = node.parentElement;
|
|
98
|
+
}
|
|
99
|
+
return node || document.scrollingElement || document.documentElement;
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
function preventScrollStandard() {
|
|
103
|
+
return chain(setStyle(document.documentElement, 'paddingRight', "".concat(window.innerWidth - document.documentElement.clientWidth, "px")), setStyle(document.documentElement, 'overflow', 'hidden'));
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
var scrollable;
|
|
107
|
+
var onTouchStart = function onTouchStart(e) {
|
|
108
|
+
scrollable = getScrollParent(e.target);
|
|
109
|
+
if (!scrollable || scrollable === document.documentElement || scrollable === document.body) {
|
|
110
|
+
return;
|
|
111
|
+
}
|
|
112
|
+
preventInertiaScroll(scrollable);
|
|
113
|
+
scrollable.addEventListener('touchmove', allowTouchMove, listenerOptions);
|
|
114
|
+
};
|
|
115
|
+
var onTouchEnd = function onTouchEnd() {
|
|
116
|
+
if (!scrollable) {
|
|
117
|
+
return;
|
|
118
|
+
}
|
|
119
|
+
scrollable.removeEventListener('touchmove', allowTouchMove, listenerOptions);
|
|
120
|
+
scrollable = undefined;
|
|
121
|
+
};
|
|
122
|
+
var preventScrollMobileSafari = function preventScrollMobileSafari() {
|
|
123
|
+
document.addEventListener('touchstart', onTouchStart, listenerOptions);
|
|
124
|
+
document.addEventListener('touchmove', preventTouchMove, listenerOptions);
|
|
125
|
+
document.addEventListener('touchend', onTouchEnd, listenerOptions);
|
|
126
|
+
return function () {
|
|
127
|
+
document.removeEventListener('touchstart', onTouchStart, listenerOptions);
|
|
128
|
+
document.removeEventListener('touchmove', preventTouchMove, listenerOptions);
|
|
129
|
+
document.removeEventListener('touchend', onTouchEnd, listenerOptions);
|
|
130
|
+
};
|
|
131
|
+
};
|
|
132
|
+
|
|
133
|
+
var preventScrollCount = 0;
|
|
134
|
+
var restoreStandart;
|
|
135
|
+
var restoreMobileSafari;
|
|
136
|
+
var useBodyScrollLock = function useBodyScrollLock(_ref) {
|
|
137
|
+
var _ref$isActive = _ref.isActive,
|
|
138
|
+
isActive = _ref$isActive === void 0 ? true : _ref$isActive;
|
|
139
|
+
useLayoutEffect(function () {
|
|
140
|
+
if (!isActive) {
|
|
141
|
+
return;
|
|
142
|
+
}
|
|
143
|
+
var isMobileSafari = isIOS();
|
|
144
|
+
preventScrollCount++;
|
|
145
|
+
if (preventScrollCount === 1) {
|
|
146
|
+
restoreStandart = preventScrollStandard();
|
|
147
|
+
if (isMobileSafari) {
|
|
148
|
+
restoreMobileSafari = preventScrollMobileSafari();
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
return function () {
|
|
152
|
+
preventScrollCount--;
|
|
153
|
+
if (preventScrollCount === 0) {
|
|
154
|
+
restoreStandart();
|
|
155
|
+
if (isMobileSafari) {
|
|
156
|
+
restoreMobileSafari();
|
|
157
|
+
}
|
|
158
|
+
}
|
|
159
|
+
};
|
|
160
|
+
}, [isActive]);
|
|
161
|
+
};
|
|
162
|
+
|
|
163
|
+
exports.useBodyScrollLock = useBodyScrollLock;
|
|
@@ -0,0 +1,163 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
+
|
|
5
|
+
var React = require('react');
|
|
6
|
+
|
|
7
|
+
function _interopDefaultCompat (e) { return e && typeof e === 'object' && 'default' in e ? e : { default: e }; }
|
|
8
|
+
|
|
9
|
+
var React__default = /*#__PURE__*/_interopDefaultCompat(React);
|
|
10
|
+
|
|
11
|
+
var listenerOptions = {
|
|
12
|
+
capture: false,
|
|
13
|
+
passive: false
|
|
14
|
+
};
|
|
15
|
+
function testPlatform(re) {
|
|
16
|
+
var _window$navigator$use;
|
|
17
|
+
return typeof window !== 'undefined' && window.navigator != null ?
|
|
18
|
+
// @ts-ignore
|
|
19
|
+
re.test(((_window$navigator$use = window.navigator['userAgentData']) === null || _window$navigator$use === void 0 ? void 0 : _window$navigator$use.platform) || window.navigator.platform) : false;
|
|
20
|
+
}
|
|
21
|
+
function isMac() {
|
|
22
|
+
return testPlatform(/^Mac/i);
|
|
23
|
+
}
|
|
24
|
+
function isIPhone() {
|
|
25
|
+
return testPlatform(/^iPhone/i);
|
|
26
|
+
}
|
|
27
|
+
function isIPad() {
|
|
28
|
+
return testPlatform(/^iPad/i) ||
|
|
29
|
+
// iPadOS 13 lies and says it's a Mac, but we can distinguish by detecting touch support.
|
|
30
|
+
isMac() && navigator.maxTouchPoints > 1;
|
|
31
|
+
}
|
|
32
|
+
var useLayoutEffect = typeof document !== 'undefined' ? React__default.default.useLayoutEffect : function () {};
|
|
33
|
+
function isIOS() {
|
|
34
|
+
return isIPhone() || isIPad();
|
|
35
|
+
}
|
|
36
|
+
function setStyle(element, style, value) {
|
|
37
|
+
// @ts-ignore
|
|
38
|
+
var cur = element.style[style];
|
|
39
|
+
// @ts-ignore
|
|
40
|
+
element.style[style] = value;
|
|
41
|
+
return function () {
|
|
42
|
+
// @ts-ignore
|
|
43
|
+
element.style[style] = cur;
|
|
44
|
+
};
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
/**
|
|
48
|
+
* Calls all functions in the order they were chained with the same arguments.
|
|
49
|
+
*/
|
|
50
|
+
function chain() {
|
|
51
|
+
for (var _len = arguments.length, callbacks = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
52
|
+
callbacks[_key] = arguments[_key];
|
|
53
|
+
}
|
|
54
|
+
return function () {
|
|
55
|
+
for (var _i = 0, _callbacks = callbacks; _i < _callbacks.length; _i++) {
|
|
56
|
+
var callback = _callbacks[_i];
|
|
57
|
+
if (typeof callback === 'function') {
|
|
58
|
+
callback.apply(void 0, arguments);
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
};
|
|
62
|
+
}
|
|
63
|
+
var preventTouchMove = function preventTouchMove(e) {
|
|
64
|
+
e.preventDefault();
|
|
65
|
+
return false;
|
|
66
|
+
};
|
|
67
|
+
var allowTouchMove = function allowTouchMove(e) {
|
|
68
|
+
var target = e.currentTarget;
|
|
69
|
+
if (target.scrollHeight > target.clientHeight || target.scrollWidth > target.clientWidth) {
|
|
70
|
+
e.stopPropagation();
|
|
71
|
+
return true;
|
|
72
|
+
}
|
|
73
|
+
e.preventDefault();
|
|
74
|
+
return false;
|
|
75
|
+
};
|
|
76
|
+
function preventInertiaScroll(target) {
|
|
77
|
+
var top = target.scrollTop;
|
|
78
|
+
var totalScroll = target.scrollHeight;
|
|
79
|
+
var currentScroll = top + target.offsetHeight;
|
|
80
|
+
if (top === 0) {
|
|
81
|
+
target.scrollTop = 1;
|
|
82
|
+
} else if (currentScroll === totalScroll) {
|
|
83
|
+
target.scrollTop = top - 1;
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
function isScrollable(node) {
|
|
87
|
+
var style = window.getComputedStyle(node);
|
|
88
|
+
return /(auto|scroll)/.test(style.overflow + style.overflowX + style.overflowY);
|
|
89
|
+
}
|
|
90
|
+
function getScrollParent(node) {
|
|
91
|
+
if (isScrollable(node)) {
|
|
92
|
+
// @ts-ignore
|
|
93
|
+
node = node.parentElement;
|
|
94
|
+
}
|
|
95
|
+
while (node && !isScrollable(node)) {
|
|
96
|
+
// @ts-ignore
|
|
97
|
+
node = node.parentElement;
|
|
98
|
+
}
|
|
99
|
+
return node || document.scrollingElement || document.documentElement;
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
function preventScrollStandard() {
|
|
103
|
+
return chain(setStyle(document.documentElement, 'paddingRight', "".concat(window.innerWidth - document.documentElement.clientWidth, "px")), setStyle(document.documentElement, 'overflow', 'hidden'));
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
var scrollable;
|
|
107
|
+
var onTouchStart = function onTouchStart(e) {
|
|
108
|
+
scrollable = getScrollParent(e.target);
|
|
109
|
+
if (!scrollable || scrollable === document.documentElement || scrollable === document.body) {
|
|
110
|
+
return;
|
|
111
|
+
}
|
|
112
|
+
preventInertiaScroll(scrollable);
|
|
113
|
+
scrollable.addEventListener('touchmove', allowTouchMove, listenerOptions);
|
|
114
|
+
};
|
|
115
|
+
var onTouchEnd = function onTouchEnd() {
|
|
116
|
+
if (!scrollable) {
|
|
117
|
+
return;
|
|
118
|
+
}
|
|
119
|
+
scrollable.removeEventListener('touchmove', allowTouchMove, listenerOptions);
|
|
120
|
+
scrollable = undefined;
|
|
121
|
+
};
|
|
122
|
+
var preventScrollMobileSafari = function preventScrollMobileSafari() {
|
|
123
|
+
document.addEventListener('touchstart', onTouchStart, listenerOptions);
|
|
124
|
+
document.addEventListener('touchmove', preventTouchMove, listenerOptions);
|
|
125
|
+
document.addEventListener('touchend', onTouchEnd, listenerOptions);
|
|
126
|
+
return function () {
|
|
127
|
+
document.removeEventListener('touchstart', onTouchStart, listenerOptions);
|
|
128
|
+
document.removeEventListener('touchmove', preventTouchMove, listenerOptions);
|
|
129
|
+
document.removeEventListener('touchend', onTouchEnd, listenerOptions);
|
|
130
|
+
};
|
|
131
|
+
};
|
|
132
|
+
|
|
133
|
+
var preventScrollCount = 0;
|
|
134
|
+
var restoreStandart;
|
|
135
|
+
var restoreMobileSafari;
|
|
136
|
+
var useBodyScrollLock = function useBodyScrollLock(_ref) {
|
|
137
|
+
var _ref$isActive = _ref.isActive,
|
|
138
|
+
isActive = _ref$isActive === void 0 ? true : _ref$isActive;
|
|
139
|
+
useLayoutEffect(function () {
|
|
140
|
+
if (!isActive) {
|
|
141
|
+
return;
|
|
142
|
+
}
|
|
143
|
+
var isMobileSafari = isIOS();
|
|
144
|
+
preventScrollCount++;
|
|
145
|
+
if (preventScrollCount === 1) {
|
|
146
|
+
restoreStandart = preventScrollStandard();
|
|
147
|
+
if (isMobileSafari) {
|
|
148
|
+
restoreMobileSafari = preventScrollMobileSafari();
|
|
149
|
+
}
|
|
150
|
+
}
|
|
151
|
+
return function () {
|
|
152
|
+
preventScrollCount--;
|
|
153
|
+
if (preventScrollCount === 0) {
|
|
154
|
+
restoreStandart();
|
|
155
|
+
if (isMobileSafari) {
|
|
156
|
+
restoreMobileSafari();
|
|
157
|
+
}
|
|
158
|
+
}
|
|
159
|
+
};
|
|
160
|
+
}, [isActive]);
|
|
161
|
+
};
|
|
162
|
+
|
|
163
|
+
exports.useBodyScrollLock = useBodyScrollLock;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react");function t(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var n={capture:!1,passive:!1};function o(e){var t;return"undefined"!=typeof window&&null!=window.navigator&&e.test((null===(t=window.navigator.userAgentData)||void 0===t?void 0:t.platform)||window.navigator.platform)}function r(){return o(/^iPad/i)||o(/^Mac/i)&&navigator.maxTouchPoints>1}var u="undefined"!=typeof document?t(e).default.useLayoutEffect:function(){};function i(){return o(/^iPhone/i)||r()}function c(e,t,n){var o=e.style[t];return e.style[t]=n,function(){e.style[t]=o}}var d,a=function(e){return e.preventDefault(),!1},l=function(e){var t=e.currentTarget;return t.scrollHeight>t.clientHeight||t.scrollWidth>t.clientWidth?(e.stopPropagation(),!0):(e.preventDefault(),!1)};function v(e){var t=window.getComputedStyle(e);return/(auto|scroll)/.test(t.overflow+t.overflowX+t.overflowY)}function f(){return function(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];return function(){for(var e=0,n=t;e<n.length;e++){var o=n[e];"function"==typeof o&&o.apply(void 0,arguments)}}}(c(document.documentElement,"paddingRight","".concat(window.innerWidth-document.documentElement.clientWidth,"px")),c(document.documentElement,"overflow","hidden"))}var m,s,p=function(e){var t,o,r,u;(d=function(e){for(v(e)&&(e=e.parentElement);e&&!v(e);)e=e.parentElement;return e||document.scrollingElement||document.documentElement}(e.target))&&d!==document.documentElement&&d!==document.body&&(o=(t=d).scrollTop,r=t.scrollHeight,u=o+t.offsetHeight,0===o?t.scrollTop=1:u===r&&(t.scrollTop=o-1),d.addEventListener("touchmove",l,n))},h=function(){d&&(d.removeEventListener("touchmove",l,n),d=void 0)},g=0;exports.useBodyScrollLock=function(e){var t=e.isActive,o=void 0===t||t;u((function(){if(o){var e=i();return 1===++g&&(m=f(),e&&(document.addEventListener("touchstart",p,n),document.addEventListener("touchmove",a,n),document.addEventListener("touchend",h,n),s=function(){document.removeEventListener("touchstart",p,n),document.removeEventListener("touchmove",a,n),document.removeEventListener("touchend",h,n)})),function(){0===--g&&(m(),e&&s())}}}),[o])};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react");function t(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var n={capture:!1,passive:!1};function o(e){var t;return"undefined"!=typeof window&&null!=window.navigator&&e.test((null===(t=window.navigator.userAgentData)||void 0===t?void 0:t.platform)||window.navigator.platform)}function r(){return o(/^iPad/i)||o(/^Mac/i)&&navigator.maxTouchPoints>1}var u="undefined"!=typeof document?t(e).default.useLayoutEffect:function(){};function i(){return o(/^iPhone/i)||r()}function c(e,t,n){var o=e.style[t];return e.style[t]=n,function(){e.style[t]=o}}var d,a=function(e){return e.preventDefault(),!1},l=function(e){var t=e.currentTarget;return t.scrollHeight>t.clientHeight||t.scrollWidth>t.clientWidth?(e.stopPropagation(),!0):(e.preventDefault(),!1)};function v(e){var t=window.getComputedStyle(e);return/(auto|scroll)/.test(t.overflow+t.overflowX+t.overflowY)}function f(){return function(){for(var e=arguments.length,t=new Array(e),n=0;n<e;n++)t[n]=arguments[n];return function(){for(var e=0,n=t;e<n.length;e++){var o=n[e];"function"==typeof o&&o.apply(void 0,arguments)}}}(c(document.documentElement,"paddingRight","".concat(window.innerWidth-document.documentElement.clientWidth,"px")),c(document.documentElement,"overflow","hidden"))}var m,s,p=function(e){var t,o,r,u;(d=function(e){for(v(e)&&(e=e.parentElement);e&&!v(e);)e=e.parentElement;return e||document.scrollingElement||document.documentElement}(e.target))&&d!==document.documentElement&&d!==document.body&&(o=(t=d).scrollTop,r=t.scrollHeight,u=o+t.offsetHeight,0===o?t.scrollTop=1:u===r&&(t.scrollTop=o-1),d.addEventListener("touchmove",l,n))},h=function(){d&&(d.removeEventListener("touchmove",l,n),d=void 0)},g=0;exports.useBodyScrollLock=function(e){var t=e.isActive,o=void 0===t||t;u((function(){if(o){var e=i();return 1===++g&&(m=f(),e&&(document.addEventListener("touchstart",p,n),document.addEventListener("touchmove",a,n),document.addEventListener("touchend",h,n),s=function(){document.removeEventListener("touchstart",p,n),document.removeEventListener("touchmove",a,n),document.removeEventListener("touchend",h,n)})),function(){0===--g&&(m(),e&&s())}}}),[o])};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const preventScrollMobileSafari: () => () => void;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function preventScrollStandard(): (...args: any[]) => void;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
export declare const listenerOptions: {
|
|
3
|
+
capture: boolean;
|
|
4
|
+
passive: boolean;
|
|
5
|
+
};
|
|
6
|
+
export declare const useLayoutEffect: typeof React.useLayoutEffect;
|
|
7
|
+
export declare function isIOS(): boolean;
|
|
8
|
+
export declare function setStyle(element: HTMLElement, style: string, value: string): () => void;
|
|
9
|
+
/**
|
|
10
|
+
* Calls all functions in the order they were chained with the same arguments.
|
|
11
|
+
*/
|
|
12
|
+
export declare function chain(...callbacks: any[]): (...args: any[]) => void;
|
|
13
|
+
export declare const preventTouchMove: (e: TouchEvent) => boolean;
|
|
14
|
+
export declare const allowTouchMove: (e: TouchEvent) => boolean;
|
|
15
|
+
export declare function preventInertiaScroll(target: HTMLElement): void;
|
|
16
|
+
export declare function getScrollParent(node: HTMLElement): HTMLElement;
|
package/useBodyTTag/package.json
CHANGED
package/useDebounce/package.json
CHANGED
package/useId/package.json
CHANGED
package/useKeyPress/package.json
CHANGED
package/useMedia/package.json
CHANGED
package/usePortal/package.json
CHANGED