From 1a9d76933fa68f6798b29672e7230deb60710609 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: Thu, 4 Aug 2022 10:35:24 +0800 Subject: [PATCH] refactor: Tabs use `items` instead of jsx node (#562) * chore: basic refactor * docs: more example * docs: more example * docs: more and more * docs: rest demo * chore: connect props * test: All test case convert * chore: adjust ts comiple * test: coverage --- docs/examples/basic.tsx | 43 +++++---- docs/examples/editable.tsx | 21 +++-- docs/examples/extra.tsx | 19 ++-- docs/examples/mix.tsx | 32 ++++--- docs/examples/overflow.tsx | 16 ++-- docs/examples/position.tsx | 55 ++++++----- docs/examples/renderTabBar-dragable.tsx | 54 ++++++----- docs/examples/renderTabBar-sticky.tsx | 35 ++++--- docs/examples/renderTabBar-use-panes.tsx | 35 ++++--- src/TabNavList/OperationNode.tsx | 6 +- src/TabNavList/TabNode.tsx | 10 +- src/TabNavList/Wrapper.tsx | 30 ++++++ src/TabNavList/index.tsx | 3 +- src/TabPanelList/index.tsx | 24 ++--- src/Tabs.tsx | 53 ++++------- src/index.ts | 6 +- src/interface.ts | 8 +- tests/common/util.tsx | 50 ++++++---- tests/index.test.tsx | 115 ++++++++++++++++------- tests/mobile.test.tsx | 25 ++--- tests/operation-overflow.test.tsx | 2 +- tests/overflow.test.tsx | 38 +++++--- tests/rtl.test.tsx | 2 +- 23 files changed, 403 insertions(+), 279 deletions(-) create mode 100644 src/TabNavList/Wrapper.tsx diff --git a/docs/examples/basic.tsx b/docs/examples/basic.tsx index c92eed9f..f92b79f9 100644 --- a/docs/examples/basic.tsx +++ b/docs/examples/basic.tsx @@ -1,19 +1,26 @@ import React from 'react'; -import Tabs, { TabPane } from 'rc-tabs'; +import Tabs from 'rc-tabs'; import '../../assets/index.less'; export default () => { const [destroy, setDestroy] = React.useState(false); - const [children, setChildren] = React.useState([ - - Light - , - - Bamboo - , - - Cute - , + const [items, setItems] = React.useState([ + { + label: 'Light', + key: 'light', + children: 'Light!', + }, + { + label: 'Bamboo', + key: 'bamboo', + children: 'Bamboo!', + }, + { + label: 'Cute', + key: 'cute', + children: 'Cute!', + disabled: true, + }, ]); if (destroy) { @@ -22,16 +29,16 @@ export default () => { return ( - - {children} - +