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

xy-select

v1.3.4

Published

基于React的下拉列表组件

Downloads

45

Readme

| IE | Chrome | Firefox | Opera | Safari | | ------------------------------------------------------------------------------------------ | -------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------- | | IE 10+ ✔ | Chrome 31.0+ ✔ | Firefox 31.0+ ✔ | Opera 30.0+ ✔ | Safari 7.0+ ✔ |

NPM version node version npm download

xy-select

xy-select

下拉列表组件。

特性

  • [x] 支持多选
  • [x] Option 支持深度嵌套和自定义
  • [x] option 支持过滤, select 可以搜索
  • [x] 支持方向键上下导航,并且跳过禁用的。

安装

# yarn
yarn add xy-select

使用例子

import React from "react";
import ReactDOM from "react-dom";
import { Select, OptGroup, Option } from "xy-select";
ReactDOM.render(
    <Select>
        <OptGroup label="编程语言">
            <Option value="C">C</Option>
            <Option value="C++">C++</Option>
            <Option value="Object-C">Object-C</Option>
            <Option value="JavaScript">JavaScript</Option>
            <Option value="C#">C#</Option>
            <Option value="VB">VB</Option>
            <Option value="GO">GO</Option>
        </OptGroup>
    </Select>,
    container,
);

何时使用

  • 弹出一个下拉菜单给用户选择操作,用于代替原生的选择器,或者需要一个更优雅的多选器时。
  • 当选项少时(少于 5 项),建议直接将选项平铺,使用 Radio 是更好的选择。

API

Select

| 属性 | 说明 | 类型 | 默认值 | | --------------- | ------------------------------------------------------------ | ---------------------------------------------- | -------- | | value | 选中值 | any/any[] | 无 | | defaultValue | 默认选中值 | any/any[] | 无 | | filter | 是否过滤 option, 提供过滤函数则过滤 | (cfg: OptionConfig, search: string) => boolean | 无 | | autoFocus | 是否焦点 | boolean | false | | disabled | 是否禁用 | boolean | false | | multiple | 是否多选 | boolean | false | | searchMode | 是否搜索模式, 启用搜索模式点击下拉列表会显示输入框, 进行搜索 | boolean | false | | popupClassName | 弹出内容类名 | string | 无 | | stretch | 弹出框是否宽度与 Select 宽度对齐 | boolean | true | | placeholder | 占位符文本 | React.ReactNode | "请选择" | | onChange | 下拉列表选中值改变回调 | (value: any) => void | 无 | | onBlur | onBlur 事件 | (e: React.FocusEvent) => void | 无 | | onSearch | 搜索事件, 此事件自带节流函数 | (search: string) => void | 无 | | empyPlaceholder | 空内容占位符, 内容为空时提示文本 | string | 无 |

OptGroup

| 属性 | 说明 | 类型 | 默认值 | | -------- | ------------------ | --------------- | ------ | | label | 标签组名 | string | 无 | | children | 标签组内的 options | React.ReactNode | 无 |

Option

| 属性 | 说明 | 类型 | 默认值 | | -------- | -------------------------------------------------------------------------- | --------------- | ------ | | label | 标签名, 对自动提取得标签不满意, 或 children 内无法提取字符串, 则需手动指定 | string | 无 | | value | 选中的值 | string/number | 无 | | children | 内容 | React.ReactNode | 无 | | disabled | 是否禁用 | boolean | false | | divided | 是否显示分割线 | boolean | false |

开发

yarn run start

例子

http://localhost:6006

测试

yarn run test

开源许可

xy-select is released under the MIT license.