This commit is contained in:
tannerlinsley 2019-04-29 12:41:02 -06:00
commit 2ab4a65dcc
7 changed files with 42 additions and 3 deletions

2
dist/index.js vendored

File diff suppressed because one or more lines are too long

2
dist/index.js.map vendored

File diff suppressed because one or more lines are too long

View File

@ -26,6 +26,7 @@ export const useRows = props => {
const row = {
original,
index: i,
path: [i], // used to create a key for each row even if not nested
subRows,
depth,
cells: [{}] // This is a dummy cell

View File

@ -0,0 +1,37 @@
export const useSimpleLayout = props => {
const {
hooks: {
columns: columnsHooks,
getHeaderProps,
getCellProps
}
} = props
columnsHooks.push((columns, api) => {
columns.forEach(column => {
column.visible =
typeof column.show === 'function' ? column.show(api) : !!column.show
})
getHeaderProps.push(column => ({
style: {
boxSizing: 'border-box',
width: column.width !== undefined ? `${column.width}px` : 'auto'
}
}))
getCellProps.push(cell => {
return {
style: {
boxSizing: 'border-box',
width: cell.column.width !== undefined ? `${cell.column.width}px` : 'auto'
}
}
})
return columns
})
return props
}

View File

@ -143,7 +143,7 @@ export const useTable = (props, ...plugins) => {
const { path } = row
row.getRowProps = props =>
mergeProps(
{ key: ['row', path].join('_') },
{ key: ['row', ...path].join('_') },
applyHooks(api.hooks.getRowProps, row, api),
props
)

View File

@ -1,6 +1,7 @@
export { useTable } from './hooks/useTable'
export { useColumns } from './hooks/useColumns'
export { useRows } from './hooks/useRows'
export { useSimpleLayout } from './hooks/useSimpleLayout'
export { useExpanded } from './hooks/useExpanded'
export { useFilters } from './hooks/useFilters'
export { useGroupBy } from './hooks/useGroupBy'