🚀 Socket Launch Week Day 5:Introducing Repository Access Permissions and Custom Roles.Learn more
Sign In

react-widget-tree-basic

Package Overview
Dependencies
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

react-widget-tree-basic

tree-basic

latest
Source
npmnpm
Version
1.0.1
Version published
Maintainers
1
Created
Source

react-widget-tree-basic

Tree基础组件

安装

npm install --save react-widget-tree-basic

使用

Edit react-widget-tree-basic


import TreeBasic from 'react-widget-tree-basic';

export default () => <TreeBasic loadData={...} itemRender={...} />

Interfaces

export interface TreeBasicProps<T = DataType> {
    /** 样式前缀 */
    prefixCls: string;
    /** 样式名称 */
    className?: string;
    /** 样式属性 */
    style?: React.CSSProperties;
    /** 树根节点ID */
    rootId: string | number | null;
    /** tree 数据结构 id 属性名称 */
    idField: string;
    /** tree 数据结构 leaf 属性名称 */
    leafField: string;
    /** tree 数据结构 parent 属性名称 */
    pidField: string;
    /** 最大展开层级限制没,默认:99 */
    maxDepth: number;
    /** 异步检测耗时机制,超过该时长即认定为异步加载,默认:16 ms */
    asyncTestDelay: number;
    /** 已展开的节点ID */
    expandedIds: (string | number)[];
    /** Tree数据加载器,必填 */
    loadData: (data: T, node: Node<T>) => T[] | Promise<any>;
    /** 自定义TreeNode的render返回 */
    nodeRender?: (props: nodeRenderProps<T>, item: React.ReactNode, children: React.ReactNode) => React.ReactNode;
    /** 自定义TreeItem的render返回,必填 */
    itemRender: (props: itemRenderProps<T>) => React.ReactNode;
    /** 自定义TreeNode的子节点渲染,一般动画需要使用。*/
    childrenRender: (props: childrenRenderProps<T>) => React.ReactNode;
    /** 异步加载时的加载内容返回,默认为:null */
    loadRender?: (props: LoadRenderProps<T>) => React.ReactNode;
    /** 自定义Tree容器组件*/
    rootComponent: React.ElementType;
}

export declare type renderProps<T> = Omit<TreeNodeProps<T>, "render" | "childrenRender">;
export interface TreeNodeProps<T = DataType> {
    node: Node<T>;
    isRoot: boolean;
    render?: (props: renderProps<T>, nodeItem: React.ReactNode, children: React.ReactNode) => React.ReactNode;
}

export interface TreeNodeProps {
	node: Node;
	isRoot: boolean;
	render?: (
		props: renderProps,
		nodeItem: React.ReactNode,
		children: React.ReactNode
	) => React.ReactNode;
}
export interface childrenRenderProps<T = DataType> {
    getChildren: () => React.ReactNode;
    expanded: boolean;
    loading: boolean;
    root: boolean;
    node: Node<T>;
    data: T;
}
export interface itemRenderProps<T = DataType> {
    expanded: boolean;
    loading: boolean;
    leaf: boolean;
    node: Node<T>;
    data: T;
}
export declare function toMarked(array: any[]): any;
export declare type DataType = Record<string, any>;
export declare type IdType = string | number;
export declare type nodeRenderProps<T> = renderProps<T>;
export interface LoadRenderProps<T = DataType> {
    root: boolean;
    node: Node;
    data: T;
}

defaultProps

{
	prefixCls: "rw-tree",
	rootId: null,
	idField: "id",
	leafField: "leaf",
	pidField: "pid",
	maxDepth: 99, 
	asyncTestDelay: 16,
	expandedIds: [],
	childrenRender(props) {
		if (!props.expanded) return null;
		return props.getChildren();
	},
	rootComponent: "div",
}

Keywords

react

FAQs

Package last updated on 24 Jun 2020

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts