UNPKG

@mantine/core

Version:

React components library focused on usability, accessibility and developer experience

56 lines (55 loc) 2.43 kB
"use client"; require("../../../_virtual/_rolldown/runtime.cjs"); const require_ScrollArea_context = require("../ScrollArea.context.cjs"); const require_is_scrolling_within_scrollbar_bounds = require("../utils/is-scrolling-within-scrollbar-bounds.cjs"); const require_get_thumb_size = require("../utils/get-thumb-size.cjs"); const require_to_int = require("../utils/to-int.cjs"); const require_Scrollbar = require("./Scrollbar.cjs"); let react = require("react"); let _mantine_hooks = require("@mantine/hooks"); let react_jsx_runtime = require("react/jsx-runtime"); //#region packages/@mantine/core/src/components/ScrollArea/ScrollAreaScrollbar/ScrollbarX.tsx const ScrollAreaScrollbarX = (props) => { const { sizes, onSizesChange, style, ref: forwardedRef, ...others } = props; const ctx = require_ScrollArea_context.useScrollAreaContext(); const [computedStyle, setComputedStyle] = (0, react.useState)(); const ref = (0, react.useRef)(null); const composeRefs = (0, _mantine_hooks.useMergedRef)(forwardedRef, ref, ctx.onScrollbarXChange); (0, react.useEffect)(() => { if (ref.current) setComputedStyle(getComputedStyle(ref.current)); }, [ref]); return /* @__PURE__ */ (0, react_jsx_runtime.jsx)(require_Scrollbar.Scrollbar, { "data-orientation": "horizontal", ...others, ref: composeRefs, sizes, style: { ...style, ["--sa-thumb-width"]: `${require_get_thumb_size.getThumbSize(sizes)}px` }, onThumbPointerDown: (pointerPos) => props.onThumbPointerDown(pointerPos.x), onDragScroll: (pointerPos) => props.onDragScroll(pointerPos.x), onWheelScroll: (event, maxScrollPos) => { if (ctx.viewport) { const scrollPos = ctx.viewport.scrollLeft + event.deltaX; props.onWheelScroll(scrollPos); if (require_is_scrolling_within_scrollbar_bounds.isScrollingWithinScrollbarBounds(scrollPos, maxScrollPos)) event.preventDefault(); } }, onResize: () => { if (ref.current && ctx.viewport && computedStyle) onSizesChange({ content: ctx.viewport.scrollWidth, viewport: ctx.viewport.offsetWidth, scrollbar: { size: ref.current.clientWidth, paddingStart: require_to_int.toInt(computedStyle.paddingLeft), paddingEnd: require_to_int.toInt(computedStyle.paddingRight) } }); } }); }; ScrollAreaScrollbarX.displayName = "@mantine/core/ScrollAreaScrollbarX"; //#endregion exports.ScrollAreaScrollbarX = ScrollAreaScrollbarX; //# sourceMappingURL=ScrollbarX.cjs.map