import "./all.js"; import { CSSProperties, ReactNode } from "react"; import { useI18n } from "../../hooks/useI18n.js"; import type { FormOptions } from "../../interfaces/index.js"; import { getComponent } from "../../registries/components.js"; import type { Tab as DefaultTab } from "./Tab.js"; import type { TabList as DefaultTabList } from "./TabList.js"; import type { TabPanel as DefaultTabPanel } from "./TabPanel.js"; import type { Tabs as DefaultTabs } from "./Tabs.js"; import type { TabsBody as DefaultTabsBody } from "./TabsBody.js"; export interface TabsItemProps extends Record { label?: string; icon?: string; children?: ReactNode; } export interface TabsLegacyProps extends Record { AddButton?: any; current?: TabsItemProps; items?: TabsItemProps[]; style?: CSSProperties; className?: string; reverse?: boolean; onClick?: (item: TabsItemProps) => void; i18n?: FormOptions["i18n"]; } export function TabsLegacy({ style, current, items = [], HeaderChildren, AddButton, className, onClick, reverse, after, ...additionalProps }: TabsLegacyProps) { const Tab = getComponent("Tab"); const TabsBody = getComponent("TabsBody"); const TabList = getComponent("TabList"); const TabPanel = getComponent("TabPanel"); const Tabs = getComponent("Tabs"); const tabs = items.filter((item) => item.label || item.icon); const { t } = useI18n(additionalProps.i18n); return (
{tabs.map((item, index) => { return ( { onClick && onClick(item); }} icon={item.icon} value={index} className={reverse ? "-reverse" : ""} after={after} > {t(item.label || "")} ); })} {AddButton && } {HeaderChildren && }
{tabs.map((item, index) => { return ( {item.children || item.content} ); })}
); }