import * as React from 'react'; import type { TabsProps as RcTabsProps } from 'rc-tabs'; import RcTabs, { TabPane, TabPaneProps } from 'rc-tabs'; import type { EditableConfig } from 'rc-tabs/lib/interface'; import classNames from 'classnames'; import EllipsisOutlined from '@ant-design/icons/EllipsisOutlined'; import PlusOutlined from '@ant-design/icons/PlusOutlined'; import CloseOutlined from '@ant-design/icons/CloseOutlined'; import warning from '../_util/warning'; import { ConfigContext } from '../config-provider'; import useStyle from './style'; import type { SizeType } from '../config-provider/SizeContext'; import SizeContext from '../config-provider/SizeContext'; export type TabsType = 'line' | 'card' | 'editable-card'; export type TabsPosition = 'top' | 'right' | 'bottom' | 'left'; export { TabPaneProps }; export interface TabsProps extends Omit { type?: TabsType; size?: SizeType; hideAdd?: boolean; centered?: boolean; addIcon?: React.ReactNode; onEdit?: (e: React.MouseEvent | React.KeyboardEvent | string, action: 'add' | 'remove') => void; } function Tabs({ type, className, size: propSize, onEdit, hideAdd, centered, addIcon, ...props }: TabsProps) { const { prefixCls: customizePrefixCls, moreIcon = } = props; const { getPrefixCls, direction } = React.useContext(ConfigContext); const prefixCls = getPrefixCls('tabs', customizePrefixCls); const [wrapSSR, hashId] = useStyle(prefixCls); let editable: EditableConfig | undefined; if (type === 'editable-card') { editable = { onEdit: (editType, { key, event }) => { onEdit?.(editType === 'add' ? event : key!, editType); }, removeIcon: , addIcon: addIcon || , showAdd: hideAdd !== true, }; } const rootPrefixCls = getPrefixCls(); warning( !('onPrevClick' in props) && !('onNextClick' in props), 'Tabs', '`onPrevClick` and `onNextClick` has been removed. Please use `onTabScroll` instead.', ); return wrapSSR( {contextSize => { const size = propSize !== undefined ? propSize : contextSize; return ( ); }} , ); } Tabs.TabPane = TabPane; export default Tabs;