Skip to content

Commit d71df4b

Browse files
committed
fix: component ts type
1 parent b13756f commit d71df4b

File tree

20 files changed

+111
-197
lines changed

20 files changed

+111
-197
lines changed

components/checkbox/Checkbox.tsx

+8-1
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,13 @@ export default defineComponent({
5959
});
6060
return () => {
6161
const children = flattenChildren(slots.default?.());
62-
const { indeterminate, skipGroup, id = formItemContext.id.value, ...restProps } = props;
62+
const {
63+
indeterminate,
64+
skipGroup,
65+
id = formItemContext.id.value,
66+
onClick,
67+
...restProps
68+
} = props;
6369
const { onMouseenter, onMouseleave, onInput, class: className, style, ...restAttrs } = attrs;
6470
const checkboxProps: CheckboxProps = {
6571
...restProps,
@@ -97,6 +103,7 @@ export default defineComponent({
97103
style={style}
98104
onMouseenter={onMouseenter as EventHandler}
99105
onMouseleave={onMouseleave as EventHandler}
106+
onClick={onClick}
100107
>
101108
<VcCheckbox {...checkboxProps} class={checkboxClass} ref={checkboxRef} />
102109
{children.length ? <span>{children}</span> : null}

components/checkbox/interface.ts

+1
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@ export const abstractCheckboxProps = () => {
5353
autofocus: { type: Boolean, default: undefined },
5454
onChange: PropTypes.func,
5555
'onUpdate:checked': PropTypes.func,
56+
onClick: PropTypes.func,
5657
skipGroup: { type: Boolean, default: false },
5758
};
5859
};

components/components.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ export { default as List, ListItem, ListItemMeta } from './list';
102102
export type { MessageArgsProps } from './message';
103103
export { default as message } from './message';
104104

105-
export type { MenuProps, MenuTheme, SubMenuProps, MenuItemProps } from './menu';
105+
export type { MenuProps, MenuTheme, SubMenuProps, MenuItemProps, MenuMode } from './menu';
106106
export { default as Menu, MenuDivider, MenuItem, MenuItemGroup, SubMenu } from './menu';
107107

108108
export type { MentionsProps } from './mentions';

components/input-number/src/InputNumber.tsx

+2
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,8 @@ export const inputNumberProps = {
7474
(value: ValueType, info: { offset: ValueType; type: 'up' | 'down' }) => void
7575
>,
7676
},
77+
onBlur: { type: Function as PropType<(e: InputEvent) => void> },
78+
onFocus: { type: Function as PropType<(e: InputEvent) => void> },
7779
};
7880

7981
export default defineComponent({

components/menu/demo/switch-mode.vue

+3-2
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,7 @@ import {
7878
AppstoreOutlined,
7979
SettingOutlined,
8080
} from '@ant-design/icons-vue';
81+
import type { MenuMode, MenuTheme } from 'ant-design-vue';
8182
export default defineComponent({
8283
components: {
8384
MailOutlined,
@@ -87,8 +88,8 @@ export default defineComponent({
8788
},
8889
setup() {
8990
const state = reactive({
90-
mode: 'inline',
91-
theme: 'light',
91+
mode: 'inline' as MenuMode,
92+
theme: 'light' as MenuTheme,
9293
selectedKeys: ['1'],
9394
openKeys: ['sub1'],
9495
});

components/menu/demo/theme.vue

+2-1
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,7 @@ import {
7878
AppstoreOutlined,
7979
SettingOutlined,
8080
} from '@ant-design/icons-vue';
81+
import type { MenuTheme } from 'ant-design-vue';
8182
export default defineComponent({
8283
components: {
8384
MailOutlined,
@@ -87,7 +88,7 @@ export default defineComponent({
8788
},
8889
setup() {
8990
const state = reactive({
90-
theme: 'dark',
91+
theme: 'dark' as MenuTheme,
9192
selectedKeys: ['1'],
9293
openKeys: ['sub1'],
9394
});

components/menu/demo/vertical.vue

+3-8
Original file line numberDiff line numberDiff line change
@@ -68,13 +68,8 @@ import {
6868
AppstoreOutlined,
6969
SettingOutlined,
7070
} from '@ant-design/icons-vue';
71+
import type { MenuProps } from 'ant-design-vue';
7172
72-
interface MenuInfo {
73-
key: string;
74-
keyPath: string[];
75-
item: any;
76-
domEvent: MouseEvent;
77-
}
7873
export default defineComponent({
7974
components: {
8075
MailOutlined,
@@ -87,8 +82,8 @@ export default defineComponent({
8782
selectedKeys: [],
8883
openKeys: [],
8984
});
90-
const handleClick = (e: MenuInfo) => {
91-
console.log('click ', e);
85+
const handleClick: MenuProps['onClick'] = menuInfo => {
86+
console.log('click ', menuInfo);
9287
};
9388
return {
9489
...toRefs(state),

components/menu/index.en-US.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ More layouts with navigation: [Layout](/components/layout).
3434
| forceSubMenuRender | render submenu into DOM before it shows | boolean | false |
3535
| inlineCollapsed | specifies the collapsed status when menu is inline mode | boolean | - |
3636
| inlineIndent | indent px of inline menu item on each level | number | 24 |
37-
| mode | type of the menu; `vertical`, `horizontal`, and `inline` modes are supported | string: `vertical` \| `vertical-right` \| `horizontal` \| `inline` | `vertical` |
37+
| mode | type of the menu; `vertical`, `horizontal`, and `inline` modes are supported | `vertical` \| `horizontal` \| `inline` | `vertical` |
3838
| multiple | Allow selection of multiple items | boolean | false |
3939
| openKeys(v-model) | array with the keys of currently opened sub menus | string\[] | |
4040
| selectable | allow selecting menu items | boolean | true |

components/menu/index.tsx

+2-2
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import type { MenuItemGroupProps } from './src/ItemGroup';
88
import ItemGroup from './src/ItemGroup';
99
import Divider from './src/Divider';
1010
import type { App, Plugin } from 'vue';
11-
import type { MenuTheme } from './src/interface';
11+
import type { MenuTheme, MenuMode } from './src/interface';
1212
/* istanbul ignore next */
1313
Menu.install = function (app: App) {
1414
app.component(Menu.name, Menu);
@@ -23,7 +23,7 @@ Menu.Item = MenuItem;
2323
Menu.Divider = Divider;
2424
Menu.SubMenu = SubMenu;
2525
Menu.ItemGroup = ItemGroup;
26-
export type { MenuProps, SubMenuProps, MenuItemProps, MenuItemGroupProps, MenuTheme };
26+
export type { MenuProps, SubMenuProps, MenuItemProps, MenuItemGroupProps, MenuTheme, MenuMode };
2727
export {
2828
SubMenu,
2929
MenuItem as Item,

components/menu/index.zh-CN.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ cover: https://gw.alipayobjects.com/zos/alicdn/3XZcjGpvK/Menu.svg
3535
| forceSubMenuRender | 在子菜单展示之前就渲染进 DOM | boolean | false |
3636
| inlineCollapsed | inline 时菜单是否收起状态 | boolean | - |
3737
| inlineIndent | inline 模式的菜单缩进宽度 | number | 24 |
38-
| mode | 菜单类型,现在支持垂直、水平、和内嵌模式三种 | string: `vertical` `vertical-right` `horizontal` `inline` | `vertical` |
38+
| mode | 菜单类型,现在支持垂直、水平、和内嵌模式三种 | `vertical` \| `horizontal` \| `inline` | `vertical` |
3939
| multiple | 是否允许多选 | boolean | false |
4040
| openKeys(v-model) | 当前展开的 SubMenu 菜单项 key 数组 | string\[] | |
4141
| selectable | 是否允许选中 | boolean | true |

components/menu/src/Menu.tsx

+12-9
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@ import type {
1212
TriggerSubMenuAction,
1313
MenuInfo,
1414
SelectInfo,
15+
MenuClickEventHandler,
16+
SelectEventHandler,
1517
} from './interface';
1618
import devWarning from '../../vc-util/devWarning';
1719
import type { CSSMotionProps } from '../../_util/transition';
@@ -25,6 +27,7 @@ import SubMenu from './SubMenu';
2527
import EllipsisOutlined from '@ant-design/icons-vue/EllipsisOutlined';
2628
import { cloneElement } from '../../_util/vnode';
2729
import { OVERFLOW_KEY, PathContext } from './hooks/useKeyPath';
30+
import type { FocusEventHandler } from '../../_util/EventInterface';
2831

2932
export const menuProps = {
3033
id: String,
@@ -55,6 +58,15 @@ export const menuProps = {
5558
getPopupContainer: Function as PropType<(node: HTMLElement) => HTMLElement>,
5659

5760
expandIcon: Function as PropType<(p?: { isOpen: boolean; [key: string]: any }) => any>,
61+
onOpenChange: Function as PropType<(keys: Key[]) => void>,
62+
onSelect: Function as PropType<SelectEventHandler>,
63+
onDeselect: Function as PropType<SelectEventHandler>,
64+
onClick: Function as PropType<MenuClickEventHandler>,
65+
onFocus: Function as PropType<FocusEventHandler>,
66+
onBlur: Function as PropType<FocusEventHandler>,
67+
'onUpdate:openKeys': Function as PropType<(keys: Key[]) => void>,
68+
'onUpdate:selectedKeys': Function as PropType<(keys: Key[]) => void>,
69+
'onUpdate:activeKey': Function as PropType<(key: Key) => void>,
5870
};
5971

6072
export type MenuProps = Partial<ExtractPropTypes<typeof menuProps>>;
@@ -64,15 +76,6 @@ export default defineComponent({
6476
name: 'AMenu',
6577
inheritAttrs: false,
6678
props: menuProps,
67-
emits: [
68-
'update:openKeys',
69-
'openChange',
70-
'select',
71-
'deselect',
72-
'update:selectedKeys',
73-
'click',
74-
'update:activeKey',
75-
],
7679
slots: ['expandIcon', 'overflowedIndicator'],
7780
setup(props, { slots, emit, attrs }) {
7881
const { prefixCls, direction, getPrefixCls } = useConfigInject('menu', props);

components/radio/Radio.tsx

+8-2
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ export const radioProps = {
2020
onChange: PropTypes.func,
2121
onFocus: PropTypes.func,
2222
onBlur: PropTypes.func,
23+
onClick: PropTypes.func,
2324
};
2425

2526
export type RadioProps = Partial<ExtractPropTypes<typeof radioProps>>;
@@ -61,7 +62,12 @@ export default defineComponent({
6162

6263
return () => {
6364
const radioGroup = radioGroupContext;
64-
const { prefixCls: customizePrefixCls, id = formItemContext.id.value, ...restProps } = props;
65+
const {
66+
prefixCls: customizePrefixCls,
67+
id = formItemContext.id.value,
68+
onClick,
69+
...restProps
70+
} = props;
6571

6672
const rProps: RadioProps = {
6773
prefixCls: prefixCls.value,
@@ -85,7 +91,7 @@ export default defineComponent({
8591
});
8692

8793
return (
88-
<label class={wrapperClassString}>
94+
<label class={wrapperClassString} onClick={onClick}>
8995
<VcCheckbox {...rProps} ref={vcCheckbox} />
9096
{slots.default && <span>{slots.default()}</span>}
9197
</label>

components/vc-overflow/RawItem.tsx

+5
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,11 @@ export default defineComponent({
1111
component: PropTypes.any,
1212
title: PropTypes.any,
1313
id: String,
14+
onMouseenter: { type: Function },
15+
onMouseleave: { type: Function },
16+
onClick: { type: Function },
17+
onKeydown: { type: Function },
18+
onFocus: { type: Function },
1419
},
1520
setup(props, { slots, attrs }) {
1621
const context = useInjectOverflowContext();

components/vc-pagination/Pager.tsx

+6
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,12 @@ export default defineComponent({
1616
type: Function,
1717
default: () => {},
1818
},
19+
onClick: {
20+
type: Function,
21+
},
22+
onKeypress: {
23+
type: Function,
24+
},
1925
},
2026
eimt: ['click', 'keypress'],
2127
setup(props, { emit, attrs }) {

0 commit comments

Comments
 (0)