@wener/console
Version:
Base console UI toolkit
29 lines (28 loc) • 1.16 kB
JavaScript
import React from "react";
import { useControllable } from "@wener/reaction";
import { HeaderContentFooterLayout } from "../../components/HeaderContentFooterLayout.js";
import { getTitleTabItemKey, TitleTabList } from "./TitleTabList.js";
export const TitleTabLayout = ({ children, className, title, active, onActiveChange, tabs, action, ...props }) => {
let [activeIndex, setActiveIndex] = useControllable(active, onActiveChange, "");
// no href use first tab
if (!activeIndex) {
if (tabs.length && !tabs.some((v) => v.href)) {
activeIndex = getTitleTabItemKey(tabs[0], 0);
}
}
const activeTab = tabs.find((v, idx) => {
return getTitleTabItemKey(v, idx) === activeIndex;
});
return /*#__PURE__*/ React.createElement(HeaderContentFooterLayout, {
header: /*#__PURE__*/ React.createElement(TitleTabList, {
title,
tabs,
action,
value: activeIndex,
onValueChange: setActiveIndex,
className: "min-h-12"
}),
...props
}, activeTab?.content, children);
};
//# sourceMappingURL=TitleTabLayout.js.map