Skip to content

Commit bbd079e

Browse files
author
刘欢
committed
feat: update README to include MoreProps details and enhance dropdown customization tests
1 parent c9d9aa6 commit bbd079e

3 files changed

Lines changed: 30 additions & 16 deletions

File tree

README.md

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@
1515

1616
<p align="center">English | <a href="./README.zh-CN.md">简体中文</a></p>
1717

18-
1918
## Highlights
2019

2120
- Supports top, bottom, left, and right tab positions with RTL layouts.
@@ -75,7 +74,7 @@ Then open `http://localhost:8000`.
7574
| `indicator` | `{ size?: GetIndicatorSize; align?: 'start' \| 'center' \| 'end' }` | - | Indicator size and alignment. |
7675
| `items` | Tab[] | [] | Tab items. |
7776
| `locale` | TabsLocale | - | Accessibility locale text. |
78-
| `more` | { icon?: ReactNode, popupRender?: (menu: ReactElement, info: { tabs: Tab[], onClose: () => void }) => ReactElement } | - | more dropdown config, support custom popup content |
77+
| `more` | MoreProps | - | more dropdown config, see [MoreProps](#moreprops) for full API. Additionally supports `popupRender` for custom popup content. |
7978
| `onChange` | `(activeKey: string) => void` | - | Triggered when active tab changes. |
8079
| `onTabClick` | `(activeKey, event) => void` | - | Triggered when a tab is clicked. |
8180
| `onTabScroll` | `({ direction }) => void` | - | Triggered when tab navigation scrolls. |
@@ -103,6 +102,14 @@ Then open `http://localhost:8000`.
103102
| `label` | React.ReactNode | - | Tab label. |
104103
| `style` | React.CSSProperties | - | Panel style. |
105104

105+
### MoreProps
106+
107+
| Name | Type | Default | Description |
108+
| --- | --- | --- | --- |
109+
| `icon` | ReactNode | - | The icon shown in the more trigger. |
110+
| `popupRender` | `(menu: ReactElement, info: { tabs: Tab[], onClose: () => void }) => ReactElement` | - | Customize the dropdown popup content. The `info` object provides `tabs` (all overflowed tabs) and `onClose` (function to close the dropdown). |
111+
| Other dropdown props | from DropdownProps | - | All other [rc-dropdown](https://github.com/react-component/dropdown) props such as `trigger`, `overlayClassName`, `visible`, etc. are also supported. |
112+
106113
## Development
107114

108115
```bash

README.zh-CN.md

Lines changed: 19 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@
1515

1616
<p align="center"><a href="./README.md">English</a> | 简体中文</p>
1717

18-
1918
## 特性
2019

2120
- 支持 RTL 布局的顶部、底部、左侧和右侧选项卡位置。
@@ -75,7 +74,7 @@ npm start
7574
| `indicator` | `{ size?: GetIndicatorSize; align?: 'start' \| 'center' \| 'end' }` | - | 指示器尺寸和对齐方式。 |
7675
| `items` | Tab[] | [] | 选项卡项目。 |
7776
| `locale` | TabsLocale | - | 无障碍本地化文本。 |
78-
| `more` | MoreProps | - | 溢出下拉菜单配置。 |
77+
| `more` | MoreProps | - | 溢出下拉菜单配置,详情见 [MoreProps](#moreprops)。支持 `popupRender` 自定义弹层内容|
7978
| `onChange` | `(activeKey: string) => void` | - | 当活动选项卡更改时触发。 |
8079
| `onTabClick` | `(activeKey, event) => void` | - | 单击选项卡时触发。 |
8180
| `onTabScroll` | `({ direction }) => void` | - | 当选项卡导航滚动时触发。 |
@@ -90,18 +89,26 @@ npm start
9089

9190
### Tab
9291

92+
| 名称 | 类型 | 默认值 | 说明 |
93+
| ----------------- | ------------------- | ------ | ---------------------------------- |
94+
| `children` | React.ReactNode | - | 选项卡面板内容。 |
95+
| `className` | string | - | 面板 className。 |
96+
| `closable` | boolean | - | 是否可以在可编辑模式下关闭选项卡。 |
97+
| `closeIcon` | React.ReactNode | - | 自定义关闭图标。 |
98+
| `destroyOnHidden` | boolean | false | 销毁非活动面板。 |
99+
| `disabled` | boolean | false | 禁用该选项卡。 |
100+
| `forceRender` | boolean | false | 在面板变为活动状态之前渲染面板。 |
101+
| `key` | string | - | 需要唯一的 Tab 键。 |
102+
| `label` | React.ReactNode | - | Tab 标签内容。 |
103+
| `style` | React.CSSProperties | - | 面板样式。 |
104+
105+
### MoreProps
106+
93107
| 名称 | 类型 | 默认值 | 说明 |
94108
| --- | --- | --- | --- |
95-
| `children` | React.ReactNode | - | 选项卡面板内容。 |
96-
| `className` | string | - | 面板 className。 |
97-
| `closable` | boolean | - | 是否可以在可编辑模式下关闭选项卡。 |
98-
| `closeIcon` | React.ReactNode | - | 自定义关闭图标。 |
99-
| `destroyOnHidden` | boolean | false | 销毁非活动面板。 |
100-
| `disabled` | boolean | false | 禁用该选项卡。 |
101-
| `forceRender` | boolean | false | 在面板变为活动状态之前渲染面板。 |
102-
| `key` | string | - | 需要唯一的 Tab 键。 |
103-
| `label` | React.ReactNode | - | Tab 标签内容。 |
104-
| `style` | React.CSSProperties | - | 面板样式。 |
109+
| `icon` | ReactNode | - | 更多按钮的图标。 |
110+
| `popupRender` | `(menu: ReactElement, info: { tabs: Tab[], onClose: () => void }) => ReactElement` | - | 自定义下拉弹层内容。`info` 对象提供 `tabs`(所有溢出标签)和 `onClose`(关闭下拉菜单的函数)。 |
111+
| 其他下拉属性 | 来自 DropdownProps | - | 其他 [rc-dropdown](https://github.com/react-component/dropdown) 属性如 `trigger``overlayClassName``visible` 等也都支持。 |
105112

106113
## 本地开发
107114

tests/overflow.test.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -698,12 +698,12 @@ describe('Tabs.Overflow', () => {
698698
expect(document.querySelector('[data-testid="custom-popup"]')).toBeTruthy();
699699

700700
const onClose = callArgs[1].onClose;
701-
fireEvent.click(document.querySelector('.rc-tabs-dropdown'));
702701
act(() => {
703702
onClose();
704703
jest.runAllTimers();
705704
});
706-
expect(container.querySelector('.rc-tabs-dropdown')).toBeFalsy();
705+
const dropdownPopup = document.querySelector('.rc-tabs-dropdown');
706+
expect(dropdownPopup?.classList.contains('rc-tabs-dropdown-hidden')).toBeTruthy();
707707

708708
jest.useRealTimers();
709709
});

0 commit comments

Comments
 (0)