@ducor/react
Version:
admin template ui interface
35 lines (34 loc) • 2.43 kB
JavaScript
var __rest = (this && this.__rest) || function (s, e) {
var t = {};
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
t[p] = s[p];
if (s != null && typeof Object.getOwnPropertySymbols === "function")
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
t[p[i]] = s[p[i]];
}
return t;
};
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
import { forwardRef } from "react";
import { twMerge } from "tailwind-merge";
import ScrollAreaControl from "./control";
import { ScrollAreaContext } from "./provider";
import Slider from "./slider";
import { useScroll } from "@ducor/hooks";
import MemoComponent from "../memo-component";
const ScrollArea = forwardRef((_a, ref) => {
var { children, className = "", direction = "col", scrollbarSize = 8, scrollHideDelay = 1000, scrollbarAlwaysVisible = false, thumbClassName = "", trackClassName = "" } = _a, rest = __rest(_a, ["children", "className", "direction", "scrollbarSize", "scrollHideDelay", "scrollbarAlwaysVisible", "thumbClassName", "trackClassName"]);
const { containerRef, contentRef, scrollOffset, setScrollOffset, scrollPercent, setScrollPercent, contentSize, getStyles, scrollTo, } = useScroll();
const value = {
direction,
size: contentSize,
scrollOffset,
setScrollOffset,
scrollTo,
scrollPercent,
setScrollPercent,
};
return (_jsx(ScrollAreaContext.Provider, { value: value, children: _jsxs("div", { className: 'scroll-grid ', children: [_jsx(ScrollAreaControl, { position: 'top', direction: direction }), _jsx(ScrollAreaControl, { position: 'right', direction: direction }), _jsx(ScrollAreaControl, { position: 'bottom', direction: direction }), _jsx(ScrollAreaControl, { position: 'left', direction: direction }), _jsx(Slider, { position: 'vertical' }), _jsx(Slider, { position: 'horizontal' }), _jsx("main", { "data-scroll-aria": 'main', children: _jsx("div", Object.assign({ ref: containerRef, "data-schole": direction, className: twMerge("relative overflow-visible cursor-default ", className) }, rest, { children: _jsx("div", { ref: contentRef, style: getStyles(), children: _jsx(MemoComponent, { component: children }) }) })) })] }) }));
});
export default ScrollArea;