From 1912e84931112c9035e9a3a2b9858bfa3dd2b961 Mon Sep 17 00:00:00 2001 From: dengfuping Date: Fri, 12 Apr 2024 14:24:28 +0800 Subject: [PATCH] fix(ui): LightFilter style in ProTable should work --- packages/design/src/table/index.tsx | 4 +- packages/ui/src/ProTable/demo/basic.tsx | 9 +++- .../ui/src/ProTable/demo/light-filter.tsx | 43 ++++++++++++++++++ packages/ui/src/ProTable/index.md | 2 + packages/ui/src/ProTable/index.tsx | 45 ++++++++++++------- packages/ui/src/ProTable/style/index.ts | 9 +--- 6 files changed, 85 insertions(+), 27 deletions(-) create mode 100644 packages/ui/src/ProTable/demo/light-filter.tsx diff --git a/packages/design/src/table/index.tsx b/packages/design/src/table/index.tsx index 77393f477..1cb426437 100644 --- a/packages/design/src/table/index.tsx +++ b/packages/design/src/table/index.tsx @@ -11,7 +11,7 @@ import React, { useContext, useEffect, useState } from 'react'; import ConfigProvider from '../config-provider'; import Typography from '../typography'; import enUS from '../locale/en-US'; -import useStyle, { genTableStyle } from './style'; +import useStyle from './style'; import type { AnyObject } from '../_util/type'; import useDefaultPagination from './hooks/useDefaultPagination'; @@ -246,6 +246,6 @@ export default Object.assign(ForwardTable, { Column: AntTable.Column, ColumnGroup: AntTable.ColumnGroup, Summary: AntTable.Summary as typeof Summary, - genTableStyle, + useStyle, useDefaultPagination, }); diff --git a/packages/ui/src/ProTable/demo/basic.tsx b/packages/ui/src/ProTable/demo/basic.tsx index 50a3dc080..b77f789e9 100644 --- a/packages/ui/src/ProTable/demo/basic.tsx +++ b/packages/ui/src/ProTable/demo/basic.tsx @@ -30,7 +30,14 @@ const App: React.FC = () => { }); } - return ; + return ( + + ); }; export default App; diff --git a/packages/ui/src/ProTable/demo/light-filter.tsx b/packages/ui/src/ProTable/demo/light-filter.tsx new file mode 100644 index 000000000..2c6c3e665 --- /dev/null +++ b/packages/ui/src/ProTable/demo/light-filter.tsx @@ -0,0 +1,43 @@ +import React from 'react'; +import { ProTable } from '@oceanbase/ui'; + +const App: React.FC = () => { + const columns = [ + { + title: '姓名', + dataIndex: 'name', + key: 'name', + }, + { + title: '年龄', + dataIndex: 'age', + key: 'age', + }, + { + title: '住址', + dataIndex: 'address', + key: 'address', + }, + ]; + + const dataSource = []; + for (let i = 1; i < 100; i++) { + dataSource.push({ + key: i, + name: '胡彦斌' + i, + age: 32, + address: `西湖区湖底公园${i}号`, + }); + } + + return ( + + ); +}; + +export default App; diff --git a/packages/ui/src/ProTable/index.md b/packages/ui/src/ProTable/index.md index ad91d2def..a2aa8dda9 100644 --- a/packages/ui/src/ProTable/index.md +++ b/packages/ui/src/ProTable/index.md @@ -13,6 +13,8 @@ nav: + + ## API | 参数 | 说明 | 类型 | 默认值 | 版本 | diff --git a/packages/ui/src/ProTable/index.tsx b/packages/ui/src/ProTable/index.tsx index 492133f29..7cc5376d9 100644 --- a/packages/ui/src/ProTable/index.tsx +++ b/packages/ui/src/ProTable/index.tsx @@ -3,6 +3,7 @@ import { ProTable as AntProTable } from '@ant-design/pro-components'; import type { ProTableProps } from '@ant-design/pro-components'; import classNames from 'classnames'; import { ConfigProvider, Table } from '@oceanbase/design'; +import useLightFilterStyle from '../LightFilter/style'; import useStyle from './style'; export { ProTableProps }; @@ -15,26 +16,38 @@ const ProTable: typeof AntProTable = ({ ...restProps }) => { const { getPrefixCls } = useContext(ConfigProvider.ConfigContext); + + // customize Table style + const tablePrefixCls = getPrefixCls('table', customizePrefixCls); + const { wrapSSR: tableWrapSSR } = Table.useStyle(tablePrefixCls); + const pagination = Table.useDefaultPagination(customPagination); + + // customize LightFilter style + const lightFilterPrefixCls = getPrefixCls('pro-form-light-filter', customizePrefixCls); + const { wrapSSR: lightFilterWrapSSR } = useLightFilterStyle(lightFilterPrefixCls); + const prefixCls = getPrefixCls('pro-table', customizePrefixCls); const { wrapSSR } = useStyle(prefixCls); const proTableCls = classNames(className); - const pagination = Table.useDefaultPagination(customPagination); - - return wrapSSR( - + return tableWrapSSR( + lightFilterWrapSSR( + wrapSSR( + + ) + ) ); }; diff --git a/packages/ui/src/ProTable/style/index.ts b/packages/ui/src/ProTable/style/index.ts index 4b17201b0..03efc4d9c 100644 --- a/packages/ui/src/ProTable/style/index.ts +++ b/packages/ui/src/ProTable/style/index.ts @@ -1,5 +1,4 @@ import type { CSSObject } from '@ant-design/cssinjs'; -import { Table } from '@oceanbase/design'; import type { GenerateStyle } from '@oceanbase/design/es/theme'; import { genComponentStyleHook } from '../../_util/genComponentStyleHook'; import type { OBToken } from '../../_util/genComponentStyleHook'; @@ -10,13 +9,7 @@ export const genProTableStyle: GenerateStyle = (token: OBToken): CSSObj export default (prefixCls: string) => { const useStyle = genComponentStyleHook('ProTable', token => { - return [ - Table.genTableStyle({ - ...token, - componentCls: `${token.antCls}-table`, - } as any), - genProTableStyle(token as OBToken), - ]; + return [genProTableStyle(token as OBToken)]; }); return useStyle(prefixCls); };