UNPKG

@itwin/itwinui-react

Version:

A react component library for iTwinUI

29 lines (28 loc) 859 B
import * as React from 'react'; import { ExpanderColumn, EXPANDER_CELL_ID } from '../columns/index.js'; export const useExpanderCell = (subComponent, expanderCell, isRowDisabled) => (hooks) => { if (!subComponent) return; hooks.allColumns.push((columns) => { let hasExpanderColumn = columns.find((c) => c.id === EXPANDER_CELL_ID); if (hasExpanderColumn) return columns; let expanderColumn = ExpanderColumn({ subComponent, isDisabled: isRowDisabled, }); return [ { ...expanderColumn, Cell: expanderCell ? (cellProps) => React.createElement( React.Fragment, null, expanderCell(cellProps), ) : expanderColumn.Cell, }, ...columns, ]; }); };