From a3fb7834a76be07b97f9019215de230084e0e216 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E4=BA=8C=E8=B4=A7=E7=88=B1=E5=90=83=E7=99=BD=E8=90=9D?= =?UTF-8?q?=E5=8D=9C?= Date: Tue, 16 May 2023 22:24:41 +0800 Subject: [PATCH] fix: Card `tabList` API to align with Tabs (#42413) * chore: pass to tabs * test: update snapshot --- components/card/Card.tsx | 15 +- .../__snapshots__/demo-extend.test.ts.snap | 5 - .../__tests__/__snapshots__/demo.test.ts.snap | 5 - .../__snapshots__/index.test.tsx.snap | 263 ++++++++++++++++++ components/card/__tests__/index.test.tsx | 40 ++- components/card/demo/tabs.tsx | 6 +- components/card/index.en-US.md | 2 +- components/card/index.zh-CN.md | 2 +- components/tabs/index.en-US.md | 1 + components/tabs/index.zh-CN.md | 1 + 10 files changed, 314 insertions(+), 26 deletions(-) diff --git a/components/card/Card.tsx b/components/card/Card.tsx index fe416d5167..fd0a63ee06 100644 --- a/components/card/Card.tsx +++ b/components/card/Card.tsx @@ -1,4 +1,5 @@ import classNames from 'classnames'; +import type { Tab } from 'rc-tabs/lib/interface'; import omit from 'rc-util/lib/omit'; import * as React from 'react'; import { ConfigContext } from '../config-provider'; @@ -12,10 +13,11 @@ import useStyle from './style'; export type CardType = 'inner'; export type CardSize = 'default' | 'small'; -export interface CardTabListType { +export interface CardTabListType extends Omit { key: string; - tab: React.ReactNode; - disabled?: boolean; + /** @deprecated Please use `label` instead */ + tab?: React.ReactNode; + label?: React.ReactNode; } export interface CardProps extends Omit, 'title'> { @@ -123,10 +125,9 @@ const Card = React.forwardRef((props, ref) => { {...extraProps} className={`${prefixCls}-head-tabs`} onChange={onTabChange} - items={tabList.map((item) => ({ - label: item.tab, - key: item.key, - disabled: item.disabled ?? false, + items={tabList.map(({ tab, ...item }) => ({ + label: tab, + ...item, }))} /> ) : null; diff --git a/components/card/__tests__/__snapshots__/demo-extend.test.ts.snap b/components/card/__tests__/__snapshots__/demo-extend.test.ts.snap index e2846da4c8..34435adb3e 100644 --- a/components/card/__tests__/__snapshots__/demo-extend.test.ts.snap +++ b/components/card/__tests__/__snapshots__/demo-extend.test.ts.snap @@ -771,7 +771,6 @@ Array [ >