import {
  ActionType,
  EditableFormInstance,
  EditableProTable,
  type EditableProTableProps,
  type ParamsType,
  ProColumns,
} from '@ant-design/pro-components';
import { Form, Table } from 'antd';
import React, { forwardRef, useEffect, useRef, useState } from 'react';

interface EditableProTableComProps<
  T extends Record<string, any>,
  U extends ParamsType = ParamsType,
> extends Omit<
    EditableProTableProps<T, U>,
    'editableFormRef' | 'recordCreatorProps'
  > {
  editableFormRef?: React.Ref<any>;
  recordCreatorProps?: any;
}

const EditableProTableCom = forwardRef(
  <T extends Record<string, any>>(
    props: EditableProTableComProps<T>,
    ref: React.Ref<any>,
  ) => {
    // 提取不应该直接传递给 EditableProTable 的属性
    const { value, columns, ...restProps } = props;

    return (
      <EditableProTable
        value={value}
        columns={columns}
        actionRef={ref}
        recordCreatorProps={false}
        {...restProps}
      />
    );
  },
);

// const EditableProTableCom = <T extends Record<string, any>>(
//   props: EditableProTableComProps<T>
// ) => {
//   // 提取不应该直接传递给 EditableProTable 的属性
//   const { value, columns, ...restProps } = props;

//   return (
//     <EditableProTable
//       value={value}
//       columns={columns}
//       recordCreatorProps={false}
//       {...restProps}
//     />
//   );
// };
export default EditableProTableCom as <T extends Record<string, any>>(
  props: EditableProTableComProps<T> & { ref?: React.Ref<any> },
) => React.ReactElement;
