1
This commit is contained in:
+20
@@ -0,0 +1,20 @@
|
||||
import * as React from 'react';
|
||||
export interface TabPaneProps {
|
||||
tab?: React.ReactNode;
|
||||
className?: string;
|
||||
style?: React.CSSProperties;
|
||||
disabled?: boolean;
|
||||
children?: React.ReactNode;
|
||||
forceRender?: boolean;
|
||||
closable?: boolean;
|
||||
closeIcon?: React.ReactNode;
|
||||
icon?: React.ReactNode;
|
||||
prefixCls?: string;
|
||||
tabKey?: string;
|
||||
id?: string;
|
||||
animated?: boolean;
|
||||
active?: boolean;
|
||||
destroyOnHidden?: boolean;
|
||||
}
|
||||
declare const TabPane: React.ForwardRefExoticComponent<TabPaneProps & React.RefAttributes<HTMLDivElement>>;
|
||||
export default TabPane;
|
||||
+28
@@ -0,0 +1,28 @@
|
||||
import { clsx } from 'clsx';
|
||||
import * as React from 'react';
|
||||
const TabPane = /*#__PURE__*/React.forwardRef((props, ref) => {
|
||||
const {
|
||||
prefixCls,
|
||||
className,
|
||||
style,
|
||||
id,
|
||||
active,
|
||||
tabKey,
|
||||
children
|
||||
} = props;
|
||||
const hasContent = React.Children.count(children) > 0;
|
||||
return /*#__PURE__*/React.createElement("div", {
|
||||
id: id && `${id}-panel-${tabKey}`,
|
||||
role: "tabpanel",
|
||||
tabIndex: active && hasContent ? 0 : -1,
|
||||
"aria-labelledby": id && `${id}-tab-${tabKey}`,
|
||||
"aria-hidden": !active,
|
||||
style: style,
|
||||
className: clsx(prefixCls, active && `${prefixCls}-active`, className),
|
||||
ref: ref
|
||||
}, children);
|
||||
});
|
||||
if (process.env.NODE_ENV !== 'production') {
|
||||
TabPane.displayName = 'TabPane';
|
||||
}
|
||||
export default TabPane;
|
||||
+13
@@ -0,0 +1,13 @@
|
||||
import * as React from 'react';
|
||||
import type { AnimatedConfig, TabPosition } from '../interface';
|
||||
export interface TabPanelListProps {
|
||||
activeKey: string;
|
||||
id: string;
|
||||
animated?: AnimatedConfig;
|
||||
tabPosition?: TabPosition;
|
||||
destroyOnHidden?: boolean;
|
||||
contentStyle?: React.CSSProperties;
|
||||
contentClassName?: string;
|
||||
}
|
||||
declare const TabPanelList: React.FC<TabPanelListProps>;
|
||||
export default TabPanelList;
|
||||
+64
@@ -0,0 +1,64 @@
|
||||
function _extends() { _extends = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
|
||||
import { clsx } from 'clsx';
|
||||
import CSSMotion from '@rc-component/motion';
|
||||
import * as React from 'react';
|
||||
import TabContext from "../TabContext";
|
||||
import TabPane from "./TabPane";
|
||||
const TabPanelList = props => {
|
||||
const {
|
||||
id,
|
||||
activeKey,
|
||||
animated,
|
||||
tabPosition,
|
||||
destroyOnHidden,
|
||||
contentStyle,
|
||||
contentClassName
|
||||
} = props;
|
||||
const {
|
||||
prefixCls,
|
||||
tabs
|
||||
} = React.useContext(TabContext);
|
||||
const tabPaneAnimated = animated.tabPane;
|
||||
const tabPanePrefixCls = `${prefixCls}-tabpane`;
|
||||
return /*#__PURE__*/React.createElement("div", {
|
||||
className: clsx(`${prefixCls}-content-holder`)
|
||||
}, /*#__PURE__*/React.createElement("div", {
|
||||
className: clsx(`${prefixCls}-content`, `${prefixCls}-content-${tabPosition}`, {
|
||||
[`${prefixCls}-content-animated`]: tabPaneAnimated
|
||||
})
|
||||
}, tabs.map(item => {
|
||||
const {
|
||||
key,
|
||||
forceRender,
|
||||
style: paneStyle,
|
||||
className: paneClassName,
|
||||
destroyOnHidden: itemDestroyOnHidden,
|
||||
...restTabProps
|
||||
} = item;
|
||||
const active = key === activeKey;
|
||||
return /*#__PURE__*/React.createElement(CSSMotion, _extends({
|
||||
key: key,
|
||||
visible: active,
|
||||
forceRender: forceRender,
|
||||
removeOnLeave: !!(destroyOnHidden ?? itemDestroyOnHidden),
|
||||
leavedClassName: `${tabPanePrefixCls}-hidden`
|
||||
}, animated.tabPaneMotion), ({
|
||||
style: motionStyle,
|
||||
className: motionClassName
|
||||
}, ref) => /*#__PURE__*/React.createElement(TabPane, _extends({}, restTabProps, {
|
||||
prefixCls: tabPanePrefixCls,
|
||||
id: id,
|
||||
tabKey: key,
|
||||
animated: tabPaneAnimated,
|
||||
active: active,
|
||||
style: {
|
||||
...contentStyle,
|
||||
...paneStyle,
|
||||
...motionStyle
|
||||
},
|
||||
className: clsx(contentClassName, paneClassName, motionClassName),
|
||||
ref: ref
|
||||
})));
|
||||
})));
|
||||
};
|
||||
export default TabPanelList;
|
||||
Reference in New Issue
Block a user