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

force-smart-table

v1.0.6

Published

May the force be with you !

Downloads

1

Readme

#Smart Table


Smart Table 是对Ant.Table组件的二次封装, 主要增加了常用功能 筛选器搜索.

其中筛选器包括表头筛选器和外部筛选器.

表头筛选器简化了原组件的参数, 自动收集指定字段的取值集合.

外部筛选器会取代表头筛选器, 在表格上方生成RadioButton的列表来展示, 适合选项较少的情况.

搜索组件可以在指定列上进行模糊搜索, 可以同时指定多个列. 版本2加入了高亮关键字的效果.

示例代码(主体):

import SmartTable from 'force-smart-table';

...
render() {
    return (
        <SmartTable
            dataSource={dataSource}
            columns={columns} // 筛选器配置见例设置部分
            search={['field1', 'field2']} // 指定在哪些字段上搜索
            keyword={keyword} // 可选参数, 传入外部的关键字来搜索
            autoFilterLabelWidth={true} // 自动计算外部筛选器Label的宽度
        />
    )
}

示例代码(例设置):

import {Slice} from 'smart-table/filters';

const mapStatus = {
    '1': 'done',
    '8': 'unknown'
};

...
const columns = [ 
    {dataIndex: 'content', title: '内容'},
    
    // 此列不显示
    {dataIndex: 'badData', title: 'xxx', hidden: true},
    
    // filter: true表示设置表头筛选器
    {dataIndex: 'id', title: 'ID', filter: true},
    {dataIndex: 'projectName', title: '项目名称'},
    
    // 直接传入map即可实现数据映射
    {dataIndex: 'status', title: '状态', filter: mapStatus, render: mapStatus},
    
    // 设置filter的同时设置buttonFilters表示使用外部按钮式筛选器
    // Slice是一个插件, 这里用其切取前四个字符表示年份
    {dataIndex: 'startTime', title: '开始时间', filter: Slice(0, 4), buttonFilters: true}
];

表格API


|名称|说明|类型|默认值| |-|-|-|-| |keyword|搜索关键字, 用于外部控制时|string|null| |hlKeyword|是否高亮显示搜索关键字|string|true| |search|指定搜索的列|Array<string>|null| |autoFilterLabelWidth|是否自动设置Label宽度|Boolean|undefined|

列API


|名称|说明|类型|默认值| |-|-|-|-| |filter|设置筛选器|false, FilterPlugin对象, map|false| |hidden|设置是否显示|Boolean|false| |buttonFilters|设置按钮式筛选器, 可能的值: true,lableObj (见附1)|Boolean|false| | lock | 是否对单元格使用LockBox | 见LockBox | "auto" |

附1:

// buttonFilters = labelConfig;
// 设置相关属性可以指定不同的显示名称, 设置自定义样式
labelConfig: {
    label: 'xxx',
    style: {...}
}

附2:

以上未例出的API同 Ant.Table.