Skip to content

Add List InnerProps export, Enable external input of custom styles #796

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions docs/examples/basic.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,16 @@ class Demo extends React.Component {
<Tree
ref={this.setTreeRef}
className="myCls"
innerProps={
{
title: '内部List包裹 自定义props注入 Inner Inject Title',
style: {
display: 'flex',
flexDirection: 'column',
backgroundColor: 'white'
}
}
}
showLine
checkable
defaultExpandAll
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "rc-tree",
"version": "5.8.2",
"version": "5.8.3",
"description": "tree ui component for react",
"engines": {
"node": ">=10.x"
Expand Down
4 changes: 4 additions & 0 deletions src/NodeList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import {
import MotionTreeNode from './MotionTreeNode';
import { findExpandedKeys, getExpandRange } from './utils/diffUtil';
import { getKey, getTreeNodeProps } from './utils/treeUtil';
import { InnerProps } from 'rc-virtual-list/lib/Filler';

const HIDDEN_STYLE = {
width: 0,
Expand Down Expand Up @@ -92,6 +93,7 @@ interface NodeListProps<TreeDataType extends BasicDataNode> {
height: number;
itemHeight: number;
virtual?: boolean;
innerProps?: InnerProps;

onKeyDown?: React.KeyboardEventHandler<HTMLDivElement>;
onFocus?: React.FocusEventHandler<HTMLDivElement>;
Expand Down Expand Up @@ -158,6 +160,7 @@ const NodeList = React.forwardRef<NodeListRef, NodeListProps<any>>((props, ref)
height,
itemHeight,
virtual,
innerProps,

focusable,
activeItem,
Expand Down Expand Up @@ -326,6 +329,7 @@ const NodeList = React.forwardRef<NodeListRef, NodeListProps<any>>((props, ref)
itemHeight={itemHeight}
prefixCls={`${prefixCls}-list`}
ref={listRef}
innerProps={innerProps}
onVisibleChange={(originList, fullList) => {
const originSet = new Set(originList);
const restList = fullList.filter(item => !originSet.has(item));
Expand Down
4 changes: 4 additions & 0 deletions src/Tree.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ import {
getTreeNodeProps,
warningWithoutKey,
} from './utils/treeUtil';
import { InnerProps } from 'rc-virtual-list/lib/Filler';

const MAX_RETRY_TIMES = 10;

Expand Down Expand Up @@ -188,6 +189,7 @@ export interface TreeProps<TreeDataType extends BasicDataNode = DataNode> {
itemHeight?: number;
itemScrollOffset?: number;
virtual?: boolean;
innerProps?: InnerProps;

// direction for drag logic
direction?: Direction;
Expand Down Expand Up @@ -1376,6 +1378,7 @@ class Tree<TreeDataType extends DataNode | BasicDataNode = DataNode> extends Rea
height,
itemHeight,
virtual,
innerProps,
titleRender,
dropIndicatorRender,
onContextMenu,
Expand Down Expand Up @@ -1470,6 +1473,7 @@ class Tree<TreeDataType extends DataNode | BasicDataNode = DataNode> extends Rea
height={height}
itemHeight={itemHeight}
virtual={virtual}
innerProps={innerProps}
focusable={focusable}
focused={focused}
tabIndex={tabIndex}
Expand Down