Skip to content

chore: update type Cascader #2725

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Aug 19, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
304 changes: 153 additions & 151 deletions types/cascader.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
// Definitions: https://github.com/vueComponent/ant-design-vue/types

import { AntdComponent } from './component';
import { VNode } from 'vue';
import { VNode, VNodeChild, CSSProperties } from 'vue';

export interface CascaderOptionType {
value?: string | number;
Expand Down Expand Up @@ -41,162 +41,164 @@ export interface ShowSearchType {

/**
* Set the count of filtered items
* @default 50
* @type number | false
*/
limit?: number | false;
}

export declare class Cascader extends AntdComponent {
/**
* whether allow clear
* @default true
* @type boolean
*/
allowClear: boolean;

/**
* get focus when component mounted
* @default false
* @type boolean
*/
autofocus: boolean;

/**
* change value on each selection if set to true.
* @default false
* @type boolean
*/
changeOnSelect: boolean;

/**
* initial selected value
* @type Array<string | number>
*/
defaultValue: Array<string | number>;

/**
* Whether disabled select
* @default false
* @type boolean
*/
disabled: boolean;

/**
* render function of displaying selected options, you can use slot="displayRender" and slot-scope="{labels, selectedOptions}"
* @default labels => labels.join(' / ')
* @type Function
*/
displayRender: ({
labels,
selectedOptions,
}: {
labels: string[];
selectedOptions: CascaderOptionType[];
}) => VNode;

/**
* expand current item when click or hover, one of 'click' 'hover'
* @default 'click'
* @type string
*/
expandTrigger: 'click' | 'hover';

/**
* custom field name for label and value and children
* @default { label: 'label', value: 'value', children: 'children' }
* @type { value: string; label: string; children?: string; }
*/
fieldNames: {
value: string;
label: string;
children?: string;
};

/**
* 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.
* @default () => document.body
* @type Function
*/
getPopupContainer: (triggerNode: any) => HTMLElement;

/**
* To load option lazily, and it cannot work with showSearch
* @type Function
*/
loadData: (selectedOptions: CascaderOptionType[]) => void;

/**
* Specify content to show when no result matches.
* @default 'Not Found'
* @type string
*/
notFoundContent: string;

/**
* data options of cascade
* @type CascaderOptionType
*/
options: CascaderOptionType;

/**
* input placeholder
* @default 'Please select'
* @type string
*/
placeholder: string;

/**
* additional className of popup overlay
* @type string
*/
popupClassName: string;

/**
* additional style of popup overlay
* @type object
*/
popupStyle: object;

/**
* use preset popup align config from builtinPlacements:bottomLeft bottomRight topLeft topRight
* @default 'bottomLeft'
* @type string
*/
popupPlacement: 'bottomLeft' | 'bottomRight' | 'topLeft' | 'topRight';

/**
* set visible of cascader popup
* @type boolean
*/
popupVisible: boolean;

/**
* Whether show search input in single mode.
* @default false
* @type boolean | ShowSearchType
*/
showSearch: boolean | ShowSearchType;

/**
* input size, one of large default small
* @default 'default'
* @type string
*/
size: 'large' | 'default' | 'small';

/**
* The custom suffix icon
* @type String | VNode | slot
*/
suffixIcon: any;

/**
* selected value
* @type Array<string | number>
*/
value: Array<string | number>;

$props: {
/**
* whether allow clear
* @default true
* @type boolean
*/
allowClear?: boolean;

/**
* get focus when component mounted
* @default false
* @type boolean
*/
autofocus?: boolean;

/**
* change value on each selection if set to true.
* @default false
* @type boolean
*/
changeOnSelect?: boolean;

/**
* initial selected value
* @type Array<string | number>
*/
defaultValue?: Array<string | number>;

/**
* Whether disabled select
* @default false
* @type boolean
*/
disabled?: boolean;

/**
* render function of displaying selected options, you can use slot="displayRender" and slot-scope="{labels, selectedOptions}"
* @default labels => labels.join(' / ')
* @type Function
*/
displayRender?: ({
labels,
selectedOptions,
}: {
labels: string[];
selectedOptions: CascaderOptionType[];
}) => VNodeChild;

/**
* expand current item when click or hover, one of 'click' 'hover'
* @default 'click'
* @type string
*/
expandTrigger?: 'click' | 'hover';

/**
* custom field name for label and value and children
* @default { label: 'label', value: 'value', children: 'children' }
* @type { value: string; label: string; children?: string; }
*/
fieldNames?: {
value: string;
label: string;
children?: string;
};

/**
* 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.
* @default () => document.body
* @type Function
*/
getPopupContainer?: (triggerNode: any) => HTMLElement;

/**
* To load option lazily, and it cannot work with showSearch
* @type Function
*/
loadData?: (selectedOptions: CascaderOptionType[]) => void;

/**
* Specify content to show when no result matches.
* @default 'Not Found'
* @type string
*/
notFoundContent?: string;

/**
* data options of cascade
* @type CascaderOptionType
*/
options?: CascaderOptionType;

/**
* input placeholder
* @default 'Please select'
* @type string
*/
placeholder?: string;

/**
* additional className of popup overlay
* @type string
*/
popupClassName?: string;

/**
* additional style of popup overlay
* @type object
*/
popupStyle?: CSSProperties;

/**
* use preset popup align config from builtinPlacements:bottomLeft bottomRight topLeft topRight
* @default 'bottomLeft'
* @type string
*/
popupPlacement?: 'bottomLeft' | 'bottomRight' | 'topLeft' | 'topRight';

/**
* set visible of cascader popup
* @type boolean
*/
popupVisible?: boolean;

/**
* Whether show search input in single mode.
* @default false
* @type boolean | ShowSearchType
*/
showSearch?: boolean | ShowSearchType;

/**
* input size, one of large default small
* @default 'default'
* @type string
*/
size?: 'large' | 'default' | 'small';

/**
* The custom suffix icon
* @type String | VNode | slot
*/
suffixIcon?: VNodeChild | JSX.Element;

/**
* selected value
* @type Array<string | number>
*/
value?: Array<string | number>;
}
/**
* remove focus
*/
Expand Down