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

igroot-search-tree

v0.0.1

Published

Downloads

1

Readme

SearchTree 搜索树组件

何时使用

文件夹、组织架构、生物分类、国家地区等等,世间万物的大多数结构都是树形结构。使用树控件可以完整展现其中的层级关系,并具有展开收起选择等交互功能。

当子节点内容较多需要搜索并高亮展示时,使用搜索树可快速找到目标节点。

安装

sl add -c igroot-search-tree

在代码中使用

import React from "react";
import SearchTree from "igroot-search-tree";

const App = () => {
  return (
    <SearchTree
      placeholder="输入节点名称"
      checkable={true}
      dataSource={mock()}
      onCheck={(keys, key, checked) => console.log(keys, key, checked)}
    />
  );
};

function mock() {
  return [
    {
      key: "global",
      title: "global",
      children: []
    },
    {
      key: "dx",
      title: "电信",
      children: [
        {
          key: "dx-huadong",
          title: "电信-华东"
        },
        {
          key: "dx-xian",
          title: "电信-西安"
        },
        {
          key: "dx-huanan",
          title: "电信-华南"
        },
        {
          key: "dx-huazhong",
          title: "电信-华中"
        },
        {
          key: "dx-xibei",
          title: "电信-西北"
        },
        {
          key: "dx-dongbei",
          title: "电信-东北"
        }
      ]
    },
    {
      key: "lt",
      title: "联通",
      children: [
        {
          key: "lt-xibu",
          title: "联通-西部"
        },
        {
          key: "lt-dongbei",
          title: "联通-东北"
        },
        {
          key: "lt-huanan",
          title: "联通-华南"
        },
        {
          key: "lt-huadong",
          title: "联通-华东"
        },
        {
          key: "lt-huazhong",
          title: "联通-华中"
        },
        {
          key: "lt-huabei",
          title: "联通-华北"
        },
      ]
    },
    {
      key: "yd",
      title: "移动",
      children: [
        {
          key: "yd-xibu",
          title: "移动-西部"
        },
        {
          key: "yd-dongbei",
          title: "移动-东北"
        },
        {
          key: "yd-huanan",
          title: "移动-华南"
        },
        {
          key: "yd-huadong",
          title: "移动-华东"
        },
        {
          key: "yd-huazhong",
          title: "移动-华中"
        },
        {
          key: "yd-huabei",
          title: "移动-华北"
        },
      ]
    }
  ];
}

ReactDOM.render(<App />, mountNode);

API

| 参数 | 是否必填 | 说明 | 类型 | 默认值 | -------- | ----------| ----- | ---- | ---- | | dataSource | 必填 | 数据源 | array | - | | placeholder | 非必填| 搜索框提示的文本 | string | "Search" | | parentCheckedAble| 非必填 | 父节点是否可选择 | bool | false | | parentNodeHide | 非必填 | 过滤节点时父节点是否隐藏 | bool | false | | childNodeHide | 非必填 | 过滤节点时子节点是否隐藏 | bool | true |

数据源dataSource格式

// 每个节点key值必须唯一
[
  {
    key:"1",
    title:"1",
    children:[
      {
        key:"1-1",
        title:"1-1"
      }
    ]
  }
]

注意

  1. react版本尽量在16.8.0之后,否则可能出现未知的问题。
  2. onCheck事件与Tree组件返回的结果不同,返回的参数为:

| 参数 | 说明 | | --- | --- | | keys | 已选择的全部树节点 | | key | 选择的树节点key | | checked | 选中或取消选中 |