123456789101112131415161718192021222324252627282930313233343536373839 |
- "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, rest = tslib_1.__rest(props, ["forwardProps", "children", "className", "removeScrollBar", "enabled", "shards", "sideCar", "noIsolation", "inert", "allowPinchZoom", "as"]);
- 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 })),
- 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,
- };
|