@gravity-ui/uikit
Version:
Gravity UI base styling and components
30 lines (29 loc) • 1.53 kB
JavaScript
'use client';
import { jsx as _jsx } from "react/jsx-runtime";
import * as React from 'react';
import { FloatingOverlay } from '@floating-ui/react';
import { Portal } from "../Portal/Portal.js";
import { SheetContentContainer } from "./SheetContent.js";
import { sheetBlock } from "./constants.js";
import "./Sheet.css";
export const Sheet = ({ children, onClose, visible, id, title, className, contentClassName, swipeAreaClassName, allowHideOnContentScroll, hideTopBar, maxContentHeightCoefficient, alwaysFullHeight, qa, }) => {
const [open, setOpen] = React.useState(visible);
const [prevVisible, setPrevVisible] = React.useState(visible);
if (!prevVisible && visible) {
setOpen(true);
}
if (visible !== prevVisible) {
setPrevVisible(visible);
}
const hideSheet = () => {
if (onClose) {
onClose();
}
setOpen(false);
};
if (!open) {
return null;
}
return (_jsx(Portal, { children: _jsx(FloatingOverlay, { "data-qa": qa, className: sheetBlock(null, className), lockScroll: open, style: { overflow: undefined }, children: _jsx(SheetContentContainer, { id: id, content: children, contentClassName: contentClassName, swipeAreaClassName: swipeAreaClassName, title: title, visible: visible, allowHideOnContentScroll: allowHideOnContentScroll, hideTopBar: hideTopBar, hideSheet: hideSheet, maxContentHeightCoefficient: maxContentHeightCoefficient, alwaysFullHeight: alwaysFullHeight }) }) }));
};
//# sourceMappingURL=Sheet.js.map