import React, { useEffect, useState } from 'react'; import { observer } from 'mobx-react-lite'; import { FiltersMap } from '@wix/bex-core'; import { NestedTableDataItem, NestedTableNodeState, } from '../../state/NestedTableState/NestedTableNodeState'; import { Box, TextButton } from '@wix/design-system'; import { ChevronRightSmall } from '@wix/wix-ui-icons-common'; import { Rotate } from '../Rotate'; import { MainCellLayout } from './MainCellLayout'; import type { NestedTableDragAndDrop } from '../NestedTableDragAndDrop/NestedTableDragAndDrop'; export interface NestedTableParentCellProps< C extends string, T, F extends FiltersMap, > { rowNum: number; state: NestedTableNodeState; item: NestedTableDataItem; dragAndDrop?: typeof NestedTableDragAndDrop; } function _NestedTableParentCell( props: NestedTableParentCellProps, ) { const { state: parentState, item, rowNum, dragAndDrop } = props; const { node: { collection }, } = parentState; const { originalKeyedItem, state: { nestedTable }, } = item; const renderProps = parentState.renderMainColumn?.(originalKeyedItem.item); const [state] = useState(() => item.state.createNode({ parent: originalKeyedItem, }), ); useEffect(() => { if (!state) { return; } state._rowNum = rowNum; }, [rowNum]); const _expanded = state?._expanded; return (
) } expandCollapseButton={ } /> } image={renderProps?.image} title={ renderProps?.title ?? collection.itemName(originalKeyedItem.item) } subtitle={renderProps?.subtitle} />
); } export const NestedTableParentCell = observer(_NestedTableParentCell);