@mantine/core
Version:
React components library focused on usability, accessibility and developer experience
41 lines (40 loc) • 1.56 kB
JavaScript
"use client";
require("../../../_virtual/_rolldown/runtime.cjs");
const require_ScrollArea_context = require("../ScrollArea.context.cjs");
const require_use_resize_observer = require("../use-resize-observer.cjs");
let react = require("react");
let react_jsx_runtime = require("react/jsx-runtime");
//#region packages/@mantine/core/src/components/ScrollArea/ScrollAreaCorner/ScrollAreaCorner.tsx
function Corner(props) {
const { style, ...others } = props;
const ctx = require_ScrollArea_context.useScrollAreaContext();
const [width, setWidth] = (0, react.useState)(0);
const [height, setHeight] = (0, react.useState)(0);
const hasSize = Boolean(width && height);
require_use_resize_observer.useResizeObserver(ctx.scrollbarX, () => {
const h = ctx.scrollbarX?.offsetHeight || 0;
ctx.onCornerHeightChange(h);
setHeight(h);
});
require_use_resize_observer.useResizeObserver(ctx.scrollbarY, () => {
const w = ctx.scrollbarY?.offsetWidth || 0;
ctx.onCornerWidthChange(w);
setWidth(w);
});
return hasSize ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
...others,
style: {
...style,
width,
height
}
}) : null;
}
function ScrollAreaCorner(props) {
const ctx = require_ScrollArea_context.useScrollAreaContext();
const hasBothScrollbarsVisible = Boolean(ctx.scrollbarX && ctx.scrollbarY);
return ctx.type !== "scroll" && hasBothScrollbarsVisible ? /* @__PURE__ */ (0, react_jsx_runtime.jsx)(Corner, { ...props }) : null;
}
//#endregion
exports.ScrollAreaCorner = ScrollAreaCorner;
//# sourceMappingURL=ScrollAreaCorner.cjs.map