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

gitee-select-react

v0.8.0

Published

React Select

Downloads

34

Readme

gitee-select-react

选择框组件,基于 rc-select 实现,主要特性有:

  • 支持远程加载选项
  • 遵循 Gitee 企业版视觉规范
  • 提供无边框样式
  • 支持设置 autoWidth 属性让选择框自适应选项宽度

安装

npm install --save gitee-select-react

用法

以下是基于 rc-select 新增的一些属性的用法,其它属性的用法请参考 rc-select 的文档:https://github.com/react-component/select

remote

是否从远程加载选项列表。当值为 true 时,必须传入 onFetchMore。

remoteSearch

是否使用远程搜索功能。默认值为 true,在 select 组件中输入搜索词时,onFetchMore 函数可将参数中的 search 属性作为请求参数发送,让后端搜索选项。当值为 false 时,select 组件会直接对已加载的选项列表进行搜索,设置 filterOption 属性可自定义搜索方法。

<Select
  remote
  remoteSearch={false}
  onFetchMore={({ page }) => {
      /// ...
  }}
  filterOption={(search, option) => option.label.includes(search)}
/>

onFetchMore

加载更多选项的回调函数。函数的参数包含 page 和 search 属性。

<Select
    remote
    onFetchMore={({ page, search }) => {
        // 请求远程数据
        // ...
    }}
/>

extraOptions

额外的选项列表。该列表中选项会被前置插入在选项列表中,主要用于:

  • 提供预加载的选项。
  • 插入“全部”、“默认”、“未选择”等额外选项。

autoLoadSelectedOption

自动加载已选中的选项。当传入的 value 是不存在于已加载的选项列表的值时,Select 组件会调用 onFetchMore 加载缺失的选项列表,onFetchMore 的参数中的 missingOptions 记录了缺失的选项。

<Select
    autoLoadSelectedOption
    onFetchMore={({ page, search, missingOptions }) => {
        // 加载指定页的选项列表
        // ...

        // 如果有缺失的选项,则顺便加载它们
        if (Array.isArray(missingOptions)) {
            // ...
        }
    }}
/>

autoWidth

是否让 select 组件的宽度自适应内容。

noBorder

是否使用无边框样式。

searchInMenu

是否在下拉菜单中显示搜索输入框。

optionRender

选项的渲染方法。当 remote 为 true 时,可传入该方法来自定义选项的渲染结果。

<Select
  remote
  optionRender={(option) => (
    <Select.Option value={option.value} key={option.value}>
      <i className={`icon ${option.icon}`} />
      {option.label}
      {option.customContent}
    </Select.Option>
  )}
/>

开发

运行以下命令然后开始开发。

npm install
npm start