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

search-filter-tree

v0.0.1

Published

基于antd-Tree组件的搜索过滤树

Downloads

8

Readme

SearchTree 搜索树组件

何时使用

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

安装

npm install search-filter-tree --save

yarn add search-filter-tree

在代码中使用

import React from "react";
import SearchTree from "search-filter-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: "电信-华南"
        }
      ]
    }
  ];
}

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 | 选中或取消选中 |