Skip to content

Commit

Permalink
chore: lint
Browse files Browse the repository at this point in the history
  • Loading branch information
uyarn committed Sep 19, 2024
1 parent ba1c5ab commit 0e35ea8
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 8 deletions.
1 change: 1 addition & 0 deletions src/table/TR.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,7 @@ export default function TR(props: TrProps) {
}
// eslint-disable-next-line
}, [virtualConfig.isVirtualScroll, trRef, row]);

const columnVNodeList = props.columns?.map((col, colIndex) => {
const cellSpans: RowspanColspan = {};
const params = {
Expand Down
2 changes: 1 addition & 1 deletion src/table/defaultProps.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ export const primaryTableDefaultProps: Pick<
columnControllerVisible: undefined,
columns: [],
expandIcon: true,
defaultExpandedRowKeys: undefined,
defaultExpandedRowKeys: [],
multipleSort: false,
reserveSelectedRowOnPaginate: true,
defaultSelectedRowKeys: [],
Expand Down
10 changes: 3 additions & 7 deletions src/table/hooks/useRowExpand.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -29,22 +29,19 @@ export default function useRowExpand(props: TdPrimaryTableProps) {
defaultExpandedRowKeys: props.defaultExpandedRowKeys || [],
});

// 用于在可展开收起的场景给各行添加类名使用,如果没有配置则不加相关类名
const innerExpandedRowKeys = props.expandedRowKeys || props.defaultExpandedRowKeys ? tExpandedRowKeys : undefined;
const showExpandedRow = Boolean(expandedRow);

const getExpandedRowClass = useCallback(
(params) => {
if (!innerExpandedRowKeys) return null;
if (!showExpandedRow) return null;
const { row } = params;
const { rowKey } = row;
const currentRowKey = get(row, rowKey || 'id');
return tableExpandClasses[tExpandedRowKeys?.includes(currentRowKey) ? 'rowExpanded' : 'rowFolded'];
},
[tExpandedRowKeys, innerExpandedRowKeys, tableExpandClasses],
[tExpandedRowKeys, tableExpandClasses, showExpandedRow],
);

const showExpandedRow = Boolean(expandedRow);

const showExpandIconColumn = props.expandIcon !== false && showExpandedRow;

const isFirstColumnFixed = props.columns?.[0]?.fixed === 'left';
Expand Down Expand Up @@ -131,7 +128,6 @@ export default function useRowExpand(props: TdPrimaryTableProps) {
getExpandColumn,
renderExpandedRow,
onInnerExpandRowClick,
innerExpandedRowKeys,
getExpandedRowClass,
};
}

0 comments on commit 0e35ea8

Please sign in to comment.