chore: update table, list types (#2694)

* fix: table typo

* fix: list typo

* fix: update table, list return JSX.Element typo

* fix: xxxRender merge params

* fix: change table event return type `void`
This commit is contained in:
言肆 2020-08-17 21:12:17 +08:00 committed by GitHub
parent 17456b68fc
commit 54d2418249
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 516 additions and 470 deletions

View File

@ -4,21 +4,24 @@
import { AntdComponent } from '../component';
import { Meta } from '../meta';
import { VNodeChild } from 'vue';
export declare class ListItem extends AntdComponent {
static Meta: typeof Meta;
/**
* The actions content of list item. If itemLayout is vertical, shows the content on bottom,
* otherwise shows content on the far right.
* @type any (VNode[] | slot)
*/
actions: any;
$props: {
/**
* The actions content of list item. If itemLayout is vertical, shows the content on bottom,
* otherwise shows content on the far right.
* @type any (VNode[] | slot)
*/
actions?: VNodeChild | JSX.Element;
/**
* The extra content of list item. If itemLayout is vertical, shows the content on right,
* otherwise shows content on the far right.
* @type any (string | slot)
*/
extra: any;
/**
* The extra content of list item. If itemLayout is vertical, shows the content on right,
* otherwise shows content on the far right.
* @type any (string | slot)
*/
extra?: VNodeChild | JSX.Element;
};
}

186
types/list/list.d.ts vendored
View File

@ -3,104 +3,118 @@
// Definitions: https://github.com/vueComponent/ant-design-vue/types
import { AntdComponent } from '../component';
import { VNode } from 'vue';
import { VNodeChild } from 'vue';
import { Pagination } from '../pagination';
import { ListItem } from './list-item';
export declare type ColumnCount = '' | 1 | 2 | 3 | 4 | 6 | 8 | 12 | 24;
export declare class PaginationConfig extends Pagination {
position: 'top' | 'bottom' | 'both';
position?: 'top' | 'bottom' | 'both';
}
export interface Item {
item?: any;
index?: number;
}
export class List extends AntdComponent {
static Item: typeof ListItem;
/**
* Toggles rendering of the border around the list
* @default false
* @type boolean
*/
bordered: boolean;
$props: {
/**
* Toggles rendering of the border around the list
* @default false
* @type boolean
*/
bordered?: boolean;
/**
* List footer renderer
* @type any (string | slot)
*/
footer: any;
/**
* List footer renderer
* @type any (string | slot)
*/
footer?: VNodeChild | JSX.Element;
/**
* The grid type of list. You can set grid to something like {gutter: 16, column: 4}
* @type object
*/
grid: {
gutter: number;
column: ColumnCount;
xs: ColumnCount;
sm: ColumnCount;
md: ColumnCount;
lg: ColumnCount;
xl: ColumnCount;
xxl: ColumnCount;
/**
* The grid type of list. You can set grid to something like {gutter: 16, column: 4}
* @type object
*/
grid?: {
gutter?: number;
column?: ColumnCount;
xs?: ColumnCount;
sm?: ColumnCount;
md?: ColumnCount;
lg?: ColumnCount;
xl?: ColumnCount;
xxl?: ColumnCount;
};
/**
* List header renderer
* @type any (string | slot)
*/
header?: VNodeChild | JSX.Element;
/**
* The layout of list, default is horizontal,
* If a vertical list is desired, set the itemLayout property to vertical
*
* @type string
*/
itemLayout?: string | 'horizontal' | 'vertical';
/**
* Shows a loading indicator while the contents of the list are being fetched
* @default false
* @type boolean | object
*/
loading?: boolean | object;
/**
* Shows a load more content
* @type any (string | slot)
*/
loadMore?: VNodeChild | JSX.Element;
/**
* i18n text including empty text
* @default emptyText: 'No Data'
* @type object
*/
locale?: object;
/**
* Pagination config, hide it by setting it to false
* @default false
* @type boolean | object
*/
pagination?: boolean | PaginationConfig;
/**
* Toggles rendering of the split under the list item
* @default true
* @type boolean
*/
split?: boolean;
/**
* dataSource array for list
*/
dataSource?: any[];
/**
* Custom item renderer, slot="renderItem" and slot-scope="{ item, index }"
* @default null
* @type Function()
*/
renderItem?: (item?: Item) => VNodeChild | JSX.Element;
/**
* Specify the key that will be used for uniquely identify each element
* @default null
* @type Function
*/
rowKey?: (item: any) => string | number;
};
/**
* List header renderer
* @type any (string | slot)
*/
header: any;
/**
* The layout of list, default is horizontal, If a vertical list is desired, set the itemLayout property to vertical
* @type string
*/
itemLayout: string;
/**
* Shows a loading indicator while the contents of the list are being fetched
* @default false
* @type boolean | object
*/
loading: boolean | object;
/**
* Shows a load more content
* @type any (string | slot)
*/
loadMore: any;
/**
* i18n text including empty text
* @default emptyText: 'No Data'
* @type object
*/
locale: object;
/**
* Pagination config, hide it by setting it to false
* @default false
* @type boolean | object
*/
pagination: boolean | PaginationConfig;
/**
* Toggles rendering of the split under the list item
* @default true
* @type boolean
*/
split: boolean;
/**
* Custom item renderer, slot="renderItem" and slot-scope="item, index"
* @default null
* @type Function
*/
renderItem: (item: any, index: number) => VNode;
/**
* Specify the key that will be used for uniquely identify each element
* @default null
* @type Function
*/
rowKey: (item: any) => string | number;
}

8
types/meta.d.ts vendored
View File

@ -2,7 +2,7 @@
// Definitions by: akki-jat <https://github.com/akki-jat>
// Definitions: https://github.com/vueComponent/ant-design-vue/types
import { AntdComponent } from './component';
import { VNodeChild } from 'vue';
export declare class Meta {
$props: {
@ -10,18 +10,18 @@ export declare class Meta {
* The avatar of list item
* @type any (slot)
*/
avatar: any;
avatar?: VNodeChild;
/**
* The description of list item
* @type any (string | slot)
*/
description: any;
description?: string | VNodeChild;
/**
* The title of list item
* @type any (string | slot)
*/
title: any;
title?: string | VNodeChild;
};
}

View File

@ -3,18 +3,21 @@
// Definitions: https://github.com/vueComponent/ant-design-vue/types
import { AntdComponent } from '../component';
import { VNodeChild } from 'vue';
export declare class ColumnGroup extends AntdComponent {
/**
* Title of the column group
* @type any
*/
title: any;
$props: {
/**
* Title of the column group
* @type any
*/
title?: VNodeChild | JSX.Element;
/**
* When using columns, you can use this property to configure the properties that support the slot,
* such as slots: { title: 'XXX'}
* @type object
*/
slots: object;
/**
* When using columns, you can use this property to configure the properties that support the slot,
* such as slots: { title: 'XXX'}
* @type object
*/
slots?: object;
};
}

View File

@ -3,8 +3,7 @@
// Definitions: https://github.com/vueComponent/ant-design-vue/types
import { AntdComponent } from '../component';
import { VNode } from 'vue';
import { ScopedSlot } from 'vue/types/vnode';
import { VNodeChild } from 'vue';
export interface ColumnFilterItem {
text?: string;
@ -14,196 +13,179 @@ export interface ColumnFilterItem {
export declare type SortOrder = 'ascend' | 'descend';
export declare class Column extends AntdComponent {
/**
* specify how content is aligned
* @default 'left'
* @type string
*/
align?: 'left' | 'right' | 'center';
/**
* ellipsize cell content, not working with sorter and filters for now.
* tableLayout would be fixed when ellipsis is true.
* @default false
* @type boolean
*/
ellipsis?: boolean;
/**
* Span of this column's title
* @type number
*/
colSpan?: number;
/**
* Display field of the data record, could be set like a.b.c
* @type string
*/
dataIndex?: string;
/**
* Default filtered values
* @type string[]
*/
defaultFilteredValue?: string[];
/**
* Default order of sorted values: 'ascend' 'descend' null
* @type string
*/
defaultSortOrder?: SortOrder;
/**
* Customized filter overlay
* @type any (slot)
*/
filterDropdown?: any;
/**
* Whether filterDropdown is visible
* @type boolean
*/
filterDropdownVisible?: boolean;
/**
* Whether the dataSource is filtered
* @default false
* @type boolean
*/
filtered?: boolean;
/**
* Controlled filtered value, filter icon will highlight
* @type string[]
*/
filteredValue?: string[];
/**
* Customized filter icon
* @default false
* @type any
*/
filterIcon?: any;
/**
* Whether multiple filters can be selected
* @default true
* @type boolean
*/
filterMultiple?: boolean;
/**
* Filter menu config
* @type object[]
*/
filters?: ColumnFilterItem[];
/**
* Set column to be fixed: true(same as left) 'left' 'right'
* @default false
* @type boolean | string
*/
fixed?: boolean | 'left' | 'right';
/**
* Unique key of this column, you can ignore this prop if you've set a unique dataIndex
* @type string
*/
key?: string;
/**
* Renderer of the table cell. The return value should be a VNode, or an object for colSpan/rowSpan config
* @type Function | ScopedSlot
*/
customRender?: Function | ScopedSlot;
/**
* Sort function for local sort, see Array.sort's compareFunction. If you need sort buttons only, set to true
* @type boolean | Function
*/
sorter?: boolean | Function;
/**
* Order of sorted values: 'ascend' 'descend' false
* @type boolean | string
*/
sortOrder?: boolean | SortOrder;
/**
* supported sort way, could be 'ascend', 'descend'
* @default ['ascend', 'descend']
* @type string[]
*/
sortDirections?: string[];
/**
* Title of this column
* @type any (string | slot)
*/
title?: any;
/**
* Width of this column
* @type string | number
*/
width?: string | number;
/**
* Set props on per cell
* @type Function
*/
customCell?: (
record: any,
rowIndex: number,
) => {
props: object;
attrs: object;
on: object;
class: object;
style: object;
nativeOn: object;
};
/**
* Set props on per header cell
* @type
*/
customHeaderCell?: (
column: any,
) => {
props: object;
attrs: object;
on: object;
class: object;
style: object;
nativeOn: object;
};
/**
* Callback executed when the confirm filter button is clicked, Use as a filter event when using template or jsx
* @type Function
*/
onFilter?: Function;
/**
* Callback executed when filterDropdownVisible is changed, Use as a filterDropdownVisible event when using template or jsx
* @type Function
*/
onFilterDropdownVisibleChange?: (visible: boolean) => void;
/**
* When using columns, you can use this property to configure the properties that support the slot,
* such as slots: { filterIcon: 'XXX'}
* @type object
*/
slots?: object;
/**
* When using columns, you can use this property to configure the properties that support the slot-scope,
* such as scopedSlots: { customRender: 'XXX'}
* @type object
*/
scopedSlots?: object;
export interface Record {
text?: any;
record?: object;
index?: number;
}
export declare type CustomRenderFunction = (record: Record) => VNodeChild | JSX.Element;
export declare class Column extends AntdComponent {
$props: {
/**
* specify how content is aligned
* @default 'left'
* @type string
*/
align?: 'left' | 'right' | 'center';
/**
* ellipsize cell content, not working with sorter and filters for now.
* tableLayout would be fixed when ellipsis is true.
* @default false
* @type boolean
*/
ellipsis?: boolean;
/**
* Span of this column's title
* @type number
*/
colSpan?: number;
/**
* Display field of the data record, could be set like a.b.c
* @type string
*/
dataIndex?: string;
/**
* Default filtered values
* @type string[]
*/
defaultFilteredValue?: string[];
/**
* Default order of sorted values: 'ascend' 'descend' null
* @type string
*/
defaultSortOrder?: SortOrder;
/**
* Customized filter overlay
* @type any (slot)
*/
filterDropdown?: any;
/**
* Whether filterDropdown is visible
* @type boolean
*/
filterDropdownVisible?: boolean;
/**
* Whether the dataSource is filtered
* @default false
* @type boolean
*/
filtered?: boolean;
/**
* Controlled filtered value, filter icon will highlight
* @type string[]
*/
filteredValue?: string[];
/**
* Customized filter icon
* @default false
* @type any
*/
filterIcon?: any;
/**
* Whether multiple filters can be selected
* @default true
* @type boolean
*/
filterMultiple?: boolean;
/**
* Filter menu config
* @type object[]
*/
filters?: ColumnFilterItem[];
/**
* Set column to be fixed: true(same as left) 'left' 'right'
* @default false
* @type boolean | string
*/
fixed?: boolean | 'left' | 'right';
/**
* Unique key of this column, you can ignore this prop if you've set a unique dataIndex
* @type string
*/
key?: string;
/**
* Renderer of the table cell. The return value should be a VNode, or an object for colSpan/rowSpan config
* @type Function | ScopedSlot
*/
customRender?: CustomRenderFunction | VNodeChild | JSX.Element;
/**
* Sort function for local sort, see Array.sort's compareFunction. If you need sort buttons only, set to true
* @type boolean | Function
*/
sorter?: boolean | Function;
/**
* Order of sorted values: 'ascend' 'descend' false
* @type boolean | string
*/
sortOrder?: boolean | SortOrder;
/**
* supported sort way, could be 'ascend', 'descend'
* @default ['ascend', 'descend']
* @type string[]
*/
sortDirections?: string[];
/**
* Title of this column
* @type any (string | slot)
*/
title?: VNodeChild | JSX.Element;
/**
* Width of this column
* @type string | number
*/
width?: string | number;
/**
* Set props on per cell
* @type Function
*/
customCell?: (record: any, rowIndex: number) => object;
/**
* Set props on per header cell
* @type object
*/
customHeaderCell?: (column: any) => object;
/**
* Callback executed when the confirm filter button is clicked, Use as a filter event when using template or jsx
* @type Function
*/
onFilter?: Function;
/**
* Callback executed when filterDropdownVisible is changed, Use as a filterDropdownVisible event when using template or jsx
* @type Function
*/
onFilterDropdownVisibleChange?: (visible: boolean) => void;
/**
* When using columns, you can use this property to configure the properties that support the slot,
* such as slots: { filterIcon: 'XXX'}
* @type object
*/
slots?: object;
};
}

370
types/table/table.d.ts vendored
View File

@ -4,13 +4,13 @@
import { AntdComponent } from '../component';
import { Spin } from '../spin';
import { ScopedSlot, VNode } from 'vue/types/vnode';
import { Pagination } from '../pagination';
import { Column } from './column';
import { ColumnGroup } from './column-group';
import { VNodeChild } from 'vue';
export declare class PaginationConfig extends Pagination {
position: 'top' | 'bottom' | 'both';
position?: 'top' | 'bottom' | 'both';
}
export interface customSelection {
@ -28,7 +28,7 @@ export interface customSelection {
* @default undefined
* @type string | VNode
*/
text?: string | VNode;
text?: string | VNodeChild | JSX.Element;
/**
* On Select
@ -36,7 +36,7 @@ export interface customSelection {
* @default undefined
* @type Function
*/
onSelect?: (changeableRowKeys?: any) => any;
onSelect?: (changeableRowKeys?: any[]) => any;
}
export interface TableRowSelection {
@ -88,7 +88,7 @@ export interface TableRowSelection {
* Set the title of the selection column
* @type string | VNode
*/
columnTitle?: string | VNode;
columnTitle?: VNodeChild | JSX.Element;
/**
* Callback executed when selected rows change
@ -115,190 +115,234 @@ export interface TableRowSelection {
onSelectInvert?: (selectedRows: Object[]) => any;
}
export interface TableCustomRecord {
record?: any;
index?: number;
}
export interface ExpandedRowRenderRecord extends TableCustomRecord {
indent?: number;
expanded?: boolean;
}
export declare class Table extends AntdComponent {
static Column: typeof Column;
static ColumnGroup: typeof ColumnGroup;
/**
* Whether to show all table borders
* @default false
* @type boolean
*/
bordered: boolean;
$props: {
/**
* Whether to show all table borders
* @default false
* @type boolean
*/
bordered?: boolean;
/**
* The column contains children to display
* @default 'children'
* @type string | string[]
*/
childrenColumnName: string | string[];
/**
* The column contains children to display
* @default 'children'
* @type string | string[]
*/
childrenColumnName?: string | string[];
/**
* Columns of table
* @type any
*/
columns: any;
/**
* Columns of table
* @type array
*/
columns: any[];
/**
* Override default table elements
* @type object
*/
components: object;
/**
* Override default table elements
* @type object
*/
components?: object;
/**
* Data record array to be displayed
* @type any
*/
dataSource: any;
/**
* Data record array to be displayed
* @type array
*/
dataSource: any;
/**
* Expand all rows initially
* @default false
* @type boolean
*/
defaultExpandAllRows: boolean;
/**
* Expand all rows initially
* @default false
* @type boolean
*/
defaultExpandAllRows?: boolean;
/**
* Initial expanded row keys
* @type string[]
*/
defaultExpandedRowKeys: string[];
/**
* Initial expanded row keys
* @type string[]
*/
defaultExpandedRowKeys?: string[];
/**
* Current expanded row keys
* @type string[]
*/
expandedRowKeys: string[];
/**
* Current expanded row keys
* @type string[]
*/
expandedRowKeys?: string[];
/**
* Expanded container render for each row
* @type Function
*/
expandedRowRender: (record: any, index: number, indent: number, expanded: boolean) => any;
/**
* Expanded container render for each row
* @type Function
*/
expandedRowRender?: (record?: ExpandedRowRenderRecord) => any;
/**
* Customize row expand Icon.
* @type Function | ScopedSlot
*/
expandIcon: Function | ScopedSlot;
/**
* Customize row expand Icon.
* @type Function | VNodeChild
*/
expandIcon?: Function | VNodeChild | JSX.Element;
/**
* Whether to expand row by clicking anywhere in the whole row
* @default false
* @type boolean
*/
expandRowByClick: boolean;
/**
* Whether to expand row by clicking anywhere in the whole row
* @default false
* @type boolean
*/
expandRowByClick?: boolean;
/**
* Table footer renderer
* @type Function | ScopedSlot
*/
footer: Function | ScopedSlot;
/**
* The index of `expandIcon` which column will be inserted when `expandIconAsCell` is false. default 0
*/
expandIconColumnIndex?: number;
/**
* Indent size in pixels of tree data
* @default 15
* @type number
*/
indentSize: number;
/**
* Table footer renderer
* @type Function | VNodeChild
*/
footer?: Function | VNodeChild | JSX.Element;
/**
* Loading status of table
* @default false
* @type boolean | object
*/
loading: boolean | Spin;
/**
* Indent size in pixels of tree data
* @default 15
* @type number
*/
indentSize?: number;
/**
* i18n text including filter, sort, empty text, etc
* @default { filterConfirm: 'Ok', filterReset: 'Reset', emptyText: 'No Data' }
* @type object
*/
locale: object;
/**
* Loading status of table
* @default false
* @type boolean | object
*/
loading?: boolean | Spin | VNodeChild | JSX.Element;
/**
* Pagination config or [Pagination] (/components/pagination/), hide it by setting it to false
* @type boolean | PaginationConfig
*/
pagination: boolean | PaginationConfig;
/**
* i18n text including filter, sort, empty text, etc
* @default { filterConfirm: 'Ok', filterReset: 'Reset', emptyText: 'No Data' }
* @type object
*/
locale?: object;
/**
* Row's className
* @type Function
*/
rowClassName: (record: any, index: number) => string;
/**
* Pagination config or [Pagination] (/components/pagination/), hide it by setting it to false
* @type boolean | PaginationConfig
*/
pagination?: boolean | PaginationConfig;
/**
* Row's unique key, could be a string or function that returns a string
* @default 'key'
* @type string | Function
*/
rowKey: string | Function;
/**
* Row's className
* @type Function
*/
rowClassName?: (record?: TableCustomRecord) => string;
/**
* Row selection config
* @type object
*/
rowSelection: TableRowSelection;
/**
* Row's unique key, could be a string or function that returns a string
* @default 'key'
* @type string | Function
*/
rowKey?: string | Function;
/**
* Set horizontal or vertical scrolling, can also be used to specify the width and height of the scroll area.
* It is recommended to set a number for x, if you want to set it to true,
* you need to add style .ant-table td { white-space: nowrap; }.
* @type object
*/
scroll: { x: number | true; y: number };
/**
* Row selection config
* @type object
*/
rowSelection?: TableRowSelection;
/**
* Whether to show table header
* @default true
* @type boolean
*/
showHeader: boolean;
/**
* Set horizontal or vertical scrolling, can also be used to specify the width and height of the scroll area.
* It is recommended to set a number for x, if you want to set it to true,
* you need to add style .ant-table td { white-space: nowrap; }.
* @type object
*/
scroll?: { x: number | true; y: number };
/**
* Size of table
* @default 'default'
* @type string
*/
size: 'default' | 'middle' | 'small' | 'large';
/**
* Whether to show table header
* @default true
* @type boolean
*/
showHeader?: boolean;
/**
* Table title renderer
* @type Function | ScopedSlot
*/
title: Function | ScopedSlot;
/**
* Size of table
* @default 'default'
* @type string
*/
size?: 'default' | 'middle' | 'small' | 'large';
/**
* Set props on per header row
* @type Function
*/
customHeaderRow: (
column: any,
index: number,
) => {
props: object;
attrs: object;
on: object;
class: object;
style: object;
nativeOn: object;
/**
* Table title renderer
* @type Function | ScopedSlot
*/
title?: Function | VNodeChild | JSX.Element;
/**
* Set props on per header row
* @type Function
*/
customHeaderRow?: (column: any, index: number) => object;
/**
* Set props on per row
* @type Function
*/
customRow?: (record: any, index: number) => object;
/**
* `table-layout` attribute of table element
* `fixed` when header/columns are fixed, or using `column.ellipsis`
*
* @see https://developer.mozilla.org/en-US/docs/Web/CSS/table-layout
* @version 1.5.0
*/
tableLayout?: 'auto' | 'fixed' | string;
/**
* the render container of dropdowns in table
* @param triggerNode
* @version 1.5.0
*/
getPopupContainer?: (triggerNode?: HTMLElement) => HTMLElement;
/**
* Data can be changed again before rendering.
* The default configuration of general user empty data.
* You can configured globally through [ConfigProvider](https://antdv.com/components/config-provider-cn/)
*
* @version 1.5.4
*/
transformCellText?: Function;
/**
* Callback executed when pagination, filters or sorter is changed
* @param pagination
* @param filters
* @param sorter
* @param currentDataSource
*/
onChange?: (pagination: object, filters, sorter, { currentDataSource }) => void;
/**
* Callback executed when the row expand icon is clicked
*
* @param expanded
* @param record
*/
onExpand: (expanded, record) => void;
/**
* Callback executed when the expanded rows change
* @param expandedRows
*/
onExpandedRowsChange: (expandedRows: any) => void;
};
/**
* Set props on per row
* @type Function
*/
customRow: (
record: any,
index: number,
) => {
props: object;
attrs: object;
on: object;
class: object;
style: object;
nativeOn: object;
};
transformCellText: Function;
}