Table.d.ts 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117
  1. /**
  2. * Feature:
  3. * - fixed not need to set width
  4. * - support `rowExpandable` to config row expand logic
  5. * - add `summary` to support `() => ReactNode`
  6. *
  7. * Update:
  8. * - `dataIndex` is `array[]` now
  9. * - `expandable` wrap all the expand related props
  10. *
  11. * Removed:
  12. * - expandIconAsCell
  13. * - useFixedHeader
  14. * - rowRef
  15. * - columns[number].onCellClick
  16. * - onRowClick
  17. * - onRowDoubleClick
  18. * - onRowMouseEnter
  19. * - onRowMouseLeave
  20. * - getBodyWrapper
  21. * - bodyStyle
  22. *
  23. * Deprecated:
  24. * - All expanded props, move into expandable
  25. */
  26. import type { CompareProps } from '@rc-component/context/lib/Immutable';
  27. import * as React from 'react';
  28. import { EXPAND_COLUMN, INTERNAL_HOOKS } from './constant';
  29. import { FooterComponents } from './Footer';
  30. import type { ColumnsType, ColumnType, DefaultRecordType, Direction, ExpandableConfig, GetComponentProps, GetRowKey, LegacyExpandableProps, PanelRender, Reference, RowClassName, TableComponents, TableLayout, TableSticky } from './interface';
  31. import Column from './sugar/Column';
  32. import ColumnGroup from './sugar/ColumnGroup';
  33. export declare const DEFAULT_PREFIX = "rc-table";
  34. export interface TableProps<RecordType = any> extends Omit<LegacyExpandableProps<RecordType>, 'showExpandColumn'> {
  35. prefixCls?: string;
  36. className?: string;
  37. style?: React.CSSProperties;
  38. children?: React.ReactNode;
  39. data?: readonly RecordType[];
  40. columns?: ColumnsType<RecordType>;
  41. rowKey?: string | keyof RecordType | GetRowKey<RecordType>;
  42. tableLayout?: TableLayout;
  43. scroll?: {
  44. x?: number | true | string;
  45. y?: number | string;
  46. };
  47. /** Config expand rows */
  48. expandable?: ExpandableConfig<RecordType>;
  49. indentSize?: number;
  50. rowClassName?: string | RowClassName<RecordType>;
  51. footer?: PanelRender<RecordType>;
  52. summary?: (data: readonly RecordType[]) => React.ReactNode;
  53. caption?: React.ReactNode;
  54. id?: string;
  55. showHeader?: boolean;
  56. components?: TableComponents<RecordType>;
  57. onRow?: GetComponentProps<RecordType>;
  58. onHeaderRow?: GetComponentProps<readonly ColumnType<RecordType>[]>;
  59. emptyText?: React.ReactNode | (() => React.ReactNode);
  60. direction?: Direction;
  61. sticky?: boolean | TableSticky;
  62. rowHoverable?: boolean;
  63. onScroll?: React.UIEventHandler<HTMLDivElement>;
  64. /**
  65. * @private Internal usage, may remove by refactor. Should always use `columns` instead.
  66. *
  67. * !!! DO NOT USE IN PRODUCTION ENVIRONMENT !!!
  68. */
  69. internalHooks?: string;
  70. /**
  71. * @private Internal usage, may remove by refactor. Should always use `columns` instead.
  72. *
  73. * !!! DO NOT USE IN PRODUCTION ENVIRONMENT !!!
  74. */
  75. transformColumns?: (columns: ColumnsType<RecordType>) => ColumnsType<RecordType>;
  76. /**
  77. * @private Internal usage, may remove by refactor.
  78. *
  79. * !!! DO NOT USE IN PRODUCTION ENVIRONMENT !!!
  80. */
  81. tailor?: boolean;
  82. /**
  83. * @private Internal usage, may remove by refactor.
  84. *
  85. * !!! DO NOT USE IN PRODUCTION ENVIRONMENT !!!
  86. */
  87. getContainerWidth?: (ele: HTMLElement, width: number) => number;
  88. /**
  89. * @private Internal usage, may remove by refactor.
  90. *
  91. * !!! DO NOT USE IN PRODUCTION ENVIRONMENT !!!
  92. */
  93. internalRefs?: {
  94. body: React.MutableRefObject<HTMLDivElement>;
  95. };
  96. /**
  97. * @private Internal usage, may remove by refactor.
  98. *
  99. * !!! DO NOT USE IN PRODUCTION ENVIRONMENT !!!
  100. */
  101. measureRowRender?: (measureRow: React.ReactNode) => React.ReactNode;
  102. }
  103. declare function Table<RecordType extends DefaultRecordType>(tableProps: TableProps<RecordType>, ref: React.Ref<Reference>): React.JSX.Element;
  104. export type ForwardGenericTable = (<RecordType extends DefaultRecordType = any>(props: TableProps<RecordType> & React.RefAttributes<Reference>) => React.ReactElement) & {
  105. displayName?: string;
  106. };
  107. export declare function genTable(shouldTriggerRender?: CompareProps<typeof Table>): ForwardGenericTable;
  108. declare const ImmutableTable: ForwardGenericTable;
  109. type ImmutableTableType = typeof ImmutableTable & {
  110. EXPAND_COLUMN: typeof EXPAND_COLUMN;
  111. INTERNAL_HOOKS: typeof INTERNAL_HOOKS;
  112. Column: typeof Column;
  113. ColumnGroup: typeof ColumnGroup;
  114. Summary: typeof FooterComponents;
  115. };
  116. declare const _default: ImmutableTableType;
  117. export default _default;