Merge branches 'feat-vue3' and 'feat-vue3' of https://github.com/vueComponent/ant-design-vue into feat-vue3

pull/2717/head^2
tanjinzhou 2020-08-19 15:27:49 +08:00
commit aa7d2d92d1
7 changed files with 339 additions and 301 deletions

View File

@ -3,70 +3,73 @@
import { AntdComponent } from '../component'; import { AntdComponent } from '../component';
import { Option } from './option'; import { Option } from './option';
import { VNodeChild } from 'vue';
export declare class Mentions extends AntdComponent { export declare class Mentions extends AntdComponent {
static Option: typeof Option; static Option: typeof Option;
$props: {
/** /**
* Auto get focus when component mounted * Auto get focus when component mounted
* @default false * @default false
* @type boolean * @type boolean
*/ */
autofocus: boolean; autofocus?: boolean;
/** /**
* Default value * Default value
* @type string * @type string
*/ */
defaultValue: string; defaultValue?: string;
/** /**
* Customize filter option logic * Customize filter option logic
* @type false | (input: string, option: OptionProps) => boolean * @type false | (input: string, option: OptionProps) => boolean
*/ */
filterOption: false | ((input: string, option: Option) => boolean); filterOption?: false | ((input: string, option: Option) => boolean);
/** /**
* Set mentions content when not match * Set mentions content when not match
* @type any (string | slot) * @type any (string | slot)
*/ */
notFoundContent: any; notFoundContent?: VNodeChild | JSX.Element;
/** /**
* Set popup placement * Set popup placement
* @default 'top' * @default 'top'
* @type string * @type string
*/ */
placement: 'top' | 'bottom'; placement?: 'top' | 'bottom';
/** /**
* Set trigger prefix keyword * Set trigger prefix keyword
* @default '@' * @default '@'
* @type string | string[] * @type string | string[]
*/ */
prefix: string | string[]; prefix?: string | string[];
/** /**
* Set split string before and after selected mention * Set split string before and after selected mention
* @default ' ' * @default ' '
* @type string * @type string
*/ */
split: string; split?: string;
/** /**
* Customize trigger search logic * Customize trigger search logic
* @type (text: string, props: MentionsProps) => void * @type (text: string, props: MentionsProps) => void
*/ */
validateSearch: (text: string, props: Mentions) => void; validateSearch?: (text: string, props: Mentions) => void;
/** /**
* Set value of mentions * Set value of mentions
* @type string * @type string
*/ */
value: string; value?: string;
/** /**
* Set the mount HTML node for suggestions * Set the mount HTML node for suggestions
* @default () => HTMLElement * @default () => HTMLElement
*/ */
getPopupContainer: (triggerNode: HTMLElement) => HTMLElement; getPopupContainer?: (triggerNode: HTMLElement) => HTMLElement;
}
} }

View File

@ -4,10 +4,12 @@
import { AntdComponent } from '../component'; import { AntdComponent } from '../component';
export declare class Option extends AntdComponent { export declare class Option extends AntdComponent {
$props: {
/** /**
* value of suggestion, the value will insert into input filed while selected * value of suggestion, the value will insert into input filed while selected
* @default '' * @default ''
* @type string * @type string
*/ */
value: string; value?: string;
}
} }

View File

@ -22,7 +22,7 @@ export interface NotificationOptions extends NotificationConfigOptions {
* The content of notification box (required) * The content of notification box (required)
* @type string | VNode | Function * @type string | VNode | Function
*/ */
description: VNodeChild | JSX.Element | Function; description?: VNodeChild | JSX.Element | Function;
/** /**
* Customized icon * Customized icon

19
types/spin.d.ts vendored
View File

@ -5,14 +5,7 @@
import { AntdComponent } from './component'; import { AntdComponent } from './component';
import { VNodeChild } from 'vue'; import { VNodeChild } from 'vue';
export declare class Spin extends AntdComponent { export interface SpinProps {
/**
* As indicator, you can define the global default spin element
* @param param0 indicator
*/
static setDefaultIndicator({ indicator }: { indicator: any }): void;
$props: {
/** /**
* specifies a delay in milliseconds for loading state (prevent flush) * specifies a delay in milliseconds for loading state (prevent flush)
* @type number (milliseconds) * @type number (milliseconds)
@ -50,5 +43,13 @@ export declare class Spin extends AntdComponent {
* @type string * @type string
*/ */
wrapperClassName?: string; wrapperClassName?: string;
} }
export declare class Spin extends AntdComponent {
/**
* As indicator, you can define the global default spin element
* @param param0 indicator
*/
static setDefaultIndicator({ indicator }: { indicator: any }): void;
$props: SpinProps;
} }

View File

@ -2,8 +2,8 @@
// Definitions by: akki-jat <https://github.com/akki-jat> // Definitions by: akki-jat <https://github.com/akki-jat>
// Definitions: https://github.com/vueComponent/ant-design-vue/types // Definitions: https://github.com/vueComponent/ant-design-vue/types
import { VNodeChild, Slots } from 'vue';
import { AntdComponent } from '../component'; import { AntdComponent } from '../component';
import { VNodeChild } from 'vue';
export declare class ColumnGroup extends AntdComponent { export declare class ColumnGroup extends AntdComponent {
$props: { $props: {
@ -18,6 +18,6 @@ export declare class ColumnGroup extends AntdComponent {
* such as slots: { title: 'XXX'} * such as slots: { title: 'XXX'}
* @type object * @type object
*/ */
slots?: object; slots?: Slots;
}; };
} }

View File

@ -2,8 +2,8 @@
// Definitions by: akki-jat <https://github.com/akki-jat> // Definitions by: akki-jat <https://github.com/akki-jat>
// Definitions: https://github.com/vueComponent/ant-design-vue/types // Definitions: https://github.com/vueComponent/ant-design-vue/types
import { VNodeChild, Slots } from 'vue';
import { AntdComponent } from '../component'; import { AntdComponent } from '../component';
import { VNodeChild } from 'vue';
export interface ColumnFilterItem { export interface ColumnFilterItem {
text?: string; text?: string;
@ -13,16 +13,26 @@ export interface ColumnFilterItem {
export declare type SortOrder = 'ascend' | 'descend'; export declare type SortOrder = 'ascend' | 'descend';
export interface Record { export interface RecordProps<T> {
text?: any; text: any;
record?: object; record: T;
index?: number; index: number;
} }
export declare type CustomRenderFunction = (record: Record) => VNodeChild | JSX.Element; export interface FilterDropdownProps {
prefixCls?: string;
setSelectedKeys?: (selectedKeys: string[]) => void;
selectedKeys?: string[];
confirm?: () => void;
clearFilters?: () => void;
filters?: ColumnFilterItem[];
getPopupContainer?: (triggerNode: HTMLElement) => HTMLElement;
visible?: boolean;
}
export declare class Column extends AntdComponent { export declare type CustomRenderFunction<T> = (record: RecordProps<T>) => VNodeChild | JSX.Element;
$props: {
export interface ColumnProps<T> {
/** /**
* specify how content is aligned * specify how content is aligned
* @default 'left' * @default 'left'
@ -66,7 +76,10 @@ export declare class Column extends AntdComponent {
* Customized filter overlay * Customized filter overlay
* @type any (slot) * @type any (slot)
*/ */
filterDropdown?: any; filterDropdown?:
| VNodeChild
| JSX.Element
| ((props: FilterDropdownProps) => VNodeChild | JSX.Element);
/** /**
* Whether filterDropdown is visible * Whether filterDropdown is visible
@ -92,7 +105,7 @@ export declare class Column extends AntdComponent {
* @default false * @default false
* @type any * @type any
*/ */
filterIcon?: any; filterIcon?: boolean | VNodeChild | JSX.Element;
/** /**
* Whether multiple filters can be selected * Whether multiple filters can be selected
@ -124,7 +137,7 @@ export declare class Column extends AntdComponent {
* Renderer of the table cell. The return value should be a VNode, or an object for colSpan/rowSpan config * Renderer of the table cell. The return value should be a VNode, or an object for colSpan/rowSpan config
* @type Function | ScopedSlot * @type Function | ScopedSlot
*/ */
customRender?: CustomRenderFunction | VNodeChild | JSX.Element; customRender?: CustomRenderFunction<T> | VNodeChild | JSX.Element;
/** /**
* Sort function for local sort, see Array.sort's compareFunction. If you need sort buttons only, set to true * Sort function for local sort, see Array.sort's compareFunction. If you need sort buttons only, set to true
@ -143,7 +156,7 @@ export declare class Column extends AntdComponent {
* @default ['ascend', 'descend'] * @default ['ascend', 'descend']
* @type string[] * @type string[]
*/ */
sortDirections?: string[]; sortDirections?: SortOrder[];
/** /**
* Title of this column * Title of this column
@ -161,19 +174,19 @@ export declare class Column extends AntdComponent {
* Set props on per cell * Set props on per cell
* @type Function * @type Function
*/ */
customCell?: (record: any, rowIndex: number) => object; customCell?: (record: T, rowIndex: number) => object;
/** /**
* Set props on per header cell * Set props on per header cell
* @type object * @type object
*/ */
customHeaderCell?: (column: any) => object; customHeaderCell?: (column: ColumnProps<T>) => object;
/** /**
* Callback executed when the confirm filter button is clicked, Use as a filter event when using template or jsx * Callback executed when the confirm filter button is clicked, Use as a filter event when using template or jsx
* @type Function * @type Function
*/ */
onFilter?: Function; onFilter?: (value: any, record: T) => boolean;
/** /**
* Callback executed when filterDropdownVisible is changed, Use as a filterDropdownVisible event when using template or jsx * Callback executed when filterDropdownVisible is changed, Use as a filterDropdownVisible event when using template or jsx
@ -186,6 +199,9 @@ export declare class Column extends AntdComponent {
* such as slots: { filterIcon: 'XXX'} * such as slots: { filterIcon: 'XXX'}
* @type object * @type object
*/ */
slots?: object; slots?: { [key: string]: string };
}; }
export declare class Column<T> extends AntdComponent {
$props: ColumnProps<T>;
} }

View File

@ -3,9 +3,9 @@
// Definitions: https://github.com/vueComponent/ant-design-vue/types // Definitions: https://github.com/vueComponent/ant-design-vue/types
import { AntdComponent } from '../component'; import { AntdComponent } from '../component';
import { Spin } from '../spin'; import { SpinProps } from '../spin';
import { Pagination } from '../pagination'; import { Pagination } from '../pagination';
import { Column } from './column'; import { Column, ColumnProps, SortOrder } from './column';
import { ColumnGroup } from './column-group'; import { ColumnGroup } from './column-group';
import { VNodeChild } from 'vue'; import { VNodeChild } from 'vue';
@ -13,7 +13,14 @@ export declare class PaginationConfig extends Pagination {
position?: 'top' | 'bottom' | 'both'; position?: 'top' | 'bottom' | 'both';
} }
export interface customSelection { export interface SorterResult<T> {
column: ColumnProps<T>;
order: SortOrder;
field: string;
columnKey: string;
}
export interface SelectionItem {
/** /**
* Key * Key
* @description Unique key of this selection * @description Unique key of this selection
@ -36,10 +43,14 @@ export interface customSelection {
* @default undefined * @default undefined
* @type Function * @type Function
*/ */
onSelect?: (changeableRowKeys?: any[]) => any; onSelect?: (changeableRowKeys?: string[]) => void;
} }
export interface TableRowSelection { export interface TableCurrentDataSource<T> {
currentDataSource: T[];
}
export interface TableRowSelection<T> {
/** /**
* checkbox or radio * checkbox or radio
* @default 'checkbox' * @default 'checkbox'
@ -57,13 +68,13 @@ export interface TableRowSelection {
* Get Checkbox or Radio props * Get Checkbox or Radio props
* @type Function * @type Function
*/ */
getCheckboxProps?: (record: any) => any; getCheckboxProps?: (record: T) => Object;
/** /**
* Custom selection config, only displays default selections when set to true * Custom selection config, only displays default selections when set to true
* @type boolean | object[] * @type boolean | object[]
*/ */
selections?: boolean | customSelection[]; selections?: boolean | SelectionItem[];
/** /**
* Remove the default Select All and Select Invert selections * Remove the default Select All and Select Invert selections
@ -94,38 +105,38 @@ export interface TableRowSelection {
* Callback executed when selected rows change * Callback executed when selected rows change
* @type Function * @type Function
*/ */
onChange?: (selectedRowKeys: Array<string | number>, selectedRows: object[]) => any; onChange?: (selectedRowKeys: string[] | number[], selectedRows: T[]) => any;
/** /**
* Callback executed when select/deselect one row * Callback executed when select/deselect one row
* @type Function * @type FunctionT
*/ */
onSelect?: (record: any, selected: boolean, selectedRows: object[], nativeEvent: Event) => any; onSelect?: (record: T, selected: boolean, selectedRows: Object[], nativeEvent: Event) => any;
/** /**
* Callback executed when select/deselect all rows * Callback executed when select/deselect all rows
* @type Function * @type Function
*/ */
onSelectAll?: (selected: boolean, selectedRows: object[], changeRows: object[]) => any; onSelectAll?: (selected: boolean, selectedRows: T[], changeRows: T[]) => any;
/** /**
* Callback executed when row selection is inverted * Callback executed when row selection is inverted
* @type Function * @type Function
*/ */
onSelectInvert?: (selectedRows: Object[]) => any; onSelectInvert?: (selectedRows: string[] | number[]) => any;
} }
export interface TableCustomRecord { export interface TableCustomRecord<T> {
record?: any; record?: T;
index?: number; index?: number;
} }
export interface ExpandedRowRenderRecord extends TableCustomRecord { export interface ExpandedRowRenderRecord<T> extends TableCustomRecord<T> {
indent?: number; indent?: number;
expanded?: boolean; expanded?: boolean;
} }
export declare class Table extends AntdComponent { export declare class Table<T> extends AntdComponent {
static Column: typeof Column; static Column: typeof Column;
static ColumnGroup: typeof ColumnGroup; static ColumnGroup: typeof ColumnGroup;
@ -148,7 +159,7 @@ export declare class Table extends AntdComponent {
* Columns of table * Columns of table
* @type array * @type array
*/ */
columns: any[]; columns?: ColumnProps<T>[];
/** /**
* Override default table elements * Override default table elements
@ -160,7 +171,7 @@ export declare class Table extends AntdComponent {
* Data record array to be displayed * Data record array to be displayed
* @type array * @type array
*/ */
dataSource: any; dataSource?: T[];
/** /**
* Expand all rows initially * Expand all rows initially
@ -185,7 +196,7 @@ export declare class Table extends AntdComponent {
* Expanded container render for each row * Expanded container render for each row
* @type Function * @type Function
*/ */
expandedRowRender?: (record?: ExpandedRowRenderRecord) => any; expandedRowRender?: (record?: ExpandedRowRenderRecord<T>) => VNodeChild | JSX.Element;
/** /**
* Customize row expand Icon. * Customize row expand Icon.
@ -223,7 +234,7 @@ export declare class Table extends AntdComponent {
* @default false * @default false
* @type boolean | object * @type boolean | object
*/ */
loading?: boolean | Spin | VNodeChild | JSX.Element; loading?: boolean | SpinProps | VNodeChild | JSX.Element;
/** /**
* i18n text including filter, sort, empty text, etc * i18n text including filter, sort, empty text, etc
@ -242,7 +253,7 @@ export declare class Table extends AntdComponent {
* Row's className * Row's className
* @type Function * @type Function
*/ */
rowClassName?: (record?: TableCustomRecord) => string; rowClassName?: (record?: TableCustomRecord<T>) => string;
/** /**
* Row's unique key, could be a string or function that returns a string * Row's unique key, could be a string or function that returns a string
@ -255,7 +266,7 @@ export declare class Table extends AntdComponent {
* Row selection config * Row selection config
* @type object * @type object
*/ */
rowSelection?: TableRowSelection; rowSelection?: TableRowSelection<T>;
/** /**
* Set horizontal or vertical scrolling, can also be used to specify the width and height of the scroll area. * Set horizontal or vertical scrolling, can also be used to specify the width and height of the scroll area.
@ -283,19 +294,19 @@ export declare class Table extends AntdComponent {
* Table title renderer * Table title renderer
* @type Function | ScopedSlot * @type Function | ScopedSlot
*/ */
title?: Function | VNodeChild | JSX.Element; title?: VNodeChild | JSX.Element;
/** /**
* Set props on per header row * Set props on per header row
* @type Function * @type Function
*/ */
customHeaderRow?: (column: any, index: number) => object; customHeaderRow?: (column: ColumnProps<T>, index: number) => object;
/** /**
* Set props on per row * Set props on per row
* @type Function * @type Function
*/ */
customRow?: (record: any, index: number) => object; customRow?: (record: T, index: number) => object;
/** /**
* `table-layout` attribute of table element * `table-layout` attribute of table element
@ -329,7 +340,12 @@ export declare class Table extends AntdComponent {
* @param sorter * @param sorter
* @param currentDataSource * @param currentDataSource
*/ */
onChange?: (pagination: object, filters, sorter, { currentDataSource }) => void; onChange?: (
pagination: PaginationConfig,
filters: Partial<Record<keyof T, string[]>>,
sorter: SorterResult<T>,
extra: TableCurrentDataSource<T>,
) => void;
/** /**
* Callback executed when the row expand icon is clicked * Callback executed when the row expand icon is clicked
@ -337,12 +353,12 @@ export declare class Table extends AntdComponent {
* @param expanded * @param expanded
* @param record * @param record
*/ */
onExpand: (expanded, record) => void; onExpand?: (expande: boolean, record: T) => void;
/** /**
* Callback executed when the expanded rows change * Callback executed when the expanded rows change
* @param expandedRows * @param expandedRows
*/ */
onExpandedRowsChange: (expandedRows: any) => void; onExpandedRowsChange?: (expandedRows: string[] | number[]) => void;
}; };
} }