chore: update type Cascader (#2725)

pull/2730/head
binhaoCen 2020-08-19 22:59:41 +08:00 committed by GitHub
parent 4063fe6627
commit 941ebc2b66
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 133 additions and 131 deletions

264
types/cascader.d.ts vendored
View File

@ -3,7 +3,7 @@
// 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 { VNode } from 'vue'; import { VNode, VNodeChild, CSSProperties } from 'vue';
export interface CascaderOptionType { export interface CascaderOptionType {
value?: string | number; value?: string | number;
@ -41,162 +41,164 @@ export interface ShowSearchType {
/** /**
* Set the count of filtered items * Set the count of filtered items
* @default 50
* @type number | false * @type number | false
*/ */
limit?: number | false; limit?: number | false;
} }
export declare class Cascader extends AntdComponent { export declare class Cascader extends AntdComponent {
/** $props: {
* whether allow clear /**
* @default true * whether allow clear
* @type boolean * @default true
*/ * @type boolean
allowClear: boolean; */
allowClear?: boolean;
/** /**
* get focus when component mounted * get focus when component mounted
* @default false * @default false
* @type boolean * @type boolean
*/ */
autofocus: boolean; autofocus?: boolean;
/** /**
* change value on each selection if set to true. * change value on each selection if set to true.
* @default false * @default false
* @type boolean * @type boolean
*/ */
changeOnSelect: boolean; changeOnSelect?: boolean;
/** /**
* initial selected value * initial selected value
* @type Array<string | number> * @type Array<string | number>
*/ */
defaultValue: Array<string | number>; defaultValue?: Array<string | number>;
/** /**
* Whether disabled select * Whether disabled select
* @default false * @default false
* @type boolean * @type boolean
*/ */
disabled: boolean; disabled?: boolean;
/** /**
* render function of displaying selected options, you can use slot="displayRender" and slot-scope="{labels, selectedOptions}" * render function of displaying selected options, you can use slot="displayRender" and slot-scope="{labels, selectedOptions}"
* @default labels => labels.join(' / ') * @default labels => labels.join(' / ')
* @type Function * @type Function
*/ */
displayRender: ({ displayRender?: ({
labels, labels,
selectedOptions, selectedOptions,
}: { }: {
labels: string[]; labels: string[];
selectedOptions: CascaderOptionType[]; selectedOptions: CascaderOptionType[];
}) => VNode; }) => VNodeChild;
/** /**
* expand current item when click or hover, one of 'click' 'hover' * expand current item when click or hover, one of 'click' 'hover'
* @default 'click' * @default 'click'
* @type string * @type string
*/ */
expandTrigger: 'click' | 'hover'; expandTrigger?: 'click' | 'hover';
/** /**
* custom field name for label and value and children * custom field name for label and value and children
* @default { label: 'label', value: 'value', children: 'children' } * @default { label: 'label', value: 'value', children: 'children' }
* @type { value: string; label: string; children?: string; } * @type { value: string; label: string; children?: string; }
*/ */
fieldNames: { fieldNames?: {
value: string; value: string;
label: string; label: string;
children?: string; children?: string;
}; };
/** /**
* Parent Node which the selector should be rendered to. Default to body. * Parent Node which the selector should be rendered to. Default to body.
* When position issues happen, try to modify it into scrollable content and position it relative. * When position issues happen, try to modify it into scrollable content and position it relative.
* @default () => document.body * @default () => document.body
* @type Function * @type Function
*/ */
getPopupContainer: (triggerNode: any) => HTMLElement; getPopupContainer?: (triggerNode: any) => HTMLElement;
/** /**
* To load option lazily, and it cannot work with showSearch * To load option lazily, and it cannot work with showSearch
* @type Function * @type Function
*/ */
loadData: (selectedOptions: CascaderOptionType[]) => void; loadData?: (selectedOptions: CascaderOptionType[]) => void;
/** /**
* Specify content to show when no result matches. * Specify content to show when no result matches.
* @default 'Not Found' * @default 'Not Found'
* @type string * @type string
*/ */
notFoundContent: string; notFoundContent?: string;
/** /**
* data options of cascade * data options of cascade
* @type CascaderOptionType * @type CascaderOptionType
*/ */
options: CascaderOptionType; options?: CascaderOptionType;
/** /**
* input placeholder * input placeholder
* @default 'Please select' * @default 'Please select'
* @type string * @type string
*/ */
placeholder: string; placeholder?: string;
/** /**
* additional className of popup overlay * additional className of popup overlay
* @type string * @type string
*/ */
popupClassName: string; popupClassName?: string;
/** /**
* additional style of popup overlay * additional style of popup overlay
* @type object * @type object
*/ */
popupStyle: object; popupStyle?: CSSProperties;
/** /**
* use preset popup align config from builtinPlacementsbottomLeft bottomRight topLeft topRight * use preset popup align config from builtinPlacementsbottomLeft bottomRight topLeft topRight
* @default 'bottomLeft' * @default 'bottomLeft'
* @type string * @type string
*/ */
popupPlacement: 'bottomLeft' | 'bottomRight' | 'topLeft' | 'topRight'; popupPlacement?: 'bottomLeft' | 'bottomRight' | 'topLeft' | 'topRight';
/** /**
* set visible of cascader popup * set visible of cascader popup
* @type boolean * @type boolean
*/ */
popupVisible: boolean; popupVisible?: boolean;
/** /**
* Whether show search input in single mode. * Whether show search input in single mode.
* @default false * @default false
* @type boolean | ShowSearchType * @type boolean | ShowSearchType
*/ */
showSearch: boolean | ShowSearchType; showSearch?: boolean | ShowSearchType;
/** /**
* input size, one of large default small * input size, one of large default small
* @default 'default' * @default 'default'
* @type string * @type string
*/ */
size: 'large' | 'default' | 'small'; size?: 'large' | 'default' | 'small';
/** /**
* The custom suffix icon * The custom suffix icon
* @type String | VNode | slot * @type String | VNode | slot
*/ */
suffixIcon: any; suffixIcon?: VNodeChild | JSX.Element;
/**
* selected value
* @type Array<string | number>
*/
value: Array<string | number>;
/**
* selected value
* @type Array<string | number>
*/
value?: Array<string | number>;
}
/** /**
* remove focus * remove focus
*/ */