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

@sinoui/data-table

v0.1.31

Published

sinoui数据表格

Downloads

141

Readme

sinoui-data-table

sinoui 数据表格组件。

roadmap

next

  • 100%单元测试
  • 支持不分页渲染所有的数据
  • 数据分组展示
  • demo:添加<Toolbar>展示

v1.0.0

  • <TableColumn/>组件的方式定义表格
  • 支持分页
  • 支持主题定制
  • 支持排序
  • 支持数据行选择
  • 无数据时显示提示
  • 可监听数据行单击和双击事件

使用教程

安装

sinoui-data-table 依赖sinoui-components,所以需要同时安装 sinoui-data-table 和 sinoui-components 以及 styled-components:

yarn add sinoui-components sinoui-data-table styled-components

例子

准备数据:

import moment from 'moment';

const users = [];

const begin = new Date(1980, 0, 18);

for (let i = 0; i < 100; i += 1) {
  users.push({
    id: i,
    userName: `张三${i + 1}`,
    age: 21,
    sex: '男',
    telephone: '13455555555',
    birthday: moment(begin)
      .add(i, 'month')
      .toDate(),
  });
}

function getSortedUsers(name, direction) {
  return name
    ? users
        .slice()
        .sort(
          (user1, user2) =>
            direction === 'desc'
              ? user2[name] - user1[name]
              : user1[name] - user2[name],
        )
    : users;
}

使用DataTable展示人员信息:

import DataTable, { TableColumn } from '@sinoui/data-table';
import { withState } from 'recompose';

const enhance = withState('sort', 'setSort', null);

const DataTableDemo = enhance(({ sort, setSort, ...props }) => (
  <DataTable
    selectable
    data={getSortedUsers(sort && sort.name, sort && sort.direction)}
    onChange={(pageNo, pageSize, _sort) => {
      setSort(_sort);
    }}
    onSelect={action('选择行事件')}
    onRowClick={action('单击一行数据')}
    onRowDblClick={action('双击一行数据')}
    keyName="id"
    {...props}
  >
    <TableColumn
      name="userName"
      title="姓名"
      sortable
      sortActive
      sortDirection="asc"
      width={150}
    />
    <TableColumn name="sex" title="性别" sortable width={80} />
    <TableColumn name="age" title="年龄" sortable numeric width={80} />
    <TableColumn
      name="birthday"
      title="出生日期"
      sortable
      render={(data) => moment(data).format('YYYY-MM-DD')}
      width={200}
      numeric
    />
    <TableColumn name="telephone" title="联系电话" width={200} numeric />
  </DataTable>
));