import React, { ForwardRefExoticComponent, HTMLAttributes, ReactElement, forwardRef, } from 'react'; import { observer } from 'mobx-react-lite'; import { FiltersMap, KeyedItem } from '@wix/bex-core'; import { TableSectionsState } from './TableSectionsState'; import { CollectionSectionHeader } from '../CollectionSectionHeader'; export interface TableSectionRowProps extends HTMLAttributes { rowData: KeyedItem; state: TableSectionsState; RegularTrElement: ForwardRefExoticComponent<{ children: ReactElement[]; rowData: { id: string }; className: string; }>; } const _TableSectionRow = forwardRef< HTMLTableRowElement, TableSectionRowProps >(({ state, RegularTrElement, rowData, ...props }, ref) => { const { children, className, style } = props; const isSectionRow = state.isSectionRow(rowData); const contentWidth = state.table.toolbar.itemsContentRect.rect.width; const sectionContentWidth = contentWidth ? `${contentWidth}px` : '100%'; const regularTrElementProps = { ...props, rowData, className: className || '', children: (children as ReactElement[]) || [], }; if (state.isInvisibleRow(rowData)) { return ( ); } if (isSectionRow && Array.isArray(children) && children.length > 0) { const result = state.getSectionWithCount(rowData); if (!result) { return ; } const { sectionId, sectionIndex, section, collapsible } = result; return (
); } return ; }); export const TableSectionRow = observer(_TableSectionRow);