npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

r-org-tree

v1.1.1

Published

org-tree

Downloads

7

Readme

介绍

react的组织树组件

使用方式

import React, { useState } from 'react'
import { OrgTree } from 'r-org-tree'
import { DataProps } from 'r-org-tree/es/components/OrgTree'

const horizontal = false; // true:横向  false:纵向
const collapsable = false; // true:可折叠 false:不可折叠 
const expandAll = true; // true: 全部展开 false:全部折叠 

interface DemoProps {
	// 自己添加
}

const Demo: React.FC<DemoProps> = ({

}) => {
	const [value, setValue] = useState()

	const data: DataProps = {
		id: 0,
		label: '一级',
		children: [
			{
				id: 1,
				label: <div>二级内容1</div>,
				conditionList: '条件项',
				children: [
					{
						id: 4,
						label: '三级内容1',
						conditionList: '年后111',
					},
					{
						id: 5,
						label: '三级内容2'
					}
				]
			},
			{
				id: 2,
				label: <div>二级内容1</div>,
				children: [{ id: 44, label: 'demo' }]
			}
		]
	}

	const handleClick = (_e, data) => {
		console.log('data', data)
	}

	return (
		<OrgTree
			data={data}
			activeId={value}
			horizontal={horizontal}
			collapsable={collapsable}
			expandAll={expandAll}
			onClick={handleClick}
		/>
	)
}

属性

| 参数 | 说明 | 类型 | 默认值 | 是否必填 | | ------------------ | ------------------------------------------------------------ | ------------------------------------------------------------ | ------------------------------------------------------------ | -------- | | data | 数据源 | json | - | 是 | | labelWidth | label项宽度 | string | number | - | 否 | | horizontal | 是否水平 | boolean | false | 否 | | collapsable | 是否可折叠 | boolean | false | 否 | | expandAll | 是否全部展开 | boolean | false | 否 | | activeId | 选中的id | string | number | - | 否 | | node | data中的 id label expand children的字段,可以将数据源的字段进行替换 | object | {id: 'id',label: 'label',expand: 'expand',children: 'children'} | 否 | | labelClassName | label自定义类名 | string | - | 否 | | conditionClassName | conditionList自定义类名 | string | - | 否 | | onClick | 点击label函数 | (e: React.MouseEventHandler, data: any) => void | - | 否 | | onConditionClick | 点击conditionList时触发函数 | (e: React.MouseEventHandler, data: any) => void | - | | | renderContent | 处理label的数据,渲染label函数 | (data: any) => void | - | 否 |