Skip to content

Commit 32c8b4a

Browse files
committed
chore: expanded info
1 parent c9a7126 commit 32c8b4a

File tree

4 files changed

+23
-5
lines changed

4 files changed

+23
-5
lines changed

docs/examples/virtual.tsx

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -204,6 +204,7 @@ const Demo = () => {
204204
expandable={{
205205
expandedRowRender: () => 2333,
206206
columnWidth: 60,
207+
expandedRowClassName: () => 'good-one',
207208
}}
208209
// onRow={() => ({ className: 'rowed' })}
209210
rowClassName="nice-try"

src/StaticTable/BodyLine.tsx

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,11 +34,24 @@ const BodyLine = React.forwardRef<HTMLDivElement, BodyLineProps>((props, ref) =>
3434
const rowInfo = useRowInfo(record, rowKey, index, indent);
3535

3636
// ========================== Expand ==========================
37-
const { rowSupportExpand, expanded, rowProps } = rowInfo;
37+
const { rowSupportExpand, expanded, rowProps, expandedRowRender, expandedRowClassName } = rowInfo;
3838

3939
let expandRowNode: React.ReactElement;
4040
if (rowSupportExpand && expanded) {
41-
expandRowNode = <>233</>;
41+
const expandContent = expandedRowRender(record, index, indent + 1, expanded);
42+
const computedExpandedRowClassName = expandedRowClassName?.(record, index, indent);
43+
44+
expandRowNode = (
45+
<div
46+
className={classNames(
47+
`${prefixCls}-expanded-row`,
48+
`${prefixCls}-expanded-row-level-${indent + 1}`,
49+
computedExpandedRowClassName,
50+
)}
51+
>
52+
{expandContent}
53+
</div>
54+
);
4255
}
4356

4457
// ========================== Render ==========================

src/StaticTable/index.tsx

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,12 @@ import type { CompareProps } from '@rc-component/context/lib/Immutable';
22
import * as React from 'react';
33
import { INTERNAL_HOOKS } from '..';
44
import type { CustomizeScrollBody } from '../interface';
5-
import Table, { type TableProps } from '../Table';
5+
import Table, { DEFAULT_PREFIX, type TableProps } from '../Table';
66
import Grid from './BodyGrid';
77
import { StaticContext } from './context';
88
import { makeImmutable } from '../context/TableContext';
99
import { warning } from 'rc-util';
10+
import classNames from 'classnames';
1011

1112
const renderBody: CustomizeScrollBody<any> = (rawData, props) => {
1213
const { ref, onScroll } = props;
@@ -24,7 +25,7 @@ export interface StaticTableProps<RecordType> extends Omit<TableProps<RecordType
2425
const PRESET_COLUMN_WIDTH = 100;
2526

2627
function VirtualTable<RecordType>(props: StaticTableProps<RecordType>) {
27-
const { columns, scroll } = props;
28+
const { columns, scroll, prefixCls = DEFAULT_PREFIX, className } = props;
2829

2930
const { x: scrollX, y: scrollY } = scroll || {};
3031
let mergedScrollX = scrollX;
@@ -44,6 +45,7 @@ function VirtualTable<RecordType>(props: StaticTableProps<RecordType>) {
4445
<StaticContext.Provider value={{ scrollX: mergedScrollX, scrollY }}>
4546
<Table
4647
{...props}
48+
className={classNames(className, `${prefixCls}-virtual`)}
4749
scroll={{
4850
...scroll,
4951
x: mergedScrollX,

src/Table.tsx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,8 @@ import Column from './sugar/Column';
7575
import ColumnGroup from './sugar/ColumnGroup';
7676
import { getColumnsKey, validateValue } from './utils/valueUtil';
7777

78+
export const DEFAULT_PREFIX = 'rc-table';
79+
7880
// Used for conditions cache
7981
const EMPTY_DATA = [];
8082

@@ -160,7 +162,7 @@ function defaultEmpty() {
160162
function Table<RecordType extends DefaultRecordType>(tableProps: TableProps<RecordType>) {
161163
const props = {
162164
rowKey: 'key',
163-
prefixCls: 'rc-table',
165+
prefixCls: DEFAULT_PREFIX,
164166
emptyText: defaultEmpty,
165167
...tableProps,
166168
};

0 commit comments

Comments
 (0)