mirror of
https://github.com/gosticks/react-table.git
synced 2026-01-30 05:17:38 +00:00
Merge
This commit is contained in:
commit
2ab4a65dcc
2
dist/index.js
vendored
2
dist/index.js
vendored
File diff suppressed because one or more lines are too long
2
dist/index.js.map
vendored
2
dist/index.js.map
vendored
File diff suppressed because one or more lines are too long
@ -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
|
||||
|
||||
37
src/hooks/useSimpleLayout.js
Normal file
37
src/hooks/useSimpleLayout.js
Normal 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
|
||||
}
|
||||
@ -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
|
||||
)
|
||||
|
||||
@ -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'
|
||||
|
||||
Loading…
Reference in New Issue
Block a user