fix: declare components type (#3145)
* fix: update alert code * chore: declare link type * chore: declare auto-complete type * chore: declare Badge type * chore: declare Breadcrumb type * chore: declare Calendar type * chore: declare Card type * chore: declare Checkbox type * chore: declare Descriptions type * chore: declare Dropdown * chore: declare Form type * chore: declare Mentions type * chore: declare Menu type * chore: declare popconfirm type * chore: update Radio typescript * chore: declare Rate type * chore: declare Transfer type * fix: update Transfer type * fix: update type * fix: update typepull/3165/head
parent
ba971c4f2c
commit
4ab7a681a7
|
@ -34,7 +34,7 @@ const iconMapOutlined = {
|
|||
|
||||
export const AlertProps = {
|
||||
/**
|
||||
* Type of Alert styles, options:`success`, `info`, `warning`, `error`
|
||||
* Type of Alert styles, options: `success`, `info`, `warning`, `error`
|
||||
*/
|
||||
type: PropTypes.oneOf(tuple('success', 'info', 'warning', 'error')),
|
||||
/** Whether Alert can be closed */
|
||||
|
|
|
@ -183,7 +183,7 @@ export default defineComponent({
|
|||
return '';
|
||||
},
|
||||
|
||||
handleScrollTo(link) {
|
||||
handleScrollTo(link: string) {
|
||||
const { offsetTop, getContainer, targetOffset } = this;
|
||||
|
||||
this.setCurrentActiveLink(link);
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
import { App, defineComponent, inject, provide, Plugin } from 'vue';
|
||||
import { App, defineComponent, inject, provide, Plugin, VNode } from 'vue';
|
||||
import Select, { SelectProps } from '../select';
|
||||
import Input from '../input';
|
||||
import InputElement from './InputElement';
|
||||
|
@ -56,10 +56,10 @@ const AutoComplete = defineComponent({
|
|||
provide('savePopupRef', this.savePopupRef);
|
||||
},
|
||||
methods: {
|
||||
savePopupRef(ref: any) {
|
||||
savePopupRef(ref: VNode) {
|
||||
this.popupRef = ref;
|
||||
},
|
||||
saveSelect(node: any) {
|
||||
saveSelect(node: VNode) {
|
||||
this.select = node;
|
||||
},
|
||||
getInputElement() {
|
||||
|
@ -125,7 +125,7 @@ const AutoComplete = defineComponent({
|
|||
: [];
|
||||
}
|
||||
const selectProps = {
|
||||
...Omit(getOptionProps(this), ['dataSource', 'optionLabelProp'] as any),
|
||||
...Omit(getOptionProps(this), ['dataSource', 'optionLabelProp']),
|
||||
...this.$attrs,
|
||||
mode: Select.SECRET_COMBOBOX_MODE_DO_NOT_USE,
|
||||
// optionLabelProp,
|
||||
|
|
|
@ -7,7 +7,7 @@ import { cloneElement } from '../_util/vnode';
|
|||
import { getTransitionProps, Transition } from '../_util/transition';
|
||||
import isNumeric from '../_util/isNumeric';
|
||||
import { defaultConfigProvider } from '../config-provider';
|
||||
import { inject, defineComponent, CSSProperties } from 'vue';
|
||||
import { inject, defineComponent, CSSProperties, VNode } from 'vue';
|
||||
import { tuple } from '../_util/type';
|
||||
|
||||
const BadgeProps = {
|
||||
|
@ -28,7 +28,7 @@ const BadgeProps = {
|
|||
title: PropTypes.string,
|
||||
};
|
||||
function isPresetColor(color?: string): boolean {
|
||||
return (PresetColorTypes as any[]).indexOf(color) !== -1;
|
||||
return (PresetColorTypes as string[]).indexOf(color) !== -1;
|
||||
}
|
||||
export default defineComponent({
|
||||
name: 'ABadge',
|
||||
|
@ -79,7 +79,7 @@ export default defineComponent({
|
|||
}
|
||||
: { ...numberStyle };
|
||||
},
|
||||
getBadgeClassName(prefixCls: string, children: any[]) {
|
||||
getBadgeClassName(prefixCls: string, children: VNode[]) {
|
||||
const hasStatus = this.hasStatus();
|
||||
return classNames(prefixCls, {
|
||||
[`${prefixCls}-status`]: hasStatus,
|
||||
|
|
|
@ -20,12 +20,12 @@ const BreadcrumbProps = {
|
|||
separator: PropTypes.VNodeChild,
|
||||
itemRender: {
|
||||
type: Function as PropType<
|
||||
(opt: { route: Route; params: any; routes: Route[]; paths: string[] }) => VueNode
|
||||
(opt: { route: Route; params: unknown; routes: Route[]; paths: string[] }) => VueNode
|
||||
>,
|
||||
},
|
||||
};
|
||||
|
||||
function getBreadcrumbName(route: Route, params: any) {
|
||||
function getBreadcrumbName(route: Route, params: unknown) {
|
||||
if (!route.breadcrumbName) {
|
||||
return null;
|
||||
}
|
||||
|
@ -38,7 +38,7 @@ function getBreadcrumbName(route: Route, params: any) {
|
|||
}
|
||||
function defaultItemRender(opt: {
|
||||
route: Route;
|
||||
params: any;
|
||||
params: unknown;
|
||||
routes: Route[];
|
||||
paths: string[];
|
||||
}): VueNode {
|
||||
|
@ -57,7 +57,7 @@ export default defineComponent({
|
|||
};
|
||||
},
|
||||
methods: {
|
||||
getPath(path: string, params: any) {
|
||||
getPath(path: string, params: unknown) {
|
||||
path = (path || '').replace(/^\//, '');
|
||||
Object.keys(params).forEach(key => {
|
||||
path = path.replace(`:${key}`, params[key]);
|
||||
|
@ -65,7 +65,7 @@ export default defineComponent({
|
|||
return path;
|
||||
},
|
||||
|
||||
addChildPath(paths: string[], childPath = '', params: any) {
|
||||
addChildPath(paths: string[], childPath = '', params: unknown) {
|
||||
const originalPaths = [...paths];
|
||||
const path = this.getPath(childPath, params);
|
||||
if (path) {
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
import { defineComponent, inject } from 'vue';
|
||||
import { defineComponent, HTMLAttributes, inject } from 'vue';
|
||||
import PropTypes from '../_util/vue-types';
|
||||
import { hasProp, getComponent, getSlot } from '../_util/props-util';
|
||||
import { defaultConfigProvider } from '../config-provider';
|
||||
|
@ -24,7 +24,7 @@ export default defineComponent({
|
|||
* if overlay is have
|
||||
* Wrap a DropDown
|
||||
*/
|
||||
renderBreadcrumbNode(breadcrumbItem: any, prefixCls: string) {
|
||||
renderBreadcrumbNode(breadcrumbItem: HTMLAttributes, prefixCls: string) {
|
||||
const overlay = getComponent(this, 'overlay');
|
||||
if (overlay) {
|
||||
return (
|
||||
|
@ -45,7 +45,7 @@ export default defineComponent({
|
|||
const prefixCls = getPrefixCls('breadcrumb', customizePrefixCls);
|
||||
const separator = getComponent(this, 'separator');
|
||||
const children = getSlot(this);
|
||||
let link;
|
||||
let link: HTMLAttributes;
|
||||
if (hasProp(this, 'href')) {
|
||||
link = <a class={`${prefixCls}-link`}>{children}</a>;
|
||||
} else {
|
||||
|
|
|
@ -5,6 +5,7 @@ import PropTypes from '../_util/vue-types';
|
|||
import { defaultConfigProvider } from '../config-provider';
|
||||
import { VueNode } from '../_util/type';
|
||||
import moment from 'moment';
|
||||
import { RadioChangeEvent } from '../radio/interface';
|
||||
|
||||
function getMonthsLocale(value: moment.Moment): string[] {
|
||||
const current = value.clone();
|
||||
|
@ -141,8 +142,8 @@ export default defineComponent({
|
|||
this.$emit('valueChange', newValue);
|
||||
},
|
||||
|
||||
onInternalTypeChange(e: Event) {
|
||||
this.triggerTypeChange((e.target as any).value);
|
||||
onInternalTypeChange(e: RadioChangeEvent) {
|
||||
this.triggerTypeChange(e.target.value);
|
||||
},
|
||||
|
||||
triggerTypeChange(val: string) {
|
||||
|
|
|
@ -71,7 +71,7 @@ const Card = defineComponent({
|
|||
this.$emit('tabChange', key);
|
||||
},
|
||||
isContainGrid(obj: VNode[] = []) {
|
||||
let containGrid;
|
||||
let containGrid: boolean;
|
||||
obj.forEach(element => {
|
||||
if (element && isPlainObject(element.type) && (element.type as any).__ANT_CARD_GRID) {
|
||||
containGrid = true;
|
||||
|
|
|
@ -5,6 +5,7 @@ import VcCheckbox from '../vc-checkbox';
|
|||
import hasProp, { getOptionProps, getSlot } from '../_util/props-util';
|
||||
import { defaultConfigProvider } from '../config-provider';
|
||||
import warning from '../_util/warning';
|
||||
import { RadioChangeEvent } from '../radio/interface';
|
||||
function noop() {}
|
||||
|
||||
export default defineComponent({
|
||||
|
@ -65,17 +66,17 @@ export default defineComponent({
|
|||
}
|
||||
},
|
||||
methods: {
|
||||
handleChange(event: Event) {
|
||||
const targetChecked = (event.target as any).checked;
|
||||
handleChange(event: RadioChangeEvent) {
|
||||
const targetChecked = event.target.checked;
|
||||
this.$emit('update:checked', targetChecked);
|
||||
// this.$emit('input', targetChecked);
|
||||
this.$emit('change', event);
|
||||
},
|
||||
focus() {
|
||||
(this.$refs.vcCheckbox as any).focus();
|
||||
(this.$refs.vcCheckbox as HTMLInputElement).focus();
|
||||
},
|
||||
blur() {
|
||||
(this.$refs.vcCheckbox as any).blur();
|
||||
(this.$refs.vcCheckbox as HTMLInputElement).blur();
|
||||
},
|
||||
},
|
||||
|
||||
|
@ -93,7 +94,7 @@ export default defineComponent({
|
|||
class: className,
|
||||
style,
|
||||
...restAttrs
|
||||
} = $attrs as any;
|
||||
} = $attrs;
|
||||
const checkboxProps: any = {
|
||||
...restProps,
|
||||
prefixCls,
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
import Cell from './Cell';
|
||||
import { getOptionProps, getSlot, getClass, getStyle, getComponent } from '../_util/props-util';
|
||||
import { FunctionalComponent } from 'vue';
|
||||
import { FunctionalComponent, VNode } from 'vue';
|
||||
|
||||
interface CellConfig {
|
||||
component: string | [string, string];
|
||||
|
@ -20,7 +20,7 @@ export interface RowProps {
|
|||
|
||||
const Row: FunctionalComponent<RowProps> = props => {
|
||||
const renderCells = (
|
||||
items,
|
||||
items: VNode[],
|
||||
{ colon, prefixCls, bordered },
|
||||
{ component, type, showLabel, showContent }: CellConfig,
|
||||
) => {
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
import { provide, inject, defineComponent } from 'vue';
|
||||
import { provide, inject, defineComponent, VNode } from 'vue';
|
||||
import Button from '../button';
|
||||
import classNames from '../_util/classNames';
|
||||
import buttonTypes from '../button/buttonTypes';
|
||||
|
@ -45,13 +45,13 @@ export default defineComponent({
|
|||
provide('savePopupRef', this.savePopupRef);
|
||||
},
|
||||
methods: {
|
||||
savePopupRef(ref: any) {
|
||||
savePopupRef(ref: VNode) {
|
||||
this.popupRef = ref;
|
||||
},
|
||||
handleClick(e) {
|
||||
handleClick(e: Event) {
|
||||
this.$emit('click', e);
|
||||
},
|
||||
handleVisibleChange(val) {
|
||||
handleVisibleChange(val: boolean) {
|
||||
this.$emit('update:visible', val);
|
||||
this.$emit('visibleChange', val);
|
||||
},
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
import { provide, inject, cloneVNode, defineComponent } from 'vue';
|
||||
import { provide, inject, cloneVNode, defineComponent, VNode } from 'vue';
|
||||
import RcDropdown from '../vc-dropdown/src/index';
|
||||
import DropdownButton from './dropdown-button';
|
||||
import PropTypes from '../_util/vue-types';
|
||||
|
@ -37,7 +37,7 @@ const Dropdown = defineComponent({
|
|||
provide('savePopupRef', this.savePopupRef);
|
||||
},
|
||||
methods: {
|
||||
savePopupRef(ref: any) {
|
||||
savePopupRef(ref: VNode) {
|
||||
this.popupRef = ref;
|
||||
},
|
||||
getTransitionName() {
|
||||
|
|
|
@ -14,7 +14,7 @@ import scrollIntoView from 'scroll-into-view-if-needed';
|
|||
import initDefaultProps from '../_util/props-util/initDefaultProps';
|
||||
import { tuple, VueNode } from '../_util/type';
|
||||
import { ColProps } from '../grid/Col';
|
||||
import { InternalNamePath, NamePath, ValidateOptions } from './interface';
|
||||
import { InternalNamePath, NamePath, ValidateErrorEntity, ValidateOptions } from './interface';
|
||||
|
||||
export type ValidationRule = {
|
||||
/** validation error message */
|
||||
|
@ -119,7 +119,7 @@ const Form = defineComponent({
|
|||
this.handleFinishFailed(errors);
|
||||
});
|
||||
},
|
||||
getFieldsByNameList(nameList) {
|
||||
getFieldsByNameList(nameList: NamePath) {
|
||||
const provideNameList = !!nameList;
|
||||
const namePathList = provideNameList ? toArray(nameList).map(getNamePath) : [];
|
||||
if (!provideNameList) {
|
||||
|
@ -139,12 +139,12 @@ const Form = defineComponent({
|
|||
field.resetField();
|
||||
});
|
||||
},
|
||||
clearValidate(name) {
|
||||
clearValidate(name: NamePath) {
|
||||
this.getFieldsByNameList(name).forEach(field => {
|
||||
field.clearValidate();
|
||||
});
|
||||
},
|
||||
handleFinishFailed(errorInfo) {
|
||||
handleFinishFailed(errorInfo: ValidateErrorEntity) {
|
||||
const { scrollToFirstError } = this;
|
||||
this.$emit('finishFailed', errorInfo);
|
||||
if (scrollToFirstError && errorInfo.errorFields.length) {
|
||||
|
@ -154,8 +154,8 @@ const Form = defineComponent({
|
|||
validate(...args: any[]) {
|
||||
return this.validateField(...args);
|
||||
},
|
||||
scrollToField(name: string | number, options = {}) {
|
||||
const fields = this.getFieldsByNameList([name]);
|
||||
scrollToField(name: NamePath, options = {}) {
|
||||
const fields = this.getFieldsByNameList(name);
|
||||
if (fields.length) {
|
||||
const fieldId = fields[0].fieldId;
|
||||
const node = fieldId ? document.getElementById(fieldId) : null;
|
||||
|
|
|
@ -151,10 +151,10 @@ const Mentions = defineComponent({
|
|||
return filterOption;
|
||||
},
|
||||
focus() {
|
||||
(this.$refs.vcMentions as any).focus();
|
||||
(this.$refs.vcMentions as HTMLTextAreaElement).focus();
|
||||
},
|
||||
blur() {
|
||||
(this.$refs.vcMentions as any).blur();
|
||||
(this.$refs.vcMentions as HTMLTextAreaElement).blur();
|
||||
},
|
||||
},
|
||||
render() {
|
||||
|
|
|
@ -24,7 +24,7 @@ export default defineComponent({
|
|||
};
|
||||
},
|
||||
methods: {
|
||||
onKeyDown(e) {
|
||||
onKeyDown(e: Event) {
|
||||
(this.$refs.subMenu as any).onKeyDown(e);
|
||||
},
|
||||
},
|
||||
|
|
|
@ -29,8 +29,8 @@ export const menuProps = {
|
|||
selectable: PropTypes.looseBool,
|
||||
selectedKeys: PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.string, PropTypes.number])),
|
||||
defaultSelectedKeys: PropTypes.array,
|
||||
openKeys: PropTypes.array,
|
||||
defaultOpenKeys: PropTypes.array,
|
||||
openKeys: PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.string, PropTypes.number])),
|
||||
defaultOpenKeys: PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.string, PropTypes.number])),
|
||||
openAnimation: PropTypes.oneOfType([PropTypes.string, PropTypes.object]),
|
||||
openTransitionName: PropTypes.string,
|
||||
prefixCls: PropTypes.string,
|
||||
|
@ -88,7 +88,7 @@ const Menu = defineComponent({
|
|||
'Menu',
|
||||
"`inlineCollapsed` should only be used when Menu's `mode` is inline.",
|
||||
);
|
||||
let sOpenKeys;
|
||||
let sOpenKeys: (number | string)[];
|
||||
|
||||
if ('openKeys' in props) {
|
||||
sOpenKeys = props.openKeys;
|
||||
|
@ -126,7 +126,7 @@ const Menu = defineComponent({
|
|||
this.propsUpdating = false;
|
||||
},
|
||||
methods: {
|
||||
collapsedChange(val) {
|
||||
collapsedChange(val: unknown) {
|
||||
if (this.propsUpdating) {
|
||||
return;
|
||||
}
|
||||
|
@ -154,7 +154,7 @@ const Menu = defineComponent({
|
|||
// Restore vertical mode when menu is collapsed responsively when mounted
|
||||
// https://github.com/ant-design/ant-design/issues/13104
|
||||
// TODO: not a perfect solution, looking a new way to avoid setting switchingModeFromInline in this situation
|
||||
handleMouseEnter(e) {
|
||||
handleMouseEnter(e: Event) {
|
||||
this.restoreModeVerticalFromInline();
|
||||
this.$emit('mouseenter', e);
|
||||
},
|
||||
|
@ -180,7 +180,7 @@ const Menu = defineComponent({
|
|||
this.restoreModeVerticalFromInline();
|
||||
}
|
||||
},
|
||||
handleClick(e) {
|
||||
handleClick(e: Event) {
|
||||
this.handleOpenChange([]);
|
||||
this.$emit('click', e);
|
||||
},
|
||||
|
@ -194,12 +194,12 @@ const Menu = defineComponent({
|
|||
this.$emit('deselect', info);
|
||||
this.$emit('selectChange', info.selectedKeys);
|
||||
},
|
||||
handleOpenChange(openKeys) {
|
||||
handleOpenChange(openKeys: (number | string)[]) {
|
||||
this.setOpenKeys(openKeys);
|
||||
this.$emit('update:openKeys', openKeys);
|
||||
this.$emit('openChange', openKeys);
|
||||
},
|
||||
setOpenKeys(openKeys) {
|
||||
setOpenKeys(openKeys: (number | string)[]) {
|
||||
if (!hasProp(this, 'openKeys')) {
|
||||
this.setState({ sOpenKeys: openKeys });
|
||||
}
|
||||
|
@ -219,7 +219,7 @@ const Menu = defineComponent({
|
|||
}
|
||||
return inlineCollapsed;
|
||||
},
|
||||
getMenuOpenAnimation(menuMode) {
|
||||
getMenuOpenAnimation(menuMode: string) {
|
||||
const { openAnimation, openTransitionName } = this.$props;
|
||||
let menuOpenAnimation = openAnimation || openTransitionName;
|
||||
if (openAnimation === undefined && openTransitionName === undefined) {
|
||||
|
@ -287,7 +287,7 @@ const Menu = defineComponent({
|
|||
menuProps.onClick = this.handleClick;
|
||||
menuProps.openTransitionName = menuOpenAnimation;
|
||||
} else {
|
||||
menuProps.onClick = e => {
|
||||
menuProps.onClick = (e: Event) => {
|
||||
this.$emit('click', e);
|
||||
};
|
||||
menuProps.openAnimation = menuOpenAnimation;
|
||||
|
|
|
@ -60,17 +60,17 @@ const Popconfirm = defineComponent({
|
|||
},
|
||||
},
|
||||
methods: {
|
||||
onConfirmHandle(e) {
|
||||
onConfirmHandle(e: Event) {
|
||||
this.setVisible(false, e);
|
||||
this.$emit('confirm', e);
|
||||
},
|
||||
|
||||
onCancelHandle(e) {
|
||||
onCancelHandle(e: Event) {
|
||||
this.setVisible(false, e);
|
||||
this.$emit('cancel', e);
|
||||
},
|
||||
|
||||
onVisibleChangeHandle(sVisible) {
|
||||
onVisibleChangeHandle(sVisible: boolean) {
|
||||
const { disabled } = this.$props;
|
||||
if (disabled) {
|
||||
return;
|
||||
|
|
|
@ -36,10 +36,10 @@ export default defineComponent({
|
|||
},
|
||||
methods: {
|
||||
focus() {
|
||||
(this.$refs.vcCheckbox as any).focus();
|
||||
(this.$refs.vcCheckbox as HTMLInputElement).focus();
|
||||
},
|
||||
blur() {
|
||||
(this.$refs.vcCheckbox as any).blur();
|
||||
(this.$refs.vcCheckbox as HTMLInputElement).blur();
|
||||
},
|
||||
handleChange(event: RadioChangeEvent) {
|
||||
const targetChecked = event.target.checked;
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
import { inject, defineComponent } from 'vue';
|
||||
import { inject, defineComponent, VNode } from 'vue';
|
||||
import omit from 'omit.js';
|
||||
import PropTypes from '../_util/vue-types';
|
||||
import { getOptionProps, getComponent } from '../_util/props-util';
|
||||
|
@ -30,16 +30,16 @@ const Rate = defineComponent({
|
|||
};
|
||||
},
|
||||
methods: {
|
||||
characterRender(node, { index }) {
|
||||
characterRender(node: VNode, { index }) {
|
||||
const { tooltips } = this.$props;
|
||||
if (!tooltips) return node;
|
||||
return <Tooltip title={tooltips[index]}>{node}</Tooltip>;
|
||||
},
|
||||
focus() {
|
||||
(this.$refs.refRate as any).focus();
|
||||
(this.$refs.refRate as HTMLUListElement).focus();
|
||||
},
|
||||
blur() {
|
||||
(this.$refs.refRate as any).blur();
|
||||
(this.$refs.refRate as HTMLUListElement).blur();
|
||||
},
|
||||
},
|
||||
render() {
|
||||
|
|
|
@ -7,7 +7,8 @@ import Checkbox from '../checkbox';
|
|||
import Search from './search';
|
||||
import defaultRenderList from './renderListBody';
|
||||
import triggerEvent from '../_util/triggerEvent';
|
||||
import { defineComponent, nextTick } from 'vue';
|
||||
import { defineComponent, HTMLAttributes, nextTick, VNode } from 'vue';
|
||||
import { RadioChangeEvent } from '../radio/interface';
|
||||
|
||||
const defaultRender = () => null;
|
||||
|
||||
|
@ -18,7 +19,14 @@ const TransferItem = {
|
|||
disabled: PropTypes.looseBool,
|
||||
};
|
||||
|
||||
function isRenderResultPlainObject(result) {
|
||||
export interface DataSourceItem {
|
||||
key: string;
|
||||
title: string;
|
||||
description?: string;
|
||||
disabled?: boolean;
|
||||
}
|
||||
|
||||
function isRenderResultPlainObject(result: VNode) {
|
||||
return (
|
||||
result &&
|
||||
!isValidElement(result) &&
|
||||
|
@ -55,7 +63,7 @@ export const TransferListProps = {
|
|||
onScroll: PropTypes.func,
|
||||
};
|
||||
|
||||
function renderListNode(renderList, props) {
|
||||
function renderListNode(renderList: Function, props: any) {
|
||||
let bodyContent = renderList ? renderList(props) : null;
|
||||
const customize = !!bodyContent && filterEmpty(bodyContent).length > 0;
|
||||
if (!customize) {
|
||||
|
@ -103,10 +111,10 @@ export default defineComponent({
|
|||
});
|
||||
},
|
||||
methods: {
|
||||
handleScroll(e) {
|
||||
handleScroll(e: Event) {
|
||||
this.$emit('scroll', e);
|
||||
},
|
||||
getCheckStatus(filteredItems) {
|
||||
getCheckStatus(filteredItems: DataSourceItem[]) {
|
||||
const { checkedKeys } = this.$props;
|
||||
if (checkedKeys.length === 0) {
|
||||
return 'none';
|
||||
|
@ -117,7 +125,7 @@ export default defineComponent({
|
|||
return 'part';
|
||||
},
|
||||
|
||||
getFilteredItems(dataSource, filterValue) {
|
||||
getFilteredItems(dataSource: DataSourceItem[], filterValue: string) {
|
||||
const filteredItems = [];
|
||||
const filteredRenderItems = [];
|
||||
|
||||
|
@ -138,17 +146,17 @@ export default defineComponent({
|
|||
},
|
||||
|
||||
getListBody(
|
||||
prefixCls,
|
||||
searchPlaceholder,
|
||||
filterValue,
|
||||
filteredItems,
|
||||
notFoundContent,
|
||||
bodyDom,
|
||||
filteredRenderItems,
|
||||
checkedKeys,
|
||||
renderList,
|
||||
showSearch,
|
||||
disabled,
|
||||
prefixCls: string,
|
||||
searchPlaceholder: string,
|
||||
filterValue: string,
|
||||
filteredItems: DataSourceItem[],
|
||||
notFoundContent: unknown,
|
||||
bodyDom: unknown,
|
||||
filteredRenderItems: unknown,
|
||||
checkedKeys: string[],
|
||||
renderList: Function,
|
||||
showSearch: boolean,
|
||||
disabled: boolean,
|
||||
) {
|
||||
const search = showSearch ? (
|
||||
<div class={`${prefixCls}-body-search-wrapper`}>
|
||||
|
@ -165,7 +173,7 @@ export default defineComponent({
|
|||
|
||||
let listBody = bodyDom;
|
||||
if (!listBody) {
|
||||
let bodyNode;
|
||||
let bodyNode: HTMLAttributes;
|
||||
const { onEvents } = splitAttrs(this.$attrs);
|
||||
const { bodyContent, customize } = renderListNode(renderList, {
|
||||
...this.$props,
|
||||
|
@ -200,7 +208,7 @@ export default defineComponent({
|
|||
return listBody;
|
||||
},
|
||||
|
||||
getCheckBox(filteredItems, showSelectAll, disabled) {
|
||||
getCheckBox(filteredItems: DataSourceItem[], showSelectAll: boolean, disabled: boolean) {
|
||||
const checkStatus = this.getCheckStatus(filteredItems);
|
||||
const checkedAll = checkStatus === 'all';
|
||||
const checkAllCheckbox = showSelectAll !== false && (
|
||||
|
@ -222,12 +230,12 @@ export default defineComponent({
|
|||
return checkAllCheckbox;
|
||||
},
|
||||
|
||||
_handleSelect(selectedItem) {
|
||||
_handleSelect(selectedItem: DataSourceItem) {
|
||||
const { checkedKeys } = this.$props;
|
||||
const result = checkedKeys.some(key => key === selectedItem.key);
|
||||
this.handleSelect(selectedItem, !result);
|
||||
},
|
||||
_handleFilter(e) {
|
||||
_handleFilter(e: RadioChangeEvent) {
|
||||
const { handleFilter } = this.$props;
|
||||
const {
|
||||
target: { value: filterValue },
|
||||
|
@ -247,11 +255,11 @@ export default defineComponent({
|
|||
}
|
||||
}, 0);
|
||||
},
|
||||
_handleClear(e) {
|
||||
_handleClear(e: Event) {
|
||||
this.setState({ filterValue: '' });
|
||||
this.handleClear(e);
|
||||
},
|
||||
matchFilter(text, item) {
|
||||
matchFilter(text: string, item: DataSourceItem) {
|
||||
const { filterValue } = this.$data;
|
||||
const { filterOption } = this.$props;
|
||||
if (filterOption) {
|
||||
|
@ -259,7 +267,7 @@ export default defineComponent({
|
|||
}
|
||||
return text.indexOf(filterValue) >= 0;
|
||||
},
|
||||
renderItemHtml(item) {
|
||||
renderItemHtml(item: DataSourceItem) {
|
||||
const { renderItem = defaultRender } = this.$props;
|
||||
const renderResult = renderItem(item);
|
||||
const isRenderResultPlain = isRenderResultPlainObject(renderResult);
|
||||
|
@ -269,7 +277,7 @@ export default defineComponent({
|
|||
item,
|
||||
};
|
||||
},
|
||||
filterNull(arr) {
|
||||
filterNull(arr: unknown[]) {
|
||||
return arr.filter(item => {
|
||||
return item !== null;
|
||||
});
|
||||
|
|
|
@ -4,6 +4,7 @@ import ListItem from './ListItem';
|
|||
import PropTypes, { withUndefined } from '../_util/vue-types';
|
||||
import { findDOMNode } from '../_util/props-util';
|
||||
import { getTransitionGroupProps, TransitionGroup } from '../_util/transition';
|
||||
import { DataSourceItem } from './list';
|
||||
const ListBody = defineComponent({
|
||||
name: 'ListBody',
|
||||
inheritAttrs: false,
|
||||
|
@ -61,12 +62,12 @@ const ListBody = defineComponent({
|
|||
raf.cancel(this.lazyId);
|
||||
},
|
||||
methods: {
|
||||
handleItemSelect(item) {
|
||||
handleItemSelect(item: DataSourceItem) {
|
||||
const { selectedKeys } = this.$props;
|
||||
const checked = selectedKeys.indexOf(item.key) >= 0;
|
||||
this.$emit('itemSelect', item.key, !checked);
|
||||
},
|
||||
handleScroll(e) {
|
||||
handleScroll(e: Event) {
|
||||
this.$emit('scroll', e);
|
||||
},
|
||||
},
|
||||
|
|
|
@ -22,10 +22,10 @@ export default defineComponent({
|
|||
placeholder: '',
|
||||
}),
|
||||
methods: {
|
||||
handleChange(e) {
|
||||
handleChange(e: Event) {
|
||||
this.$emit('change', e);
|
||||
},
|
||||
handleClear2(e) {
|
||||
handleClear2(e: Event) {
|
||||
e.preventDefault();
|
||||
const { handleClear, disabled } = this.$props;
|
||||
if (!disabled && handleClear) {
|
||||
|
|
Loading…
Reference in New Issue