1.5.2 • Published 5 years ago

@zzwing/react-table v1.5.2

Weekly downloads
1
License
MIT
Repository
github
Last release
5 years ago

React Fixed Table

CircleCI codecov

Edit n3ml9m0zz4

Document

Document

Install

$ npm install @zzwing/react-table

import { Table, HorizontalScrollBar } from '@zzwing/react-table'

Usage

Table

PropsTypeDefaultDesc
dataSourceArray[]dataSource
columscolumnsProps[][]columns props
rowKeystringnonerow key, unique, eg: id/a.b.c
classNamestring''table classname
styleobject{}table style
multiLinebooleanfalseif row is multiline, need to set true
offsetTopnumber0thead fixed-top offset
scrollBarOffsetnumber5scrollbar fixed-bottom offset
onRow(record: T) => TableRowProp--a function return table row props
type PlainObject = {
  [key: string]: any
}

interface TableProp<T extends PlainObject = PlainObject> {
  columns?: ColumnProps<T>[]
  dataSource?: T[]
  rowKey?: string
  className?: string
  style?: React.CSSProperties
  offsetTop?: number
  multiLine?: boolean
  scrollBarOffset?: number
  onRow?: (record: T) => TableRowProp
}

ColumnsProps

PropsTypeDefaultDesc
titleanynonecolumn title
keystringnonecolumn key, default is dataIndex
dataIndexstring''data field in each record, support chain eg: a.b.c.d
render(text, record, index) => any() => {}column render function
alignleft | right | centercentertext align
classNamestring''--
fixedleft | right | rightfalsefixed flag
interface ColumnProps<T> {
  title?: React.ReactNode
  key?: React.Key
  dataIndex?: keyof T | string
  render?: (text: any, record: T, index: number) => React.ReactNode
  align?: 'left' | 'right' | 'center'
  className?: string
  fixed?: boolean | ('left' | 'right')
}

BaseTable

like Table, but not fixed left and `right

export interface BaseTableProp<T extends PlainObject = PlainObject> {
  columns?: ColumnProps<T>[]
  dataSource?: T[]
  rowKey?: string
  maxTop?: number
  getRef?: React.RefObject<HTMLTableElement>
  className?: string
  multiLine?: boolean
  style?: React.CSSProperties
  offsetTop?: number
  onRow?: (record: T) => TableRowProp
}

ScrollBar

PropsTypeDefaultDesc
classNamestring''scrollbar className
scrollTargetstring | HTMLElementwindownative scroll container
offsetBottomnumber5scrollbar bottom offset
interface HorizontalScrollBarProp {
  className?: string
  scrollTarget?: string | HTMLElement
  offsetBottom?: number
}
1.5.2

5 years ago

1.5.1

5 years ago

1.4.1

5 years ago

1.4.0

5 years ago

1.3.3

5 years ago

1.3.2

5 years ago

1.3.0

5 years ago

1.2.0

5 years ago

1.1.3

5 years ago

1.1.2

5 years ago

1.1.1

5 years ago

1.1.0

5 years ago

1.0.0

6 years ago