Skip to content

Commit f211afe

Browse files
authored
[improvement] ContactCard: tsx (youzan#2783)
1 parent ad27b88 commit f211afe

File tree

7 files changed

+56
-4
lines changed

7 files changed

+56
-4
lines changed

packages/button/index.tsx

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,10 @@ export type ButtonProps = RouteProps & {
2323
bottomAction?: boolean;
2424
};
2525

26+
export type ButtonEvents = {
27+
onClick?(event: Event): void;
28+
};
29+
2630
const [sfc, bem] = use('button');
2731

2832
function Button(
@@ -100,4 +104,4 @@ Button.props = {
100104
}
101105
};
102106

103-
export default sfc<ButtonProps>(Button);
107+
export default sfc<ButtonProps, ButtonEvents>(Button);

packages/card/index.tsx

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,10 @@ export type CardSlots = DefaultSlots & {
3232
'origin-price'?: ScopedSlot;
3333
};
3434

35+
export type CardEvents = {
36+
onClick?(event: Event): void;
37+
};
38+
3539
const [sfc, bem] = use('card');
3640

3741
function Card(
@@ -140,4 +144,4 @@ Card.props = {
140144
}
141145
};
142146

143-
export default sfc<CardProps>(Card);
147+
export default sfc<CardProps, CardEvents>(Card);

packages/contact-card/en-US.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -140,6 +140,12 @@ export default {
140140
| tel | Phone | `String` | - |
141141
| add-text | Add card text | `String` | `Add contact info` |
142142

143+
### ContactCard Event
144+
145+
| Event | Description | Arguments |
146+
|------|------|------|
147+
| click | Triggered when clicked | - |
148+
143149
### ContactList API
144150

145151
| Attribute | Description | Type | Default |

packages/contact-card/zh-CN.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -140,6 +140,12 @@ export default {
140140
| tel | 联系人手机号 | `String` | - | - |
141141
| add-text | 添加时的文案提示 | `String` | `添加订单联系人信息` | - |
142142

143+
### ContactCard Event
144+
145+
| 事件名 | 说明 | 参数 |
146+
|------|------|------|
147+
| click | 点击时触发 | - |
148+
143149
### ContactList API
144150

145151
| 参数 | 说明 | 类型 | 默认值 | 版本 |

packages/field/en-US.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -138,6 +138,7 @@ Field support all native events of input tag,such as `focus`、`blur`、`keypr
138138

139139
| Event | Description | Parameters |
140140
|------|------|------|
141+
| input | Triggered when value changed | - |
141142
| clear | Triggered when click clear icon | - |
142143
| click-left-icon | Triggered when click the left icon of Field | - |
143144
| click-right-icon | Triggered when click the right icon of Field | - |

packages/field/zh-CN.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -140,6 +140,7 @@ Field 默认支持 Input 标签所有的原生事件,如 `focus`、`blur`、`k
140140

141141
| 事件 | 说明 | 回调参数 |
142142
|------|------|------|
143+
| input | 输入框内容变化时触发 | - |
143144
| clear | 点击清除按钮后触发 | - |
144145
| click-left-icon | 点击头部图标时触发 | - |
145146
| click-right-icon | 点击尾部图标时触发 | - |

packages/nav-bar/index.js renamed to packages/nav-bar/index.tsx

Lines changed: 32 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,39 @@ import { use, noop } from '../utils';
22
import { inherit } from '../utils/functional';
33
import Icon from '../icon';
44

5+
// Types
6+
import { CreateElement, RenderContext } from 'vue/types';
7+
import { ScopedSlot, DefaultSlots } from '../utils/use/sfc';
8+
9+
export type NavBarProps = {
10+
title?: string;
11+
fixed?: boolean;
12+
zIndex?: number;
13+
border?: boolean;
14+
leftText?: string;
15+
rightText?: string;
16+
leftArrow?: boolean;
17+
};
18+
19+
export type NavBarSlots = DefaultSlots & {
20+
left?: ScopedSlot;
21+
title?: ScopedSlot;
22+
right?: ScopedSlot;
23+
};
24+
25+
export type NavBarEvents = {
26+
'click-left'?(event: Event): void;
27+
'click-right'?(event: Event): void;
28+
};
29+
530
const [sfc, bem] = use('nav-bar');
631

7-
function NavBar(h, props, slots, ctx) {
32+
function NavBar(
33+
h: CreateElement,
34+
props: NavBarProps,
35+
slots: NavBarSlots,
36+
ctx: RenderContext<NavBarProps>
37+
) {
838
return (
939
<div
1040
class={[
@@ -56,4 +86,4 @@ NavBar.props = {
5686
}
5787
};
5888

59-
export default sfc(NavBar);
89+
export default sfc<NavBarProps, NavBarEvents>(NavBar);

0 commit comments

Comments
 (0)