Skip to content

Commit 03760e3

Browse files
committed
Merge remote-tracking branch 'origin/main' into feat-v4
2 parents c36f7e7 + 144bb2e commit 03760e3

File tree

88 files changed

+598
-272
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

88 files changed

+598
-272
lines changed

antd-tools/getBabelCommonConfig.js

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
const { resolve } = require('./utils/projectHelper');
1+
const { resolve, isThereHaveBrowserslistConfig } = require('./utils/projectHelper');
22

33
module.exports = function (modules) {
44
const plugins = [
@@ -39,9 +39,11 @@ module.exports = function (modules) {
3939
resolve('@babel/preset-env'),
4040
{
4141
modules,
42-
targets: {
43-
browsers: ['last 2 versions', 'Firefox ESR', '> 1%', 'ie >= 11'],
44-
},
42+
targets: isThereHaveBrowserslistConfig()
43+
? undefined
44+
: {
45+
browsers: ['last 2 versions', 'Firefox ESR', '> 1%', 'ie >= 11'],
46+
},
4547
},
4648
],
4749
],

components/_util/type.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
import type { App, PropType, Plugin, Ref, VNode } from 'vue';
1+
// @ts-ignore
2+
import type { App, PropType, Plugin, Ref, VNode, SlotsType } from 'vue';
23

34
// https://stackoverflow.com/questions/46176165/ways-to-get-string-literal-type-of-array-values-without-enum-overhead
45
export const tuple = <T extends string[]>(...args: T) => args;
@@ -87,3 +88,5 @@ export function stringType<T extends string = string>(defaultVal?: T) {
8788
export function someType<T>(types?: any[], defaultVal?: T) {
8889
return types ? { type: types as PropType<T>, default: defaultVal as T } : anyType<T>(defaultVal);
8990
}
91+
92+
export type CustomSlotsType<T> = SlotsType<T>;

components/anchor/AnchorLink.tsx

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import { initDefaultProps } from '../_util/props-util';
44
import classNames from '../_util/classNames';
55
import useConfigInject from '../config-provider/hooks/useConfigInject';
66
import { useInjectAnchor } from './context';
7-
import type { Key, VueNode } from '../_util/type';
7+
import type { Key, VueNode, CustomSlotsType } from '../_util/type';
88
import { objectType, anyType } from '../_util/type';
99
import type { CSSProperties } from '../_util/cssinjs/hooks/useStyleRegister';
1010

@@ -33,7 +33,11 @@ export default defineComponent({
3333
name: 'AAnchorLink',
3434
inheritAttrs: false,
3535
props: initDefaultProps(anchorLinkProps(), { href: '#' }),
36-
slots: ['title', 'customTitle'],
36+
slots: Object as CustomSlotsType<{
37+
title: any;
38+
default: any;
39+
customTitle: any;
40+
}>,
3741
setup(props, { slots, attrs }) {
3842
let mergedTitle = null;
3943
const {

components/auto-complete/index.tsx

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,12 @@ import warning from '../_util/warning';
66
import Option from './Option';
77
import OptGroup from './OptGroup';
88
import omit from '../_util/omit';
9+
910
import useConfigInject from '../config-provider/hooks/useConfigInject';
1011
import type { InputStatus } from '../_util/statusUtils';
1112

13+
import type { CustomSlotsType } from '../_util/type';
14+
1215
function isSelectOptionOrSelectOptGroup(child: any): boolean {
1316
return child?.type?.isSelectOption || child?.type?.isSelectOptGroup;
1417
}
@@ -46,7 +49,12 @@ const AutoComplete = defineComponent({
4649
inheritAttrs: false,
4750
props: autoCompleteProps(),
4851
// emits: ['change', 'select', 'focus', 'blur'],
49-
slots: ['option'],
52+
slots: Object as CustomSlotsType<{
53+
options: any;
54+
default: any;
55+
notFoundContent: any;
56+
dataSource: any;
57+
}>,
5058
setup(props, { slots, attrs, expose }) {
5159
warning(
5260
!('dataSource' in slots),

components/avatar/Avatar.tsx

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import type { VueNode } from '../_util/type';
1+
import type { CustomSlotsType, VueNode } from '../_util/type';
22

33
import type { CSSProperties, ExtractPropTypes, PropType } from 'vue';
44
import { computed, defineComponent, nextTick, onMounted, shallowRef, watch } from 'vue';
@@ -42,7 +42,10 @@ const Avatar = defineComponent({
4242
name: 'AAvatar',
4343
inheritAttrs: false,
4444
props: avatarProps(),
45-
slots: ['icon'],
45+
slots: Object as CustomSlotsType<{
46+
icon: any;
47+
default: any;
48+
}>,
4649
setup(props, { slots, attrs }) {
4750
const isImgExist = shallowRef(true);
4851
const isMounted = shallowRef(false);

components/badge/Badge.tsx

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ import useConfigInject from '../config-provider/hooks/useConfigInject';
1111
import isNumeric from '../_util/isNumeric';
1212
import useStyle from './style';
1313
import type { PresetColorKey } from '../theme/interface';
14-
import type { LiteralUnion } from '../_util/type';
14+
import type { LiteralUnion, CustomSlotsType } from '../_util/type';
1515
import type { PresetStatusColorType } from '../_util/colors';
1616
import { isPresetColor } from '../_util/colors';
1717

@@ -42,7 +42,11 @@ export default defineComponent({
4242
Ribbon,
4343
inheritAttrs: false,
4444
props: badgeProps(),
45-
slots: ['text', 'count'],
45+
slots: Object as CustomSlotsType<{
46+
text: any;
47+
count: any;
48+
default: any;
49+
}>,
4650
setup(props, { slots, attrs }) {
4751
const { prefixCls, direction } = useConfigInject('badge', props);
4852
const [wrapSSR, hashId] = useStyle(prefixCls);

components/badge/Ribbon.tsx

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import type { LiteralUnion } from '../_util/type';
1+
import type { CustomSlotsType, LiteralUnion } from '../_util/type';
22
import type { PresetColorType } from '../_util/colors';
33
import useStyle from './style';
44
import { isPresetColor } from '../_util/colors';
@@ -21,7 +21,10 @@ export default defineComponent({
2121
name: 'ABadgeRibbon',
2222
inheritAttrs: false,
2323
props: ribbonProps(),
24-
slots: ['text'],
24+
slots: Object as CustomSlotsType<{
25+
text: any;
26+
default: any;
27+
}>,
2528
setup(props, { attrs, slots }) {
2629
const { prefixCls, direction } = useConfigInject('ribbon', props);
2730
const [wrapSSR, hashId] = useStyle(prefixCls);

components/breadcrumb/Breadcrumb.tsx

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,10 @@ import warning from '../_util/warning';
66
import type { BreadcrumbItemProps } from './BreadcrumbItem';
77
import BreadcrumbItem from './BreadcrumbItem';
88
import Menu from '../menu';
9-
import type { VueNode } from '../_util/type';
109
import useConfigInject from '../config-provider/hooks/useConfigInject';
1110
import useStyle from './style';
11+
import type { CustomSlotsType, VueNode } from '../_util/type';
12+
1213
export interface Route {
1314
path: string;
1415
breadcrumbName: string;
@@ -57,7 +58,11 @@ export default defineComponent({
5758
name: 'ABreadcrumb',
5859
inheritAttrs: false,
5960
props: breadcrumbProps(),
60-
slots: ['separator', 'itemRender'],
61+
slots: Object as CustomSlotsType<{
62+
separator: any;
63+
itemRender: { route: Route; params: any; routes: Route[]; paths: string[] };
64+
default: any;
65+
}>,
6166
setup(props, { slots, attrs }) {
6267
const { prefixCls, direction } = useConfigInject('breadcrumb', props);
6368
const [wrapSSR, hashId] = useStyle(prefixCls);

components/breadcrumb/BreadcrumbItem.tsx

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import DownOutlined from '@ant-design/icons-vue/DownOutlined';
88
import useConfigInject from '../config-provider/hooks/useConfigInject';
99
import type { MouseEventHandler } from '../_util/EventInterface';
1010
import { eventType, objectType } from '../_util/type';
11+
import type { CustomSlotsType } from '../_util/type';
1112

1213
export const breadcrumbItemProps = () => ({
1314
prefixCls: String,
@@ -26,7 +27,11 @@ export default defineComponent({
2627
__ANT_BREADCRUMB_ITEM: true,
2728
props: breadcrumbItemProps(),
2829
// emits: ['click'],
29-
slots: ['separator', 'overlay'],
30+
slots: Object as CustomSlotsType<{
31+
separator: any;
32+
overlay: any;
33+
default: any;
34+
}>,
3035
setup(props, { slots, attrs, emit }) {
3136
const { prefixCls } = useConfigInject('breadcrumb', props);
3237
/**

components/button/button.tsx

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ import type { ButtonType } from './buttonTypes';
2020
import type { VNode } from 'vue';
2121
import { GroupSizeContext } from './button-group';
2222
import { useCompactItemContext } from '../space/Compact';
23+
import type { CustomSlotsType } from '../_util/type';
2324

2425
type Loading = boolean | number;
2526

@@ -36,7 +37,10 @@ export default defineComponent({
3637
inheritAttrs: false,
3738
__ANT_BUTTON: true,
3839
props: initDefaultProps(buttonProps(), { type: 'default' }),
39-
slots: ['icon'],
40+
slots: Object as CustomSlotsType<{
41+
icon: any;
42+
default: any;
43+
}>,
4044
// emits: ['click', 'mousedown'],
4145
setup(props, { slots, attrs, emit, expose }) {
4246
const { prefixCls, autoInsertSpaceInButton, direction, size } = useConfigInject('btn', props);

0 commit comments

Comments
 (0)