diff --git a/antd-tools/getBabelCommonConfig.js b/antd-tools/getBabelCommonConfig.js index 4790b9536..3232837b9 100644 --- a/antd-tools/getBabelCommonConfig.js +++ b/antd-tools/getBabelCommonConfig.js @@ -1,4 +1,4 @@ -const { resolve } = require('./utils/projectHelper'); +const { resolve, isThereHaveBrowserslistConfig } = require('./utils/projectHelper'); module.exports = function (modules) { const plugins = [ @@ -39,9 +39,11 @@ module.exports = function (modules) { resolve('@babel/preset-env'), { modules, - targets: { - browsers: ['last 2 versions', 'Firefox ESR', '> 1%', 'ie >= 11'], - }, + targets: isThereHaveBrowserslistConfig() + ? undefined + : { + browsers: ['last 2 versions', 'Firefox ESR', '> 1%', 'ie >= 11'], + }, }, ], ], diff --git a/components/_util/type.ts b/components/_util/type.ts index a48ad6f66..bc1cb530e 100644 --- a/components/_util/type.ts +++ b/components/_util/type.ts @@ -1,4 +1,5 @@ -import type { App, PropType, Plugin, Ref, VNode } from 'vue'; +// @ts-ignore +import type { App, PropType, Plugin, Ref, VNode, SlotsType } from 'vue'; // https://stackoverflow.com/questions/46176165/ways-to-get-string-literal-type-of-array-values-without-enum-overhead export const tuple = (...args: T) => args; @@ -87,3 +88,5 @@ export function stringType(defaultVal?: T) { export function someType(types?: any[], defaultVal?: T) { return types ? { type: types as PropType, default: defaultVal as T } : anyType(defaultVal); } + +export type CustomSlotsType = SlotsType; diff --git a/components/anchor/AnchorLink.tsx b/components/anchor/AnchorLink.tsx index 312471ee0..5c5afa873 100644 --- a/components/anchor/AnchorLink.tsx +++ b/components/anchor/AnchorLink.tsx @@ -4,7 +4,7 @@ import { initDefaultProps } from '../_util/props-util'; import classNames from '../_util/classNames'; import useConfigInject from '../config-provider/hooks/useConfigInject'; import { useInjectAnchor } from './context'; -import type { Key, VueNode } from '../_util/type'; +import type { Key, VueNode, CustomSlotsType } from '../_util/type'; import { objectType, anyType } from '../_util/type'; import type { CSSProperties } from '../_util/cssinjs/hooks/useStyleRegister'; @@ -33,7 +33,11 @@ export default defineComponent({ name: 'AAnchorLink', inheritAttrs: false, props: initDefaultProps(anchorLinkProps(), { href: '#' }), - slots: ['title', 'customTitle'], + slots: Object as CustomSlotsType<{ + title: any; + default: any; + customTitle: any; + }>, setup(props, { slots, attrs }) { let mergedTitle = null; const { diff --git a/components/auto-complete/index.tsx b/components/auto-complete/index.tsx index 465f089e0..a6b8fb8ad 100644 --- a/components/auto-complete/index.tsx +++ b/components/auto-complete/index.tsx @@ -6,9 +6,12 @@ import warning from '../_util/warning'; import Option from './Option'; import OptGroup from './OptGroup'; import omit from '../_util/omit'; + import useConfigInject from '../config-provider/hooks/useConfigInject'; import type { InputStatus } from '../_util/statusUtils'; +import type { CustomSlotsType } from '../_util/type'; + function isSelectOptionOrSelectOptGroup(child: any): boolean { return child?.type?.isSelectOption || child?.type?.isSelectOptGroup; } @@ -46,7 +49,12 @@ const AutoComplete = defineComponent({ inheritAttrs: false, props: autoCompleteProps(), // emits: ['change', 'select', 'focus', 'blur'], - slots: ['option'], + slots: Object as CustomSlotsType<{ + options: any; + default: any; + notFoundContent: any; + dataSource: any; + }>, setup(props, { slots, attrs, expose }) { warning( !('dataSource' in slots), diff --git a/components/avatar/Avatar.tsx b/components/avatar/Avatar.tsx index 5713610fc..88f5cbcdd 100644 --- a/components/avatar/Avatar.tsx +++ b/components/avatar/Avatar.tsx @@ -1,4 +1,4 @@ -import type { VueNode } from '../_util/type'; +import type { CustomSlotsType, VueNode } from '../_util/type'; import type { CSSProperties, ExtractPropTypes, PropType } from 'vue'; import { computed, defineComponent, nextTick, onMounted, shallowRef, watch } from 'vue'; @@ -42,7 +42,10 @@ const Avatar = defineComponent({ name: 'AAvatar', inheritAttrs: false, props: avatarProps(), - slots: ['icon'], + slots: Object as CustomSlotsType<{ + icon: any; + default: any; + }>, setup(props, { slots, attrs }) { const isImgExist = shallowRef(true); const isMounted = shallowRef(false); diff --git a/components/badge/Badge.tsx b/components/badge/Badge.tsx index 6a661943f..e1d8a9e6d 100644 --- a/components/badge/Badge.tsx +++ b/components/badge/Badge.tsx @@ -11,7 +11,7 @@ import useConfigInject from '../config-provider/hooks/useConfigInject'; import isNumeric from '../_util/isNumeric'; import useStyle from './style'; import type { PresetColorKey } from '../theme/interface'; -import type { LiteralUnion } from '../_util/type'; +import type { LiteralUnion, CustomSlotsType } from '../_util/type'; import type { PresetStatusColorType } from '../_util/colors'; import { isPresetColor } from '../_util/colors'; @@ -42,7 +42,11 @@ export default defineComponent({ Ribbon, inheritAttrs: false, props: badgeProps(), - slots: ['text', 'count'], + slots: Object as CustomSlotsType<{ + text: any; + count: any; + default: any; + }>, setup(props, { slots, attrs }) { const { prefixCls, direction } = useConfigInject('badge', props); const [wrapSSR, hashId] = useStyle(prefixCls); diff --git a/components/badge/Ribbon.tsx b/components/badge/Ribbon.tsx index d61e38035..6725d833b 100644 --- a/components/badge/Ribbon.tsx +++ b/components/badge/Ribbon.tsx @@ -1,4 +1,4 @@ -import type { LiteralUnion } from '../_util/type'; +import type { CustomSlotsType, LiteralUnion } from '../_util/type'; import type { PresetColorType } from '../_util/colors'; import useStyle from './style'; import { isPresetColor } from '../_util/colors'; @@ -21,7 +21,10 @@ export default defineComponent({ name: 'ABadgeRibbon', inheritAttrs: false, props: ribbonProps(), - slots: ['text'], + slots: Object as CustomSlotsType<{ + text: any; + default: any; + }>, setup(props, { attrs, slots }) { const { prefixCls, direction } = useConfigInject('ribbon', props); const [wrapSSR, hashId] = useStyle(prefixCls); diff --git a/components/breadcrumb/Breadcrumb.tsx b/components/breadcrumb/Breadcrumb.tsx index 703035760..ad9e24b0d 100644 --- a/components/breadcrumb/Breadcrumb.tsx +++ b/components/breadcrumb/Breadcrumb.tsx @@ -6,9 +6,10 @@ import warning from '../_util/warning'; import type { BreadcrumbItemProps } from './BreadcrumbItem'; import BreadcrumbItem from './BreadcrumbItem'; import Menu from '../menu'; -import type { VueNode } from '../_util/type'; import useConfigInject from '../config-provider/hooks/useConfigInject'; import useStyle from './style'; +import type { CustomSlotsType, VueNode } from '../_util/type'; + export interface Route { path: string; breadcrumbName: string; @@ -57,7 +58,11 @@ export default defineComponent({ name: 'ABreadcrumb', inheritAttrs: false, props: breadcrumbProps(), - slots: ['separator', 'itemRender'], + slots: Object as CustomSlotsType<{ + separator: any; + itemRender: { route: Route; params: any; routes: Route[]; paths: string[] }; + default: any; + }>, setup(props, { slots, attrs }) { const { prefixCls, direction } = useConfigInject('breadcrumb', props); const [wrapSSR, hashId] = useStyle(prefixCls); diff --git a/components/breadcrumb/BreadcrumbItem.tsx b/components/breadcrumb/BreadcrumbItem.tsx index 312d87459..194114c98 100644 --- a/components/breadcrumb/BreadcrumbItem.tsx +++ b/components/breadcrumb/BreadcrumbItem.tsx @@ -8,6 +8,7 @@ import DownOutlined from '@ant-design/icons-vue/DownOutlined'; import useConfigInject from '../config-provider/hooks/useConfigInject'; import type { MouseEventHandler } from '../_util/EventInterface'; import { eventType, objectType } from '../_util/type'; +import type { CustomSlotsType } from '../_util/type'; export const breadcrumbItemProps = () => ({ prefixCls: String, @@ -26,7 +27,11 @@ export default defineComponent({ __ANT_BREADCRUMB_ITEM: true, props: breadcrumbItemProps(), // emits: ['click'], - slots: ['separator', 'overlay'], + slots: Object as CustomSlotsType<{ + separator: any; + overlay: any; + default: any; + }>, setup(props, { slots, attrs, emit }) { const { prefixCls } = useConfigInject('breadcrumb', props); /** diff --git a/components/button/button.tsx b/components/button/button.tsx index acdd7d07e..06a30f118 100644 --- a/components/button/button.tsx +++ b/components/button/button.tsx @@ -20,6 +20,7 @@ import type { ButtonType } from './buttonTypes'; import type { VNode } from 'vue'; import { GroupSizeContext } from './button-group'; import { useCompactItemContext } from '../space/Compact'; +import type { CustomSlotsType } from '../_util/type'; type Loading = boolean | number; @@ -36,7 +37,10 @@ export default defineComponent({ inheritAttrs: false, __ANT_BUTTON: true, props: initDefaultProps(buttonProps(), { type: 'default' }), - slots: ['icon'], + slots: Object as CustomSlotsType<{ + icon: any; + default: any; + }>, // emits: ['click', 'mousedown'], setup(props, { slots, attrs, emit, expose }) { const { prefixCls, autoInsertSpaceInButton, direction, size } = useConfigInject('btn', props); diff --git a/components/calendar/demo/customize-header.vue b/components/calendar/demo/customize-header.vue index fba5ec58b..dd925003f 100644 --- a/components/calendar/demo/customize-header.vue +++ b/components/calendar/demo/customize-header.vue @@ -37,7 +37,7 @@ Customize Calendar header content. :value="String(current.year())" @change=" newYear => { - onChange(current.year(newYear)); + onChange(current.year(+newYear)); } " > diff --git a/components/calendar/generateCalendar.tsx b/components/calendar/generateCalendar.tsx index a49f5d473..419332460 100644 --- a/components/calendar/generateCalendar.tsx +++ b/components/calendar/generateCalendar.tsx @@ -10,8 +10,8 @@ import type { import { useLocaleReceiver } from '../locale-provider/LocaleReceiver'; import enUS from './locale/en_US'; import CalendarHeader from './Header'; -import type { VueNode } from '../_util/type'; -import type { App } from 'vue'; +import type { CustomSlotsType, VueNode } from '../_util/type'; +import type { App, PropType } from 'vue'; import { computed, defineComponent, toRef } from 'vue'; import useConfigInject from '../config-provider/hooks/useConfigInject'; import classNames from '../_util/classNames'; @@ -88,36 +88,56 @@ function generateCalendar< ); } - const Calendar = defineComponent({ + const Calendar = defineComponent({ name: 'ACalendar', inheritAttrs: false, - props: [ - 'prefixCls', - 'locale', - 'validRange', - 'disabledDate', - 'dateFullCellRender', - 'dateCellRender', - 'monthFullCellRender', - 'monthCellRender', - 'headerRender', - 'value', - 'defaultValue', - 'mode', - 'fullscreen', - 'onChange', - 'onPanelChange', - 'onSelect', - 'valueFormat', - ] as any, - slots: [ - 'dateFullCellRender', - 'dateCellRender', - 'monthFullCellRender', - 'monthCellRender', - 'headerRender', - ], - setup(props, { emit, slots, attrs }) { + props: { + prefixCls: String, + locale: { type: Object as PropType, default: undefined as Props['locale'] }, + validRange: { type: Array as PropType, default: undefined }, + disabledDate: { type: Function as PropType, default: undefined }, + dateFullCellRender: { + type: Function as PropType, + default: undefined, + }, + dateCellRender: { type: Function as PropType, default: undefined }, + monthFullCellRender: { + type: Function as PropType, + default: undefined, + }, + monthCellRender: { type: Function as PropType, default: undefined }, + headerRender: { type: Function as PropType, default: undefined }, + value: { + type: [Object, String] as PropType, + default: undefined as Props['value'], + }, + defaultValue: { + type: [Object, String] as PropType, + default: undefined as Props['defaultValue'], + }, + mode: { type: String as PropType, default: undefined }, + fullscreen: { type: Boolean as PropType, default: undefined }, + onChange: { type: Function as PropType, default: undefined }, + 'onUpdate:value': { type: Function as PropType, default: undefined }, + onPanelChange: { type: Function as PropType, default: undefined }, + onSelect: { type: Function as PropType, default: undefined }, + valueFormat: { type: String, default: undefined }, + }, + slots: Object as CustomSlotsType<{ + dateFullCellRender?: { current: DateType }; + dateCellRender?: { current: DateType }; + monthFullCellRender?: { current: DateType }; + monthCellRender?: { current: DateType }; + headerRender?: { + value: DateType; + type: CalendarMode; + onChange: (date: DateType) => void; + onTypeChange: (type: CalendarMode) => void; + }; + default: any; + }>, + setup(p, { emit, slots, attrs }) { + const props = p as unknown as Props; const { prefixCls, direction } = useConfigInject('picker', props); // style diff --git a/components/card/Card.tsx b/components/card/Card.tsx index e4e81fe13..18d330cf0 100644 --- a/components/card/Card.tsx +++ b/components/card/Card.tsx @@ -9,6 +9,7 @@ import useConfigInject from '../config-provider/hooks/useConfigInject'; import devWarning from '../vc-util/devWarning'; import useStyle from './style'; import Skeleton from '../skeleton'; +import type { CustomSlotsType } from '../_util/type'; export interface CardTabListType { key: string; tab: any; @@ -53,7 +54,15 @@ const Card = defineComponent({ name: 'ACard', inheritAttrs: false, props: cardProps(), - slots: ['title', 'extra', 'tabBarExtraContent', 'actions', 'cover', 'customTab'], + slots: Object as CustomSlotsType<{ + title: any; + extra: any; + tabBarExtraContent: any; + actions: any; + cover: any; + customTab: CardTabListType; + default: any; + }>, setup(props, { slots, attrs }) { const { prefixCls, direction, size } = useConfigInject('card', props); const [wrapSSR, hashId] = useStyle(prefixCls); diff --git a/components/card/Meta.tsx b/components/card/Meta.tsx index 40a54bae7..c94eda974 100644 --- a/components/card/Meta.tsx +++ b/components/card/Meta.tsx @@ -3,6 +3,7 @@ import { defineComponent } from 'vue'; import { getPropsSlot } from '../_util/props-util'; import useConfigInject from '../config-provider/hooks/useConfigInject'; import { vNodeType } from '../_util/type'; +import type { CustomSlotsType } from '../_util/type'; export const cardMetaProps = () => ({ prefixCls: String, @@ -15,7 +16,12 @@ export default defineComponent({ compatConfig: { MODE: 3 }, name: 'ACardMeta', props: cardMetaProps(), - slots: ['title', 'description', 'avatar'], + slots: Object as CustomSlotsType<{ + title: any; + description: any; + avatar: any; + default: any; + }>, setup(props, { slots }) { const { prefixCls } = useConfigInject('card', props); return () => { diff --git a/components/collapse/Collapse.tsx b/components/collapse/Collapse.tsx index 99b498e69..722aae18c 100644 --- a/components/collapse/Collapse.tsx +++ b/components/collapse/Collapse.tsx @@ -16,6 +16,7 @@ import classNames from '../_util/classNames'; import useConfigInject from '../config-provider/hooks/useConfigInject'; import type { CollapsePanelProps } from './CollapsePanel'; import collapseMotion from '../_util/collapseMotion'; +import type { CustomSlotsType } from '../_util/type'; // CSSINJS import useStyle from './style'; @@ -44,8 +45,10 @@ export default defineComponent({ openAnimation: collapseMotion('ant-motion-collapse', false), expandIconPosition: 'start', }), - slots: ['expandIcon'], - // emits: ['change', 'update:activeKey'], + slots: Object as CustomSlotsType<{ + default?: any; + expandIcon?: CollapsePanelProps; + }>, setup(props, { attrs, slots, emit }) { const stateActiveKey = ref( getActiveKeysArray(firstNotUndefined([props.activeKey, props.defaultActiveKey])), diff --git a/components/collapse/CollapsePanel.tsx b/components/collapse/CollapsePanel.tsx index 24e17afc2..4ff984dd7 100644 --- a/components/collapse/CollapsePanel.tsx +++ b/components/collapse/CollapsePanel.tsx @@ -7,7 +7,7 @@ import Transition from '../_util/transition'; import classNames from '../_util/classNames'; import devWarning from '../vc-util/devWarning'; import useConfigInject from '../config-provider/hooks/useConfigInject'; - +import type { CustomSlotsType } from '../_util/type'; export { collapsePanelProps }; export type CollapsePanelProps = Partial>>; export default defineComponent({ @@ -21,7 +21,13 @@ export default defineComponent({ headerClass: '', forceRender: false, }), - slots: ['expandIcon', 'extra', 'header'], + slots: Object as CustomSlotsType<{ + expandIcon?: any; + extra?: any; + header?: any; + default?: any; + }>, + // emits: ['itemClick'], setup(props, { slots, emit, attrs }) { devWarning( diff --git a/components/comment/index.tsx b/components/comment/index.tsx index 48ed574d5..eda4e8ac5 100644 --- a/components/comment/index.tsx +++ b/components/comment/index.tsx @@ -2,7 +2,7 @@ import type { ExtractPropTypes } from 'vue'; import { defineComponent } from 'vue'; import PropTypes from '../_util/vue-types'; import { flattenChildren } from '../_util/props-util'; -import type { VueNode } from '../_util/type'; +import type { CustomSlotsType, VueNode } from '../_util/type'; import { withInstall } from '../_util/type'; import useConfigInject from '../config-provider/hooks/useConfigInject'; @@ -30,7 +30,14 @@ const Comment = defineComponent({ name: 'AComment', inheritAttrs: false, props: commentProps(), - slots: ['actions', 'author', 'avatar', 'content', 'datetime'], + slots: Object as CustomSlotsType<{ + actions: any; + author: any; + avatar: any; + content: any; + datetime: any; + default: any; + }>, setup(props, { slots, attrs }) { const { prefixCls, direction } = useConfigInject('comment', props); @@ -50,7 +57,7 @@ const Comment = defineComponent({ return () => { const pre = prefixCls.value; - const actions = props.actions ?? slots.actions?.(); + const actions: any[] = props.actions ?? slots.actions?.(); const author = props.author ?? slots.author?.(); const avatar = props.avatar ?? slots.avatar?.(); const content = props.content ?? slots.content?.(); diff --git a/components/date-picker/generatePicker/generateRangePicker.tsx b/components/date-picker/generatePicker/generateRangePicker.tsx index 0039623ca..a321706c3 100644 --- a/components/date-picker/generatePicker/generateRangePicker.tsx +++ b/components/date-picker/generatePicker/generateRangePicker.tsx @@ -23,6 +23,7 @@ import { getMergedStatus, getStatusClassNames } from '../../_util/statusUtils'; import useStyle from '../style'; import { useCompactItemContext } from '../../space/Compact'; import devWarning from '../../vc-util/devWarning'; +import type { CustomSlotsType } from '../../_util/type'; export default function generateRangePicker( generateConfig: GenerateConfig, @@ -37,18 +38,18 @@ export default function generateRangePicker( ...rangePickerProps(), ...extraProps, }, - slots: [ - 'suffixIcon', - // 'clearIcon', - 'prevIcon', - 'nextIcon', - 'superPrevIcon', - 'superNextIcon', - // 'panelRender', - 'dateRender', - 'renderExtraFooter', - // 'separator', - ], + slots: Object as CustomSlotsType<{ + suffixIcon?: any; + prevIcon?: any; + nextIcon?: any; + superPrevIcon?: any; + superNextIcon?: any; + dateRender?: any; + renderExtraFooter?: any; + default?: any; + separator?: any; + clearIcon?: any; + }>, setup(_props, { expose, slots, attrs, emit }) { const props = _props as unknown as CommonProps & RangePickerProps; const formItemContext = useInjectFormItemContext(); diff --git a/components/date-picker/generatePicker/generateSinglePicker.tsx b/components/date-picker/generatePicker/generateSinglePicker.tsx index 4a9b38305..f20fbb260 100644 --- a/components/date-picker/generatePicker/generateSinglePicker.tsx +++ b/components/date-picker/generatePicker/generateSinglePicker.tsx @@ -18,7 +18,7 @@ import devWarning from '../../vc-util/devWarning'; import { FormItemInputContext, useInjectFormItemContext } from '../../form/FormItemContext'; import { getMergedStatus, getStatusClassNames } from '../../_util/statusUtils'; import { useCompactItemContext } from '../../space/Compact'; - +import type { CustomSlotsType } from '../../_util/type'; //CSSINJS import useStyle from '../style'; @@ -37,18 +37,19 @@ export default function generateSinglePicker( name: displayName, inheritAttrs: false, props: comProps, - slots: [ - 'suffixIcon', - // 'clearIcon', - 'prevIcon', - 'nextIcon', - 'superPrevIcon', - 'superNextIcon', - // 'panelRender', - 'dateRender', - 'renderExtraFooter', - 'monthCellRender', - ], + slots: Object as CustomSlotsType<{ + suffixIcon?: any; + prevIcon?: any; + nextIcon?: any; + superPrevIcon?: any; + superNextIcon?: any; + dateRender?: any; + renderExtraFooter?: any; + monthCellRender?: any; + monthCellContentRender?: any; + clearIcon?: any; + default?: any; + }>, setup(_props, { slots, expose, attrs, emit }) { // 兼容 vue 3.2.7 const props = _props as unknown as CommonProps & @@ -178,7 +179,7 @@ export default function generateSinglePicker( id = formItemContext.id.value, ...restProps } = p; - const showTime = (p as any).showTime === '' ? true : p.showTime; + const showTime = (p.showTime as string) === '' ? true : p.showTime; const { format } = p as any; let additionalOverrideProps: any = {}; diff --git a/components/descriptions/index.tsx b/components/descriptions/index.tsx index 793a94811..9068ec530 100644 --- a/components/descriptions/index.tsx +++ b/components/descriptions/index.tsx @@ -26,7 +26,7 @@ import PropTypes from '../_util/vue-types'; import { cloneElement } from '../_util/vnode'; import { flattenChildren } from '../_util/props-util'; import useConfigInject from '../config-provider/hooks/useConfigInject'; - +import type { CustomSlotsType } from '../_util/type'; import useStyle from './style'; export const DescriptionsItemProps = { @@ -51,7 +51,6 @@ export const DescriptionsItem = defineComponent({ compatConfig: { MODE: 3 }, name: 'ADescriptionsItem', props: descriptionsItemProp(), - slots: ['label'], setup(_, { slots }) { return () => slots.default?.(); }, @@ -164,7 +163,11 @@ const Descriptions = defineComponent({ name: 'ADescriptions', inheritAttrs: false, props: descriptionsProps(), - slots: ['title', 'extra'], + slots: Object as CustomSlotsType<{ + title?: any; + extra?: any; + default?: any; + }>, Item: DescriptionsItem, setup(props, { slots, attrs }) { const { prefixCls, direction } = useConfigInject('descriptions', props); diff --git a/components/drawer/index.tsx b/components/drawer/index.tsx index d4beb9058..89ed320f3 100644 --- a/components/drawer/index.tsx +++ b/components/drawer/index.tsx @@ -17,6 +17,7 @@ import PropTypes from '../_util/vue-types'; import CloseOutlined from '@ant-design/icons-vue/CloseOutlined'; import useConfigInject from '../config-provider/hooks/useConfigInject'; import { objectType, withInstall } from '../_util/type'; +import type { CustomSlotsType } from '../_util/type'; import omit from '../_util/omit'; import devWarning from '../vc-util/devWarning'; import type { KeyboardEventHandler, MouseEventHandler } from '../_util/EventInterface'; @@ -114,7 +115,14 @@ const Drawer = defineComponent({ keyboard: true, push: defaultPushState, }), - slots: ['closeIcon', 'title', 'extra', 'footer', 'handle'], + slots: Object as CustomSlotsType<{ + closeIcon: any; + title: any; + extra: any; + footer: any; + handle: any; + default: any; + }>, // emits: ['update:visible', 'close', 'afterVisibleChange'], setup(props, { emit, slots, attrs }) { const sPush = shallowRef(false); diff --git a/components/dropdown/dropdown-button.tsx b/components/dropdown/dropdown-button.tsx index baa418647..03a6c2a31 100644 --- a/components/dropdown/dropdown-button.tsx +++ b/components/dropdown/dropdown-button.tsx @@ -6,8 +6,11 @@ import classNames from '../_util/classNames'; import { initDefaultProps } from '../_util/props-util'; import { dropdownButtonProps } from './props'; import EllipsisOutlined from '@ant-design/icons-vue/EllipsisOutlined'; + import useConfigInject from '../config-provider/hooks/useConfigInject'; import useStyle from './style'; +import type { CustomSlotsType } from '../_util/type'; + const ButtonGroup = Button.Group; export type DropdownButtonProps = Partial>>; @@ -22,8 +25,14 @@ export default defineComponent({ placement: 'bottomRight', type: 'default', }), - // emits: ['click', 'visibleChange', 'update:visible'], - slots: ['icon', 'leftButton', 'rightButton', 'overlay'], + // emits: ['click', 'visibleChange', 'update:visible'],s + slots: Object as CustomSlotsType<{ + icon: any; + leftButton: { button: any }; + rightButton: { button: any }; + overlay: any; + default: any; + }>, setup(props, { slots, attrs, emit }) { const handleVisibleChange = (val: boolean) => { emit('update:visible', val); diff --git a/components/dropdown/dropdown.tsx b/components/dropdown/dropdown.tsx index 1fc02a71e..79639d9e9 100644 --- a/components/dropdown/dropdown.tsx +++ b/components/dropdown/dropdown.tsx @@ -14,6 +14,7 @@ import getPlacements from '../_util/placements'; import warning from '../_util/warning'; import useStyle from './style'; import { useProvideOverride } from '../menu/src/OverrideContext'; +import type { CustomSlotsType } from '../_util/type'; export type DropdownProps = Partial>>; @@ -28,7 +29,10 @@ const Dropdown = defineComponent({ trigger: 'hover', }), // emits: ['visibleChange', 'update:visible'], - slots: ['overlay'], + slots: Object as CustomSlotsType<{ + default?: any; + overlay?: any; + }>, setup(props, { slots, attrs, emit }) { const { prefixCls, rootPrefixCls, direction, getPopupContainer } = useConfigInject( 'dropdown', diff --git a/components/form/FormItem.tsx b/components/form/FormItem.tsx index 9a2c1c4fe..1f8a1eb2e 100644 --- a/components/form/FormItem.tsx +++ b/components/form/FormItem.tsx @@ -32,6 +32,7 @@ import { getNamePath } from './utils/valueUtil'; import { toArray } from './utils/typeUtil'; import { warning } from '../vc-util/warning'; import find from 'lodash-es/find'; +import type { CustomSlotsType } from '../_util/type'; import { tuple } from '../_util/type'; import type { FormLabelAlign, @@ -149,7 +150,12 @@ export default defineComponent({ inheritAttrs: false, __ANT_NEW_FORM_ITEM: true, props: formItemProps(), - slots: ['help', 'label', 'extra'], + slots: Object as CustomSlotsType<{ + help: any; + label: any; + extra: any; + default: any; + }>, setup(props, { slots, attrs, expose }) { warning(props.prop === undefined, `\`prop\` is deprecated. Please use \`name\` instead.`); const eventKey = `form-item-${++indexGuid}`; diff --git a/components/form/FormItemInput.tsx b/components/form/FormItemInput.tsx index 423058c8c..656116c14 100644 --- a/components/form/FormItemInput.tsx +++ b/components/form/FormItemInput.tsx @@ -4,7 +4,7 @@ import { useProvideForm, useInjectForm, useProvideFormItemPrefix } from './conte import ErrorList from './ErrorList'; import classNames from '../_util/classNames'; import type { ValidateStatus } from './FormItem'; -import type { VueNode } from '../_util/type'; +import type { CustomSlotsType, VueNode } from '../_util/type'; import type { HTMLAttributes } from 'vue'; import { computed, defineComponent } from 'vue'; import { filterEmpty } from '../_util/props-util'; @@ -25,7 +25,12 @@ export interface FormItemInputProps { const FormItemInput = defineComponent({ compatConfig: { MODE: 3 }, - slots: ['help', 'extra', 'errors'], + slots: Object as CustomSlotsType<{ + help: any; + errors: any; + extra: any; + default: any; + }>, inheritAttrs: false, props: [ 'prefixCls', diff --git a/components/input-number/index.tsx b/components/input-number/index.tsx index c2cd97ef9..05caeb101 100644 --- a/components/input-number/index.tsx +++ b/components/input-number/index.tsx @@ -24,6 +24,7 @@ import useStyle from './style'; import { NoCompactStyle, useCompactItemContext } from '../space/Compact'; import { useInjectDisabled } from '../config-provider/DisabledContext'; +import type { CustomSlotsType } from '../_util/type'; const baseProps = baseInputNumberProps(); export const inputNumberProps = () => ({ ...baseProps, @@ -49,7 +50,15 @@ const InputNumber = defineComponent({ inheritAttrs: false, props: inputNumberProps(), // emits: ['focus', 'blur', 'change', 'input', 'update:value'], - slots: ['addonBefore', 'addonAfter', 'prefix'], + slots: Object as CustomSlotsType<{ + addonBefore?: any; + addonAfter?: any; + prefix?: any; + default?: any; + upIcon?: any; + downIcon?: any; + }>, + setup(props, { emit, expose, attrs, slots }) { const formItemContext = useInjectFormItemContext(); const formItemInputContext = FormItemInputContext.useInject(); diff --git a/components/input-number/src/InputNumber.tsx b/components/input-number/src/InputNumber.tsx index e6b64d7d3..811b8eeef 100644 --- a/components/input-number/src/InputNumber.tsx +++ b/components/input-number/src/InputNumber.tsx @@ -11,6 +11,7 @@ import type { ChangeEvent, KeyboardEventHandler } from '../../_util/EventInterfa import KeyCode from '../../_util/KeyCode'; import classNames from '../../_util/classNames'; import { booleanType, stringType, someType, functionType } from '../../_util/type'; +import type { CustomSlotsType } from '../../_util/type'; /** * We support `stringMode` which need handle correct type when user call in onChange @@ -83,7 +84,11 @@ export default defineComponent({ ...inputNumberProps(), lazy: Boolean, }, - slots: ['upHandler', 'downHandler'], + slots: Object as CustomSlotsType<{ + upHandler: any; + downHandler: any; + default: any; + }>, setup(props, { attrs, slots, emit, expose }) { const inputRef = shallowRef(); const focus = shallowRef(false); diff --git a/components/input-number/src/StepHandler.tsx b/components/input-number/src/StepHandler.tsx index 95845fb65..a433a841e 100644 --- a/components/input-number/src/StepHandler.tsx +++ b/components/input-number/src/StepHandler.tsx @@ -2,6 +2,7 @@ import isMobile from '../../vc-util/isMobile'; import { onBeforeUnmount, ref, defineComponent } from 'vue'; import classNames from '../../_util/classNames'; import { functionType } from '../../_util/type'; +import type { CustomSlotsType } from '../../_util/type'; /** * When click and hold on a button - the speed of auto changing the value. @@ -23,7 +24,11 @@ export default defineComponent({ downDisabled: Boolean, onStep: functionType<(up: boolean) => void>(), }, - slots: ['upNode', 'downNode'], + slots: Object as CustomSlotsType<{ + upNode?: any; + downNode?: any; + default?: any; + }>, setup(props, { slots, emit }) { const stepTimeoutRef = ref(); diff --git a/components/list/Item.tsx b/components/list/Item.tsx index a89875327..bdfe28d9f 100644 --- a/components/list/Item.tsx +++ b/components/list/Item.tsx @@ -9,6 +9,7 @@ import ItemMeta from './ItemMeta'; import useConfigInject from '../config-provider/hooks/useConfigInject'; import { ListContextKey } from './contextKey'; import type { ListGridType } from '.'; +import type { CustomSlotsType } from '../_util/type'; export const listItemProps = () => ({ prefixCls: String, @@ -25,7 +26,11 @@ export default defineComponent({ inheritAttrs: false, Meta: ItemMeta, props: listItemProps(), - slots: ['actions', 'extra'], + slots: Object as CustomSlotsType<{ + actions: any; + extra: any; + default: any; + }>, setup(props, { slots, attrs }) { const { itemLayout, grid } = inject(ListContextKey, { grid: ref(), diff --git a/components/list/ItemMeta.tsx b/components/list/ItemMeta.tsx index 31cad5627..c2ff70209 100644 --- a/components/list/ItemMeta.tsx +++ b/components/list/ItemMeta.tsx @@ -2,6 +2,7 @@ import type { ExtractPropTypes } from 'vue'; import { defineComponent } from 'vue'; import useConfigInject from '../config-provider/hooks/useConfigInject'; import PropTypes from '../_util/vue-types'; +import type { CustomSlotsType } from '../_util/type'; export const listItemMetaProps = () => ({ avatar: PropTypes.any, @@ -18,7 +19,12 @@ export default defineComponent({ props: listItemMetaProps(), displayName: 'AListItemMeta', // 兼容历史函数式组件 __ANT_LIST_ITEM_META: true, - slots: ['avatar', 'description', 'title'], + slots: Object as CustomSlotsType<{ + avatar: any; + description: any; + title: any; + default: any; + }>, setup(props, { slots }) { const { prefixCls } = useConfigInject('list', props); return () => { diff --git a/components/list/index.tsx b/components/list/index.tsx index dd5a150c0..60d91cdbc 100644 --- a/components/list/index.tsx +++ b/components/list/index.tsx @@ -11,7 +11,6 @@ import { Row } from '../grid'; import Item from './Item'; import { flattenChildren } from '../_util/props-util'; import initDefaultProps from '../_util/props-util/initDefaultProps'; -import type { Key } from '../_util/type'; import { arrayType, someType, @@ -20,6 +19,7 @@ import { vNodeType, functionType, } from '../_util/type'; +import type { CustomSlotsType, Key } from '../_util/type'; import ItemMeta from './ItemMeta'; import useConfigInject from '../config-provider/hooks/useConfigInject'; import useBreakpoint from '../_util/hooks/useBreakpoint'; @@ -90,7 +90,14 @@ const List = defineComponent({ loading: false, pagination: false, }), - slots: ['extra', 'loadMore', 'renderItem', 'header', 'footer'], + slots: Object as CustomSlotsType<{ + extra: any; + loadMore: any; + renderItem: { item: any; index: number }; + header: any; + footer: any; + default: any; + }>, setup(props, { slots, attrs }) { provide(ListContextKey, { grid: toRef(props, 'grid'), diff --git a/components/mentions/index.tsx b/components/mentions/index.tsx index 1094ee27b..1715c3ead 100644 --- a/components/mentions/index.tsx +++ b/components/mentions/index.tsx @@ -17,6 +17,7 @@ import { useProvideOverride } from '../menu/src/OverrideContext'; import warning from '../_util/warning'; import Spin from '../spin'; import devWarning from '../vc-util/devWarning'; +import type { CustomSlotsType } from '../_util/type'; interface MentionsConfig { prefix?: string | string[]; @@ -103,7 +104,11 @@ const Mentions = defineComponent({ name: 'AMentions', inheritAttrs: false, props: mentionsProps(), - slots: ['notFoundContent', 'option'], + slots: Object as CustomSlotsType<{ + notFoundContent?: any; + option?: any; + default?: any; + }>, setup(props, { slots, emit, attrs, expose }) { // =================== Warning ===================== if (process.env.NODE_ENV !== 'production') { diff --git a/components/menu/src/ItemGroup.tsx b/components/menu/src/ItemGroup.tsx index 970ccfe8d..218e80978 100644 --- a/components/menu/src/ItemGroup.tsx +++ b/components/menu/src/ItemGroup.tsx @@ -6,6 +6,7 @@ import { useInjectMenu } from './hooks/useMenuContext'; import { useMeasure } from './hooks/useKeyPath'; import type { ItemType } from './interface'; import { objectType } from '../../_util/type'; +import type { CustomSlotsType } from '../../_util/type'; export const menuItemGroupProps = () => ({ title: PropTypes.any, @@ -20,7 +21,10 @@ export default defineComponent({ name: 'AMenuItemGroup', inheritAttrs: false, props: menuItemGroupProps(), - slots: ['title'], + slots: Object as CustomSlotsType<{ + title?: any; + default?: any; + }>, setup(props, { slots, attrs }) { const { prefixCls } = useInjectMenu(); const groupPrefixCls = computed(() => `${prefixCls.value}-item-group`); diff --git a/components/menu/src/Menu.tsx b/components/menu/src/Menu.tsx index 9730b5a1a..1e6a7461d 100644 --- a/components/menu/src/Menu.tsx +++ b/components/menu/src/Menu.tsx @@ -1,4 +1,4 @@ -import type { Key } from '../../_util/type'; +import type { CustomSlotsType, Key } from '../../_util/type'; import type { ExtractPropTypes, PropType, VNode } from 'vue'; import { shallowRef, @@ -58,9 +58,9 @@ export const menuProps = () => ({ activeKey: String, // 内部组件使用 selectable: { type: Boolean, default: true }, multiple: { type: Boolean, default: false }, - + tabindex: { type: [Number, String] }, motion: Object as PropType, - + role: String, theme: { type: String as PropType, default: 'light' }, mode: { type: String as PropType, default: 'vertical' }, @@ -95,7 +95,11 @@ export default defineComponent({ name: 'AMenu', inheritAttrs: false, props: menuProps(), - slots: ['expandIcon', 'overflowedIndicator'], + slots: Object as CustomSlotsType<{ + expandIcon?: { isOpen: boolean; [key: string]: any }; + overflowedIndicator?: any; + default: any; + }>, setup(props, { slots, emit, attrs }) { const { direction, getPrefixCls } = useConfigInject('menu', props); const override = useInjectOverride(); diff --git a/components/menu/src/MenuItem.tsx b/components/menu/src/MenuItem.tsx index ce741a433..c487830c7 100644 --- a/components/menu/src/MenuItem.tsx +++ b/components/menu/src/MenuItem.tsx @@ -20,6 +20,7 @@ import Overflow from '../../vc-overflow'; import devWarning from '../../vc-util/devWarning'; import type { MouseEventHandler } from '../../_util/EventInterface'; import { objectType } from '../../_util/type'; +import type { CustomSlotsType } from '../../_util/type'; let indexGuid = 0; export const menuItemProps = () => ({ @@ -45,8 +46,12 @@ export default defineComponent({ name: 'AMenuItem', inheritAttrs: false, props: menuItemProps(), - // emits: ['mouseenter', 'mouseleave', 'click', 'keydown', 'focus'], - slots: ['icon', 'title'], + slots: Object as CustomSlotsType<{ + icon?: any; + title?: any; + default?: any; + }>, + setup(props, { slots, emit, attrs }) { const instance = getCurrentInstance(); const isMeasure = useMeasure(); diff --git a/components/menu/src/PopupTrigger.tsx b/components/menu/src/PopupTrigger.tsx index 93c9183fa..b79e025ec 100644 --- a/components/menu/src/PopupTrigger.tsx +++ b/components/menu/src/PopupTrigger.tsx @@ -7,6 +7,7 @@ import { placements, placementsRtl } from './placements'; import raf from '../../_util/raf'; import classNames from '../../_util/classNames'; import { getTransitionProps } from '../../_util/transition'; +import type { CustomSlotsType } from '../../_util/type'; const popupPlacementMap = { horizontal: 'bottomLeft', @@ -28,7 +29,10 @@ export default defineComponent({ disabled: Boolean, onVisibleChange: Function as PropType<(visible: boolean) => void>, }, - slots: ['popup'], + slots: Object as CustomSlotsType<{ + default?: any; + popup?: any; + }>, emits: ['visibleChange'], setup(props, { slots, emit }) { const innerVisible = shallowRef(false); diff --git a/components/menu/src/SubMenu.tsx b/components/menu/src/SubMenu.tsx index 5d5fdbd78..b95076e65 100644 --- a/components/menu/src/SubMenu.tsx +++ b/components/menu/src/SubMenu.tsx @@ -27,7 +27,7 @@ import Overflow from '../../vc-overflow'; import devWarning from '../../vc-util/devWarning'; import isValid from '../../_util/isValid'; import type { MouseEventHandler } from '../../_util/EventInterface'; -import type { Key } from '../../_util/type'; +import type { Key, CustomSlotsType } from '../../_util/type'; import { objectType } from '../../_util/type'; import type { ItemType, MenuTheme } from './interface'; @@ -59,8 +59,12 @@ export default defineComponent({ name: 'ASubMenu', inheritAttrs: false, props: subMenuProps(), - slots: ['icon', 'title', 'expandIcon'], - // emits: ['titleClick', 'mouseenter', 'mouseleave'], + slots: Object as CustomSlotsType<{ + icon?: any; + title?: any; + expandIcon?: { isOpen: boolean; [key: string]: any }; + default?: any; + }>, setup(props, { slots, attrs, emit }) { useProvideFirstLevel(false); const isMeasure = useMeasure(); diff --git a/components/page-header/index.tsx b/components/page-header/index.tsx index 849488600..cf8cfdf18 100644 --- a/components/page-header/index.tsx +++ b/components/page-header/index.tsx @@ -9,8 +9,11 @@ import type { AvatarProps } from '../avatar'; import Avatar from '../avatar'; import TransButton from '../_util/transButton'; import LocaleReceiver from '../locale-provider/LocaleReceiver'; + import { objectType, vNodeType, withInstall } from '../_util/type'; import useConfigInject from '../config-provider/hooks/useConfigInject'; +import type { CustomSlotsType } from '../_util/type'; + import classNames from '../_util/classNames'; import ResizeObserver from '../vc-resize-observer'; import useDestroyed from '../_util/hooks/useDestroyed'; @@ -42,7 +45,17 @@ const PageHeader = defineComponent({ inheritAttrs: false, props: pageHeaderProps(), // emits: ['back'], - slots: ['backIcon', 'avatar', 'breadcrumb', 'title', 'subTitle', 'tags', 'extra', 'footer'], + slots: Object as CustomSlotsType<{ + backIcon: any; + avatar: any; + breadcrumb: any; + title: any; + subTitle: any; + tags: any; + extra: any; + footer: any; + default: any; + }>, setup(props, { emit, slots, attrs }) { const { prefixCls, direction, pageHeader } = useConfigInject('page-header', props); diff --git a/components/popconfirm/index.tsx b/components/popconfirm/index.tsx index 1682c0853..e4e788b06 100644 --- a/components/popconfirm/index.tsx +++ b/components/popconfirm/index.tsx @@ -8,8 +8,11 @@ import { convertLegacyProps } from '../button/buttonTypes'; import ExclamationCircleFilled from '@ant-design/icons-vue/ExclamationCircleFilled'; import Button from '../button'; import { useLocaleReceiver } from '../locale-provider/LocaleReceiver'; + import defaultLocale from '../locale/en_US'; import { anyType, objectType, stringType, withInstall } from '../_util/type'; +import type { CustomSlotsType } from '../_util/type'; + import useMergedState from '../_util/hooks/useMergedState'; import KeyCode from '../_util/KeyCode'; @@ -63,7 +66,18 @@ const Popconfirm = defineComponent({ okType: 'primary', disabled: false, }), - slots: ['title', 'content', 'okText', 'icon', 'cancelText', 'cancelButton', 'okButton'], + slots: Object as CustomSlotsType<{ + title?: any; + content?: any; + description?: any; + okText?: any; + icon?: any; + cancel?: any; + cancelText?: any; + cancelButton?: any; + okButton?: any; + default?: any; + }>, // emits: ['update:open', 'visibleChange'], setup(props: PopconfirmProps, { slots, emit, expose, attrs }) { const rootRef = ref(); diff --git a/components/progress/progress.tsx b/components/progress/progress.tsx index d43ccff1f..137c0470c 100644 --- a/components/progress/progress.tsx +++ b/components/progress/progress.tsx @@ -11,7 +11,7 @@ import { getSize, getSuccessPercent, validProgress } from './utils'; import useConfigInject from '../config-provider/hooks/useConfigInject'; import devWarning from '../vc-util/devWarning'; import { progressProps, progressStatuses } from './props'; -import type { VueNode } from '../_util/type'; +import type { VueNode, CustomSlotsType, VueNode } from '../_util/type'; import useStyle from './style'; export default defineComponent({ @@ -27,7 +27,10 @@ export default defineComponent({ size: 'default', strokeLinecap: 'round', }), - slots: ['format'], + slots: Object as CustomSlotsType<{ + default?: any; + format?: any; + }>, setup(props, { slots, attrs }) { const { prefixCls, direction } = useConfigInject('progress', props); const [wrapSSR, hashId] = useStyle(prefixCls); diff --git a/components/result/index.tsx b/components/result/index.tsx index b90a93efc..307f200e9 100644 --- a/components/result/index.tsx +++ b/components/result/index.tsx @@ -10,6 +10,7 @@ import serverError from './serverError'; import unauthorized from './unauthorized'; import useConfigInject from '../config-provider/hooks/useConfigInject'; import classNames from '../_util/classNames'; +import type { CustomSlotsType } from '../_util/type'; import useStyle from './style'; @@ -65,7 +66,13 @@ const Result = defineComponent({ name: 'AResult', inheritAttrs: false, props: resultProps(), - slots: ['title', 'subTitle', 'icon', 'extra'], + slots: Object as CustomSlotsType<{ + title?: any; + subTitle?: any; + icon?: any; + extra?: any; + default?: any; + }>, setup(props, { slots, attrs }) { const { prefixCls, direction } = useConfigInject('result', props); diff --git a/components/select/index.tsx b/components/select/index.tsx index 4d86638fd..d77100df9 100644 --- a/components/select/index.tsx +++ b/components/select/index.tsx @@ -15,6 +15,7 @@ import type { SelectCommonPlacement } from '../_util/transition'; import { getTransitionDirection, getTransitionName } from '../_util/transition'; import type { SizeType } from '../config-provider'; import { initDefaultProps } from '../_util/props-util'; + import type { InputStatus } from '../_util/statusUtils'; import { getStatusClassNames, getMergedStatus } from '../_util/statusUtils'; import { stringType, someType, functionType, booleanType } from '../_util/type'; @@ -24,6 +25,8 @@ import useStyle from './style'; import { useInjectDisabled } from '../config-provider/DisabledContext'; import devWarning from '../vc-util/devWarning'; +import type { CustomSlotsType } from '../_util/type'; + type RawValue = string | number; export type OptionType = typeof Option; @@ -76,20 +79,20 @@ const Select = defineComponent({ listItemHeight: 24, }), SECRET_COMBOBOX_MODE_DO_NOT_USE, - // emits: ['change', 'update:value', 'blur'], - slots: [ - 'notFoundContent', - 'suffixIcon', - 'itemIcon', - 'removeIcon', - 'clearIcon', - 'dropdownRender', - 'option', - 'placeholder', - 'tagRender', - 'maxTagPlaceholder', - 'optionLabel', // donot use, maybe remove it - ], + slots: Object as CustomSlotsType<{ + notFoundContent: any; + suffixIcon: any; + itemIcon: any; + removeIcon: any; + clearIcon: any; + dropdownRender: any; + option: any; + placeholder: any; + tagRender: any; + maxTagPlaceholder: any; + optionLabel: any; + default: any; + }>, setup(props, { attrs, emit, slots, expose }) { const selectRef = ref(); const formItemContext = useInjectFormItemContext(); diff --git a/components/slider/index.tsx b/components/slider/index.tsx index 4ddb1334c..f08c430fe 100644 --- a/components/slider/index.tsx +++ b/components/slider/index.tsx @@ -3,7 +3,8 @@ import { computed, ref, defineComponent } from 'vue'; import VcSlider from '../vc-slider/src/Slider'; import VcRange from '../vc-slider/src/Range'; import VcHandle from '../vc-slider/src/Handle'; -import type { VueNode } from '../_util/type'; + +import type { VueNode, CustomSlotsType } from '../_util/type'; import { stringType, booleanType, @@ -94,7 +95,10 @@ const Slider = defineComponent({ inheritAttrs: false, props: sliderProps(), // emits: ['update:value', 'change', 'afterChange', 'blur'], - slots: ['mark'], + slots: Object as CustomSlotsType<{ + mark?: any; + default?: any; + }>, setup(props, { attrs, slots, emit, expose }) { // Warning for deprecated usage if (process.env.NODE_ENV !== 'production') { diff --git a/components/space/index.tsx b/components/space/index.tsx index 3d5b88ffc..c61b12ca8 100644 --- a/components/space/index.tsx +++ b/components/space/index.tsx @@ -3,6 +3,7 @@ import { defineComponent, computed, ref, watch, Fragment } from 'vue'; import PropTypes from '../_util/vue-types'; import { filterEmpty } from '../_util/props-util'; import type { SizeType } from '../config-provider'; +import type { CustomSlotsType } from '../_util/type'; import { booleanType, tuple } from '../_util/type'; import useConfigInject from '../config-provider/hooks/useConfigInject'; import useFlexGapSupport from '../_util/hooks/useFlexGapSupport'; @@ -38,7 +39,10 @@ const Space = defineComponent({ name: 'ASpace', inheritAttrs: false, props: spaceProps(), - slots: ['split'], + slots: Object as CustomSlotsType<{ + split?: any; + default?: any; + }>, setup(props, { slots, attrs }) { const { prefixCls, space, direction: directionConfig } = useConfigInject('space', props); const [wrapSSR, hashId] = useStyle(prefixCls); diff --git a/components/statistic/Statistic.tsx b/components/statistic/Statistic.tsx index 35127402b..ac87d2e2a 100644 --- a/components/statistic/Statistic.tsx +++ b/components/statistic/Statistic.tsx @@ -9,6 +9,7 @@ import useConfigInject from '../config-provider/hooks/useConfigInject'; // CSSINJS import useStyle from './style'; import { anyType, booleanType, functionType, someType, vNodeType } from '../_util/type'; +import type { CustomSlotsType } from '../_util/type'; export const statisticProps = () => ({ prefixCls: String, @@ -37,7 +38,13 @@ export default defineComponent({ groupSeparator: ',', loading: false, }), - slots: ['title', 'prefix', 'suffix', 'formatter'], + slots: Object as CustomSlotsType<{ + title?: any; + prefix?: any; + suffix?: any; + formatter?: any; + default?: any; + }>, setup(props, { slots, attrs }) { const { prefixCls, direction } = useConfigInject('statistic', props); diff --git a/components/steps/index.tsx b/components/steps/index.tsx index cc3a53347..2316d6346 100644 --- a/components/steps/index.tsx +++ b/components/steps/index.tsx @@ -2,7 +2,7 @@ import type { App, ExtractPropTypes } from 'vue'; import { computed, defineComponent } from 'vue'; import CloseOutlined from '@ant-design/icons-vue/CloseOutlined'; import CheckOutlined from '@ant-design/icons-vue/CheckOutlined'; -import type { VueNode } from '../_util/type'; +import type { VueNode, CustomSlotsType } from '../_util/type'; import { anyType, booleanType, stringType, functionType, someType, arrayType } from '../_util/type'; import initDefaultProps from '../_util/props-util/initDefaultProps'; import VcSteps, { Step as VcStep } from '../vc-steps'; @@ -61,7 +61,11 @@ const Steps = defineComponent({ responsive: true, labelPlacement: 'horizontal', }), - slots: ['progressDot'], + slots: Object as CustomSlotsType<{ + progressDot: any; + default: any; + }>, + // emits: ['update:current', 'change'], setup(props, { attrs, slots, emit }) { const { prefixCls, direction: rtlDirection, configProvider } = useConfigInject('steps', props); diff --git a/components/switch/index.tsx b/components/switch/index.tsx index 14d14221a..33a17eeb3 100644 --- a/components/switch/index.tsx +++ b/components/switch/index.tsx @@ -5,6 +5,7 @@ import PropTypes from '../_util/vue-types'; import KeyCode from '../_util/KeyCode'; import Wave from '../_util/wave'; import warning from '../_util/warning'; +import type { CustomSlotsType } from '../_util/type'; import { tuple, withInstall } from '../_util/type'; import { getPropsSlot } from '../_util/props-util'; import useConfigInject from '../config-provider/hooks/useConfigInject'; @@ -60,7 +61,11 @@ const Switch = defineComponent({ __ANT_SWITCH: true, inheritAttrs: false, props: switchProps(), - slots: ['checkedChildren', 'unCheckedChildren'], + slots: Object as CustomSlotsType<{ + checkedChildren: any; + unCheckedChildren: any; + default: any; + }>, // emits: ['update:checked', 'mouseup', 'change', 'click', 'keydown', 'blur'], setup(props, { attrs, slots, expose, emit }) { const formItemContext = useInjectFormItemContext(); diff --git a/components/table/Column.tsx b/components/table/Column.tsx index 588cddedf..6ee9d992e 100644 --- a/components/table/Column.tsx +++ b/components/table/Column.tsx @@ -1,10 +1,16 @@ import { defineComponent } from 'vue'; import type { ColumnType } from './interface'; +import type { CustomSlotsType } from '../_util/type'; export type ColumnProps = ColumnType; export default defineComponent({ name: 'ATableColumn', - slots: ['title', 'filterIcon'], + slots: Object as CustomSlotsType<{ + title?: any; + filterIcon?: any; + default?: any; + }>, + render() { return null; }, diff --git a/components/table/ColumnGroup.tsx b/components/table/ColumnGroup.tsx index b1d03ae0a..7d6b78459 100644 --- a/components/table/ColumnGroup.tsx +++ b/components/table/ColumnGroup.tsx @@ -1,9 +1,13 @@ import { defineComponent } from 'vue'; import type { ColumnGroupProps } from '../vc-table/sugar/ColumnGroup'; +import type { CustomSlotsType } from '../_util/type'; export default defineComponent>({ name: 'ATableColumnGroup', - slots: ['title'], + slots: Object as CustomSlotsType<{ + title?: any; + default?: any; + }>, __ANT_TABLE_COLUMN_GROUP: true, render() { return null; diff --git a/components/table/Table.tsx b/components/table/Table.tsx index 19428a765..a2bf84ffd 100644 --- a/components/table/Table.tsx +++ b/components/table/Table.tsx @@ -36,7 +36,7 @@ import type { SizeType } from '../config-provider'; import devWarning from '../vc-util/devWarning'; import type { CSSProperties } from 'vue'; import { nextTick, reactive, ref, computed, defineComponent, toRef, watchEffect, watch } from 'vue'; -import type { DefaultRecordType } from '../vc-table/interface'; +import type { DefaultRecordType, RenderExpandIconProps } from '../vc-table/interface'; import useBreakpoint from '../_util/hooks/useBreakpoint'; import useConfigInject from '../config-provider/hooks/useConfigInject'; import { useLocaleReceiver } from '../locale-provider/LocaleReceiver'; @@ -47,6 +47,7 @@ import { useProvideSlots, useProvideTableContext } from './context'; import type { ContextSlots } from './context'; import useColumns from './hooks/useColumns'; import { convertChildrenToColumns } from './util'; + import { stringType, booleanType, @@ -58,6 +59,7 @@ import { // CSSINJS import useStyle from './style'; +import type { CustomSlotsType } from '../_util/type'; export type { ColumnsType, TablePaginationConfig }; @@ -179,35 +181,22 @@ export const tableProps = () => { >(), sortDirections: arrayType(), showSorterTooltip: someType([Boolean, Object], true), - contextSlots: objectType(), transformCellText: functionType(), }; }; -const InteralTable = defineComponent< - TableProps & { - contextSlots: ContextSlots; - } ->({ +const InteralTable = defineComponent({ name: 'InteralTable', inheritAttrs: false, - props: initDefaultProps(tableProps(), { - rowKey: 'key', - }) as any, - // emits: ['expandedRowsChange', 'change', 'expand'], - slots: [ - 'emptyText', - 'expandIcon', - 'title', - 'footer', - 'summary', - 'expandedRowRender', - 'bodyCell', - 'headerCell', - 'customFilterIcon', - 'customFilterDropdown', - 'expandColumnTitle', - ], + props: initDefaultProps( + { + ...tableProps(), + contextSlots: objectType(), + }, + { + rowKey: 'key', + }, + ), setup(props, { attrs, slots, expose, emit }) { devWarning( !(typeof props.rowKey === 'function' && props.rowKey.length > 1), @@ -651,9 +640,34 @@ const InteralTable = defineComponent< }, }); -const Table = defineComponent({ +const Table = defineComponent({ name: 'ATable', inheritAttrs: false, + props: initDefaultProps(tableProps(), { + rowKey: 'key', + }), + slots: Object as CustomSlotsType<{ + emptyText?: any; + expandIcon?: RenderExpandIconProps; + title?: any; + footer?: any; + summary?: any; + expandedRowRender?: any; + bodyCell?: { + text: any; + value: any; + record: Record; + index: number; + column: ColumnType; + }; + headerCell?: { + title: any; + column: ColumnType; + }; + customFilterIcon?: any; + customFilterDropdown?: any; + default: any; + }>, setup(_props, { attrs, slots, expose }) { const table = ref(); expose({ diff --git a/components/table/demo/stripe.vue b/components/table/demo/stripe.vue index c497ce7cb..b3786fe00 100644 --- a/components/table/demo/stripe.vue +++ b/components/table/demo/stripe.vue @@ -67,7 +67,10 @@ const data = [ diff --git a/components/tabs/src/TabNavList/OperationNode.tsx b/components/tabs/src/TabNavList/OperationNode.tsx index 98ef88ddd..a304ba801 100644 --- a/components/tabs/src/TabNavList/OperationNode.tsx +++ b/components/tabs/src/TabNavList/OperationNode.tsx @@ -2,7 +2,7 @@ import Menu, { MenuItem } from '../../../menu'; import Dropdown from '../../../vc-dropdown'; import type { Tab, TabsLocale, EditableConfig } from '../interface'; import AddButton from './AddButton'; -import type { Key } from '../../../_util/type'; +import type { CustomSlotsType, Key } from '../../../_util/type'; import { functionType } from '../../../_util/type'; import KeyCode from '../../../_util/KeyCode'; import type { CSSProperties, ExtractPropTypes, PropType } from 'vue'; @@ -41,7 +41,10 @@ export default defineComponent({ inheritAttrs: false, props: operationNodeProps, emits: ['tabClick'], - slots: ['moreIcon'], + slots: Object as CustomSlotsType<{ + moreIcon?: any; + default?: any; + }>, setup(props, { attrs, slots }) { // ======================== Dropdown ======================== const [open, setOpen] = useState(false); diff --git a/components/tabs/src/TabNavList/index.tsx b/components/tabs/src/TabNavList/index.tsx index a9c7ceebd..36a798aca 100644 --- a/components/tabs/src/TabNavList/index.tsx +++ b/components/tabs/src/TabNavList/index.tsx @@ -16,8 +16,8 @@ import OperationNode from './OperationNode'; import { useInjectTabs } from '../TabContext'; import useTouchMove from '../hooks/useTouchMove'; import AddButton from './AddButton'; -import type { Key } from '../../../_util/type'; import { objectType, functionType } from '../../../_util/type'; +import type { CustomSlotsType, Key } from '../../../_util/type'; import type { ExtractPropTypes, PropType, CSSProperties } from 'vue'; import { shallowRef, onBeforeUnmount, defineComponent, watch, watchEffect, computed } from 'vue'; import PropTypes from '../../../_util/vue-types'; @@ -69,7 +69,13 @@ export default defineComponent({ name: 'TabNavList', inheritAttrs: false, props: tabNavListProps(), - slots: ['moreIcon', 'leftExtra', 'rightExtra', 'tabBarExtraContent'], + slots: Object as CustomSlotsType<{ + moreIcon?: any; + leftExtra?: any; + rightExtra?: any; + tabBarExtraContent?: any; + default?: any; + }>, emits: ['tabClick', 'tabScroll'], setup(props, { attrs, slots }) { const { tabs, prefixCls } = useInjectTabs(); diff --git a/components/tabs/src/TabPanelList/TabPane.tsx b/components/tabs/src/TabPanelList/TabPane.tsx index 34afe68e4..ff8cdbc28 100644 --- a/components/tabs/src/TabPanelList/TabPane.tsx +++ b/components/tabs/src/TabPanelList/TabPane.tsx @@ -1,6 +1,7 @@ import { defineComponent, ref, watch, computed } from 'vue'; import type { CSSProperties, ExtractPropTypes } from 'vue'; import PropTypes from '../../../_util/vue-types'; +import type { CustomSlotsType } from '../../../_util/type'; const tabPaneProps = () => ({ tab: PropTypes.any, @@ -26,7 +27,11 @@ export default defineComponent({ inheritAttrs: false, __ANT_TAB_PANE: true, props: tabPaneProps(), - slots: ['closeIcon', 'tab'], + slots: Object as CustomSlotsType<{ + closeIcon: any; + tab: any; + default: any; + }>, setup(props, { attrs, slots }) { const visited = ref(props.forceRender); watch( diff --git a/components/tabs/src/Tabs.tsx b/components/tabs/src/Tabs.tsx index be40e02c2..3a4307733 100644 --- a/components/tabs/src/Tabs.tsx +++ b/components/tabs/src/Tabs.tsx @@ -23,7 +23,6 @@ import PlusOutlined from '@ant-design/icons-vue/PlusOutlined'; import devWarning from '../../vc-util/devWarning'; import type { SizeType } from '../../config-provider'; import { useProvideTabs } from './TabContext'; -import type { Key } from '../../_util/type'; import { arrayType, stringType, @@ -32,6 +31,7 @@ import { objectType, booleanType, } from '../../_util/type'; +import type { CustomSlotsType, Key } from '../../_util/type'; import pick from 'lodash-es/pick'; import PropTypes from '../../_util/vue-types'; import type { MouseEventHandler } from '../../_util/EventInterface'; @@ -133,15 +133,16 @@ const InternalTabs = defineComponent({ }), tabs: arrayType(), }, - slots: [ - 'tabBarExtraContent', - 'leftExtra', - 'rightExtra', - 'moreIcon', - 'addIcon', - 'removeIcon', - 'renderTabBar', - ], + slots: Object as CustomSlotsType<{ + tabBarExtraContent?: any; + leftExtra?: any; + rightExtra?: any; + moreIcon?: any; + addIcon?: any; + removeIcon?: any; + renderTabBar?: any; + default: any; + }>, // emits: ['tabClick', 'tabScroll', 'change', 'update:activeKey'], setup(props, { attrs, slots }) { devWarning( @@ -351,15 +352,16 @@ export default defineComponent({ tabPane: false, }, }), - slots: [ - 'tabBarExtraContent', - 'leftExtra', - 'rightExtra', - 'moreIcon', - 'addIcon', - 'removeIcon', - 'renderTabBar', - ], + slots: Object as CustomSlotsType<{ + tabBarExtraContent?: any; + leftExtra?: any; + rightExtra?: any; + moreIcon?: any; + addIcon?: any; + removeIcon?: any; + renderTabBar?: any; + default?: any; + }>, // emits: ['tabClick', 'tabScroll', 'change', 'update:activeKey'], setup(props, { attrs, slots, emit }) { const handleChange = (key: string) => { diff --git a/components/tag/index.tsx b/components/tag/index.tsx index d286c533c..993c2454f 100644 --- a/components/tag/index.tsx +++ b/components/tag/index.tsx @@ -6,8 +6,9 @@ import CloseOutlined from '@ant-design/icons-vue/CloseOutlined'; import Wave from '../_util/wave'; import type { PresetColorType, PresetStatusColorType } from '../_util/colors'; import { isPresetColor, isPresetStatusColor } from '../_util/colors'; -import type { LiteralUnion } from '../_util/type'; import { eventType } from '../_util/type'; +import type { CustomSlotsType, LiteralUnion } from '../_util/type'; + import CheckableTag from './CheckableTag'; import useConfigInject from '../config-provider/hooks/useConfigInject'; import warning from '../_util/warning'; @@ -39,7 +40,11 @@ const Tag = defineComponent({ inheritAttrs: false, props: tagProps(), // emits: ['update:visible', 'close'], - slots: ['closeIcon', 'icon'], + slots: Object as CustomSlotsType<{ + closeIcon: any; + icon: any; + default: any; + }>, setup(props, { slots, emit, attrs }) { const { prefixCls, direction } = useConfigInject('tag', props); diff --git a/components/time-picker/time-picker.tsx b/components/time-picker/time-picker.tsx index a7a83f24e..81348d6d6 100644 --- a/components/time-picker/time-picker.tsx +++ b/components/time-picker/time-picker.tsx @@ -14,8 +14,10 @@ import type { RangePickerSharedProps } from '../vc-picker/RangePicker'; import devWarning from '../vc-util/devWarning'; import { useInjectFormItemContext } from '../form/FormItemContext'; import omit from '../_util/omit'; + import type { InputStatus } from '../_util/statusUtils'; import { booleanType, stringType } from '../_util/type'; +import type { CustomSlotsType } from '../_util/type'; export interface TimePickerLocale { placeholder?: string; @@ -75,7 +77,7 @@ function createTimePicker< }); const { TimePicker: InternalTimePicker, RangePicker: InternalRangePicker } = DatePicker as any; - const TimePicker = defineComponent({ + const TimePicker = defineComponent({ name: 'ATimePicker', inheritAttrs: false, props: { @@ -83,9 +85,16 @@ function createTimePicker< ...datePickerProps(), ...timePickerProps(), addon: { type: Function }, - } as any, - slot: ['addon', 'renderExtraFooter', 'suffixIcon', 'clearIcon'], - setup(props, { slots, expose, emit, attrs }) { + }, + slots: Object as CustomSlotsType<{ + addon?: any; + renderExtraFooter?: any; + suffixIcon?: any; + clearIcon?: any; + default: any; + }>, + setup(p, { slots, expose, emit, attrs }) { + const props = p as unknown as DTimePickerProps; const formItemContext = useInjectFormItemContext(); devWarning( !(slots.addon || props.addon), @@ -146,7 +155,7 @@ function createTimePicker< }, }); - const TimeRangePicker = defineComponent({ + const TimeRangePicker = defineComponent({ name: 'ATimeRangePicker', inheritAttrs: false, props: { @@ -154,9 +163,15 @@ function createTimePicker< ...rangePickerProps(), ...timePickerProps(), order: { type: Boolean, default: true }, - } as any, - slot: ['renderExtraFooter', 'suffixIcon', 'clearIcon'], - setup(props, { slots, expose, emit, attrs }) { + }, + slots: Object as CustomSlotsType<{ + renderExtraFooter?: any; + suffixIcon?: any; + clearIcon?: any; + default: any; + }>, + setup(p, { slots, expose, emit, attrs }) { + const props = p as unknown as DTimeRangePickerProps; const pickerRef = ref(); const formItemContext = useInjectFormItemContext(); expose({ diff --git a/components/timeline/Timeline.tsx b/components/timeline/Timeline.tsx index a808711f8..be4ec4c26 100644 --- a/components/timeline/Timeline.tsx +++ b/components/timeline/Timeline.tsx @@ -6,11 +6,13 @@ import { filterEmpty } from '../_util/props-util'; import initDefaultProps from '../_util/props-util/initDefaultProps'; import TimelineItem from './TimelineItem'; import LoadingOutlined from '@ant-design/icons-vue/LoadingOutlined'; + import { tuple, booleanType } from '../_util/type'; import useConfigInject from '../config-provider/hooks/useConfigInject'; // CSSINJS import useStyle from './style'; +import type { CustomSlotsType } from '../_util/type'; export const timelineProps = () => ({ prefixCls: String, @@ -31,7 +33,11 @@ export default defineComponent({ reverse: false, mode: '', }), - slots: ['pending', 'pendingDot'], + slots: Object as CustomSlotsType<{ + pending?: any; + pendingDot?: any; + default?: any; + }>, setup(props, { slots, attrs }) { const { prefixCls, direction } = useConfigInject('timeline', props); diff --git a/components/timeline/TimelineItem.tsx b/components/timeline/TimelineItem.tsx index 0f8ee9563..d1a226bc0 100644 --- a/components/timeline/TimelineItem.tsx +++ b/components/timeline/TimelineItem.tsx @@ -2,8 +2,10 @@ import type { ExtractPropTypes } from 'vue'; import { computed, defineComponent } from 'vue'; import PropTypes from '../_util/vue-types'; import initDefaultProps from '../_util/props-util/initDefaultProps'; + import { tuple, booleanType } from '../_util/type'; import useConfigInject from '../config-provider/hooks/useConfigInject'; +import type { CustomSlotsType } from '../_util/type'; export const timelineItemProps = () => ({ prefixCls: String, @@ -23,7 +25,11 @@ export default defineComponent({ color: 'blue', pending: false, }), - slots: ['dot', 'label'], + slots: Object as CustomSlotsType<{ + dot?: any; + label?: any; + default?: any; + }>, setup(props, { slots }) { const { prefixCls } = useConfigInject('timeline', props); const itemClassName = computed(() => ({ diff --git a/components/tooltip/Tooltip.tsx b/components/tooltip/Tooltip.tsx index 68e9032a4..0a9902afb 100644 --- a/components/tooltip/Tooltip.tsx +++ b/components/tooltip/Tooltip.tsx @@ -18,10 +18,12 @@ import useConfigInject from '../config-provider/hooks/useConfigInject'; import getPlacements from '../_util/placements'; import firstNotUndefined from '../_util/firstNotUndefined'; import raf from '../_util/raf'; + import { parseColor } from './util'; export type { AdjustOverflow, PlacementsConfig } from '../_util/placements'; import useStyle from './style'; import { getTransitionName } from '../_util/transition'; +import type { CustomSlotsType } from '../_util/type'; // https://github.com/react-component/tooltip // https://github.com/yiminghe/dom-align @@ -79,7 +81,10 @@ export default defineComponent({ arrowPointAtCenter: false, autoAdjustOverflow: true, }), - slots: ['title'], + slots: Object as CustomSlotsType<{ + title?: any; + default?: any; + }>, // emits: ['update:visible', 'visibleChange'], setup(props, { slots, emit, attrs, expose }) { if (process.env.NODE_ENV !== 'production') { diff --git a/components/transfer/index.tsx b/components/transfer/index.tsx index 8d2e0e773..e0661cb6a 100644 --- a/components/transfer/index.tsx +++ b/components/transfer/index.tsx @@ -6,8 +6,9 @@ import classNames from '../_util/classNames'; import List from './list'; import Operation from './operation'; import LocaleReceiver from '../locale-provider/LocaleReceiver'; + import defaultLocale from '../locale/en_US'; -import type { VueNode } from '../_util/type'; +import type { VueNode, CustomSlotsType } from '../_util/type'; import { withInstall, stringType, @@ -18,6 +19,7 @@ import { functionType, } from '../_util/type'; import useConfigInject from '../config-provider/hooks/useConfigInject'; + import type { TransferListBodyProps } from './ListBody'; import type { PaginationType } from './interface'; import { FormItemInputContext, useInjectFormItemContext } from '../form/FormItemContext'; @@ -123,16 +125,17 @@ const Transfer = defineComponent({ name: 'ATransfer', inheritAttrs: false, props: transferProps(), - slots: [ - 'leftTitle', - 'rightTitle', - 'children', - 'render', - 'notFoundContent', - 'leftSelectAllLabel', - 'rightSelectAllLabel', - 'footer', - ], + slots: Object as CustomSlotsType<{ + leftTitle?: any; + rightTitle?: any; + children?: any; + render?: TransferItem; + notFoundContent?: any; + leftSelectAllLabel?: any; + rightSelectAllLabel?: any; + footer?: any; + default?: any; + }>, // emits: ['update:targetKeys', 'update:selectedKeys', 'change', 'search', 'scroll', 'selectChange'], setup(props, { emit, attrs, slots, expose }) { const { configProvider, prefixCls, direction } = useConfigInject('transfer', props); diff --git a/components/transfer/list.tsx b/components/transfer/list.tsx index 2673b7db8..3e09521cf 100644 --- a/components/transfer/list.tsx +++ b/components/transfer/list.tsx @@ -13,6 +13,7 @@ import type { RadioChangeEvent } from '../radio/interface'; import type { TransferDirection, TransferItem } from './index'; import { stringType, arrayType, booleanType } from '../_util/type'; import { groupKeysMap } from '../_util/transKeys'; +import type { CustomSlotsType } from '../_util/type'; const defaultRender = () => null; @@ -69,7 +70,11 @@ export default defineComponent({ inheritAttrs: false, props: transferListProps, // emits: ['scroll', 'itemSelectAll', 'itemRemove', 'itemSelect'], - slots: ['footer', 'titleText'], + slots: Object as CustomSlotsType<{ + footer?: any; + titleText?: any; + default?: any; + }>, setup(props, { attrs, slots }) { const filterValue = ref(''); const transferNode = ref(); diff --git a/components/tree-select/index.tsx b/components/tree-select/index.tsx index 064ac32b3..4e6985e24 100644 --- a/components/tree-select/index.tsx +++ b/components/tree-select/index.tsx @@ -24,6 +24,7 @@ import { FormItemInputContext, useInjectFormItemContext } from '../form/FormItem import type { BaseSelectRef } from '../vc-select'; import type { BaseOptionType, DefaultOptionType } from '../vc-tree-select/TreeSelect'; import type { TreeProps } from '../tree'; + import type { SelectCommonPlacement } from '../_util/transition'; import { getTransitionDirection } from '../_util/transition'; import type { InputStatus } from '../_util/statusUtils'; @@ -36,6 +37,8 @@ import useStyle from './style'; import { useCompactItemContext } from '../space/Compact'; import { useInjectDisabled } from '../config-provider/DisabledContext'; +import type { CustomSlotsType } from '../_util/type'; + const getTransitionName = (rootPrefixCls: string, motion: string, transitionName?: string) => { if (transitionName !== undefined) { return transitionName; @@ -96,15 +99,17 @@ const TreeSelect = defineComponent({ listItemHeight: 26, bordered: true, }), - slots: [ - 'title', - 'titleRender', - 'placeholder', - 'maxTagPlaceholder', - 'treeIcon', - 'switcherIcon', - 'notFoundContent', - ], + slots: Object as CustomSlotsType<{ + title?: any; + titleRender?: any; + placeholder?: any; + maxTagPlaceholder?: any; + treeIcon?: any; + switcherIcon?: any; + notFoundContent?: any; + default?: any; + leafIcon?: any; + }>, setup(props, { attrs, slots, expose, emit }) { warning( !(props.treeData === undefined && slots.default), diff --git a/components/tree/DirectoryTree.tsx b/components/tree/DirectoryTree.tsx index 6efe877b6..b71cbe424 100644 --- a/components/tree/DirectoryTree.tsx +++ b/components/tree/DirectoryTree.tsx @@ -19,6 +19,7 @@ import { calcRangeKeys, convertDirectoryKeysToNodes } from './utils/dictUtil'; import useConfigInject from '../config-provider/hooks/useConfigInject'; import { filterEmpty } from '../_util/props-util'; import { someType } from '../_util/type'; +import type { CustomSlotsType } from '../_util/type'; export type ExpandAction = false | 'click' | 'doubleclick' | 'dblclick'; @@ -45,7 +46,14 @@ export default defineComponent({ showIcon: true, expandAction: 'click', }), - slots: ['icon', 'title', 'switcherIcon', 'titleRender'], + slots: Object as CustomSlotsType<{ + icon?: any; + title?: any; + switcherIcon?: any; + titleRender?: any; + default?: any; + }>, + // emits: [ // 'update:selectedKeys', // 'update:checkedKeys', diff --git a/components/tree/Tree.tsx b/components/tree/Tree.tsx index 6ffecafca..4c615ad8f 100644 --- a/components/tree/Tree.tsx +++ b/components/tree/Tree.tsx @@ -19,6 +19,7 @@ import { booleanType, someType, arrayType, functionType, objectType } from '../_ // CSSINJS import useStyle from './style'; +import type { CustomSlotsType } from '../_util/type'; export interface AntdTreeNodeAttribute { eventKey: string; @@ -150,17 +151,15 @@ export default defineComponent({ showIcon: false, blockNode: false, }), - slots: ['icon', 'title', 'switcherIcon', 'titleRender'], - // emits: [ - // 'update:selectedKeys', - // 'update:checkedKeys', - // 'update:expandedKeys', - // 'expand', - // 'select', - // 'check', - // 'doubleclick', - // 'dblclick', - // ], + + slots: Object as CustomSlotsType<{ + icon?: any; + title?: any; + switcherIcon?: any; + titleRender?: any; + default?: any; + leafIcon?: any; + }>, setup(props, { attrs, expose, emit, slots }) { warning( !(props.treeData === undefined && slots.default), diff --git a/components/typography/Typography.tsx b/components/typography/Typography.tsx index 99c0e7f4c..c0eae59e6 100644 --- a/components/typography/Typography.tsx +++ b/components/typography/Typography.tsx @@ -21,10 +21,10 @@ export const typographyProps = () => ({ // Form Internal use component: String, }); -const Typography = defineComponent({ +const Typography = defineComponent({ name: 'ATypography', inheritAttrs: false, - props: typographyProps() as any, + props: typographyProps(), setup(props, { slots, attrs }) { const { prefixCls, direction } = useConfigInject('typography', props); @@ -34,20 +34,19 @@ const Typography = defineComponent({ return () => { const { prefixCls: _prefixCls, - class: _className, direction: _direction, component: Component = 'article' as any, ...restProps } = { ...props, ...attrs }; return wrapSSR( {slots.default?.()} , diff --git a/components/upload/index.en-US.md b/components/upload/index.en-US.md index 2cb74ff8e..d1c478db2 100644 --- a/components/upload/index.en-US.md +++ b/components/upload/index.en-US.md @@ -112,7 +112,7 @@ When uploading state change, it returns: ### How to select albums or folders on mobile devices? -You can set `:accept="null"` +You can set `:capture="null"` ### I want to display download links. diff --git a/components/upload/index.zh-CN.md b/components/upload/index.zh-CN.md index cddad3aae..ecceb38de 100644 --- a/components/upload/index.zh-CN.md +++ b/components/upload/index.zh-CN.md @@ -113,7 +113,7 @@ coverDark: https://mdn.alipayobjects.com/huamei_7uahnr/afts/img/A*l1nlSryXib8AAA ### 手机设备如何选择相册或文件夹? -你可以设置 `:accept="null"` +你可以设置 `:capture="null"` ### 如何显示下载链接? diff --git a/components/vc-drawer/src/DrawerWrapper.tsx b/components/vc-drawer/src/DrawerWrapper.tsx index 88f038da1..3b0a024fc 100644 --- a/components/vc-drawer/src/DrawerWrapper.tsx +++ b/components/vc-drawer/src/DrawerWrapper.tsx @@ -24,7 +24,6 @@ const DrawerWrapper = defineComponent({ autofocus: true, }), emits: ['handleClick', 'close'], - slots: ['handler'], setup(props, { emit, slots }) { const dom = ref(null); diff --git a/components/vc-dropdown/Dropdown.tsx b/components/vc-dropdown/Dropdown.tsx index 7ce3c67f6..147f5516a 100644 --- a/components/vc-dropdown/Dropdown.tsx +++ b/components/vc-dropdown/Dropdown.tsx @@ -34,7 +34,6 @@ export default defineComponent({ mouseLeaveDelay: PropTypes.number.def(0.1), }, emits: ['visibleChange', 'overlayClick'], - slots: ['overlay'], setup(props, { slots, emit, expose }) { const triggerVisible = ref(!!props.visible); watch( diff --git a/components/vc-mentions/src/DropdownMenu.tsx b/components/vc-mentions/src/DropdownMenu.tsx index 860235248..4d353b491 100644 --- a/components/vc-mentions/src/DropdownMenu.tsx +++ b/components/vc-mentions/src/DropdownMenu.tsx @@ -16,7 +16,6 @@ export default defineComponent({ default: () => [], }, }, - slots: ['notFoundContent', 'option'], setup(props, { slots }) { const { activeIndex, diff --git a/components/vc-mentions/src/KeywordTrigger.tsx b/components/vc-mentions/src/KeywordTrigger.tsx index 7291f49e4..8d1f48f0c 100644 --- a/components/vc-mentions/src/KeywordTrigger.tsx +++ b/components/vc-mentions/src/KeywordTrigger.tsx @@ -56,7 +56,6 @@ export default defineComponent({ direction: String, dropdownClassName: String, }, - slots: ['notFoundContent', 'option'], setup(props, { slots }) { const getDropdownPrefix = () => { return `${props.prefixCls}-dropdown`; diff --git a/components/vc-mentions/src/Mentions.tsx b/components/vc-mentions/src/Mentions.tsx index 2965c3830..77cf05a47 100644 --- a/components/vc-mentions/src/Mentions.tsx +++ b/components/vc-mentions/src/Mentions.tsx @@ -37,7 +37,6 @@ export default defineComponent({ name: 'Mentions', inheritAttrs: false, props: initDefaultProps(vcMentionsProps, defaultProps), - slots: ['notFoundContent', 'option'], emits: ['change', 'select', 'search', 'focus', 'blur', 'pressenter'], setup(props, { emit, attrs, expose, slots }) { const measure = ref(null); diff --git a/components/vc-picker/Picker.tsx b/components/vc-picker/Picker.tsx index c26099885..1607528d2 100644 --- a/components/vc-picker/Picker.tsx +++ b/components/vc-picker/Picker.tsx @@ -196,15 +196,6 @@ function Picker() { 'secondStep', 'hideDisabledOptions', ] as any, - // slots: [ - // 'suffixIcon', - // 'clearIcon', - // 'prevIcon', - // 'nextIcon', - // 'superPrevIcon', - // 'superNextIcon', - // 'panelRender', - // ], setup(props, { attrs, expose }) { const inputRef = ref(null); const presets = computed(() => props.presets); diff --git a/components/vc-select/OptionList.tsx b/components/vc-select/OptionList.tsx index cb05797d1..e11bd73e1 100644 --- a/components/vc-select/OptionList.tsx +++ b/components/vc-select/OptionList.tsx @@ -37,7 +37,6 @@ const OptionList = defineComponent({ compatConfig: { MODE: 3 }, name: 'OptionList', inheritAttrs: false, - slots: ['option'], setup(_, { expose, slots }) { const baseProps = useBaseProps(); const props = useSelectProps(); diff --git a/components/vc-slider/src/common/createSlider.tsx b/components/vc-slider/src/common/createSlider.tsx index 0937a8526..4713b50ca 100644 --- a/components/vc-slider/src/common/createSlider.tsx +++ b/components/vc-slider/src/common/createSlider.tsx @@ -43,7 +43,6 @@ export default function createSlider(Component) { name: 'CreateSlider', mixins: [BaseMixin, Component], inheritAttrs: false, - slots: ['mark'], props: initDefaultProps(propTypes, { prefixCls: 'rc-slider', min: 0, diff --git a/components/vc-steps/Step.tsx b/components/vc-steps/Step.tsx index 49808886d..fa45659c2 100644 --- a/components/vc-steps/Step.tsx +++ b/components/vc-steps/Step.tsx @@ -45,7 +45,6 @@ export default defineComponent({ name: 'Step', inheritAttrs: false, props: VcStepProps(), - slots: ['title', 'subTitle', 'description', 'tailContent', 'stepIcon', 'progressDot'], setup(props, { slots, emit, attrs }) { const onItemClick: EventHandler = e => { emit('click', e); diff --git a/components/vc-steps/Steps.tsx b/components/vc-steps/Steps.tsx index 8b9e6096e..20f360cf7 100644 --- a/components/vc-steps/Steps.tsx +++ b/components/vc-steps/Steps.tsx @@ -32,7 +32,6 @@ export default defineComponent({ isInline: PropTypes.looseBool, itemRender: functionType<(item: Record, stepItem: VueNode) => VueNode>(), }, - slots: ['stepIcon', 'progressDot'], emits: ['change'], setup(props, { slots, emit }) { const onStepClick = (next: number) => { diff --git a/components/vc-table/Body/index.tsx b/components/vc-table/Body/index.tsx index f1eec769a..81bba38ec 100644 --- a/components/vc-table/Body/index.tsx +++ b/components/vc-table/Body/index.tsx @@ -32,7 +32,6 @@ export default defineComponent>({ 'rowExpandable', 'childrenColumnName', ] as any, - slots: ['emptyNode'], setup(props, { slots }) { const resizeContext = useInjectResize(); const tableContext = useInjectTable(); diff --git a/components/vc-table/Cell/index.tsx b/components/vc-table/Cell/index.tsx index 28f14d4e7..37fd51fbc 100644 --- a/components/vc-table/Cell/index.tsx +++ b/components/vc-table/Cell/index.tsx @@ -103,7 +103,6 @@ export default defineComponent({ 'cellType', 'transformCellText', ] as any, - slots: ['appendNode'], setup(props, { slots }) { const contextSlots = useInjectSlots(); const { onHover, startRow, endRow } = useInjectHover(); diff --git a/components/vc-table/Table.tsx b/components/vc-table/Table.tsx index 6259cb138..bc418b971 100644 --- a/components/vc-table/Table.tsx +++ b/components/vc-table/Table.tsx @@ -192,7 +192,6 @@ export default defineComponent>({ 'onUpdateInternalRefs', 'transformCellText', ] as any, - slots: ['title', 'footer', 'summary', 'emptyText'], emits: ['expand', 'expandedRowsChange', 'updateInternalRefs', 'update:expandedRowKeys'], setup(props, { attrs, slots, emit }) { const mergedData = computed(() => props.data || EMPTY_DATA); diff --git a/components/vc-tooltip/src/Content.tsx b/components/vc-tooltip/src/Content.tsx index f51b277c4..884bd43b5 100644 --- a/components/vc-tooltip/src/Content.tsx +++ b/components/vc-tooltip/src/Content.tsx @@ -14,7 +14,6 @@ export default defineComponent({ compatConfig: { MODE: 3 }, name: 'Content', props: tooltipContentProps, - slots: ['overlay'], setup(props: TooltipContentProps, { slots }) { return () => (
}, }, - slots: ['title', 'icon', 'switcherIcon', 'checkable'], setup(props, { attrs, slots }) { const visible = shallowRef(true); const context = useInjectTreeContext(); diff --git a/components/vc-tree/Tree.tsx b/components/vc-tree/Tree.tsx index ec65f55aa..dc4defb77 100644 --- a/components/vc-tree/Tree.tsx +++ b/components/vc-tree/Tree.tsx @@ -54,7 +54,6 @@ export default defineComponent({ compatConfig: { MODE: 3 }, name: 'Tree', inheritAttrs: false, - slots: ['checkable', 'title', 'icon', 'titleRender'], props: initDefaultProps(treeProps(), { prefixCls: 'vc-tree', showLine: false, diff --git a/components/vc-tree/TreeNode.tsx b/components/vc-tree/TreeNode.tsx index 174792f5d..b5df1668d 100644 --- a/components/vc-tree/TreeNode.tsx +++ b/components/vc-tree/TreeNode.tsx @@ -29,7 +29,6 @@ export default defineComponent({ inheritAttrs: false, props: treeNodeProps, isTreeNode: 1, - slots: ['title', 'icon', 'switcherIcon'], setup(props, { attrs, slots, expose }) { warning( !('slots' in props.data), diff --git a/package.json b/package.json index cf0ebbdb6..744c18e07 100644 --- a/package.json +++ b/package.json @@ -259,7 +259,6 @@ "vanilla-jsoneditor": "^0.15.1", "vite": "^3.0.0", "vue": "^3.2.0", - "vue-antd-md-loader": "^1.2.1-beta.1", "vue-clipboard2": "0.3.3", "vue-drag-resize": "^2.0.3", "vue-eslint-parser": "^8.0.0", @@ -268,7 +267,6 @@ "vue-loader": "^17.0.0", "vue-request": "^1.0.2", "vue-router": "^4.0.0", - "vue-server-renderer": "^2.6.11", "vue-style-loader": "^4.1.2", "vue-tsc": "^1.0.6", "vuex": "^4.0.0",