mirror of
https://github.com/gosticks/react-table.git
synced 2026-08-19 16:30:21 +00:00
Compare commits
4
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
932f529105 | ||
|
|
bc35e3262d | ||
|
|
1a6056859a | ||
|
|
834ab4b4a7 |
Vendored
+1
-1
File diff suppressed because one or more lines are too long
Vendored
+1
-1
File diff suppressed because one or more lines are too long
@@ -26,6 +26,7 @@ export const useRows = props => {
|
|||||||
const row = {
|
const row = {
|
||||||
original,
|
original,
|
||||||
index: i,
|
index: i,
|
||||||
|
path: [i], // used to create a key for each row even if not nested
|
||||||
subRows,
|
subRows,
|
||||||
depth,
|
depth,
|
||||||
cells: [{}] // This is a dummy cell
|
cells: [{}] // This is a dummy cell
|
||||||
|
|||||||
@@ -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
|
const { path } = row
|
||||||
row.getRowProps = props =>
|
row.getRowProps = props =>
|
||||||
mergeProps(
|
mergeProps(
|
||||||
{ key: ['row', path].join('_') },
|
{ key: ['row', ...path].join('_') },
|
||||||
applyHooks(api.hooks.getRowProps, row, api),
|
applyHooks(api.hooks.getRowProps, row, api),
|
||||||
props
|
props
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
export { useTable } from './hooks/useTable'
|
export { useTable } from './hooks/useTable'
|
||||||
export { useColumns } from './hooks/useColumns'
|
export { useColumns } from './hooks/useColumns'
|
||||||
export { useRows } from './hooks/useRows'
|
export { useRows } from './hooks/useRows'
|
||||||
|
export { useSimpleLayout } from './hooks/useSimpleLayout'
|
||||||
export { useExpanded } from './hooks/useExpanded'
|
export { useExpanded } from './hooks/useExpanded'
|
||||||
export { useFilters } from './hooks/useFilters'
|
export { useFilters } from './hooks/useFilters'
|
||||||
export { useGroupBy } from './hooks/useGroupBy'
|
export { useGroupBy } from './hooks/useGroupBy'
|
||||||
|
|||||||
Reference in New Issue
Block a user