Initial commit
This commit is contained in:
21
node_modules/react-remove-scroll/LICENSE
generated
vendored
Normal file
21
node_modules/react-remove-scroll/LICENSE
generated
vendored
Normal file
@ -0,0 +1,21 @@
|
||||
MIT License
|
||||
|
||||
Copyright (c) 2017 Anton Korzunov
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
152
node_modules/react-remove-scroll/README.md
generated
vendored
Normal file
152
node_modules/react-remove-scroll/README.md
generated
vendored
Normal file
@ -0,0 +1,152 @@
|
||||
<div align="center">
|
||||
<h1>React-remove-📜</h1>
|
||||
<br/>
|
||||
dont even scroll
|
||||
<br/>
|
||||
|
||||
<a href="https://www.npmjs.com/package/react-remove-scroll">
|
||||
<img src="https://img.shields.io/npm/v/react-remove-scroll.svg?style=flat-square" />
|
||||
</a>
|
||||
|
||||
<a href="https://travis-ci.org/theKashey/react-remove-scroll">
|
||||
<img src="https://img.shields.io/travis/theKashey/react-remove-scroll.svg?style=flat-square" alt="Build status">
|
||||
</a>
|
||||
|
||||
<a href="https://www.npmjs.com/package/react-remove-scroll">
|
||||
<img src="https://img.shields.io/npm/dm/react-remove-scroll.svg" alt="npm downloads">
|
||||
</a>
|
||||
|
||||
<a href="https://bundlephobia.com/result?p=react-remove-scroll">
|
||||
<img src="https://img.shields.io/bundlephobia/minzip/react-remove-scroll.svg" alt="bundle size">
|
||||
</a>
|
||||
<br/>
|
||||
</div>
|
||||
|
||||
react-remove-scroll
|
||||
====
|
||||
[](https://www.npmjs.com/package/react-remove-scroll)
|
||||
|
||||
Disables scroll outside of `children` node.
|
||||
|
||||
- 🖱 mouse and touch devices friendly
|
||||
- 📈 vertical and horizontal
|
||||
- 📜 removes document scroll bar maintaining it space
|
||||
- ✅ support nested scrollable elements
|
||||
- 🕳 supports react-portals (uses React Event system)
|
||||
- ☠️ it could block literally any scroll anywhere
|
||||
|
||||
# Usage
|
||||
Just wrap content, which should be scrollable, and everything else would not.
|
||||
```js
|
||||
import {RemoveScroll} from 'react-remove-scroll';
|
||||
|
||||
<RemoveScroll>
|
||||
Only this content would be scrollable
|
||||
</RemoveScroll>
|
||||
```
|
||||
|
||||
`RemoveScroll` accept following props
|
||||
- `children`
|
||||
- `[enabled]` - activate or deactivate component behaviour without removing it.
|
||||
- `[allowPinchZoom=false]` - enabled "pinch-n-zoom" behavior. By default it might be prevented. However - pinch and zoom might break "scroll isolation", and __disabled by default__.
|
||||
- `[noIsolation=false]` - disables outer event capturing. Event capturing is React friendly and unlikely be a problem.
|
||||
But if you are using _shadowbox_ of some sort - you dont need it.
|
||||
- `[inert=false]` - ☠️(be careful) disables events the rest of page completely using `pointer-events` except the Lock(+shards).
|
||||
React portals not friendly, might lead to production issues. Enable only for __rare__ cases, when you have to disable scrollbars somewhere on the page(except body, Lock and shards).
|
||||
- `[forwardProps]` - will forward all props to the `children`
|
||||
- `[className]` - className for an internal div
|
||||
- `[removeScrollBar]` - to control scroll bar removal. Set to false, if you prefer to keep it (wheel and touch scroll is still disabled).
|
||||
|
||||
# Size
|
||||
- (🧩 full) 1.7kb after compression (excluding tslib).
|
||||
---
|
||||
- (👁 UI) __400b__, visual elements only
|
||||
- (🚗 sidecar) 1.5kb, side effects
|
||||
```js
|
||||
import {sidecar} from "react-remove-scroll";
|
||||
import {RemoveScroll} from 'react-remove-scroll/UI';
|
||||
|
||||
const sidecar = sidecar(() => import('react-remove-scroll/sidecar'));
|
||||
|
||||
<RemoveScroll sideCar={sidecar}>
|
||||
Will load logic from a sidecar when needed
|
||||
</RemoveScroll>
|
||||
```
|
||||
|
||||
> Consider setting `-webkit-overflow-scrolling: touch;` on a document level for a proper mobile experience.
|
||||
|
||||
## Internal div
|
||||
But default RemoveScroll will create a div to handle and capture events.
|
||||
You may specify `className` for it, if you need, or __remove it__.
|
||||
|
||||
The following code samples will produce the same output
|
||||
```js
|
||||
<RemoveScroll className="scroll">
|
||||
Only this content would be scrollable
|
||||
</RemoveScroll>
|
||||
```
|
||||
|
||||
```js
|
||||
<RemoveScroll forwardProps>
|
||||
<div className="scroll"> //RemoveScroll will inject props to this div
|
||||
Only this content would be scrollable
|
||||
</div>
|
||||
</RemoveScroll>
|
||||
```
|
||||
Pick the first one if you don't need a second.
|
||||
|
||||
## Position:fixed elements
|
||||
To properly size these elements please add a special className to them.
|
||||
```jsx
|
||||
import {RemoveScroll} from 'react-remove-scroll';
|
||||
|
||||
// to make "width: 100%"
|
||||
<div className={cx(classWithPositionFixed, RemoveScroll.classNames.fullWidth)} />
|
||||
|
||||
// to make "right:0"
|
||||
<div className={cx(classWithPositionFixed, RemoveScroll.classNames.zeroRight)} />
|
||||
```
|
||||
See [react-remove-scroll-bar](https://github.com/theKashey/react-remove-scroll-bar) documentation for details.
|
||||
|
||||
## More than one lock
|
||||
When stacked more is active (default) only one (last) component would be active.
|
||||
|
||||
## Over isolation
|
||||
That could happen -
|
||||
you disable scroll on the body,
|
||||
you are suppressing all scroll and wheel events,
|
||||
and you are ghosting the rest of the page by the `inert` prop.
|
||||
|
||||
Only something inside Lock does exists for the browser, and that might be less than you expected.
|
||||
|
||||
Dont forget about `shard`, dont forget - `inert` is not portals friendly, dont forget - you dont need over isolation in most of the cases.
|
||||
|
||||
> just be careful!
|
||||
|
||||
# Performance
|
||||
To do the job this library setup _non_ passive event listener. Chrome dev tools would complain about it, as a
|
||||
performance no-op.
|
||||
|
||||
We have to use synchronous scroll/touch handler, and it may affect scrolling performance.
|
||||
|
||||
Consider using `noIsolation` mode, if you have large scrollable areas.
|
||||
|
||||
# Supported React versions
|
||||
- v1 supports React 15/16
|
||||
- v2 requires 16.8.0+ (hooks)
|
||||
|
||||
# Scroll-Locky
|
||||
This is a refactoring of another library - [react-scroll-locky](https://github.com/theKashey/react-scroll-locky) -
|
||||
to make package smaller and more react-portals friendly.
|
||||
|
||||
## See also
|
||||
- [react-focus-on](https://github.com/theKashey/react-focus-on) - Finite Modal creator (uses Scroll-Locky) underneath.
|
||||
- [react-locky](https://github.com/theKashey/react-locky) - React event canceler
|
||||
- [react-scrolllock](https://github.com/jossmac/react-scrolllock) - React scroll lock
|
||||
- [scroll-lock](https://github.com/FL3NKEY/scroll-lock) - DOM scroll lock
|
||||
- [body-scroll-lock](https://github.com/willmcpo/body-scroll-lock) - DOM scroll lock
|
||||
|
||||
> This package is relative smaller(1), more react friendly(2), works with non zero body margins(3), and has a better "overscroll" management.
|
||||
|
||||
# License
|
||||
MIT
|
||||
1
node_modules/react-remove-scroll/UI/UI.d.ts
generated
vendored
Normal file
1
node_modules/react-remove-scroll/UI/UI.d.ts
generated
vendored
Normal file
@ -0,0 +1 @@
|
||||
export * from '../dist/es2015/UI'
|
||||
8
node_modules/react-remove-scroll/UI/package.json
generated
vendored
Normal file
8
node_modules/react-remove-scroll/UI/package.json
generated
vendored
Normal file
@ -0,0 +1,8 @@
|
||||
{
|
||||
"private": true,
|
||||
"main": "../dist/es5/UI.js",
|
||||
"jsnext:main": "../dist/es2015/UI.js",
|
||||
"module": "../dist/es2015/UI.js",
|
||||
"types": "UI.d.ts",
|
||||
"sideEffects": false
|
||||
}
|
||||
3
node_modules/react-remove-scroll/dist/es2015/Combination.d.ts
generated
vendored
Normal file
3
node_modules/react-remove-scroll/dist/es2015/Combination.d.ts
generated
vendored
Normal file
@ -0,0 +1,3 @@
|
||||
import { RemoveScrollType } from './types';
|
||||
declare const ReactRemoveScroll: RemoveScrollType;
|
||||
export default ReactRemoveScroll;
|
||||
7
node_modules/react-remove-scroll/dist/es2015/Combination.js
generated
vendored
Normal file
7
node_modules/react-remove-scroll/dist/es2015/Combination.js
generated
vendored
Normal file
@ -0,0 +1,7 @@
|
||||
import { __assign } from "tslib";
|
||||
import * as React from 'react';
|
||||
import { RemoveScroll } from './UI';
|
||||
import SideCar from './sidecar';
|
||||
var ReactRemoveScroll = React.forwardRef(function (props, ref) { return (React.createElement(RemoveScroll, __assign({}, props, { ref: ref, sideCar: SideCar }))); });
|
||||
ReactRemoveScroll.classNames = RemoveScroll.classNames;
|
||||
export default ReactRemoveScroll;
|
||||
5
node_modules/react-remove-scroll/dist/es2015/SideEffect.d.ts
generated
vendored
Normal file
5
node_modules/react-remove-scroll/dist/es2015/SideEffect.d.ts
generated
vendored
Normal file
@ -0,0 +1,5 @@
|
||||
import { TouchEvent } from 'react';
|
||||
import { IRemoveScrollEffectProps } from './types';
|
||||
export declare const getTouchXY: (event: TouchEvent | WheelEvent) => number[];
|
||||
export declare const getDeltaXY: (event: WheelEvent) => number[];
|
||||
export declare function RemoveScrollSideCar(props: IRemoveScrollEffectProps): JSX.Element;
|
||||
157
node_modules/react-remove-scroll/dist/es2015/SideEffect.js
generated
vendored
Normal file
157
node_modules/react-remove-scroll/dist/es2015/SideEffect.js
generated
vendored
Normal file
@ -0,0 +1,157 @@
|
||||
import { __spreadArray } from "tslib";
|
||||
import * as React from 'react';
|
||||
import { RemoveScrollBar } from 'react-remove-scroll-bar';
|
||||
import { styleSingleton } from 'react-style-singleton';
|
||||
import { nonPassive } from './aggresiveCapture';
|
||||
import { handleScroll, locationCouldBeScrolled } from './handleScroll';
|
||||
export var getTouchXY = function (event) {
|
||||
return 'changedTouches' in event ? [event.changedTouches[0].clientX, event.changedTouches[0].clientY] : [0, 0];
|
||||
};
|
||||
export var getDeltaXY = function (event) { return [event.deltaX, event.deltaY]; };
|
||||
var extractRef = function (ref) {
|
||||
return ref && 'current' in ref ? ref.current : ref;
|
||||
};
|
||||
var deltaCompare = function (x, y) { return x[0] === y[0] && x[1] === y[1]; };
|
||||
var generateStyle = function (id) { return "\n .block-interactivity-".concat(id, " {pointer-events: none;}\n .allow-interactivity-").concat(id, " {pointer-events: all;}\n"); };
|
||||
var idCounter = 0;
|
||||
var lockStack = [];
|
||||
export function RemoveScrollSideCar(props) {
|
||||
var shouldPreventQueue = React.useRef([]);
|
||||
var touchStartRef = React.useRef([0, 0]);
|
||||
var activeAxis = React.useRef();
|
||||
var id = React.useState(idCounter++)[0];
|
||||
var Style = React.useState(styleSingleton)[0];
|
||||
var lastProps = React.useRef(props);
|
||||
React.useEffect(function () {
|
||||
lastProps.current = props;
|
||||
}, [props]);
|
||||
React.useEffect(function () {
|
||||
if (props.inert) {
|
||||
document.body.classList.add("block-interactivity-".concat(id));
|
||||
var allow_1 = __spreadArray([props.lockRef.current], (props.shards || []).map(extractRef), true).filter(Boolean);
|
||||
allow_1.forEach(function (el) { return el.classList.add("allow-interactivity-".concat(id)); });
|
||||
return function () {
|
||||
document.body.classList.remove("block-interactivity-".concat(id));
|
||||
allow_1.forEach(function (el) { return el.classList.remove("allow-interactivity-".concat(id)); });
|
||||
};
|
||||
}
|
||||
return;
|
||||
}, [props.inert, props.lockRef.current, props.shards]);
|
||||
var shouldCancelEvent = React.useCallback(function (event, parent) {
|
||||
if (('touches' in event && event.touches.length === 2) || (event.type === 'wheel' && event.ctrlKey)) {
|
||||
return !lastProps.current.allowPinchZoom;
|
||||
}
|
||||
var touch = getTouchXY(event);
|
||||
var touchStart = touchStartRef.current;
|
||||
var deltaX = 'deltaX' in event ? event.deltaX : touchStart[0] - touch[0];
|
||||
var deltaY = 'deltaY' in event ? event.deltaY : touchStart[1] - touch[1];
|
||||
var currentAxis;
|
||||
var target = event.target;
|
||||
var moveDirection = Math.abs(deltaX) > Math.abs(deltaY) ? 'h' : 'v';
|
||||
// allow horizontal touch move on Range inputs. They will not cause any scroll
|
||||
if ('touches' in event && moveDirection === 'h' && target.type === 'range') {
|
||||
return false;
|
||||
}
|
||||
var canBeScrolledInMainDirection = locationCouldBeScrolled(moveDirection, target);
|
||||
if (!canBeScrolledInMainDirection) {
|
||||
return true;
|
||||
}
|
||||
if (canBeScrolledInMainDirection) {
|
||||
currentAxis = moveDirection;
|
||||
}
|
||||
else {
|
||||
currentAxis = moveDirection === 'v' ? 'h' : 'v';
|
||||
canBeScrolledInMainDirection = locationCouldBeScrolled(moveDirection, target);
|
||||
// other axis might be not scrollable
|
||||
}
|
||||
if (!canBeScrolledInMainDirection) {
|
||||
return false;
|
||||
}
|
||||
if (!activeAxis.current && 'changedTouches' in event && (deltaX || deltaY)) {
|
||||
activeAxis.current = currentAxis;
|
||||
}
|
||||
if (!currentAxis) {
|
||||
return true;
|
||||
}
|
||||
var cancelingAxis = activeAxis.current || currentAxis;
|
||||
return handleScroll(cancelingAxis, parent, event, cancelingAxis === 'h' ? deltaX : deltaY, true);
|
||||
}, []);
|
||||
var shouldPrevent = React.useCallback(function (_event) {
|
||||
var event = _event;
|
||||
if (!lockStack.length || lockStack[lockStack.length - 1] !== Style) {
|
||||
// not the last active
|
||||
return;
|
||||
}
|
||||
var delta = 'deltaY' in event ? getDeltaXY(event) : getTouchXY(event);
|
||||
var sourceEvent = shouldPreventQueue.current.filter(function (e) { return e.name === event.type && (e.target === event.target || event.target === e.shadowParent) && deltaCompare(e.delta, delta); })[0];
|
||||
// self event, and should be canceled
|
||||
if (sourceEvent && sourceEvent.should) {
|
||||
if (event.cancelable) {
|
||||
event.preventDefault();
|
||||
}
|
||||
return;
|
||||
}
|
||||
// outside or shard event
|
||||
if (!sourceEvent) {
|
||||
var shardNodes = (lastProps.current.shards || [])
|
||||
.map(extractRef)
|
||||
.filter(Boolean)
|
||||
.filter(function (node) { return node.contains(event.target); });
|
||||
var shouldStop = shardNodes.length > 0 ? shouldCancelEvent(event, shardNodes[0]) : !lastProps.current.noIsolation;
|
||||
if (shouldStop) {
|
||||
if (event.cancelable) {
|
||||
event.preventDefault();
|
||||
}
|
||||
}
|
||||
}
|
||||
}, []);
|
||||
var shouldCancel = React.useCallback(function (name, delta, target, should) {
|
||||
var event = { name: name, delta: delta, target: target, should: should, shadowParent: getOutermostShadowParent(target) };
|
||||
shouldPreventQueue.current.push(event);
|
||||
setTimeout(function () {
|
||||
shouldPreventQueue.current = shouldPreventQueue.current.filter(function (e) { return e !== event; });
|
||||
}, 1);
|
||||
}, []);
|
||||
var scrollTouchStart = React.useCallback(function (event) {
|
||||
touchStartRef.current = getTouchXY(event);
|
||||
activeAxis.current = undefined;
|
||||
}, []);
|
||||
var scrollWheel = React.useCallback(function (event) {
|
||||
shouldCancel(event.type, getDeltaXY(event), event.target, shouldCancelEvent(event, props.lockRef.current));
|
||||
}, []);
|
||||
var scrollTouchMove = React.useCallback(function (event) {
|
||||
shouldCancel(event.type, getTouchXY(event), event.target, shouldCancelEvent(event, props.lockRef.current));
|
||||
}, []);
|
||||
React.useEffect(function () {
|
||||
lockStack.push(Style);
|
||||
props.setCallbacks({
|
||||
onScrollCapture: scrollWheel,
|
||||
onWheelCapture: scrollWheel,
|
||||
onTouchMoveCapture: scrollTouchMove,
|
||||
});
|
||||
document.addEventListener('wheel', shouldPrevent, nonPassive);
|
||||
document.addEventListener('touchmove', shouldPrevent, nonPassive);
|
||||
document.addEventListener('touchstart', scrollTouchStart, nonPassive);
|
||||
return function () {
|
||||
lockStack = lockStack.filter(function (inst) { return inst !== Style; });
|
||||
document.removeEventListener('wheel', shouldPrevent, nonPassive);
|
||||
document.removeEventListener('touchmove', shouldPrevent, nonPassive);
|
||||
document.removeEventListener('touchstart', scrollTouchStart, nonPassive);
|
||||
};
|
||||
}, []);
|
||||
var removeScrollBar = props.removeScrollBar, inert = props.inert;
|
||||
return (React.createElement(React.Fragment, null,
|
||||
inert ? React.createElement(Style, { styles: generateStyle(id) }) : null,
|
||||
removeScrollBar ? React.createElement(RemoveScrollBar, { gapMode: props.gapMode }) : null));
|
||||
}
|
||||
function getOutermostShadowParent(node) {
|
||||
var shadowParent = null;
|
||||
while (node !== null) {
|
||||
if (node instanceof ShadowRoot) {
|
||||
shadowParent = node.host;
|
||||
node = node.host;
|
||||
}
|
||||
node = node.parentNode;
|
||||
}
|
||||
return shadowParent;
|
||||
}
|
||||
7
node_modules/react-remove-scroll/dist/es2015/UI.d.ts
generated
vendored
Normal file
7
node_modules/react-remove-scroll/dist/es2015/UI.d.ts
generated
vendored
Normal file
@ -0,0 +1,7 @@
|
||||
import { RemoveScrollUIType, IRemoveScrollSelfProps } from './types';
|
||||
export type { IRemoveScrollSelfProps, RemoveScrollUIType };
|
||||
/**
|
||||
* Removes scrollbar from the page and contain the scroll within the Lock
|
||||
*/
|
||||
declare const RemoveScroll: RemoveScrollUIType;
|
||||
export { RemoveScroll };
|
||||
36
node_modules/react-remove-scroll/dist/es2015/UI.js
generated
vendored
Normal file
36
node_modules/react-remove-scroll/dist/es2015/UI.js
generated
vendored
Normal file
@ -0,0 +1,36 @@
|
||||
import { __assign, __rest } from "tslib";
|
||||
import * as React from 'react';
|
||||
import { fullWidthClassName, zeroRightClassName } from 'react-remove-scroll-bar/constants';
|
||||
import { useMergeRefs } from 'use-callback-ref';
|
||||
import { effectCar } from './medium';
|
||||
var nothing = function () {
|
||||
return;
|
||||
};
|
||||
/**
|
||||
* Removes scrollbar from the page and contain the scroll within the Lock
|
||||
*/
|
||||
var RemoveScroll = React.forwardRef(function (props, parentRef) {
|
||||
var ref = React.useRef(null);
|
||||
var _a = React.useState({
|
||||
onScrollCapture: nothing,
|
||||
onWheelCapture: nothing,
|
||||
onTouchMoveCapture: nothing,
|
||||
}), callbacks = _a[0], setCallbacks = _a[1];
|
||||
var forwardProps = props.forwardProps, children = props.children, className = props.className, removeScrollBar = props.removeScrollBar, enabled = props.enabled, shards = props.shards, sideCar = props.sideCar, noIsolation = props.noIsolation, inert = props.inert, allowPinchZoom = props.allowPinchZoom, _b = props.as, Container = _b === void 0 ? 'div' : _b, gapMode = props.gapMode, rest = __rest(props, ["forwardProps", "children", "className", "removeScrollBar", "enabled", "shards", "sideCar", "noIsolation", "inert", "allowPinchZoom", "as", "gapMode"]);
|
||||
var SideCar = sideCar;
|
||||
var containerRef = useMergeRefs([ref, parentRef]);
|
||||
var containerProps = __assign(__assign({}, rest), callbacks);
|
||||
return (React.createElement(React.Fragment, null,
|
||||
enabled && (React.createElement(SideCar, { sideCar: effectCar, removeScrollBar: removeScrollBar, shards: shards, noIsolation: noIsolation, inert: inert, setCallbacks: setCallbacks, allowPinchZoom: !!allowPinchZoom, lockRef: ref, gapMode: gapMode })),
|
||||
forwardProps ? (React.cloneElement(React.Children.only(children), __assign(__assign({}, containerProps), { ref: containerRef }))) : (React.createElement(Container, __assign({}, containerProps, { className: className, ref: containerRef }), children))));
|
||||
});
|
||||
RemoveScroll.defaultProps = {
|
||||
enabled: true,
|
||||
removeScrollBar: true,
|
||||
inert: false,
|
||||
};
|
||||
RemoveScroll.classNames = {
|
||||
fullWidth: fullWidthClassName,
|
||||
zeroRight: zeroRightClassName,
|
||||
};
|
||||
export { RemoveScroll };
|
||||
3
node_modules/react-remove-scroll/dist/es2015/aggresiveCapture.d.ts
generated
vendored
Normal file
3
node_modules/react-remove-scroll/dist/es2015/aggresiveCapture.d.ts
generated
vendored
Normal file
@ -0,0 +1,3 @@
|
||||
export declare const nonPassive: boolean | {
|
||||
passive: boolean;
|
||||
};
|
||||
19
node_modules/react-remove-scroll/dist/es2015/aggresiveCapture.js
generated
vendored
Normal file
19
node_modules/react-remove-scroll/dist/es2015/aggresiveCapture.js
generated
vendored
Normal file
@ -0,0 +1,19 @@
|
||||
var passiveSupported = false;
|
||||
if (typeof window !== 'undefined') {
|
||||
try {
|
||||
var options = Object.defineProperty({}, 'passive', {
|
||||
get: function () {
|
||||
passiveSupported = true;
|
||||
return true;
|
||||
},
|
||||
});
|
||||
// @ts-ignore
|
||||
window.addEventListener('test', options, options);
|
||||
// @ts-ignore
|
||||
window.removeEventListener('test', options, options);
|
||||
}
|
||||
catch (err) {
|
||||
passiveSupported = false;
|
||||
}
|
||||
}
|
||||
export var nonPassive = passiveSupported ? { passive: false } : false;
|
||||
3
node_modules/react-remove-scroll/dist/es2015/handleScroll.d.ts
generated
vendored
Normal file
3
node_modules/react-remove-scroll/dist/es2015/handleScroll.d.ts
generated
vendored
Normal file
@ -0,0 +1,3 @@
|
||||
import { Axis } from './types';
|
||||
export declare const locationCouldBeScrolled: (axis: Axis, node: HTMLElement) => boolean;
|
||||
export declare const handleScroll: (axis: Axis, endTarget: HTMLElement, event: any, sourceDelta: number, noOverscroll: boolean) => boolean;
|
||||
107
node_modules/react-remove-scroll/dist/es2015/handleScroll.js
generated
vendored
Normal file
107
node_modules/react-remove-scroll/dist/es2015/handleScroll.js
generated
vendored
Normal file
@ -0,0 +1,107 @@
|
||||
var alwaysContainsScroll = function (node) {
|
||||
// textarea will always _contain_ scroll inside self. It only can be hidden
|
||||
return node.tagName === 'TEXTAREA';
|
||||
};
|
||||
var elementCanBeScrolled = function (node, overflow) {
|
||||
if (!(node instanceof Element)) {
|
||||
return false;
|
||||
}
|
||||
var styles = window.getComputedStyle(node);
|
||||
return (
|
||||
// not-not-scrollable
|
||||
styles[overflow] !== 'hidden' &&
|
||||
// contains scroll inside self
|
||||
!(styles.overflowY === styles.overflowX && !alwaysContainsScroll(node) && styles[overflow] === 'visible'));
|
||||
};
|
||||
var elementCouldBeVScrolled = function (node) { return elementCanBeScrolled(node, 'overflowY'); };
|
||||
var elementCouldBeHScrolled = function (node) { return elementCanBeScrolled(node, 'overflowX'); };
|
||||
export var locationCouldBeScrolled = function (axis, node) {
|
||||
var ownerDocument = node.ownerDocument;
|
||||
var current = node;
|
||||
do {
|
||||
// Skip over shadow root
|
||||
if (typeof ShadowRoot !== 'undefined' && current instanceof ShadowRoot) {
|
||||
current = current.host;
|
||||
}
|
||||
var isScrollable = elementCouldBeScrolled(axis, current);
|
||||
if (isScrollable) {
|
||||
var _a = getScrollVariables(axis, current), scrollHeight = _a[1], clientHeight = _a[2];
|
||||
if (scrollHeight > clientHeight) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
current = current.parentNode;
|
||||
} while (current && current !== ownerDocument.body);
|
||||
return false;
|
||||
};
|
||||
var getVScrollVariables = function (_a) {
|
||||
var scrollTop = _a.scrollTop, scrollHeight = _a.scrollHeight, clientHeight = _a.clientHeight;
|
||||
return [
|
||||
scrollTop,
|
||||
scrollHeight,
|
||||
clientHeight,
|
||||
];
|
||||
};
|
||||
var getHScrollVariables = function (_a) {
|
||||
var scrollLeft = _a.scrollLeft, scrollWidth = _a.scrollWidth, clientWidth = _a.clientWidth;
|
||||
return [
|
||||
scrollLeft,
|
||||
scrollWidth,
|
||||
clientWidth,
|
||||
];
|
||||
};
|
||||
var elementCouldBeScrolled = function (axis, node) {
|
||||
return axis === 'v' ? elementCouldBeVScrolled(node) : elementCouldBeHScrolled(node);
|
||||
};
|
||||
var getScrollVariables = function (axis, node) {
|
||||
return axis === 'v' ? getVScrollVariables(node) : getHScrollVariables(node);
|
||||
};
|
||||
var getDirectionFactor = function (axis, direction) {
|
||||
/**
|
||||
* If the element's direction is rtl (right-to-left), then scrollLeft is 0 when the scrollbar is at its rightmost position,
|
||||
* and then increasingly negative as you scroll towards the end of the content.
|
||||
* @see https://developer.mozilla.org/en-US/docs/Web/API/Element/scrollLeft
|
||||
*/
|
||||
return axis === 'h' && direction === 'rtl' ? -1 : 1;
|
||||
};
|
||||
export var handleScroll = function (axis, endTarget, event, sourceDelta, noOverscroll) {
|
||||
var directionFactor = getDirectionFactor(axis, window.getComputedStyle(endTarget).direction);
|
||||
var delta = directionFactor * sourceDelta;
|
||||
// find scrollable target
|
||||
var target = event.target;
|
||||
var targetInLock = endTarget.contains(target);
|
||||
var shouldCancelScroll = false;
|
||||
var isDeltaPositive = delta > 0;
|
||||
var availableScroll = 0;
|
||||
var availableScrollTop = 0;
|
||||
do {
|
||||
var _a = getScrollVariables(axis, target), position = _a[0], scroll_1 = _a[1], capacity = _a[2];
|
||||
var elementScroll = scroll_1 - capacity - directionFactor * position;
|
||||
if (position || elementScroll) {
|
||||
if (elementCouldBeScrolled(axis, target)) {
|
||||
availableScroll += elementScroll;
|
||||
availableScrollTop += position;
|
||||
}
|
||||
}
|
||||
if (target instanceof ShadowRoot) {
|
||||
target = target.host;
|
||||
}
|
||||
else {
|
||||
target = target.parentNode;
|
||||
}
|
||||
} while (
|
||||
// portaled content
|
||||
(!targetInLock && target !== document.body) ||
|
||||
// self content
|
||||
(targetInLock && (endTarget.contains(target) || endTarget === target)));
|
||||
// handle epsilon around 0 (non standard zoom levels)
|
||||
if (isDeltaPositive &&
|
||||
((noOverscroll && Math.abs(availableScroll) < 1) || (!noOverscroll && delta > availableScroll))) {
|
||||
shouldCancelScroll = true;
|
||||
}
|
||||
else if (!isDeltaPositive &&
|
||||
((noOverscroll && Math.abs(availableScrollTop) < 1) || (!noOverscroll && -delta > availableScrollTop))) {
|
||||
shouldCancelScroll = true;
|
||||
}
|
||||
return shouldCancelScroll;
|
||||
};
|
||||
2
node_modules/react-remove-scroll/dist/es2015/index.d.ts
generated
vendored
Normal file
2
node_modules/react-remove-scroll/dist/es2015/index.d.ts
generated
vendored
Normal file
@ -0,0 +1,2 @@
|
||||
import RemoveScroll from './Combination';
|
||||
export { RemoveScroll };
|
||||
2
node_modules/react-remove-scroll/dist/es2015/index.js
generated
vendored
Normal file
2
node_modules/react-remove-scroll/dist/es2015/index.js
generated
vendored
Normal file
@ -0,0 +1,2 @@
|
||||
import RemoveScroll from './Combination';
|
||||
export { RemoveScroll };
|
||||
2
node_modules/react-remove-scroll/dist/es2015/medium.d.ts
generated
vendored
Normal file
2
node_modules/react-remove-scroll/dist/es2015/medium.d.ts
generated
vendored
Normal file
@ -0,0 +1,2 @@
|
||||
import { IRemoveScrollEffectProps } from './types';
|
||||
export declare const effectCar: Readonly<import("use-sidecar/dist/es5/types").SideCarMedium<IRemoveScrollEffectProps>>;
|
||||
2
node_modules/react-remove-scroll/dist/es2015/medium.js
generated
vendored
Normal file
2
node_modules/react-remove-scroll/dist/es2015/medium.js
generated
vendored
Normal file
@ -0,0 +1,2 @@
|
||||
import { createSidecarMedium } from 'use-sidecar';
|
||||
export var effectCar = createSidecarMedium();
|
||||
8
node_modules/react-remove-scroll/dist/es2015/pinchAndZoom.d.ts
generated
vendored
Normal file
8
node_modules/react-remove-scroll/dist/es2015/pinchAndZoom.d.ts
generated
vendored
Normal file
@ -0,0 +1,8 @@
|
||||
import { Touch } from 'react';
|
||||
export declare const pinchOrZoom: (event: TouchEvent, cache: Record<number, Touch>) => false | {
|
||||
action: string;
|
||||
coords?: undefined;
|
||||
} | {
|
||||
action: string;
|
||||
coords: number[];
|
||||
};
|
||||
33
node_modules/react-remove-scroll/dist/es2015/pinchAndZoom.js
generated
vendored
Normal file
33
node_modules/react-remove-scroll/dist/es2015/pinchAndZoom.js
generated
vendored
Normal file
@ -0,0 +1,33 @@
|
||||
var ds = function (ab) { return (ab[0] <= 0 && ab[1] >= 0) || (ab[0] >= 0 && ab[1] <= 0); };
|
||||
var sign = function (x) { return (x < 0 ? -1 : 1); };
|
||||
export var pinchOrZoom = function (event, cache) {
|
||||
if (!event.changedTouches) {
|
||||
return false;
|
||||
}
|
||||
if (event.touches.length === 2) {
|
||||
var oldPoints = [cache[event.touches[0].identifier], cache[event.touches[1].identifier]];
|
||||
var newPoints = [event.touches[0], event.touches[1]];
|
||||
if (oldPoints[0] && oldPoints[1]) {
|
||||
// Calculate the difference between the start and move coordinates
|
||||
var diffx = [oldPoints[0].clientX - newPoints[0].clientX, oldPoints[1].clientX - newPoints[1].clientX];
|
||||
var diffy = [oldPoints[0].clientY - newPoints[0].clientY, oldPoints[1].clientY - newPoints[1].clientY];
|
||||
console.log(diffx, diffy);
|
||||
if (ds(diffx) || ds(diffy)) {
|
||||
return {
|
||||
action: 'zoom',
|
||||
};
|
||||
}
|
||||
var mx = Math.max(Math.abs(diffx[0]), Math.abs(diffx[1]));
|
||||
var my = Math.max(Math.abs(diffy[0]), Math.abs(diffy[1]));
|
||||
return {
|
||||
action: 'pinch',
|
||||
coords: [mx * sign(diffx[0]), my * sign(diffx[1])],
|
||||
};
|
||||
}
|
||||
}
|
||||
Array.from(event.changedTouches).forEach(function (touch) { return (cache[touch.identifier] = touch); });
|
||||
return {
|
||||
action: 'move',
|
||||
coords: [event.changedTouches[0].clientX, event.changedTouches[0].clientY],
|
||||
};
|
||||
};
|
||||
2
node_modules/react-remove-scroll/dist/es2015/sidecar.d.ts
generated
vendored
Normal file
2
node_modules/react-remove-scroll/dist/es2015/sidecar.d.ts
generated
vendored
Normal file
@ -0,0 +1,2 @@
|
||||
declare const _default: import("use-sidecar").SideCarComponent<import("./types").IRemoveScrollEffectProps>;
|
||||
export default _default;
|
||||
4
node_modules/react-remove-scroll/dist/es2015/sidecar.js
generated
vendored
Normal file
4
node_modules/react-remove-scroll/dist/es2015/sidecar.js
generated
vendored
Normal file
@ -0,0 +1,4 @@
|
||||
import { exportSidecar } from 'use-sidecar';
|
||||
import { RemoveScrollSideCar } from './SideEffect';
|
||||
import { effectCar } from './medium';
|
||||
export default exportSidecar(effectCar, RemoveScrollSideCar);
|
||||
98
node_modules/react-remove-scroll/dist/es2015/types.d.ts
generated
vendored
Normal file
98
node_modules/react-remove-scroll/dist/es2015/types.d.ts
generated
vendored
Normal file
@ -0,0 +1,98 @@
|
||||
import * as React from 'react';
|
||||
import { Ref, RefObject } from 'react';
|
||||
import { ForwardRefExoticComponent } from 'react';
|
||||
import { RefAttributes } from 'react';
|
||||
export declare type Axis = 'v' | 'h';
|
||||
export declare type GapMode = 'padding' | 'margin';
|
||||
export interface RemoveScrollEffectCallbacks {
|
||||
onScrollCapture(event: any): void;
|
||||
onWheelCapture(event: any): void;
|
||||
onTouchMoveCapture(event: any): void;
|
||||
}
|
||||
export interface ChildrenNode {
|
||||
/**
|
||||
* if forwardProps is false - children should be ReactNode
|
||||
* and it would be wrapper with a div
|
||||
* @see {@link IRemoveScrollSelfProps.as}
|
||||
*/
|
||||
forwardProps?: false;
|
||||
children: React.ReactNode;
|
||||
}
|
||||
export interface ChildrenForward {
|
||||
/**
|
||||
* if forwardProps is true - everything will be forwarded to a single child node
|
||||
* otherwise - a Container, controlled by `as` prop will be rendered in place
|
||||
* @default false
|
||||
* @see {@link IRemoveScrollSelfProps.as}
|
||||
*/
|
||||
forwardProps: true;
|
||||
children: React.ReactElement;
|
||||
}
|
||||
export interface IRemoveScrollSelfProps {
|
||||
ref?: Ref<HTMLElement>;
|
||||
/**
|
||||
* disables "event isolation" (suppressing of events happening outside of the Lock)
|
||||
* @default false
|
||||
*/
|
||||
noIsolation?: boolean;
|
||||
/**
|
||||
* enabled complete Lock isolation using `pointer-events:none` for anything outside the Lock
|
||||
* you probably don't need it, except you do
|
||||
* @default false
|
||||
* @see {IRemoveScrollSelfProps.noIsolation}
|
||||
*/
|
||||
inert?: boolean;
|
||||
/**
|
||||
* allows pinch-zoom, however might work not perfectly for normal scroll
|
||||
*/
|
||||
allowPinchZoom?: boolean;
|
||||
/**
|
||||
* switches on/off the behavior of the component
|
||||
*/
|
||||
enabled?: boolean;
|
||||
/**
|
||||
* Controls the body scroll bar removal
|
||||
* @default false
|
||||
*/
|
||||
removeScrollBar?: boolean;
|
||||
className?: string;
|
||||
style?: React.CSSProperties;
|
||||
/**
|
||||
* array of refs to other Elements, which should be considered as a part of the Lock
|
||||
*/
|
||||
shards?: Array<React.RefObject<any> | HTMLElement>;
|
||||
/**
|
||||
* Control host node used for the lock.
|
||||
* @default 'div'
|
||||
*/
|
||||
as?: string | React.ElementType;
|
||||
/**
|
||||
* controls the way "gap" is filled
|
||||
* @default "margin"
|
||||
*/
|
||||
gapMode?: GapMode;
|
||||
}
|
||||
export declare type IRemoveScrollProps = IRemoveScrollSelfProps & (ChildrenForward | ChildrenNode);
|
||||
export declare type IRemoveScrollUIProps = IRemoveScrollProps & {
|
||||
sideCar: React.FC<any>;
|
||||
};
|
||||
export interface IRemoveScrollEffectProps {
|
||||
noIsolation?: boolean;
|
||||
removeScrollBar?: boolean;
|
||||
allowPinchZoom: boolean;
|
||||
inert?: boolean;
|
||||
shards?: Array<React.RefObject<any> | HTMLElement>;
|
||||
lockRef: RefObject<HTMLElement>;
|
||||
gapMode?: GapMode;
|
||||
setCallbacks(cb: RemoveScrollEffectCallbacks): void;
|
||||
}
|
||||
interface WithClassNames {
|
||||
classNames: {
|
||||
fullWidth: string;
|
||||
zeroRight: string;
|
||||
};
|
||||
}
|
||||
declare type RefForwarded<T> = ForwardRefExoticComponent<T & RefAttributes<HTMLElement>> & WithClassNames;
|
||||
export declare type RemoveScrollType = RefForwarded<IRemoveScrollProps>;
|
||||
export declare type RemoveScrollUIType = RefForwarded<IRemoveScrollUIProps>;
|
||||
export {};
|
||||
1
node_modules/react-remove-scroll/dist/es2015/types.js
generated
vendored
Normal file
1
node_modules/react-remove-scroll/dist/es2015/types.js
generated
vendored
Normal file
@ -0,0 +1 @@
|
||||
export {};
|
||||
3
node_modules/react-remove-scroll/dist/es2019/Combination.d.ts
generated
vendored
Normal file
3
node_modules/react-remove-scroll/dist/es2019/Combination.d.ts
generated
vendored
Normal file
@ -0,0 +1,3 @@
|
||||
import { RemoveScrollType } from './types';
|
||||
declare const ReactRemoveScroll: RemoveScrollType;
|
||||
export default ReactRemoveScroll;
|
||||
6
node_modules/react-remove-scroll/dist/es2019/Combination.js
generated
vendored
Normal file
6
node_modules/react-remove-scroll/dist/es2019/Combination.js
generated
vendored
Normal file
@ -0,0 +1,6 @@
|
||||
import * as React from 'react';
|
||||
import { RemoveScroll } from './UI';
|
||||
import SideCar from './sidecar';
|
||||
const ReactRemoveScroll = React.forwardRef((props, ref) => (React.createElement(RemoveScroll, { ...props, ref: ref, sideCar: SideCar })));
|
||||
ReactRemoveScroll.classNames = RemoveScroll.classNames;
|
||||
export default ReactRemoveScroll;
|
||||
5
node_modules/react-remove-scroll/dist/es2019/SideEffect.d.ts
generated
vendored
Normal file
5
node_modules/react-remove-scroll/dist/es2019/SideEffect.d.ts
generated
vendored
Normal file
@ -0,0 +1,5 @@
|
||||
import { TouchEvent } from 'react';
|
||||
import { IRemoveScrollEffectProps } from './types';
|
||||
export declare const getTouchXY: (event: TouchEvent | WheelEvent) => number[];
|
||||
export declare const getDeltaXY: (event: WheelEvent) => number[];
|
||||
export declare function RemoveScrollSideCar(props: IRemoveScrollEffectProps): JSX.Element;
|
||||
155
node_modules/react-remove-scroll/dist/es2019/SideEffect.js
generated
vendored
Normal file
155
node_modules/react-remove-scroll/dist/es2019/SideEffect.js
generated
vendored
Normal file
@ -0,0 +1,155 @@
|
||||
import * as React from 'react';
|
||||
import { RemoveScrollBar } from 'react-remove-scroll-bar';
|
||||
import { styleSingleton } from 'react-style-singleton';
|
||||
import { nonPassive } from './aggresiveCapture';
|
||||
import { handleScroll, locationCouldBeScrolled } from './handleScroll';
|
||||
export const getTouchXY = (event) => 'changedTouches' in event ? [event.changedTouches[0].clientX, event.changedTouches[0].clientY] : [0, 0];
|
||||
export const getDeltaXY = (event) => [event.deltaX, event.deltaY];
|
||||
const extractRef = (ref) => ref && 'current' in ref ? ref.current : ref;
|
||||
const deltaCompare = (x, y) => x[0] === y[0] && x[1] === y[1];
|
||||
const generateStyle = (id) => `
|
||||
.block-interactivity-${id} {pointer-events: none;}
|
||||
.allow-interactivity-${id} {pointer-events: all;}
|
||||
`;
|
||||
let idCounter = 0;
|
||||
let lockStack = [];
|
||||
export function RemoveScrollSideCar(props) {
|
||||
const shouldPreventQueue = React.useRef([]);
|
||||
const touchStartRef = React.useRef([0, 0]);
|
||||
const activeAxis = React.useRef();
|
||||
const [id] = React.useState(idCounter++);
|
||||
const [Style] = React.useState(styleSingleton);
|
||||
const lastProps = React.useRef(props);
|
||||
React.useEffect(() => {
|
||||
lastProps.current = props;
|
||||
}, [props]);
|
||||
React.useEffect(() => {
|
||||
if (props.inert) {
|
||||
document.body.classList.add(`block-interactivity-${id}`);
|
||||
const allow = [props.lockRef.current, ...(props.shards || []).map(extractRef)].filter(Boolean);
|
||||
allow.forEach((el) => el.classList.add(`allow-interactivity-${id}`));
|
||||
return () => {
|
||||
document.body.classList.remove(`block-interactivity-${id}`);
|
||||
allow.forEach((el) => el.classList.remove(`allow-interactivity-${id}`));
|
||||
};
|
||||
}
|
||||
return;
|
||||
}, [props.inert, props.lockRef.current, props.shards]);
|
||||
const shouldCancelEvent = React.useCallback((event, parent) => {
|
||||
if (('touches' in event && event.touches.length === 2) || (event.type === 'wheel' && event.ctrlKey)) {
|
||||
return !lastProps.current.allowPinchZoom;
|
||||
}
|
||||
const touch = getTouchXY(event);
|
||||
const touchStart = touchStartRef.current;
|
||||
const deltaX = 'deltaX' in event ? event.deltaX : touchStart[0] - touch[0];
|
||||
const deltaY = 'deltaY' in event ? event.deltaY : touchStart[1] - touch[1];
|
||||
let currentAxis;
|
||||
const target = event.target;
|
||||
const moveDirection = Math.abs(deltaX) > Math.abs(deltaY) ? 'h' : 'v';
|
||||
// allow horizontal touch move on Range inputs. They will not cause any scroll
|
||||
if ('touches' in event && moveDirection === 'h' && target.type === 'range') {
|
||||
return false;
|
||||
}
|
||||
let canBeScrolledInMainDirection = locationCouldBeScrolled(moveDirection, target);
|
||||
if (!canBeScrolledInMainDirection) {
|
||||
return true;
|
||||
}
|
||||
if (canBeScrolledInMainDirection) {
|
||||
currentAxis = moveDirection;
|
||||
}
|
||||
else {
|
||||
currentAxis = moveDirection === 'v' ? 'h' : 'v';
|
||||
canBeScrolledInMainDirection = locationCouldBeScrolled(moveDirection, target);
|
||||
// other axis might be not scrollable
|
||||
}
|
||||
if (!canBeScrolledInMainDirection) {
|
||||
return false;
|
||||
}
|
||||
if (!activeAxis.current && 'changedTouches' in event && (deltaX || deltaY)) {
|
||||
activeAxis.current = currentAxis;
|
||||
}
|
||||
if (!currentAxis) {
|
||||
return true;
|
||||
}
|
||||
const cancelingAxis = activeAxis.current || currentAxis;
|
||||
return handleScroll(cancelingAxis, parent, event, cancelingAxis === 'h' ? deltaX : deltaY, true);
|
||||
}, []);
|
||||
const shouldPrevent = React.useCallback((_event) => {
|
||||
const event = _event;
|
||||
if (!lockStack.length || lockStack[lockStack.length - 1] !== Style) {
|
||||
// not the last active
|
||||
return;
|
||||
}
|
||||
const delta = 'deltaY' in event ? getDeltaXY(event) : getTouchXY(event);
|
||||
const sourceEvent = shouldPreventQueue.current.filter((e) => e.name === event.type && (e.target === event.target || event.target === e.shadowParent) && deltaCompare(e.delta, delta))[0];
|
||||
// self event, and should be canceled
|
||||
if (sourceEvent && sourceEvent.should) {
|
||||
if (event.cancelable) {
|
||||
event.preventDefault();
|
||||
}
|
||||
return;
|
||||
}
|
||||
// outside or shard event
|
||||
if (!sourceEvent) {
|
||||
const shardNodes = (lastProps.current.shards || [])
|
||||
.map(extractRef)
|
||||
.filter(Boolean)
|
||||
.filter((node) => node.contains(event.target));
|
||||
const shouldStop = shardNodes.length > 0 ? shouldCancelEvent(event, shardNodes[0]) : !lastProps.current.noIsolation;
|
||||
if (shouldStop) {
|
||||
if (event.cancelable) {
|
||||
event.preventDefault();
|
||||
}
|
||||
}
|
||||
}
|
||||
}, []);
|
||||
const shouldCancel = React.useCallback((name, delta, target, should) => {
|
||||
const event = { name, delta, target, should, shadowParent: getOutermostShadowParent(target) };
|
||||
shouldPreventQueue.current.push(event);
|
||||
setTimeout(() => {
|
||||
shouldPreventQueue.current = shouldPreventQueue.current.filter((e) => e !== event);
|
||||
}, 1);
|
||||
}, []);
|
||||
const scrollTouchStart = React.useCallback((event) => {
|
||||
touchStartRef.current = getTouchXY(event);
|
||||
activeAxis.current = undefined;
|
||||
}, []);
|
||||
const scrollWheel = React.useCallback((event) => {
|
||||
shouldCancel(event.type, getDeltaXY(event), event.target, shouldCancelEvent(event, props.lockRef.current));
|
||||
}, []);
|
||||
const scrollTouchMove = React.useCallback((event) => {
|
||||
shouldCancel(event.type, getTouchXY(event), event.target, shouldCancelEvent(event, props.lockRef.current));
|
||||
}, []);
|
||||
React.useEffect(() => {
|
||||
lockStack.push(Style);
|
||||
props.setCallbacks({
|
||||
onScrollCapture: scrollWheel,
|
||||
onWheelCapture: scrollWheel,
|
||||
onTouchMoveCapture: scrollTouchMove,
|
||||
});
|
||||
document.addEventListener('wheel', shouldPrevent, nonPassive);
|
||||
document.addEventListener('touchmove', shouldPrevent, nonPassive);
|
||||
document.addEventListener('touchstart', scrollTouchStart, nonPassive);
|
||||
return () => {
|
||||
lockStack = lockStack.filter((inst) => inst !== Style);
|
||||
document.removeEventListener('wheel', shouldPrevent, nonPassive);
|
||||
document.removeEventListener('touchmove', shouldPrevent, nonPassive);
|
||||
document.removeEventListener('touchstart', scrollTouchStart, nonPassive);
|
||||
};
|
||||
}, []);
|
||||
const { removeScrollBar, inert } = props;
|
||||
return (React.createElement(React.Fragment, null,
|
||||
inert ? React.createElement(Style, { styles: generateStyle(id) }) : null,
|
||||
removeScrollBar ? React.createElement(RemoveScrollBar, { gapMode: props.gapMode }) : null));
|
||||
}
|
||||
function getOutermostShadowParent(node) {
|
||||
let shadowParent = null;
|
||||
while (node !== null) {
|
||||
if (node instanceof ShadowRoot) {
|
||||
shadowParent = node.host;
|
||||
node = node.host;
|
||||
}
|
||||
node = node.parentNode;
|
||||
}
|
||||
return shadowParent;
|
||||
}
|
||||
7
node_modules/react-remove-scroll/dist/es2019/UI.d.ts
generated
vendored
Normal file
7
node_modules/react-remove-scroll/dist/es2019/UI.d.ts
generated
vendored
Normal file
@ -0,0 +1,7 @@
|
||||
import { RemoveScrollUIType, IRemoveScrollSelfProps } from './types';
|
||||
export type { IRemoveScrollSelfProps, RemoveScrollUIType };
|
||||
/**
|
||||
* Removes scrollbar from the page and contain the scroll within the Lock
|
||||
*/
|
||||
declare const RemoveScroll: RemoveScrollUIType;
|
||||
export { RemoveScroll };
|
||||
41
node_modules/react-remove-scroll/dist/es2019/UI.js
generated
vendored
Normal file
41
node_modules/react-remove-scroll/dist/es2019/UI.js
generated
vendored
Normal file
@ -0,0 +1,41 @@
|
||||
import * as React from 'react';
|
||||
import { fullWidthClassName, zeroRightClassName } from 'react-remove-scroll-bar/constants';
|
||||
import { useMergeRefs } from 'use-callback-ref';
|
||||
import { effectCar } from './medium';
|
||||
const nothing = () => {
|
||||
return;
|
||||
};
|
||||
/**
|
||||
* Removes scrollbar from the page and contain the scroll within the Lock
|
||||
*/
|
||||
const RemoveScroll = React.forwardRef((props, parentRef) => {
|
||||
const ref = React.useRef(null);
|
||||
const [callbacks, setCallbacks] = React.useState({
|
||||
onScrollCapture: nothing,
|
||||
onWheelCapture: nothing,
|
||||
onTouchMoveCapture: nothing,
|
||||
});
|
||||
const { forwardProps, children, className, removeScrollBar, enabled, shards, sideCar, noIsolation, inert, allowPinchZoom, as: Container = 'div', gapMode, ...rest } = props;
|
||||
const SideCar = sideCar;
|
||||
const containerRef = useMergeRefs([ref, parentRef]);
|
||||
const containerProps = {
|
||||
...rest,
|
||||
...callbacks,
|
||||
};
|
||||
return (React.createElement(React.Fragment, null,
|
||||
enabled && (React.createElement(SideCar, { sideCar: effectCar, removeScrollBar: removeScrollBar, shards: shards, noIsolation: noIsolation, inert: inert, setCallbacks: setCallbacks, allowPinchZoom: !!allowPinchZoom, lockRef: ref, gapMode: gapMode })),
|
||||
forwardProps ? (React.cloneElement(React.Children.only(children), {
|
||||
...containerProps,
|
||||
ref: containerRef,
|
||||
})) : (React.createElement(Container, { ...containerProps, className: className, ref: containerRef }, children))));
|
||||
});
|
||||
RemoveScroll.defaultProps = {
|
||||
enabled: true,
|
||||
removeScrollBar: true,
|
||||
inert: false,
|
||||
};
|
||||
RemoveScroll.classNames = {
|
||||
fullWidth: fullWidthClassName,
|
||||
zeroRight: zeroRightClassName,
|
||||
};
|
||||
export { RemoveScroll };
|
||||
3
node_modules/react-remove-scroll/dist/es2019/aggresiveCapture.d.ts
generated
vendored
Normal file
3
node_modules/react-remove-scroll/dist/es2019/aggresiveCapture.d.ts
generated
vendored
Normal file
@ -0,0 +1,3 @@
|
||||
export declare const nonPassive: boolean | {
|
||||
passive: boolean;
|
||||
};
|
||||
19
node_modules/react-remove-scroll/dist/es2019/aggresiveCapture.js
generated
vendored
Normal file
19
node_modules/react-remove-scroll/dist/es2019/aggresiveCapture.js
generated
vendored
Normal file
@ -0,0 +1,19 @@
|
||||
let passiveSupported = false;
|
||||
if (typeof window !== 'undefined') {
|
||||
try {
|
||||
const options = Object.defineProperty({}, 'passive', {
|
||||
get() {
|
||||
passiveSupported = true;
|
||||
return true;
|
||||
},
|
||||
});
|
||||
// @ts-ignore
|
||||
window.addEventListener('test', options, options);
|
||||
// @ts-ignore
|
||||
window.removeEventListener('test', options, options);
|
||||
}
|
||||
catch (err) {
|
||||
passiveSupported = false;
|
||||
}
|
||||
}
|
||||
export const nonPassive = passiveSupported ? { passive: false } : false;
|
||||
3
node_modules/react-remove-scroll/dist/es2019/handleScroll.d.ts
generated
vendored
Normal file
3
node_modules/react-remove-scroll/dist/es2019/handleScroll.d.ts
generated
vendored
Normal file
@ -0,0 +1,3 @@
|
||||
import { Axis } from './types';
|
||||
export declare const locationCouldBeScrolled: (axis: Axis, node: HTMLElement) => boolean;
|
||||
export declare const handleScroll: (axis: Axis, endTarget: HTMLElement, event: any, sourceDelta: number, noOverscroll: boolean) => boolean;
|
||||
95
node_modules/react-remove-scroll/dist/es2019/handleScroll.js
generated
vendored
Normal file
95
node_modules/react-remove-scroll/dist/es2019/handleScroll.js
generated
vendored
Normal file
@ -0,0 +1,95 @@
|
||||
const alwaysContainsScroll = (node) =>
|
||||
// textarea will always _contain_ scroll inside self. It only can be hidden
|
||||
node.tagName === 'TEXTAREA';
|
||||
const elementCanBeScrolled = (node, overflow) => {
|
||||
if (!(node instanceof Element)) {
|
||||
return false;
|
||||
}
|
||||
const styles = window.getComputedStyle(node);
|
||||
return (
|
||||
// not-not-scrollable
|
||||
styles[overflow] !== 'hidden' &&
|
||||
// contains scroll inside self
|
||||
!(styles.overflowY === styles.overflowX && !alwaysContainsScroll(node) && styles[overflow] === 'visible'));
|
||||
};
|
||||
const elementCouldBeVScrolled = (node) => elementCanBeScrolled(node, 'overflowY');
|
||||
const elementCouldBeHScrolled = (node) => elementCanBeScrolled(node, 'overflowX');
|
||||
export const locationCouldBeScrolled = (axis, node) => {
|
||||
const ownerDocument = node.ownerDocument;
|
||||
let current = node;
|
||||
do {
|
||||
// Skip over shadow root
|
||||
if (typeof ShadowRoot !== 'undefined' && current instanceof ShadowRoot) {
|
||||
current = current.host;
|
||||
}
|
||||
const isScrollable = elementCouldBeScrolled(axis, current);
|
||||
if (isScrollable) {
|
||||
const [, scrollHeight, clientHeight] = getScrollVariables(axis, current);
|
||||
if (scrollHeight > clientHeight) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
current = current.parentNode;
|
||||
} while (current && current !== ownerDocument.body);
|
||||
return false;
|
||||
};
|
||||
const getVScrollVariables = ({ scrollTop, scrollHeight, clientHeight }) => [
|
||||
scrollTop,
|
||||
scrollHeight,
|
||||
clientHeight,
|
||||
];
|
||||
const getHScrollVariables = ({ scrollLeft, scrollWidth, clientWidth }) => [
|
||||
scrollLeft,
|
||||
scrollWidth,
|
||||
clientWidth,
|
||||
];
|
||||
const elementCouldBeScrolled = (axis, node) => axis === 'v' ? elementCouldBeVScrolled(node) : elementCouldBeHScrolled(node);
|
||||
const getScrollVariables = (axis, node) => axis === 'v' ? getVScrollVariables(node) : getHScrollVariables(node);
|
||||
const getDirectionFactor = (axis, direction) =>
|
||||
/**
|
||||
* If the element's direction is rtl (right-to-left), then scrollLeft is 0 when the scrollbar is at its rightmost position,
|
||||
* and then increasingly negative as you scroll towards the end of the content.
|
||||
* @see https://developer.mozilla.org/en-US/docs/Web/API/Element/scrollLeft
|
||||
*/
|
||||
axis === 'h' && direction === 'rtl' ? -1 : 1;
|
||||
export const handleScroll = (axis, endTarget, event, sourceDelta, noOverscroll) => {
|
||||
const directionFactor = getDirectionFactor(axis, window.getComputedStyle(endTarget).direction);
|
||||
const delta = directionFactor * sourceDelta;
|
||||
// find scrollable target
|
||||
let target = event.target;
|
||||
const targetInLock = endTarget.contains(target);
|
||||
let shouldCancelScroll = false;
|
||||
const isDeltaPositive = delta > 0;
|
||||
let availableScroll = 0;
|
||||
let availableScrollTop = 0;
|
||||
do {
|
||||
const [position, scroll, capacity] = getScrollVariables(axis, target);
|
||||
const elementScroll = scroll - capacity - directionFactor * position;
|
||||
if (position || elementScroll) {
|
||||
if (elementCouldBeScrolled(axis, target)) {
|
||||
availableScroll += elementScroll;
|
||||
availableScrollTop += position;
|
||||
}
|
||||
}
|
||||
if (target instanceof ShadowRoot) {
|
||||
target = target.host;
|
||||
}
|
||||
else {
|
||||
target = target.parentNode;
|
||||
}
|
||||
} while (
|
||||
// portaled content
|
||||
(!targetInLock && target !== document.body) ||
|
||||
// self content
|
||||
(targetInLock && (endTarget.contains(target) || endTarget === target)));
|
||||
// handle epsilon around 0 (non standard zoom levels)
|
||||
if (isDeltaPositive &&
|
||||
((noOverscroll && Math.abs(availableScroll) < 1) || (!noOverscroll && delta > availableScroll))) {
|
||||
shouldCancelScroll = true;
|
||||
}
|
||||
else if (!isDeltaPositive &&
|
||||
((noOverscroll && Math.abs(availableScrollTop) < 1) || (!noOverscroll && -delta > availableScrollTop))) {
|
||||
shouldCancelScroll = true;
|
||||
}
|
||||
return shouldCancelScroll;
|
||||
};
|
||||
2
node_modules/react-remove-scroll/dist/es2019/index.d.ts
generated
vendored
Normal file
2
node_modules/react-remove-scroll/dist/es2019/index.d.ts
generated
vendored
Normal file
@ -0,0 +1,2 @@
|
||||
import RemoveScroll from './Combination';
|
||||
export { RemoveScroll };
|
||||
2
node_modules/react-remove-scroll/dist/es2019/index.js
generated
vendored
Normal file
2
node_modules/react-remove-scroll/dist/es2019/index.js
generated
vendored
Normal file
@ -0,0 +1,2 @@
|
||||
import RemoveScroll from './Combination';
|
||||
export { RemoveScroll };
|
||||
2
node_modules/react-remove-scroll/dist/es2019/medium.d.ts
generated
vendored
Normal file
2
node_modules/react-remove-scroll/dist/es2019/medium.d.ts
generated
vendored
Normal file
@ -0,0 +1,2 @@
|
||||
import { IRemoveScrollEffectProps } from './types';
|
||||
export declare const effectCar: Readonly<import("use-sidecar/dist/es5/types").SideCarMedium<IRemoveScrollEffectProps>>;
|
||||
2
node_modules/react-remove-scroll/dist/es2019/medium.js
generated
vendored
Normal file
2
node_modules/react-remove-scroll/dist/es2019/medium.js
generated
vendored
Normal file
@ -0,0 +1,2 @@
|
||||
import { createSidecarMedium } from 'use-sidecar';
|
||||
export const effectCar = createSidecarMedium();
|
||||
8
node_modules/react-remove-scroll/dist/es2019/pinchAndZoom.d.ts
generated
vendored
Normal file
8
node_modules/react-remove-scroll/dist/es2019/pinchAndZoom.d.ts
generated
vendored
Normal file
@ -0,0 +1,8 @@
|
||||
import { Touch } from 'react';
|
||||
export declare const pinchOrZoom: (event: TouchEvent, cache: Record<number, Touch>) => false | {
|
||||
action: string;
|
||||
coords?: undefined;
|
||||
} | {
|
||||
action: string;
|
||||
coords: number[];
|
||||
};
|
||||
33
node_modules/react-remove-scroll/dist/es2019/pinchAndZoom.js
generated
vendored
Normal file
33
node_modules/react-remove-scroll/dist/es2019/pinchAndZoom.js
generated
vendored
Normal file
@ -0,0 +1,33 @@
|
||||
const ds = (ab) => (ab[0] <= 0 && ab[1] >= 0) || (ab[0] >= 0 && ab[1] <= 0);
|
||||
const sign = (x) => (x < 0 ? -1 : 1);
|
||||
export const pinchOrZoom = (event, cache) => {
|
||||
if (!event.changedTouches) {
|
||||
return false;
|
||||
}
|
||||
if (event.touches.length === 2) {
|
||||
const oldPoints = [cache[event.touches[0].identifier], cache[event.touches[1].identifier]];
|
||||
const newPoints = [event.touches[0], event.touches[1]];
|
||||
if (oldPoints[0] && oldPoints[1]) {
|
||||
// Calculate the difference between the start and move coordinates
|
||||
const diffx = [oldPoints[0].clientX - newPoints[0].clientX, oldPoints[1].clientX - newPoints[1].clientX];
|
||||
const diffy = [oldPoints[0].clientY - newPoints[0].clientY, oldPoints[1].clientY - newPoints[1].clientY];
|
||||
console.log(diffx, diffy);
|
||||
if (ds(diffx) || ds(diffy)) {
|
||||
return {
|
||||
action: 'zoom',
|
||||
};
|
||||
}
|
||||
const mx = Math.max(Math.abs(diffx[0]), Math.abs(diffx[1]));
|
||||
const my = Math.max(Math.abs(diffy[0]), Math.abs(diffy[1]));
|
||||
return {
|
||||
action: 'pinch',
|
||||
coords: [mx * sign(diffx[0]), my * sign(diffx[1])],
|
||||
};
|
||||
}
|
||||
}
|
||||
Array.from(event.changedTouches).forEach((touch) => (cache[touch.identifier] = touch));
|
||||
return {
|
||||
action: 'move',
|
||||
coords: [event.changedTouches[0].clientX, event.changedTouches[0].clientY],
|
||||
};
|
||||
};
|
||||
2
node_modules/react-remove-scroll/dist/es2019/sidecar.d.ts
generated
vendored
Normal file
2
node_modules/react-remove-scroll/dist/es2019/sidecar.d.ts
generated
vendored
Normal file
@ -0,0 +1,2 @@
|
||||
declare const _default: import("use-sidecar").SideCarComponent<import("./types").IRemoveScrollEffectProps>;
|
||||
export default _default;
|
||||
4
node_modules/react-remove-scroll/dist/es2019/sidecar.js
generated
vendored
Normal file
4
node_modules/react-remove-scroll/dist/es2019/sidecar.js
generated
vendored
Normal file
@ -0,0 +1,4 @@
|
||||
import { exportSidecar } from 'use-sidecar';
|
||||
import { RemoveScrollSideCar } from './SideEffect';
|
||||
import { effectCar } from './medium';
|
||||
export default exportSidecar(effectCar, RemoveScrollSideCar);
|
||||
98
node_modules/react-remove-scroll/dist/es2019/types.d.ts
generated
vendored
Normal file
98
node_modules/react-remove-scroll/dist/es2019/types.d.ts
generated
vendored
Normal file
@ -0,0 +1,98 @@
|
||||
import * as React from 'react';
|
||||
import { Ref, RefObject } from 'react';
|
||||
import { ForwardRefExoticComponent } from 'react';
|
||||
import { RefAttributes } from 'react';
|
||||
export declare type Axis = 'v' | 'h';
|
||||
export declare type GapMode = 'padding' | 'margin';
|
||||
export interface RemoveScrollEffectCallbacks {
|
||||
onScrollCapture(event: any): void;
|
||||
onWheelCapture(event: any): void;
|
||||
onTouchMoveCapture(event: any): void;
|
||||
}
|
||||
export interface ChildrenNode {
|
||||
/**
|
||||
* if forwardProps is false - children should be ReactNode
|
||||
* and it would be wrapper with a div
|
||||
* @see {@link IRemoveScrollSelfProps.as}
|
||||
*/
|
||||
forwardProps?: false;
|
||||
children: React.ReactNode;
|
||||
}
|
||||
export interface ChildrenForward {
|
||||
/**
|
||||
* if forwardProps is true - everything will be forwarded to a single child node
|
||||
* otherwise - a Container, controlled by `as` prop will be rendered in place
|
||||
* @default false
|
||||
* @see {@link IRemoveScrollSelfProps.as}
|
||||
*/
|
||||
forwardProps: true;
|
||||
children: React.ReactElement;
|
||||
}
|
||||
export interface IRemoveScrollSelfProps {
|
||||
ref?: Ref<HTMLElement>;
|
||||
/**
|
||||
* disables "event isolation" (suppressing of events happening outside of the Lock)
|
||||
* @default false
|
||||
*/
|
||||
noIsolation?: boolean;
|
||||
/**
|
||||
* enabled complete Lock isolation using `pointer-events:none` for anything outside the Lock
|
||||
* you probably don't need it, except you do
|
||||
* @default false
|
||||
* @see {IRemoveScrollSelfProps.noIsolation}
|
||||
*/
|
||||
inert?: boolean;
|
||||
/**
|
||||
* allows pinch-zoom, however might work not perfectly for normal scroll
|
||||
*/
|
||||
allowPinchZoom?: boolean;
|
||||
/**
|
||||
* switches on/off the behavior of the component
|
||||
*/
|
||||
enabled?: boolean;
|
||||
/**
|
||||
* Controls the body scroll bar removal
|
||||
* @default false
|
||||
*/
|
||||
removeScrollBar?: boolean;
|
||||
className?: string;
|
||||
style?: React.CSSProperties;
|
||||
/**
|
||||
* array of refs to other Elements, which should be considered as a part of the Lock
|
||||
*/
|
||||
shards?: Array<React.RefObject<any> | HTMLElement>;
|
||||
/**
|
||||
* Control host node used for the lock.
|
||||
* @default 'div'
|
||||
*/
|
||||
as?: string | React.ElementType;
|
||||
/**
|
||||
* controls the way "gap" is filled
|
||||
* @default "margin"
|
||||
*/
|
||||
gapMode?: GapMode;
|
||||
}
|
||||
export declare type IRemoveScrollProps = IRemoveScrollSelfProps & (ChildrenForward | ChildrenNode);
|
||||
export declare type IRemoveScrollUIProps = IRemoveScrollProps & {
|
||||
sideCar: React.FC<any>;
|
||||
};
|
||||
export interface IRemoveScrollEffectProps {
|
||||
noIsolation?: boolean;
|
||||
removeScrollBar?: boolean;
|
||||
allowPinchZoom: boolean;
|
||||
inert?: boolean;
|
||||
shards?: Array<React.RefObject<any> | HTMLElement>;
|
||||
lockRef: RefObject<HTMLElement>;
|
||||
gapMode?: GapMode;
|
||||
setCallbacks(cb: RemoveScrollEffectCallbacks): void;
|
||||
}
|
||||
interface WithClassNames {
|
||||
classNames: {
|
||||
fullWidth: string;
|
||||
zeroRight: string;
|
||||
};
|
||||
}
|
||||
declare type RefForwarded<T> = ForwardRefExoticComponent<T & RefAttributes<HTMLElement>> & WithClassNames;
|
||||
export declare type RemoveScrollType = RefForwarded<IRemoveScrollProps>;
|
||||
export declare type RemoveScrollUIType = RefForwarded<IRemoveScrollUIProps>;
|
||||
export {};
|
||||
1
node_modules/react-remove-scroll/dist/es2019/types.js
generated
vendored
Normal file
1
node_modules/react-remove-scroll/dist/es2019/types.js
generated
vendored
Normal file
@ -0,0 +1 @@
|
||||
export {};
|
||||
3
node_modules/react-remove-scroll/dist/es5/Combination.d.ts
generated
vendored
Normal file
3
node_modules/react-remove-scroll/dist/es5/Combination.d.ts
generated
vendored
Normal file
@ -0,0 +1,3 @@
|
||||
import { RemoveScrollType } from './types';
|
||||
declare const ReactRemoveScroll: RemoveScrollType;
|
||||
export default ReactRemoveScroll;
|
||||
9
node_modules/react-remove-scroll/dist/es5/Combination.js
generated
vendored
Normal file
9
node_modules/react-remove-scroll/dist/es5/Combination.js
generated
vendored
Normal file
@ -0,0 +1,9 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
var tslib_1 = require("tslib");
|
||||
var React = tslib_1.__importStar(require("react"));
|
||||
var UI_1 = require("./UI");
|
||||
var sidecar_1 = tslib_1.__importDefault(require("./sidecar"));
|
||||
var ReactRemoveScroll = React.forwardRef(function (props, ref) { return (React.createElement(UI_1.RemoveScroll, tslib_1.__assign({}, props, { ref: ref, sideCar: sidecar_1.default }))); });
|
||||
ReactRemoveScroll.classNames = UI_1.RemoveScroll.classNames;
|
||||
exports.default = ReactRemoveScroll;
|
||||
5
node_modules/react-remove-scroll/dist/es5/SideEffect.d.ts
generated
vendored
Normal file
5
node_modules/react-remove-scroll/dist/es5/SideEffect.d.ts
generated
vendored
Normal file
@ -0,0 +1,5 @@
|
||||
import { TouchEvent } from 'react';
|
||||
import { IRemoveScrollEffectProps } from './types';
|
||||
export declare const getTouchXY: (event: TouchEvent | WheelEvent) => number[];
|
||||
export declare const getDeltaXY: (event: WheelEvent) => number[];
|
||||
export declare function RemoveScrollSideCar(props: IRemoveScrollEffectProps): JSX.Element;
|
||||
163
node_modules/react-remove-scroll/dist/es5/SideEffect.js
generated
vendored
Normal file
163
node_modules/react-remove-scroll/dist/es5/SideEffect.js
generated
vendored
Normal file
@ -0,0 +1,163 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.RemoveScrollSideCar = exports.getDeltaXY = exports.getTouchXY = void 0;
|
||||
var tslib_1 = require("tslib");
|
||||
var React = tslib_1.__importStar(require("react"));
|
||||
var react_remove_scroll_bar_1 = require("react-remove-scroll-bar");
|
||||
var react_style_singleton_1 = require("react-style-singleton");
|
||||
var aggresiveCapture_1 = require("./aggresiveCapture");
|
||||
var handleScroll_1 = require("./handleScroll");
|
||||
var getTouchXY = function (event) {
|
||||
return 'changedTouches' in event ? [event.changedTouches[0].clientX, event.changedTouches[0].clientY] : [0, 0];
|
||||
};
|
||||
exports.getTouchXY = getTouchXY;
|
||||
var getDeltaXY = function (event) { return [event.deltaX, event.deltaY]; };
|
||||
exports.getDeltaXY = getDeltaXY;
|
||||
var extractRef = function (ref) {
|
||||
return ref && 'current' in ref ? ref.current : ref;
|
||||
};
|
||||
var deltaCompare = function (x, y) { return x[0] === y[0] && x[1] === y[1]; };
|
||||
var generateStyle = function (id) { return "\n .block-interactivity-".concat(id, " {pointer-events: none;}\n .allow-interactivity-").concat(id, " {pointer-events: all;}\n"); };
|
||||
var idCounter = 0;
|
||||
var lockStack = [];
|
||||
function RemoveScrollSideCar(props) {
|
||||
var shouldPreventQueue = React.useRef([]);
|
||||
var touchStartRef = React.useRef([0, 0]);
|
||||
var activeAxis = React.useRef();
|
||||
var id = React.useState(idCounter++)[0];
|
||||
var Style = React.useState(react_style_singleton_1.styleSingleton)[0];
|
||||
var lastProps = React.useRef(props);
|
||||
React.useEffect(function () {
|
||||
lastProps.current = props;
|
||||
}, [props]);
|
||||
React.useEffect(function () {
|
||||
if (props.inert) {
|
||||
document.body.classList.add("block-interactivity-".concat(id));
|
||||
var allow_1 = tslib_1.__spreadArray([props.lockRef.current], (props.shards || []).map(extractRef), true).filter(Boolean);
|
||||
allow_1.forEach(function (el) { return el.classList.add("allow-interactivity-".concat(id)); });
|
||||
return function () {
|
||||
document.body.classList.remove("block-interactivity-".concat(id));
|
||||
allow_1.forEach(function (el) { return el.classList.remove("allow-interactivity-".concat(id)); });
|
||||
};
|
||||
}
|
||||
return;
|
||||
}, [props.inert, props.lockRef.current, props.shards]);
|
||||
var shouldCancelEvent = React.useCallback(function (event, parent) {
|
||||
if (('touches' in event && event.touches.length === 2) || (event.type === 'wheel' && event.ctrlKey)) {
|
||||
return !lastProps.current.allowPinchZoom;
|
||||
}
|
||||
var touch = (0, exports.getTouchXY)(event);
|
||||
var touchStart = touchStartRef.current;
|
||||
var deltaX = 'deltaX' in event ? event.deltaX : touchStart[0] - touch[0];
|
||||
var deltaY = 'deltaY' in event ? event.deltaY : touchStart[1] - touch[1];
|
||||
var currentAxis;
|
||||
var target = event.target;
|
||||
var moveDirection = Math.abs(deltaX) > Math.abs(deltaY) ? 'h' : 'v';
|
||||
// allow horizontal touch move on Range inputs. They will not cause any scroll
|
||||
if ('touches' in event && moveDirection === 'h' && target.type === 'range') {
|
||||
return false;
|
||||
}
|
||||
var canBeScrolledInMainDirection = (0, handleScroll_1.locationCouldBeScrolled)(moveDirection, target);
|
||||
if (!canBeScrolledInMainDirection) {
|
||||
return true;
|
||||
}
|
||||
if (canBeScrolledInMainDirection) {
|
||||
currentAxis = moveDirection;
|
||||
}
|
||||
else {
|
||||
currentAxis = moveDirection === 'v' ? 'h' : 'v';
|
||||
canBeScrolledInMainDirection = (0, handleScroll_1.locationCouldBeScrolled)(moveDirection, target);
|
||||
// other axis might be not scrollable
|
||||
}
|
||||
if (!canBeScrolledInMainDirection) {
|
||||
return false;
|
||||
}
|
||||
if (!activeAxis.current && 'changedTouches' in event && (deltaX || deltaY)) {
|
||||
activeAxis.current = currentAxis;
|
||||
}
|
||||
if (!currentAxis) {
|
||||
return true;
|
||||
}
|
||||
var cancelingAxis = activeAxis.current || currentAxis;
|
||||
return (0, handleScroll_1.handleScroll)(cancelingAxis, parent, event, cancelingAxis === 'h' ? deltaX : deltaY, true);
|
||||
}, []);
|
||||
var shouldPrevent = React.useCallback(function (_event) {
|
||||
var event = _event;
|
||||
if (!lockStack.length || lockStack[lockStack.length - 1] !== Style) {
|
||||
// not the last active
|
||||
return;
|
||||
}
|
||||
var delta = 'deltaY' in event ? (0, exports.getDeltaXY)(event) : (0, exports.getTouchXY)(event);
|
||||
var sourceEvent = shouldPreventQueue.current.filter(function (e) { return e.name === event.type && (e.target === event.target || event.target === e.shadowParent) && deltaCompare(e.delta, delta); })[0];
|
||||
// self event, and should be canceled
|
||||
if (sourceEvent && sourceEvent.should) {
|
||||
if (event.cancelable) {
|
||||
event.preventDefault();
|
||||
}
|
||||
return;
|
||||
}
|
||||
// outside or shard event
|
||||
if (!sourceEvent) {
|
||||
var shardNodes = (lastProps.current.shards || [])
|
||||
.map(extractRef)
|
||||
.filter(Boolean)
|
||||
.filter(function (node) { return node.contains(event.target); });
|
||||
var shouldStop = shardNodes.length > 0 ? shouldCancelEvent(event, shardNodes[0]) : !lastProps.current.noIsolation;
|
||||
if (shouldStop) {
|
||||
if (event.cancelable) {
|
||||
event.preventDefault();
|
||||
}
|
||||
}
|
||||
}
|
||||
}, []);
|
||||
var shouldCancel = React.useCallback(function (name, delta, target, should) {
|
||||
var event = { name: name, delta: delta, target: target, should: should, shadowParent: getOutermostShadowParent(target) };
|
||||
shouldPreventQueue.current.push(event);
|
||||
setTimeout(function () {
|
||||
shouldPreventQueue.current = shouldPreventQueue.current.filter(function (e) { return e !== event; });
|
||||
}, 1);
|
||||
}, []);
|
||||
var scrollTouchStart = React.useCallback(function (event) {
|
||||
touchStartRef.current = (0, exports.getTouchXY)(event);
|
||||
activeAxis.current = undefined;
|
||||
}, []);
|
||||
var scrollWheel = React.useCallback(function (event) {
|
||||
shouldCancel(event.type, (0, exports.getDeltaXY)(event), event.target, shouldCancelEvent(event, props.lockRef.current));
|
||||
}, []);
|
||||
var scrollTouchMove = React.useCallback(function (event) {
|
||||
shouldCancel(event.type, (0, exports.getTouchXY)(event), event.target, shouldCancelEvent(event, props.lockRef.current));
|
||||
}, []);
|
||||
React.useEffect(function () {
|
||||
lockStack.push(Style);
|
||||
props.setCallbacks({
|
||||
onScrollCapture: scrollWheel,
|
||||
onWheelCapture: scrollWheel,
|
||||
onTouchMoveCapture: scrollTouchMove,
|
||||
});
|
||||
document.addEventListener('wheel', shouldPrevent, aggresiveCapture_1.nonPassive);
|
||||
document.addEventListener('touchmove', shouldPrevent, aggresiveCapture_1.nonPassive);
|
||||
document.addEventListener('touchstart', scrollTouchStart, aggresiveCapture_1.nonPassive);
|
||||
return function () {
|
||||
lockStack = lockStack.filter(function (inst) { return inst !== Style; });
|
||||
document.removeEventListener('wheel', shouldPrevent, aggresiveCapture_1.nonPassive);
|
||||
document.removeEventListener('touchmove', shouldPrevent, aggresiveCapture_1.nonPassive);
|
||||
document.removeEventListener('touchstart', scrollTouchStart, aggresiveCapture_1.nonPassive);
|
||||
};
|
||||
}, []);
|
||||
var removeScrollBar = props.removeScrollBar, inert = props.inert;
|
||||
return (React.createElement(React.Fragment, null,
|
||||
inert ? React.createElement(Style, { styles: generateStyle(id) }) : null,
|
||||
removeScrollBar ? React.createElement(react_remove_scroll_bar_1.RemoveScrollBar, { gapMode: props.gapMode }) : null));
|
||||
}
|
||||
exports.RemoveScrollSideCar = RemoveScrollSideCar;
|
||||
function getOutermostShadowParent(node) {
|
||||
var shadowParent = null;
|
||||
while (node !== null) {
|
||||
if (node instanceof ShadowRoot) {
|
||||
shadowParent = node.host;
|
||||
node = node.host;
|
||||
}
|
||||
node = node.parentNode;
|
||||
}
|
||||
return shadowParent;
|
||||
}
|
||||
7
node_modules/react-remove-scroll/dist/es5/UI.d.ts
generated
vendored
Normal file
7
node_modules/react-remove-scroll/dist/es5/UI.d.ts
generated
vendored
Normal file
@ -0,0 +1,7 @@
|
||||
import { RemoveScrollUIType, IRemoveScrollSelfProps } from './types';
|
||||
export type { IRemoveScrollSelfProps, RemoveScrollUIType };
|
||||
/**
|
||||
* Removes scrollbar from the page and contain the scroll within the Lock
|
||||
*/
|
||||
declare const RemoveScroll: RemoveScrollUIType;
|
||||
export { RemoveScroll };
|
||||
39
node_modules/react-remove-scroll/dist/es5/UI.js
generated
vendored
Normal file
39
node_modules/react-remove-scroll/dist/es5/UI.js
generated
vendored
Normal file
@ -0,0 +1,39 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.RemoveScroll = void 0;
|
||||
var tslib_1 = require("tslib");
|
||||
var React = tslib_1.__importStar(require("react"));
|
||||
var constants_1 = require("react-remove-scroll-bar/constants");
|
||||
var use_callback_ref_1 = require("use-callback-ref");
|
||||
var medium_1 = require("./medium");
|
||||
var nothing = function () {
|
||||
return;
|
||||
};
|
||||
/**
|
||||
* Removes scrollbar from the page and contain the scroll within the Lock
|
||||
*/
|
||||
var RemoveScroll = React.forwardRef(function (props, parentRef) {
|
||||
var ref = React.useRef(null);
|
||||
var _a = React.useState({
|
||||
onScrollCapture: nothing,
|
||||
onWheelCapture: nothing,
|
||||
onTouchMoveCapture: nothing,
|
||||
}), callbacks = _a[0], setCallbacks = _a[1];
|
||||
var forwardProps = props.forwardProps, children = props.children, className = props.className, removeScrollBar = props.removeScrollBar, enabled = props.enabled, shards = props.shards, sideCar = props.sideCar, noIsolation = props.noIsolation, inert = props.inert, allowPinchZoom = props.allowPinchZoom, _b = props.as, Container = _b === void 0 ? 'div' : _b, gapMode = props.gapMode, rest = tslib_1.__rest(props, ["forwardProps", "children", "className", "removeScrollBar", "enabled", "shards", "sideCar", "noIsolation", "inert", "allowPinchZoom", "as", "gapMode"]);
|
||||
var SideCar = sideCar;
|
||||
var containerRef = (0, use_callback_ref_1.useMergeRefs)([ref, parentRef]);
|
||||
var containerProps = tslib_1.__assign(tslib_1.__assign({}, rest), callbacks);
|
||||
return (React.createElement(React.Fragment, null,
|
||||
enabled && (React.createElement(SideCar, { sideCar: medium_1.effectCar, removeScrollBar: removeScrollBar, shards: shards, noIsolation: noIsolation, inert: inert, setCallbacks: setCallbacks, allowPinchZoom: !!allowPinchZoom, lockRef: ref, gapMode: gapMode })),
|
||||
forwardProps ? (React.cloneElement(React.Children.only(children), tslib_1.__assign(tslib_1.__assign({}, containerProps), { ref: containerRef }))) : (React.createElement(Container, tslib_1.__assign({}, containerProps, { className: className, ref: containerRef }), children))));
|
||||
});
|
||||
exports.RemoveScroll = RemoveScroll;
|
||||
RemoveScroll.defaultProps = {
|
||||
enabled: true,
|
||||
removeScrollBar: true,
|
||||
inert: false,
|
||||
};
|
||||
RemoveScroll.classNames = {
|
||||
fullWidth: constants_1.fullWidthClassName,
|
||||
zeroRight: constants_1.zeroRightClassName,
|
||||
};
|
||||
3
node_modules/react-remove-scroll/dist/es5/aggresiveCapture.d.ts
generated
vendored
Normal file
3
node_modules/react-remove-scroll/dist/es5/aggresiveCapture.d.ts
generated
vendored
Normal file
@ -0,0 +1,3 @@
|
||||
export declare const nonPassive: boolean | {
|
||||
passive: boolean;
|
||||
};
|
||||
22
node_modules/react-remove-scroll/dist/es5/aggresiveCapture.js
generated
vendored
Normal file
22
node_modules/react-remove-scroll/dist/es5/aggresiveCapture.js
generated
vendored
Normal file
@ -0,0 +1,22 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.nonPassive = void 0;
|
||||
var passiveSupported = false;
|
||||
if (typeof window !== 'undefined') {
|
||||
try {
|
||||
var options = Object.defineProperty({}, 'passive', {
|
||||
get: function () {
|
||||
passiveSupported = true;
|
||||
return true;
|
||||
},
|
||||
});
|
||||
// @ts-ignore
|
||||
window.addEventListener('test', options, options);
|
||||
// @ts-ignore
|
||||
window.removeEventListener('test', options, options);
|
||||
}
|
||||
catch (err) {
|
||||
passiveSupported = false;
|
||||
}
|
||||
}
|
||||
exports.nonPassive = passiveSupported ? { passive: false } : false;
|
||||
3
node_modules/react-remove-scroll/dist/es5/handleScroll.d.ts
generated
vendored
Normal file
3
node_modules/react-remove-scroll/dist/es5/handleScroll.d.ts
generated
vendored
Normal file
@ -0,0 +1,3 @@
|
||||
import { Axis } from './types';
|
||||
export declare const locationCouldBeScrolled: (axis: Axis, node: HTMLElement) => boolean;
|
||||
export declare const handleScroll: (axis: Axis, endTarget: HTMLElement, event: any, sourceDelta: number, noOverscroll: boolean) => boolean;
|
||||
112
node_modules/react-remove-scroll/dist/es5/handleScroll.js
generated
vendored
Normal file
112
node_modules/react-remove-scroll/dist/es5/handleScroll.js
generated
vendored
Normal file
@ -0,0 +1,112 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.handleScroll = exports.locationCouldBeScrolled = void 0;
|
||||
var alwaysContainsScroll = function (node) {
|
||||
// textarea will always _contain_ scroll inside self. It only can be hidden
|
||||
return node.tagName === 'TEXTAREA';
|
||||
};
|
||||
var elementCanBeScrolled = function (node, overflow) {
|
||||
if (!(node instanceof Element)) {
|
||||
return false;
|
||||
}
|
||||
var styles = window.getComputedStyle(node);
|
||||
return (
|
||||
// not-not-scrollable
|
||||
styles[overflow] !== 'hidden' &&
|
||||
// contains scroll inside self
|
||||
!(styles.overflowY === styles.overflowX && !alwaysContainsScroll(node) && styles[overflow] === 'visible'));
|
||||
};
|
||||
var elementCouldBeVScrolled = function (node) { return elementCanBeScrolled(node, 'overflowY'); };
|
||||
var elementCouldBeHScrolled = function (node) { return elementCanBeScrolled(node, 'overflowX'); };
|
||||
var locationCouldBeScrolled = function (axis, node) {
|
||||
var ownerDocument = node.ownerDocument;
|
||||
var current = node;
|
||||
do {
|
||||
// Skip over shadow root
|
||||
if (typeof ShadowRoot !== 'undefined' && current instanceof ShadowRoot) {
|
||||
current = current.host;
|
||||
}
|
||||
var isScrollable = elementCouldBeScrolled(axis, current);
|
||||
if (isScrollable) {
|
||||
var _a = getScrollVariables(axis, current), scrollHeight = _a[1], clientHeight = _a[2];
|
||||
if (scrollHeight > clientHeight) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
current = current.parentNode;
|
||||
} while (current && current !== ownerDocument.body);
|
||||
return false;
|
||||
};
|
||||
exports.locationCouldBeScrolled = locationCouldBeScrolled;
|
||||
var getVScrollVariables = function (_a) {
|
||||
var scrollTop = _a.scrollTop, scrollHeight = _a.scrollHeight, clientHeight = _a.clientHeight;
|
||||
return [
|
||||
scrollTop,
|
||||
scrollHeight,
|
||||
clientHeight,
|
||||
];
|
||||
};
|
||||
var getHScrollVariables = function (_a) {
|
||||
var scrollLeft = _a.scrollLeft, scrollWidth = _a.scrollWidth, clientWidth = _a.clientWidth;
|
||||
return [
|
||||
scrollLeft,
|
||||
scrollWidth,
|
||||
clientWidth,
|
||||
];
|
||||
};
|
||||
var elementCouldBeScrolled = function (axis, node) {
|
||||
return axis === 'v' ? elementCouldBeVScrolled(node) : elementCouldBeHScrolled(node);
|
||||
};
|
||||
var getScrollVariables = function (axis, node) {
|
||||
return axis === 'v' ? getVScrollVariables(node) : getHScrollVariables(node);
|
||||
};
|
||||
var getDirectionFactor = function (axis, direction) {
|
||||
/**
|
||||
* If the element's direction is rtl (right-to-left), then scrollLeft is 0 when the scrollbar is at its rightmost position,
|
||||
* and then increasingly negative as you scroll towards the end of the content.
|
||||
* @see https://developer.mozilla.org/en-US/docs/Web/API/Element/scrollLeft
|
||||
*/
|
||||
return axis === 'h' && direction === 'rtl' ? -1 : 1;
|
||||
};
|
||||
var handleScroll = function (axis, endTarget, event, sourceDelta, noOverscroll) {
|
||||
var directionFactor = getDirectionFactor(axis, window.getComputedStyle(endTarget).direction);
|
||||
var delta = directionFactor * sourceDelta;
|
||||
// find scrollable target
|
||||
var target = event.target;
|
||||
var targetInLock = endTarget.contains(target);
|
||||
var shouldCancelScroll = false;
|
||||
var isDeltaPositive = delta > 0;
|
||||
var availableScroll = 0;
|
||||
var availableScrollTop = 0;
|
||||
do {
|
||||
var _a = getScrollVariables(axis, target), position = _a[0], scroll_1 = _a[1], capacity = _a[2];
|
||||
var elementScroll = scroll_1 - capacity - directionFactor * position;
|
||||
if (position || elementScroll) {
|
||||
if (elementCouldBeScrolled(axis, target)) {
|
||||
availableScroll += elementScroll;
|
||||
availableScrollTop += position;
|
||||
}
|
||||
}
|
||||
if (target instanceof ShadowRoot) {
|
||||
target = target.host;
|
||||
}
|
||||
else {
|
||||
target = target.parentNode;
|
||||
}
|
||||
} while (
|
||||
// portaled content
|
||||
(!targetInLock && target !== document.body) ||
|
||||
// self content
|
||||
(targetInLock && (endTarget.contains(target) || endTarget === target)));
|
||||
// handle epsilon around 0 (non standard zoom levels)
|
||||
if (isDeltaPositive &&
|
||||
((noOverscroll && Math.abs(availableScroll) < 1) || (!noOverscroll && delta > availableScroll))) {
|
||||
shouldCancelScroll = true;
|
||||
}
|
||||
else if (!isDeltaPositive &&
|
||||
((noOverscroll && Math.abs(availableScrollTop) < 1) || (!noOverscroll && -delta > availableScrollTop))) {
|
||||
shouldCancelScroll = true;
|
||||
}
|
||||
return shouldCancelScroll;
|
||||
};
|
||||
exports.handleScroll = handleScroll;
|
||||
2
node_modules/react-remove-scroll/dist/es5/index.d.ts
generated
vendored
Normal file
2
node_modules/react-remove-scroll/dist/es5/index.d.ts
generated
vendored
Normal file
@ -0,0 +1,2 @@
|
||||
import RemoveScroll from './Combination';
|
||||
export { RemoveScroll };
|
||||
6
node_modules/react-remove-scroll/dist/es5/index.js
generated
vendored
Normal file
6
node_modules/react-remove-scroll/dist/es5/index.js
generated
vendored
Normal file
@ -0,0 +1,6 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.RemoveScroll = void 0;
|
||||
var tslib_1 = require("tslib");
|
||||
var Combination_1 = tslib_1.__importDefault(require("./Combination"));
|
||||
exports.RemoveScroll = Combination_1.default;
|
||||
2
node_modules/react-remove-scroll/dist/es5/medium.d.ts
generated
vendored
Normal file
2
node_modules/react-remove-scroll/dist/es5/medium.d.ts
generated
vendored
Normal file
@ -0,0 +1,2 @@
|
||||
import { IRemoveScrollEffectProps } from './types';
|
||||
export declare const effectCar: Readonly<import("use-sidecar/dist/es5/types").SideCarMedium<IRemoveScrollEffectProps>>;
|
||||
5
node_modules/react-remove-scroll/dist/es5/medium.js
generated
vendored
Normal file
5
node_modules/react-remove-scroll/dist/es5/medium.js
generated
vendored
Normal file
@ -0,0 +1,5 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.effectCar = void 0;
|
||||
var use_sidecar_1 = require("use-sidecar");
|
||||
exports.effectCar = (0, use_sidecar_1.createSidecarMedium)();
|
||||
8
node_modules/react-remove-scroll/dist/es5/pinchAndZoom.d.ts
generated
vendored
Normal file
8
node_modules/react-remove-scroll/dist/es5/pinchAndZoom.d.ts
generated
vendored
Normal file
@ -0,0 +1,8 @@
|
||||
import { Touch } from 'react';
|
||||
export declare const pinchOrZoom: (event: TouchEvent, cache: Record<number, Touch>) => false | {
|
||||
action: string;
|
||||
coords?: undefined;
|
||||
} | {
|
||||
action: string;
|
||||
coords: number[];
|
||||
};
|
||||
37
node_modules/react-remove-scroll/dist/es5/pinchAndZoom.js
generated
vendored
Normal file
37
node_modules/react-remove-scroll/dist/es5/pinchAndZoom.js
generated
vendored
Normal file
@ -0,0 +1,37 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.pinchOrZoom = void 0;
|
||||
var ds = function (ab) { return (ab[0] <= 0 && ab[1] >= 0) || (ab[0] >= 0 && ab[1] <= 0); };
|
||||
var sign = function (x) { return (x < 0 ? -1 : 1); };
|
||||
var pinchOrZoom = function (event, cache) {
|
||||
if (!event.changedTouches) {
|
||||
return false;
|
||||
}
|
||||
if (event.touches.length === 2) {
|
||||
var oldPoints = [cache[event.touches[0].identifier], cache[event.touches[1].identifier]];
|
||||
var newPoints = [event.touches[0], event.touches[1]];
|
||||
if (oldPoints[0] && oldPoints[1]) {
|
||||
// Calculate the difference between the start and move coordinates
|
||||
var diffx = [oldPoints[0].clientX - newPoints[0].clientX, oldPoints[1].clientX - newPoints[1].clientX];
|
||||
var diffy = [oldPoints[0].clientY - newPoints[0].clientY, oldPoints[1].clientY - newPoints[1].clientY];
|
||||
console.log(diffx, diffy);
|
||||
if (ds(diffx) || ds(diffy)) {
|
||||
return {
|
||||
action: 'zoom',
|
||||
};
|
||||
}
|
||||
var mx = Math.max(Math.abs(diffx[0]), Math.abs(diffx[1]));
|
||||
var my = Math.max(Math.abs(diffy[0]), Math.abs(diffy[1]));
|
||||
return {
|
||||
action: 'pinch',
|
||||
coords: [mx * sign(diffx[0]), my * sign(diffx[1])],
|
||||
};
|
||||
}
|
||||
}
|
||||
Array.from(event.changedTouches).forEach(function (touch) { return (cache[touch.identifier] = touch); });
|
||||
return {
|
||||
action: 'move',
|
||||
coords: [event.changedTouches[0].clientX, event.changedTouches[0].clientY],
|
||||
};
|
||||
};
|
||||
exports.pinchOrZoom = pinchOrZoom;
|
||||
2
node_modules/react-remove-scroll/dist/es5/sidecar.d.ts
generated
vendored
Normal file
2
node_modules/react-remove-scroll/dist/es5/sidecar.d.ts
generated
vendored
Normal file
@ -0,0 +1,2 @@
|
||||
declare const _default: import("use-sidecar").SideCarComponent<import("./types").IRemoveScrollEffectProps>;
|
||||
export default _default;
|
||||
6
node_modules/react-remove-scroll/dist/es5/sidecar.js
generated
vendored
Normal file
6
node_modules/react-remove-scroll/dist/es5/sidecar.js
generated
vendored
Normal file
@ -0,0 +1,6 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
var use_sidecar_1 = require("use-sidecar");
|
||||
var SideEffect_1 = require("./SideEffect");
|
||||
var medium_1 = require("./medium");
|
||||
exports.default = (0, use_sidecar_1.exportSidecar)(medium_1.effectCar, SideEffect_1.RemoveScrollSideCar);
|
||||
98
node_modules/react-remove-scroll/dist/es5/types.d.ts
generated
vendored
Normal file
98
node_modules/react-remove-scroll/dist/es5/types.d.ts
generated
vendored
Normal file
@ -0,0 +1,98 @@
|
||||
import * as React from 'react';
|
||||
import { Ref, RefObject } from 'react';
|
||||
import { ForwardRefExoticComponent } from 'react';
|
||||
import { RefAttributes } from 'react';
|
||||
export declare type Axis = 'v' | 'h';
|
||||
export declare type GapMode = 'padding' | 'margin';
|
||||
export interface RemoveScrollEffectCallbacks {
|
||||
onScrollCapture(event: any): void;
|
||||
onWheelCapture(event: any): void;
|
||||
onTouchMoveCapture(event: any): void;
|
||||
}
|
||||
export interface ChildrenNode {
|
||||
/**
|
||||
* if forwardProps is false - children should be ReactNode
|
||||
* and it would be wrapper with a div
|
||||
* @see {@link IRemoveScrollSelfProps.as}
|
||||
*/
|
||||
forwardProps?: false;
|
||||
children: React.ReactNode;
|
||||
}
|
||||
export interface ChildrenForward {
|
||||
/**
|
||||
* if forwardProps is true - everything will be forwarded to a single child node
|
||||
* otherwise - a Container, controlled by `as` prop will be rendered in place
|
||||
* @default false
|
||||
* @see {@link IRemoveScrollSelfProps.as}
|
||||
*/
|
||||
forwardProps: true;
|
||||
children: React.ReactElement;
|
||||
}
|
||||
export interface IRemoveScrollSelfProps {
|
||||
ref?: Ref<HTMLElement>;
|
||||
/**
|
||||
* disables "event isolation" (suppressing of events happening outside of the Lock)
|
||||
* @default false
|
||||
*/
|
||||
noIsolation?: boolean;
|
||||
/**
|
||||
* enabled complete Lock isolation using `pointer-events:none` for anything outside the Lock
|
||||
* you probably don't need it, except you do
|
||||
* @default false
|
||||
* @see {IRemoveScrollSelfProps.noIsolation}
|
||||
*/
|
||||
inert?: boolean;
|
||||
/**
|
||||
* allows pinch-zoom, however might work not perfectly for normal scroll
|
||||
*/
|
||||
allowPinchZoom?: boolean;
|
||||
/**
|
||||
* switches on/off the behavior of the component
|
||||
*/
|
||||
enabled?: boolean;
|
||||
/**
|
||||
* Controls the body scroll bar removal
|
||||
* @default false
|
||||
*/
|
||||
removeScrollBar?: boolean;
|
||||
className?: string;
|
||||
style?: React.CSSProperties;
|
||||
/**
|
||||
* array of refs to other Elements, which should be considered as a part of the Lock
|
||||
*/
|
||||
shards?: Array<React.RefObject<any> | HTMLElement>;
|
||||
/**
|
||||
* Control host node used for the lock.
|
||||
* @default 'div'
|
||||
*/
|
||||
as?: string | React.ElementType;
|
||||
/**
|
||||
* controls the way "gap" is filled
|
||||
* @default "margin"
|
||||
*/
|
||||
gapMode?: GapMode;
|
||||
}
|
||||
export declare type IRemoveScrollProps = IRemoveScrollSelfProps & (ChildrenForward | ChildrenNode);
|
||||
export declare type IRemoveScrollUIProps = IRemoveScrollProps & {
|
||||
sideCar: React.FC<any>;
|
||||
};
|
||||
export interface IRemoveScrollEffectProps {
|
||||
noIsolation?: boolean;
|
||||
removeScrollBar?: boolean;
|
||||
allowPinchZoom: boolean;
|
||||
inert?: boolean;
|
||||
shards?: Array<React.RefObject<any> | HTMLElement>;
|
||||
lockRef: RefObject<HTMLElement>;
|
||||
gapMode?: GapMode;
|
||||
setCallbacks(cb: RemoveScrollEffectCallbacks): void;
|
||||
}
|
||||
interface WithClassNames {
|
||||
classNames: {
|
||||
fullWidth: string;
|
||||
zeroRight: string;
|
||||
};
|
||||
}
|
||||
declare type RefForwarded<T> = ForwardRefExoticComponent<T & RefAttributes<HTMLElement>> & WithClassNames;
|
||||
export declare type RemoveScrollType = RefForwarded<IRemoveScrollProps>;
|
||||
export declare type RemoveScrollUIType = RefForwarded<IRemoveScrollUIProps>;
|
||||
export {};
|
||||
2
node_modules/react-remove-scroll/dist/es5/types.js
generated
vendored
Normal file
2
node_modules/react-remove-scroll/dist/es5/types.js
generated
vendored
Normal file
@ -0,0 +1,2 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
93
node_modules/react-remove-scroll/dist/index.js
generated
vendored
Normal file
93
node_modules/react-remove-scroll/dist/index.js
generated
vendored
Normal file
@ -0,0 +1,93 @@
|
||||
!function (e) {
|
||||
var r = {};
|
||||
|
||||
function t(n) {
|
||||
if (r[n]) return r[n].exports;
|
||||
var o = r[n] = {i: n, l: !1, exports: {}};
|
||||
return e[n].call(o.exports, o, o.exports, t), o.l = !0, o.exports
|
||||
}
|
||||
|
||||
t.m = e, t.c = r, t.d = function (e, r, n) {
|
||||
t.o(e, r) || Object.defineProperty(e, r, {enumerable: !0, get: n})
|
||||
}, t.r = function (e) {
|
||||
"undefined" != typeof Symbol && Symbol.toStringTag && Object.defineProperty(e, Symbol.toStringTag, {value: "Module"}), Object.defineProperty(e, "__esModule", {value: !0})
|
||||
}, t.t = function (e, r) {
|
||||
if (1 & r && (e = t(e)), 8 & r) return e;
|
||||
if (4 & r && "object" == typeof e && e && e.__esModule) return e;
|
||||
var n = Object.create(null);
|
||||
if (t.r(n), Object.defineProperty(n, "default", {
|
||||
enumerable: !0,
|
||||
value: e
|
||||
}), 2 & r && "string" != typeof e) for (var o in e) t.d(n, o, function (r) {
|
||||
return e[r]
|
||||
}.bind(null, o));
|
||||
return n
|
||||
}, t.n = function (e) {
|
||||
var r = e && e.__esModule ? function () {
|
||||
return e.default
|
||||
} : function () {
|
||||
return e
|
||||
};
|
||||
return t.d(r, "a", r), r
|
||||
}, t.o = function (e, r) {
|
||||
return Object.prototype.hasOwnProperty.call(e, r)
|
||||
}, t.p = "", t(t.s = 1)
|
||||
}([function (e, r) {
|
||||
e.exports = a
|
||||
}, function (e, r, t) {
|
||||
e.exports = t(2)
|
||||
}, function (e, r, t) {
|
||||
"use strict";
|
||||
t.r(r), t.d(r, "RemoveScroll", (function () {
|
||||
return c
|
||||
}));
|
||||
var n = t(0), o = Object(n.createSidecarMedium)();
|
||||
|
||||
function a(e, r) {
|
||||
return t = r, o = function (r) {
|
||||
return e.forEach((function (e) {
|
||||
return function (e, r) {
|
||||
return "function" == typeof e ? e(r) : e && (e.current = r), e
|
||||
}(e, r)
|
||||
}))
|
||||
}, (a = Object(n.useState)((function () {
|
||||
return {
|
||||
value: t, callback: o, facade: {
|
||||
get current() {
|
||||
return a.value
|
||||
}, set current(e) {
|
||||
var r = a.value;
|
||||
r !== e && (a.value = e, a.callback(e, r))
|
||||
}
|
||||
}
|
||||
}
|
||||
}))[0]).callback = o, a.facade;
|
||||
var t, o, a
|
||||
}
|
||||
|
||||
var l = function () {
|
||||
}, c = n.forwardRef((function (e, r) {
|
||||
var t = n.useRef(null), c = n.useState({onScrollCapture: l, onWheelCapture: l, onTouchMoveCapture: l}), u = c[0],
|
||||
i = c[1], s = e.forwardProps, f = e.children, d = e.className, b = e.removeScrollBar, p = e.enabled, v = e.shards,
|
||||
m = e.sideCar, _ = e.noIsolation, h = e.inert, g = e.allowPinchZoom, j = e.as, O = void 0 === j ? "div" : j,
|
||||
y = Object(n.__rest)(e, ["forwardProps", "children", "className", "removeScrollBar", "enabled", "shards", "sideCar", "noIsolation", "inert", "allowPinchZoom", "as"]),
|
||||
S = m, P = a([t, r]), w = Object(n.__assign)(Object(n.__assign)({}, y), u);
|
||||
return n.createElement(n.Fragment, null, p && n.createElement(S, {
|
||||
sideCar: o,
|
||||
removeScrollBar: b,
|
||||
shards: v,
|
||||
noIsolation: _,
|
||||
inert: h,
|
||||
setCallbacks: i,
|
||||
allowPinchZoom: !!g,
|
||||
lockRef: t
|
||||
}), s ? n.cloneElement(n.Children.only(f), Object(n.__assign)(Object(n.__assign)({}, w), {ref: P})) : n.createElement(O, Object(n.__assign)({}, w, {
|
||||
className: d,
|
||||
ref: P
|
||||
}), f))
|
||||
}));
|
||||
c.defaultProps = {enabled: !0, removeScrollBar: !0, inert: !1}, c.classNames = {
|
||||
fullWidth: "width-before-scroll-bar",
|
||||
zeroRight: "right-scroll-bar-position"
|
||||
}
|
||||
}]);
|
||||
98
node_modules/react-remove-scroll/package.json
generated
vendored
Normal file
98
node_modules/react-remove-scroll/package.json
generated
vendored
Normal file
@ -0,0 +1,98 @@
|
||||
{
|
||||
"name": "react-remove-scroll",
|
||||
"version": "2.6.0",
|
||||
"description": "Disables scroll outside of `children` node.",
|
||||
"main": "dist/es5/index.js",
|
||||
"jsnext:main": "dist/es2015/index.js",
|
||||
"module": "dist/es2015/index.js",
|
||||
"types": "dist/es5/index.d.ts",
|
||||
"module:es2019": "dist/es2019/index.js",
|
||||
"scripts": {
|
||||
"dev": "lib-builder dev",
|
||||
"test": "jest",
|
||||
"test:ci": "jest --runInBand --coverage",
|
||||
"build": "lib-builder build && yarn size:report",
|
||||
"release": "yarn build && yarn test",
|
||||
"size": "npx size-limit",
|
||||
"size:report": "npx size-limit --json > .size.json",
|
||||
"lint": "lib-builder lint",
|
||||
"format": "lib-builder format",
|
||||
"update": "lib-builder update",
|
||||
"prepublish": "yarn build && yarn changelog",
|
||||
"changelog": "conventional-changelog -p angular -i CHANGELOG.md -s",
|
||||
"changelog:rewrite": "conventional-changelog -p angular -i CHANGELOG.md -s -r 0",
|
||||
"storybook": "start-storybook -p 6006"
|
||||
},
|
||||
"keywords": [
|
||||
"scroll"
|
||||
],
|
||||
"author": "Anton Korzunov <thekashey@gmail.com>",
|
||||
"license": "MIT",
|
||||
"devDependencies": {
|
||||
"@types/react": "^18.0.0",
|
||||
"@babel/core": "^7.17.9",
|
||||
"@size-limit/preset-small-lib": "^11.0.2",
|
||||
"size-limit": "^11.0.2",
|
||||
"@storybook/react": "^6.4.22",
|
||||
"@theuiteam/lib-builder": "^0.1.4",
|
||||
"@types/enzyme-adapter-react-16": "^1.0.6",
|
||||
"babel-loader": "^8.2.4",
|
||||
"enzyme-adapter-react-16": "^1.15.6"
|
||||
},
|
||||
"resolutions": {
|
||||
"@types/react": "^18.0.0",
|
||||
"tslib": "^2.1.0"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=10"
|
||||
},
|
||||
"peerDependencies": {
|
||||
"@types/react": "^16.8.0 || ^17.0.0 || ^18.0.0",
|
||||
"react": "^16.8.0 || ^17.0.0 || ^18.0.0"
|
||||
},
|
||||
"peerDependenciesMeta": {
|
||||
"@types/react": {
|
||||
"optional": true
|
||||
}
|
||||
},
|
||||
"files": [
|
||||
"dist",
|
||||
"UI",
|
||||
"sidecar"
|
||||
],
|
||||
"repository": "https://github.com/theKashey/react-remove-scroll",
|
||||
"dependencies": {
|
||||
"react-remove-scroll-bar": "^2.3.6",
|
||||
"react-style-singleton": "^2.2.1",
|
||||
"tslib": "^2.1.0",
|
||||
"use-callback-ref": "^1.3.0",
|
||||
"use-sidecar": "^1.1.2"
|
||||
},
|
||||
"sideEffects": [
|
||||
"**/sidecar.js"
|
||||
],
|
||||
"husky": {
|
||||
"hooks": {
|
||||
"pre-commit": "lint-staged"
|
||||
}
|
||||
},
|
||||
"lint-staged": {
|
||||
"*.{ts,tsx}": [
|
||||
"prettier --write",
|
||||
"eslint --fix",
|
||||
"git add"
|
||||
],
|
||||
"*.{js,css,json,md}": [
|
||||
"prettier --write",
|
||||
"git add"
|
||||
]
|
||||
},
|
||||
"prettier": {
|
||||
"printWidth": 120,
|
||||
"trailingComma": "es5",
|
||||
"tabWidth": 2,
|
||||
"semi": true,
|
||||
"singleQuote": true
|
||||
},
|
||||
"packageManager": "yarn@1.22.19"
|
||||
}
|
||||
7
node_modules/react-remove-scroll/sidecar/package.json
generated
vendored
Normal file
7
node_modules/react-remove-scroll/sidecar/package.json
generated
vendored
Normal file
@ -0,0 +1,7 @@
|
||||
{
|
||||
"private": true,
|
||||
"main": "../dist/es5/sidecar.js",
|
||||
"jsnext:main": "../dist/es2015/sidecar.js",
|
||||
"module": "../dist/es2015/sidecar.js",
|
||||
"types": "sidecar.d.ts"
|
||||
}
|
||||
5
node_modules/react-remove-scroll/sidecar/sidecar.d.ts
generated
vendored
Normal file
5
node_modules/react-remove-scroll/sidecar/sidecar.d.ts
generated
vendored
Normal file
@ -0,0 +1,5 @@
|
||||
import * as React from 'react';
|
||||
|
||||
declare let sidecar: React.FC;
|
||||
|
||||
export default sidecar;
|
||||
Reference in New Issue
Block a user