diff --git a/docs/demo/components.md b/docs/demo/components.md new file mode 100644 index 000000000..a3bc3ee9b --- /dev/null +++ b/docs/demo/components.md @@ -0,0 +1,8 @@ +--- +title: components +nav: + title: Demo + path: /demo +--- + + diff --git a/docs/examples/components.tsx b/docs/examples/components.tsx new file mode 100644 index 000000000..b7647f52d --- /dev/null +++ b/docs/examples/components.tsx @@ -0,0 +1,40 @@ +import React from 'react'; +import Table from 'rc-table'; + +const data = []; +for (let i = 0; i < 100; i += 1) { + data.push({ + key: i, + a: `a${i}`, + b: `b${i}`, + c: `c${i}`, + }); +} + +const table = (props: any) => { + return ( + <> +
header table
+ {props.children}
+ + ); +}; + +const Demo = () => { + return ( +
+ + + ); +}; + +export default Demo; diff --git a/src/FixedHolder/index.tsx b/src/FixedHolder/index.tsx index 25fc5d1dd..55ed9e80c 100644 --- a/src/FixedHolder/index.tsx +++ b/src/FixedHolder/index.tsx @@ -63,11 +63,13 @@ const FixedHolder = React.forwardRef>( ...restProps } = props; - const { prefixCls, scrollbarSize, isSticky } = useContext(TableContext, [ + const { prefixCls, scrollbarSize, isSticky, getComponent } = useContext(TableContext, [ 'prefixCls', 'scrollbarSize', 'isSticky', + 'getComponent', ]); + const TableComponent = getComponent(['header', 'table'], 'table'); const combinationScrollBarSize = isSticky && !fixHeader ? 0 : scrollbarSize; @@ -146,7 +148,7 @@ const FixedHolder = React.forwardRef>( [stickyClassName]: !!stickyClassName, })} > -
>( columns: columnsWithScrollbar, flattenColumns: flattenColumnsWithScrollbar, })} -
+
); }); diff --git a/src/interface.ts b/src/interface.ts index 9513d3ce4..ee2199b7d 100644 --- a/src/interface.ts +++ b/src/interface.ts @@ -155,6 +155,7 @@ export type CustomizeScrollBody = ( export interface TableComponents { table?: CustomizeComponent; header?: { + table?: CustomizeComponent; wrapper?: CustomizeComponent; row?: CustomizeComponent; cell?: CustomizeComponent; diff --git a/tests/FixedColumn.spec.tsx b/tests/FixedColumn.spec.tsx index 5b8585686..7f252a396 100644 --- a/tests/FixedColumn.spec.tsx +++ b/tests/FixedColumn.spec.tsx @@ -284,4 +284,18 @@ describe('Table.FixedColumn', () => { }); }); }); + describe('components.table by sticky', () => { + it('render', async () => { + const table = props => { + return ( + <> +
header table
+ {props.children}
+ + ); + }; + const { container } = render(); + expect(container.querySelector('.healer-table')).toBeTruthy(); + }); + }); });