Skip to content

Commit dd84e3d

Browse files
committed
chore: merge branch 'dev' into ui-next
2 parents eb0e247 + 0bc3039 commit dd84e3d

File tree

7 files changed

+145
-65
lines changed

7 files changed

+145
-65
lines changed

.travis.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ jobs:
2323
script:
2424
- yarn run test:ci
2525
- stage: release
26-
if: "(branch IN (master, ui-next)) AND (NOT (type IN (pull_request))) AND (tag =~ /^v3/)"
26+
if: "(tag =~ /^v3/) AND (NOT (type IN (pull_request)))"
2727
before_install:
2828
- curl -o- -L https://yarnpkg.com/install.sh | bash
2929
- export PATH="$HOME/.yarn/bin:$PATH"

CHANGELOG.md

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,19 @@
88

99

1010
# [3.0.0-alpha.0](https://github.com/nervjs/taro-ui/compare/v2.3.1...v3.0.0-alpha.0) (2020-03-28)
11+
## [2.3.3](https://github.com/nervjs/taro-ui/compare/v2.3.2...v2.3.3) (2020-04-11)
12+
13+
14+
### Bug Fixes
15+
16+
* 删除过时的 form 参数, close [#998](https://github.com/nervjs/taro-ui/issues/998) ([ea31144](https://github.com/nervjs/taro-ui/commit/ea31144beb63cd634ab825e15375a98837d0ed9a))
17+
* 利用完整日期做唯一 ID, close [#976](https://github.com/nervjs/taro-ui/issues/976) ([ae6f01f](https://github.com/nervjs/taro-ui/commit/ae6f01f0961caf8082599cafc92150273b759328))
18+
* 用了箭头函数不应再用 bind ([d68541a](https://github.com/nervjs/taro-ui/commit/d68541a5c53079b3b1ea44a069eea72e3a1e42c6))
19+
* **input:** 修复 onChange 不能通过 return 改变 value 的问题, close [#980](https://github.com/nervjs/taro-ui/issues/980) ([c87d025](https://github.com/nervjs/taro-ui/commit/c87d025dae416c8d003018acd07c4661d72187d3))
20+
21+
22+
23+
## [2.3.2](https://github.com/nervjs/taro-ui/compare/v2.3.1...v2.3.2) (2020-03-28)
1124

1225

1326
### Bug Fixes
@@ -21,6 +34,9 @@
2134
* 修复页面跳转和循环key重复问题 ([dc1a9fc](https://github.com/nervjs/taro-ui/commit/dc1a9fc44beff9e1a25ca93b7ac6ac4fc02cb90b))
2235
* 更新 AtTextarea 的文档 ([19e3460](https://github.com/nervjs/taro-ui/commit/19e346023547e0040ec15447d950c5e38bd57976))
2336
* **input-number:** 在微信小程序中可以输入非数字或者不合法数字 [#985](https://github.com/nervjs/taro-ui/issues/985) ([#986](https://github.com/nervjs/taro-ui/issues/986)) ([5606017](https://github.com/nervjs/taro-ui/commit/56060177619497fd9e8a5685914cd7a9d45b78ef))
37+
* 更新 AtTextarea 的文档 ([19e3460](https://github.com/nervjs/taro-ui/commit/19e346023547e0040ec15447d950c5e38bd57976))
38+
* **input-number:** 在微信小程序中可以输入非数字或者不合法数字 [#985](https://github.com/nervjs/taro-ui/issues/985) ([#986](https://github.com/nervjs/taro-ui/issues/986)) ([5606017](https://github.com/nervjs/taro-ui/commit/56060177619497fd9e8a5685914cd7a9d45b78ef))
39+
* 使 AtGridItem 支持自定义字段 close [#983](https://github.com/nervjs/taro-ui/issues/983) ([8b25687](https://github.com/nervjs/taro-ui/commit/8b2568762a030d464facc8fe9dd6e447d5fd57ab))
2440

2541

2642
### Features

packages/taro-ui/src/components/button/index.tsx

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,8 @@ import classNames from 'classnames'
22
import PropTypes, { InferProps } from 'prop-types'
33
import React from 'react'
44
import { Button, Form, View } from '@tarojs/components'
5-
import { CommonEvent } from '@tarojs/components/types/common'
5+
import { ButtonProps } from '@tarojs/components/types/Button'
6+
import { BaseEventOrig, CommonEvent } from '@tarojs/components/types/common'
67
import Taro from '@tarojs/taro'
78
import { AtButtonProps, AtButtonState } from '../../../types/button'
89
import AtLoading from '../loading/index'
@@ -43,9 +44,10 @@ export default class AtButton extends React.Component<
4344
this.props.onGetUserInfo && this.props.onGetUserInfo(event)
4445
}
4546

46-
private onContact(event: CommonEvent): void {
47-
// TODO: Change Taro button component types
48-
this.props.onContact && this.props.onContact(event as any)
47+
private onContact(
48+
event: BaseEventOrig<ButtonProps.onContactEventDetail>
49+
): void {
50+
this.props.onContact && this.props.onContact(event)
4951
}
5052

5153
private onGetPhoneNumber(event: CommonEvent): void {
@@ -162,7 +164,6 @@ export default class AtButton extends React.Component<
162164
{isWEB && !disabled && webButton}
163165
{isWEAPP && !disabled && (
164166
<Form
165-
reportSubmit
166167
onSubmit={this.onSumit.bind(this)}
167168
onReset={this.onReset.bind(this)}
168169
>

packages/taro-ui/src/components/calendar/ui/date-list/index.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,9 +37,9 @@ export default class AtCalendarList extends React.Component<Props> {
3737

3838
return (
3939
<View className='at-calendar__list flex'>
40-
{list.map((item, index) => (
40+
{list.map((item: Calendar.Item) => (
4141
<View
42-
key={`list-item-${index}`}
42+
key={`list-item-${item.value}`}
4343
onClick={this.handleClick.bind(this, item)}
4444
onLongPress={this.handleLongClick.bind(this, item)}
4545
className={classnames(

packages/taro-ui/src/components/input/index.tsx

Lines changed: 65 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,16 @@ import classNames from 'classnames'
22
import PropTypes, { InferProps } from 'prop-types'
33
import React from 'react'
44
import { Input, Label, Text, View } from '@tarojs/components'
5-
import { CommonEvent, ITouchEvent } from '@tarojs/components/types/common'
5+
import { BaseEventOrig, ITouchEvent } from '@tarojs/components/types/common'
66
import { InputProps } from '@tarojs/components/types/Input'
7-
import { AtInputProps } from '../../../types/input'
7+
import {
8+
AtInputProps,
9+
BlurEventDetail,
10+
ConfirmEventDetail,
11+
FocusEventDetail,
12+
InputEventDetail,
13+
KeyboardHeightEventDetail
14+
} from '../../../types/input'
815

916
type PickAtInputProps = Pick<
1017
AtInputProps,
@@ -38,49 +45,66 @@ function getInputProps(props: AtInputProps): GetInputPropsReturn {
3845
return actualProps as GetInputPropsReturn
3946
}
4047

41-
type ExtendEvent = {
42-
target: {
43-
value: string | number
44-
}
45-
}
46-
4748
export default class AtInput extends React.Component<AtInputProps> {
4849
public static defaultProps: AtInputProps
4950
public static propTypes: InferProps<AtInputProps>
51+
// TODO: 有待考证是否为合理方式处理 #840
52+
private inputClearing = false
5053

51-
private onInput = (event: CommonEvent & ExtendEvent): void => {
52-
this.props.onChange(event.target.value, event)
53-
}
54+
private handleInput = (event: BaseEventOrig<InputEventDetail>): void =>
55+
this.props.onChange(event.detail.value, event)
5456

55-
private onFocus = (event: CommonEvent & ExtendEvent): void => {
56-
this.props.onFocus && this.props.onFocus(event.target.value, event)
57+
private handleFocus = (event: BaseEventOrig<FocusEventDetail>): void => {
58+
if (typeof this.props.onFocus === 'function') {
59+
this.props.onFocus(event.detail.value, event)
60+
}
5761
}
5862

59-
private onBlur = (event: CommonEvent & ExtendEvent): void => {
60-
this.props.onBlur && this.props.onBlur(event.target.value, event)
61-
// fix # 583 AtInput 不触发 onChange 的问题
62-
this.props.onChange(event.target.value, event)
63+
private handleBlur = (event: BaseEventOrig<BlurEventDetail>): void => {
64+
if (typeof this.props.onBlur === 'function') {
65+
this.props.onBlur(event.detail.value, event)
66+
}
67+
if (event.type === 'blur' && !this.inputClearing) {
68+
// fix # 583 AtInput 不触发 onChange 的问题
69+
this.props.onChange(
70+
event.detail.value,
71+
event as BaseEventOrig<InputEventDetail>
72+
)
73+
}
74+
// 还原状态
75+
this.inputClearing = false
6376
}
6477

65-
private onConfirm = (event: CommonEvent & ExtendEvent): void => {
66-
this.props.onConfirm && this.props.onConfirm(event.target.value, event)
78+
private handleConfirm = (event: BaseEventOrig<ConfirmEventDetail>): void => {
79+
if (typeof this.props.onConfirm === 'function') {
80+
this.props.onConfirm(event.detail.value, event)
81+
}
6782
}
6883

69-
private onClick = (): void => {
70-
if (!this.props.editable) {
71-
this.props.onClick && this.props.onClick()
84+
private handleClick = (event: ITouchEvent): void => {
85+
if (!this.props.editable && typeof this.props.onClick === 'function') {
86+
this.props.onClick(event)
7287
}
7388
}
7489

75-
private clearValue = (event: ITouchEvent): void => {
76-
// fix #840
77-
setTimeout(() => {
78-
this.props.onChange('', event)
79-
}, 50)
90+
private handleClearValue = (event: ITouchEvent): void => {
91+
this.inputClearing = true
92+
this.props.onChange('', event)
8093
}
8194

82-
private onErrorClick = (): void =>
83-
this.props.onErrorClick && this.props.onErrorClick()
95+
private handleKeyboardHeightChange = (
96+
event: BaseEventOrig<KeyboardHeightEventDetail>
97+
): void => {
98+
if (typeof this.props.onKeyboardHeightChange === 'function') {
99+
this.props.onKeyboardHeightChange(event)
100+
}
101+
}
102+
103+
private handleErrorClick = (event: ITouchEvent): void => {
104+
if (typeof this.props.onErrorClick === 'function') {
105+
this.props.onErrorClick(event)
106+
}
107+
}
84108

85109
public render(): JSX.Element {
86110
const {
@@ -103,10 +127,7 @@ export default class AtInput extends React.Component<AtInputProps> {
103127
autoFocus,
104128
focus,
105129
value,
106-
required,
107-
// eslint-disable-next-line @typescript-eslint/ban-ts-ignore
108-
// @ts-ignore
109-
onKeyboardHeightChange
130+
required
110131
} = this.props
111132
const { type, maxLength, disabled, password } = getInputProps(this.props)
112133

@@ -129,7 +150,7 @@ export default class AtInput extends React.Component<AtInputProps> {
129150
return (
130151
<View className={rootCls} style={customStyle}>
131152
<View className={containerCls}>
132-
<View className={overlayCls} onClick={this.onClick}></View>
153+
<View className={overlayCls} onClick={this.handleClick}></View>
133154
{title && (
134155
<Label
135156
className={`at-input__title ${
@@ -159,23 +180,24 @@ export default class AtInput extends React.Component<AtInputProps> {
159180
selectionStart={selectionStart}
160181
selectionEnd={selectionEnd}
161182
adjustPosition={adjustPosition}
162-
onInput={this.onInput}
163-
// fix # 840 input 清除问题
164-
// onChange={this.onInput}
165-
onFocus={this.onFocus}
166-
onBlur={this.onBlur}
167-
onConfirm={this.onConfirm}
183+
onInput={this.handleInput}
184+
onFocus={this.handleFocus}
185+
onBlur={this.handleBlur}
186+
onConfirm={this.handleConfirm}
168187
// eslint-disable-next-line @typescript-eslint/ban-ts-ignore
169188
// @ts-ignore
170-
onKeyboardHeightChange={onKeyboardHeightChange}
189+
onKeyboardHeightChange={this.handleKeyboardHeightChange}
171190
/>
172191
{clear && value && (
173-
<View className='at-input__icon' onTouchEnd={this.clearValue}>
192+
<View className='at-input__icon' onTouchEnd={this.handleClearValue}>
174193
<Text className='at-icon at-icon-close-circle at-input__icon-close'></Text>
175194
</View>
176195
)}
177196
{error && (
178-
<View className='at-input__icon' onTouchStart={this.onErrorClick}>
197+
<View
198+
className='at-input__icon'
199+
onTouchStart={this.handleErrorClick}
200+
>
179201
<Text className='at-icon at-icon-alert-circle at-input__icon-alert'></Text>
180202
</View>
181203
)}

packages/taro-ui/src/components/swipe-action/index.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -241,7 +241,7 @@ export default class AtSwipeAction extends React.Component<
241241
<View
242242
key={`${item.text}-${key}`}
243243
style={item.style}
244-
onClick={this.handleClick.bind(this, item, key)}
244+
onClick={e => this.handleClick(item, key, e)}
245245
className={classNames(
246246
'at-swipe-action__option',
247247
item.className

packages/taro-ui/types/input.d.ts

Lines changed: 54 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,51 @@
11
import { ComponentClass } from 'react'
2-
import { CommonEvent } from '@tarojs/components/types/common'
2+
import { BaseEventOrig, ITouchEvent } from '@tarojs/components/types/common'
33
import { InputProps } from '@tarojs/components/types/Input'
44
import AtComponent from './base'
55

66
declare type OmitInputProps = Omit<
77
InputProps,
8-
'className' | 'type' | 'onBlur' | 'onFocus' | 'onChange' | 'onConfirm'
8+
| 'className'
9+
| 'type'
10+
| 'onBlur'
11+
| 'onFocus'
12+
| 'onChange'
13+
| 'onConfirm'
14+
| 'onKeyboardHeightChange'
915
>
10-
declare type InputFunction<T extends string | number> = (
16+
17+
declare type InputFunction<T extends string | number, U = any, R = void> = (
1118
value: T,
12-
event: CommonEvent
13-
) => void
19+
event?: BaseEventOrig<U>
20+
) => R
21+
22+
declare type InputBaseEventDetail = {
23+
/** 输入值 */
24+
value: string | number
25+
}
26+
27+
export declare type InputEventDetail = InputBaseEventDetail & {
28+
/** 光标位置 */
29+
cursor: number
30+
/** 键值 */
31+
keyCode: number
32+
}
33+
34+
export declare type FocusEventDetail = InputBaseEventDetail & {
35+
/** 键盘高度 */
36+
height: number
37+
}
38+
39+
export declare type BlurEventDetail = InputBaseEventDetail
40+
41+
export declare type ConfirmEventDetail = InputBaseEventDetail
42+
43+
export declare type KeyboardHeightEventDetail = {
44+
/** 键盘高度 */
45+
height: number
46+
/** 持续时间 */
47+
duration: number
48+
}
1449

1550
export interface AtInputProps extends AtComponent, OmitInputProps {
1651
/**
@@ -86,28 +121,34 @@ export interface AtInputProps extends AtComponent, OmitInputProps {
86121
/**
87122
* 输入框失去焦点时触发的事件,v2.0.3 版本可以获取 event 参数
88123
*/
89-
onBlur?: InputFunction<string | number>
124+
onBlur?: InputFunction<string | number, BlurEventDetail>
90125
/**
91126
* 输入框被选中时触发的事件,v2.0.3 版本可以获取 event 参数
92127
*/
93-
onFocus?: InputFunction<string | number>
128+
onFocus?: InputFunction<string | number, FocusEventDetail>
94129
/**
95130
* 输入框值改变时触发的事件,开发者需要通过 onChange 事件来更新 value 值变化,onChange 函数必填。
96131
* 小程序中,如果想改变 value 的值,需要 return value 从而改变输入框的当前值, v2.0.3 版本可以获取 event 参数
97132
*/
98-
onChange: InputFunction<string | number>
133+
onChange: InputFunction<string | number, InputEventDetail, any>
99134
/**
100135
* 点击完成按钮时触发,v2.0.3 版本可以获取 event 参数
101136
*/
102-
onConfirm?: InputFunction<string | number>
137+
onConfirm?: InputFunction<string | number, ConfirmEventDetail>
138+
/**
139+
* 当 editable 为 false 时,点击组件触发的事件,v2.3.3 版本可以获取 event 参数
140+
*/
141+
onClick?: (event?: ITouchEvent) => void
103142
/**
104-
* 当 editable 为 false 时,点击组件触发的事件
143+
* 键盘高度发生变化的时候触发此事件
105144
*/
106-
onClick?: () => void
145+
onKeyboardHeightChange?: (
146+
event?: BaseEventOrig<KeyboardHeightEventDetail>
147+
) => void
107148
/**
108-
* 点击错误按钮触发的事件
149+
* 点击错误按钮触发的事件,v2.3.3 版本可以获取 event 参数
109150
*/
110-
onErrorClick?: () => void
151+
onErrorClick?: (event?: ITouchEvent) => void
111152
}
112153

113154
declare const AtInput: ComponentClass<AtInputProps>

0 commit comments

Comments
 (0)