mui-extended
Version:
Extended UI Components built on Material UI
40 lines (39 loc) • 1.2 kB
JavaScript
import { __assign } from "tslib";
import { jsx as _jsx } from "react/jsx-runtime";
import { Box } from "@mui/material";
import { createRef, forwardRef, useEffect } from "react";
export var Pane = forwardRef(function Pane(_a, ref) {
var size = _a.size, split = _a.split, sx = _a.sx, children = _a.children;
var style = {
flex: 1,
position: "relative",
outline: "none",
overflow: "auto"
};
if (size !== undefined) {
if (split === "vertical") {
style.width = size;
}
else {
style.height = size;
style.display = "flex";
}
style.flex = "none";
}
var finalSx = __assign(__assign({}, style), sx);
var thisRef = createRef();
useEffect(function () {
if (ref) {
if (typeof ref == "function") {
ref(thisRef.current);
}
else {
ref.current = thisRef.current;
}
}
}, [thisRef, ref]);
useEffect(function () {
thisRef.current.scroll({ top: 0, left: 0 });
}, [thisRef, children]);
return (_jsx(Box, { ref: thisRef, sx: finalSx, children: children }));
});