diff --git a/assets/panels.less b/assets/panels.less index 19819126..979dac1b 100644 --- a/assets/panels.less +++ b/assets/panels.less @@ -1,10 +1,11 @@ @tabs-prefix-cls: rc-tabs; .@{tabs-prefix-cls} { - &-content { + &-body { &-holder { flex: auto; } + position: relative; // display: flex; @@ -15,7 +16,7 @@ // } } - &-tabpane { + &-content { // flex: none; // width: 100%; diff --git a/assets/position.less b/assets/position.less index 8b64ea20..ad8ec701 100644 --- a/assets/position.less +++ b/assets/position.less @@ -24,7 +24,7 @@ order: 1; } - .@{tabs-prefix-cls}-content { + .@{tabs-prefix-cls}-body { order: 0; } @@ -71,7 +71,7 @@ order: 1; } - .@{tabs-prefix-cls}-content { + .@{tabs-prefix-cls}-body { order: 0; } diff --git a/src/TabPanelList/index.tsx b/src/TabPanelList/index.tsx index 22263540..dfdbc715 100644 --- a/src/TabPanelList/index.tsx +++ b/src/TabPanelList/index.tsx @@ -8,27 +8,45 @@ import TabPane from './TabPane'; export interface TabPanelListProps { activeKey: string; id: string; - animated?: AnimatedConfig; - tabPosition?: TabPosition; + animated: AnimatedConfig; + tabPosition: TabPosition; destroyOnHidden?: boolean; + bodyStyle?: React.CSSProperties; + bodyClassName?: string; contentStyle?: React.CSSProperties; contentClassName?: string; } const TabPanelList: React.FC = props => { - const { id, activeKey, animated, tabPosition, destroyOnHidden, contentStyle, contentClassName } = - props; + const { + id, + activeKey, + animated, + tabPosition, + destroyOnHidden, + bodyStyle, + bodyClassName, + contentStyle, + contentClassName, + } = props; const { prefixCls, tabs } = React.useContext(TabContext); const tabPaneAnimated = animated.tabPane; - const tabPanePrefixCls = `${prefixCls}-tabpane`; + const bodyPrefixCls = `${prefixCls}-body`; + const contentPrefixCls = `${prefixCls}-content`; return ( -
+
{tabs.map(item => { const { @@ -46,13 +64,13 @@ const TabPanelList: React.FC = props => { visible={active} forceRender={forceRender} removeOnLeave={!!(destroyOnHidden ?? itemDestroyOnHidden)} - leavedClassName={`${tabPanePrefixCls}-hidden`} + leavedClassName={`${contentPrefixCls}-hidden`} {...animated.tabPaneMotion} > {({ style: motionStyle, className: motionClassName }, ref) => ( , @@ -216,6 +223,8 @@ const Tabs = React.forwardRef((props, ref) => {
{ const { container, rerender } = render(getTabs(props)); function matchText(text: string) { - expect(container.querySelectorAll('.rc-tabs-tabpane')).toHaveLength(1); - expect(container.querySelector('.rc-tabs-tabpane-active').textContent).toEqual(text); + expect(container.querySelectorAll('.rc-tabs-content')).toHaveLength(1); + expect(container.querySelector('.rc-tabs-content-active').textContent).toEqual(text); } matchText('Light'); @@ -367,8 +367,8 @@ describe('Tabs.Basic', () => { const { container, rerender } = render(getTabs(props)); function matchText(text: string) { - expect(container.querySelectorAll('.rc-tabs-tabpane')).toHaveLength(1); - expect(container.querySelector('.rc-tabs-tabpane-active').textContent).toEqual(text); + expect(container.querySelectorAll('.rc-tabs-content')).toHaveLength(1); + expect(container.querySelector('.rc-tabs-content-active').textContent).toEqual(text); } matchText('Light'); @@ -743,13 +743,15 @@ describe('Tabs.Basic', () => { const customClassNames = { indicator: 'custom-indicator', item: 'custom-item', + body: 'custom-body', content: 'custom-content', header: 'custom-header', }; const customStyles = { indicator: { background: 'red' }, item: { color: 'blue' }, - content: { background: 'green' }, + body: { background: 'green' }, + content: { color: 'purple' }, header: { background: 'yellow' }, }; const { container } = render( @@ -762,17 +764,20 @@ describe('Tabs.Basic', () => { ); const indicator = container.querySelector('.rc-tabs-ink-bar') as HTMLElement; const item = container.querySelector('.rc-tabs-tab') as HTMLElement; - const content = container.querySelector('.rc-tabs-tabpane') as HTMLElement; + const body = container.querySelector('.rc-tabs-body') as HTMLElement; + const content = container.querySelector('.rc-tabs-content') as HTMLElement; const header = container.querySelector('.rc-tabs-nav') as HTMLElement; expect(indicator).toHaveClass('custom-indicator'); expect(item).toHaveClass('custom-item'); + expect(body).toHaveClass('custom-body'); expect(content).toHaveClass('custom-content'); expect(header).toHaveClass('custom-header'); expect(indicator).toHaveStyle({ background: 'red' }); expect(item).toHaveStyle({ color: 'blue' }); - expect(content).toHaveStyle({ background: 'green' }); + expect(body).toHaveStyle({ background: 'green' }); + expect(content).toHaveStyle({ color: 'purple' }); expect(header).toHaveStyle({ background: 'yellow' }); });