table-context.ts 1.3 KB

1234567891011121314151617181920212223242526272829303132
  1. /* eslint-disable max-len */
  2. import React from 'react';
  3. import { noop } from 'lodash';
  4. import { ColumnProps, GetVirtualizedListRef, RowKey } from './interface';
  5. import {
  6. BaseRowKeyType,
  7. BaseHeadWidth,
  8. } from '@douyinfe/semi-foundation/table/foundation';
  9. export interface TableContextProps {
  10. children?: React.ReactNode;
  11. anyColumnFixed?: boolean;
  12. flattenedColumns?: ColumnProps[];
  13. tableWidth?: number;
  14. headWidths?: BaseHeadWidth[][];
  15. setHeadWidths?: (headWidth?: BaseHeadWidth[], index?: number) => void;
  16. getHeadWidths?: (index?: number) => number[];
  17. getCellWidths?: (flattenColumns: ColumnProps[], flattenedWidths?: number[], ignoreScrollBarKey?: boolean) => number[];
  18. handleRowExpanded?: (expanded: boolean, realKey: RowKey<any>, domEvent: React.MouseEvent<HTMLElement>) => void;
  19. renderExpandIcon?: (record: Record<string, any>, isNested?: boolean, groupKey?: string | number) => React.ReactNode;
  20. renderSelection?: (record?: Record<string, any>, isHeader?: boolean) => React.ReactNode;
  21. getVirtualizedListRef?: GetVirtualizedListRef;
  22. setBodyHasScrollbar?: (bodyHasScrollBar: boolean) => void;
  23. }
  24. const TableContext = React.createContext<TableContextProps>({
  25. headWidths: [],
  26. setHeadWidths: noop,
  27. handleRowExpanded: noop,
  28. });
  29. export default TableContext;