UNPKG

@itwin/itwinui-react

Version:

A react component library for iTwinUI

42 lines (41 loc) 1.21 kB
'use strict'; Object.defineProperty(exports, '__esModule', { value: true, }); Object.defineProperty(exports, 'useExpanderCell', { enumerable: true, get: function () { return useExpanderCell; }, }); const _interop_require_wildcard = require('@swc/helpers/_/_interop_require_wildcard'); const _react = /*#__PURE__*/ _interop_require_wildcard._(require('react')); const _index = require('../columns/index.js'); const useExpanderCell = (subComponent, expanderCell, isRowDisabled) => (hooks) => { if (!subComponent) return; hooks.allColumns.push((columns) => { let hasExpanderColumn = columns.find( (c) => c.id === _index.EXPANDER_CELL_ID, ); if (hasExpanderColumn) return columns; let expanderColumn = (0, _index.ExpanderColumn)({ subComponent, isDisabled: isRowDisabled, }); return [ { ...expanderColumn, Cell: expanderCell ? (cellProps) => _react.createElement( _react.Fragment, null, expanderCell(cellProps), ) : expanderColumn.Cell, }, ...columns, ]; }); };