mirror of
https://github.com/ant-design/ant-design.git
synced 2024-11-24 02:59:58 +08:00
type: revert Table generic with any (#50372)
* fix: table generic default any * feat: = AnyObject
This commit is contained in:
parent
7bd9d54a62
commit
7d66a8e5cf
@ -1,8 +1,7 @@
|
||||
import type { AnyObject } from '../_util/type';
|
||||
import type { ColumnType } from './interface';
|
||||
|
||||
export interface ColumnProps<RecordType extends AnyObject = AnyObject>
|
||||
extends ColumnType<RecordType> {
|
||||
export interface ColumnProps<RecordType = AnyObject> extends ColumnType<RecordType> {
|
||||
children?: null;
|
||||
}
|
||||
|
||||
|
@ -4,7 +4,7 @@ import type { AnyObject } from '../_util/type';
|
||||
import type { ColumnProps } from './Column';
|
||||
import type { ColumnType } from './interface';
|
||||
|
||||
export interface ColumnGroupProps<RecordType extends AnyObject = AnyObject>
|
||||
export interface ColumnGroupProps<RecordType = AnyObject>
|
||||
extends Omit<ColumnType<RecordType>, 'children'> {
|
||||
children:
|
||||
| React.ReactElement<ColumnProps<RecordType>>
|
||||
|
@ -4,7 +4,7 @@ import classNames from 'classnames';
|
||||
import type { AnyObject } from '../_util/type';
|
||||
import type { TableLocale } from './interface';
|
||||
|
||||
interface DefaultExpandIconProps<RecordType extends AnyObject = AnyObject> {
|
||||
interface DefaultExpandIconProps<RecordType = AnyObject> {
|
||||
prefixCls: string;
|
||||
record: RecordType;
|
||||
expanded: boolean;
|
||||
|
@ -59,7 +59,7 @@ export type { ColumnsType, TablePaginationConfig };
|
||||
|
||||
const EMPTY_LIST: AnyObject[] = [];
|
||||
|
||||
interface ChangeEventInfo<RecordType extends AnyObject = AnyObject> {
|
||||
interface ChangeEventInfo<RecordType = AnyObject> {
|
||||
pagination: {
|
||||
current?: number;
|
||||
pageSize?: number;
|
||||
@ -113,8 +113,7 @@ export interface TableProps<RecordType = AnyObject>
|
||||
}
|
||||
|
||||
/** Same as `TableProps` but we need record parent render times */
|
||||
export interface InternalTableProps<RecordType extends AnyObject = AnyObject>
|
||||
extends TableProps<RecordType> {
|
||||
export interface InternalTableProps<RecordType = AnyObject> extends TableProps<RecordType> {
|
||||
_renderTimes: number;
|
||||
}
|
||||
|
||||
|
@ -1,5 +1,5 @@
|
||||
import React, { useContext, useEffect, useRef, useState } from 'react';
|
||||
import type { GetRef, InputRef } from 'antd';
|
||||
import type { GetRef, InputRef, TableProps } from 'antd';
|
||||
import { Button, Form, Input, Popconfirm, Table } from 'antd';
|
||||
|
||||
type FormInstance<T> = GetRef<typeof Form<T>>;
|
||||
@ -96,8 +96,6 @@ const EditableCell: React.FC<React.PropsWithChildren<EditableCellProps>> = ({
|
||||
return <td {...restProps}>{childNode}</td>;
|
||||
};
|
||||
|
||||
type EditableTableProps = Parameters<typeof Table>[0];
|
||||
|
||||
interface DataType {
|
||||
key: React.Key;
|
||||
name: string;
|
||||
@ -105,7 +103,7 @@ interface DataType {
|
||||
address: string;
|
||||
}
|
||||
|
||||
type ColumnTypes = Exclude<EditableTableProps['columns'], undefined>;
|
||||
type ColumnTypes = Exclude<TableProps['columns'], undefined>;
|
||||
|
||||
const App: React.FC = () => {
|
||||
const [dataSource, setDataSource] = useState<DataType[]>([
|
||||
|
@ -120,7 +120,7 @@ function renderFilterItems({
|
||||
|
||||
export type TreeColumnFilterItem = ColumnFilterItem & FilterTreeDataNode;
|
||||
|
||||
export interface FilterDropdownProps<RecordType extends AnyObject = AnyObject> {
|
||||
export interface FilterDropdownProps<RecordType = AnyObject> {
|
||||
tablePrefixCls: string;
|
||||
prefixCls: string;
|
||||
dropdownPrefixCls: string;
|
||||
|
@ -5,7 +5,7 @@ import type { AnyObject } from '../../../_util/type';
|
||||
import Input from '../../../input';
|
||||
import type { FilterSearchType, TableLocale } from '../../interface';
|
||||
|
||||
interface FilterSearchProps<RecordType extends AnyObject = AnyObject> {
|
||||
interface FilterSearchProps<RecordType = AnyObject> {
|
||||
value: string;
|
||||
onChange: (e: React.ChangeEvent<HTMLInputElement>) => void;
|
||||
filterSearch: FilterSearchType<RecordType>;
|
||||
|
@ -17,7 +17,7 @@ import type {
|
||||
import { getColumnKey, getColumnPos, renderColumnTitle } from '../../util';
|
||||
import FilterDropdown, { flattenKeys } from './FilterDropdown';
|
||||
|
||||
export interface FilterState<RecordType extends AnyObject = AnyObject> {
|
||||
export interface FilterState<RecordType = AnyObject> {
|
||||
column: ColumnType<RecordType>;
|
||||
key: Key;
|
||||
filteredKeys?: FilterKey;
|
||||
@ -203,7 +203,7 @@ export const getFilterData = <RecordType extends AnyObject = AnyObject>(
|
||||
return filterDatas;
|
||||
};
|
||||
|
||||
export interface FilterConfig<RecordType extends AnyObject = AnyObject> {
|
||||
export interface FilterConfig<RecordType = AnyObject> {
|
||||
prefixCls: string;
|
||||
dropdownPrefixCls: string;
|
||||
mergedColumns: ColumnsType<RecordType>;
|
||||
|
@ -3,7 +3,7 @@ import * as React from 'react';
|
||||
import type { AnyObject } from '../../_util/type';
|
||||
import type { GetRowKey, Key } from '../interface';
|
||||
|
||||
interface MapCache<RecordType extends AnyObject = AnyObject> {
|
||||
interface MapCache<RecordType = AnyObject> {
|
||||
data?: readonly RecordType[];
|
||||
childrenColumnName?: string;
|
||||
kvMap?: Map<Key, RecordType>;
|
||||
|
@ -40,7 +40,7 @@ export const SELECTION_NONE = 'SELECT_NONE' as const;
|
||||
|
||||
const EMPTY_LIST: React.Key[] = [];
|
||||
|
||||
interface UseSelectionConfig<RecordType extends AnyObject = AnyObject> {
|
||||
interface UseSelectionConfig<RecordType = AnyObject> {
|
||||
prefixCls: string;
|
||||
pageData: RecordType[];
|
||||
data: RecordType[];
|
||||
|
@ -53,7 +53,7 @@ const nextSortDirection = (sortDirections: SortOrder[], current: SortOrder | nul
|
||||
return sortDirections[sortDirections.indexOf(current) + 1];
|
||||
};
|
||||
|
||||
export interface SortState<RecordType extends AnyObject = AnyObject> {
|
||||
export interface SortState<RecordType = AnyObject> {
|
||||
column: ColumnType<RecordType>;
|
||||
key: Key;
|
||||
sortOrder: SortOrder | null;
|
||||
@ -370,7 +370,7 @@ export const getSortData = <RecordType extends AnyObject = AnyObject>(
|
||||
});
|
||||
};
|
||||
|
||||
interface SorterConfig<RecordType extends AnyObject = AnyObject> {
|
||||
interface SorterConfig<RecordType = AnyObject> {
|
||||
prefixCls: string;
|
||||
mergedColumns: ColumnsType<RecordType>;
|
||||
onSorterChange: (
|
||||
|
@ -16,11 +16,11 @@ import type { TooltipProps } from '../tooltip';
|
||||
import type { INTERNAL_SELECTION_ITEM } from './hooks/useSelection';
|
||||
import type { InternalTableProps, TableProps } from './InternalTable';
|
||||
|
||||
export type RefTable = <RecordType extends AnyObject = AnyObject>(
|
||||
export type RefTable = <RecordType = AnyObject>(
|
||||
props: React.PropsWithChildren<TableProps<RecordType>> & React.RefAttributes<Reference>,
|
||||
) => React.ReactElement;
|
||||
|
||||
export type RefInternalTable = <RecordType extends AnyObject = AnyObject>(
|
||||
export type RefInternalTable = <RecordType = AnyObject>(
|
||||
props: React.PropsWithChildren<InternalTableProps<RecordType>> & React.RefAttributes<Reference>,
|
||||
) => React.ReactElement;
|
||||
|
||||
|
@ -3,7 +3,7 @@ import { ConfigProvider, Space, Switch, Table, Tag, Transfer } from 'antd';
|
||||
import type { GetProp, TableColumnsType, TableProps, TransferProps } from 'antd';
|
||||
import difference from 'lodash/difference';
|
||||
|
||||
type TableRowSelection<T extends object = object> = TableProps<T>['rowSelection'];
|
||||
type TableRowSelection<T> = TableProps<T>['rowSelection'];
|
||||
|
||||
type TransferItem = GetProp<TransferProps, 'dataSource'>[number];
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user