@navikt/ds-react
Version:
React components from the Norwegian Labour and Welfare Administration.
31 lines • 1.9 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;
};
/* eslint-disable jsx-a11y/interactive-supports-focus */
import React, { forwardRef, useRef } from "react";
import { cl, composeEventHandlers } from "../../../utils/helpers/index.js";
import { useMergeRefs } from "../../../utils/hooks/index.js";
import ScrollButton from "./ScrollButtons.js";
import { useScrollButtons } from "./useScrollButtons.js";
import { useTabList } from "./useTabList.js";
export const TabList = forwardRef((_a, ref) => {
var { className, onKeyDown } = _a, rest = __rest(_a, ["className", "onKeyDown"]);
const { onKeyDown: _onKeyDown } = useTabList();
const listRef = useRef(null);
const mergedRef = useMergeRefs(listRef, ref);
const scrollCtx = useScrollButtons(listRef);
return (React.createElement("div", { className: "aksel-tabs__tablist-wrapper" },
scrollCtx.show && (React.createElement(ScrollButton, { dir: "left", hidden: !scrollCtx.start, onClick: scrollCtx.scrollLeft })),
React.createElement("div", Object.assign({ ref: mergedRef }, rest, { onScroll: scrollCtx.update, className: cl("aksel-tabs__tablist", className), role: "tablist", "aria-orientation": "horizontal", onKeyDown: composeEventHandlers(onKeyDown, _onKeyDown) })),
scrollCtx.show && (React.createElement(ScrollButton, { dir: "right", hidden: !scrollCtx.end, onClick: scrollCtx.scrollRight }))));
});
export default TabList;
//# sourceMappingURL=TabList.js.map