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

react-edit-table

v0.1.1-experimental.4

Published

--- ## 一个可编辑的react表单组件

Downloads

6

Readme

react-edit-table


一个可编辑的react表单组件

How to use

指定表格的数据源 dataSource 为一个数组。

npm install react-edit-table
import ReactEditeTable { InputEditor, SelectEditor, CheckboxEditor, CheckboxRender } from 'react-edit-table'

const columns = [
  {
    title: '年级',
    dataIndex: 'grade',
    key: 'grade',
    editor: {
      type: 'select',
      component: SelectEditor,
      props: {
        options: [
          {
            value: 1,
            text: '1年级'
          }, 
          {
            value: 2,
            text: '2年级'
          }
        ]
      }
    },
  suffixInfo: <SuffixCaretDown />
  },
  {
    title: '姓名',
    dataIndex: 'name',
    key: 'name',
    editor: {
      type: 'input',
      component: InputEditor
    }
  }
];

const dataSource = [
  {
    key: '1',
    name: '张三',
    age: 32,
    grade: 1,
    start: false
  },
  {
    key: '2',
    name: '李四',
    age: 42,
    grade: 2,
    start: true
  },
];


<ReactEditeTable dataSource={dataSource} columns={columns} onChange={(newDataSource=>{}}/>;

API

Table

| 参数 | 说明 | 类型 | 默认值 | 版本 | | --- | --- | ---| ---| --- | | dataSource | 数据数组 | any[] | | | | columns | 数组,见Column | ColumnProps[] | - | | | onChange | 编辑完成后的回调,返回修改后的数据dataSource | function() | -| | | scrollBodyOptions | maxHeight,设置表体的最大高度,超出后将滚动;locateRow设置新增行操作之后,表单自动定位到的行位置 | {maxHeight: 100, locateRow: 0} | -| |

Columns

| 参数 | 说明 | 类型 | 默认值 | | --- | --- | --- | --- | --- | | title | 列头显示文字 | string || ReactNode | | | dataIndex | 列数据在数据项中对应的 key | string | | | editor | 编辑器 | 见Editor | | | | valueRender | 单元格内容生成函数 | function(value) | | | suffixInfo | 单元格内容后缀提示信息 | reactNode | |

Editor

| 参数 | 说明 | 类型 | 默认值 | | --- | --- | --- | --- | --- | | type | 编辑器类型 | input || select || checkbox || | componet | 编辑器: 可使用内置的编辑器组件,也可以自定义编辑器组件。自定义组件时,type为'cumstom' | reactComponent| | | props | 传给component使用的自定义props | object |

已内置的编辑器 Build-in editor component

import {
  InputEditor,
  SelectEditor,
  CheckboxEditor } from 'react-edit-table'

online examples