diff --git a/examples/search-table-react/001-intro.md b/examples/search-table-react/001-intro.md index db888cc..b5b0f5f 100644 --- a/examples/search-table-react/001-intro.md +++ b/examples/search-table-react/001-intro.md @@ -167,11 +167,6 @@ const Demo = () => { ] } - const tabBarExtraContent = { - left: , - right: , - } - return ( { activeKey, items, onChange: setActiveKey, - tabBarExtraContent, }, + leftExtraContent: ({ loading }) => ( + + ), + rightExtraContent: ({ loading }) => ( + + ), }} titleTop={() =>
Title Top 内容自定义
} titleBottom={() =>
Title Bottom 内容自定义
} diff --git a/examples/search-table-react/050-tabs.md b/examples/search-table-react/050-tabs.md index 652dae4..e0382e1 100644 --- a/examples/search-table-react/050-tabs.md +++ b/examples/search-table-react/050-tabs.md @@ -107,9 +107,10 @@ const Demo = () => { export default Demo ``` -## 开启列设置 +## 开启列设置与刷新 -设置 `showSetting` 属性为 `true` 可以开启列设置功能。 +- 设置 `showSetting` 属性为 `true` 可以显示列设置功能。 +- 设置 `showRefresh` 属性为 `true` 可以显示刷新功能。 ```tsx import { sleep } from '@examples/utils' @@ -133,6 +134,7 @@ const Demo = () => { search={{ schema, labelWidth: 80 }} title={{ showSetting: true, + showRefresh: true, tabs: { activeKey, items, @@ -156,9 +158,9 @@ const Demo = () => { export default Demo ``` -## 单开列设置 +## 仅显示列设置与刷新 -仅开启列设置功能时,标题栏 DOM 结构有变化,不存在 Tabs 组件 DOM 结构。 +仅显示列设置与刷新,下划线样式请添加类名删除。 ```tsx import { sleep } from '@examples/utils' @@ -173,6 +175,7 @@ const Demo = () => { search={{ schema, labelWidth: 80 }} title={{ showSetting: true, + showRefresh: true, }} table={{ columns }} request={async (searchParams) => { @@ -188,9 +191,9 @@ const Demo = () => { export default Demo ``` -## 自定义两侧内容 +## 自定义左侧内容 -使用 Antd Tabs 自带的 `tabBarExtraContent` 属性实现。 +使用 `leftExtraContent` 属性可自定义左侧内容,下划线样式请按需删除。 ```tsx import { sleep } from '@examples/utils' @@ -198,40 +201,57 @@ import schema from './helpers/schema' import columns from './helpers/columns' import createDataSource from './helpers/createDataSource' import SearchTable from '@schema-render/search-table-react' -import { useState } from 'react' import { Button } from 'antd' -const items = [ - { key: '1', label: '已提交' }, - { key: '2', label: '待提交' }, - { key: '3', label: '待审核' }, -] - const Demo = () => { - const [activeKey, setActiveKey] = useState('1') + return ( + ( + <> + + + + ), + }} + table={{ columns }} + request={async (searchParams) => { + // 模拟请求接口获取表格数据 + await sleep() + const data = createDataSource(searchParams.pageSize) + return { data, total: 100 } + }} + /> + ) +} - const tabBarExtraContent = { - left: , - right: , - } +export default Demo +``` +## 自定义右侧内容 + +使用 `rightExtraContent` 属性可自定义右侧内容。 + +```tsx +import { sleep } from '@examples/utils' +import schema from './helpers/schema' +import columns from './helpers/columns' +import createDataSource from './helpers/createDataSource' +import SearchTable from '@schema-render/search-table-react' +import { Button } from 'antd' + +const Demo = () => { return ( , }} table={{ columns }} request={async (searchParams) => { - // 打印 activeKey 值 - console.log('activeKey:', activeKey) - // 模拟请求接口获取表格数据 await sleep() const data = createDataSource(searchParams.pageSize) @@ -244,9 +264,7 @@ const Demo = () => { export default Demo ``` -## 自定义两侧内容(无标签情况) - -使用 Antd Tabs 自带的 `tabBarExtraContent` 属性实现,下划线样式请按需删除。 +## 属性全开效果 ```tsx import { sleep } from '@examples/utils' @@ -255,12 +273,16 @@ import columns from './helpers/columns' import createDataSource from './helpers/createDataSource' import SearchTable from '@schema-render/search-table-react' import { Button } from 'antd' +import { useState } from 'react' + +const items = [ + { key: '1', label: '已提交' }, + { key: '2', label: '待提交' }, + { key: '3', label: '待审核' }, +] const Demo = () => { - const tabBarExtraContent = { - left: , - right: , - } + const [activeKey, setActiveKey] = useState('1') return ( { showRefresh: true, showSetting: true, tabs: { - tabBarExtraContent, + activeKey, + items, + onChange: setActiveKey, }, + leftExtraContent: ({ loading }) => , + rightExtraContent: ({ loading }) => , }} table={{ columns }} request={async (searchParams) => {