From 09863bd0813e2e3682b8832c143c79e9a2522408 Mon Sep 17 00:00:00 2001 From: Axetroy Date: Wed, 19 Jul 2023 09:36:07 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20AtSearchBar=20=E5=A2=9E=E5=8A=A0=20enab?= =?UTF-8?q?leNative=20=E5=8F=82=E6=95=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ref: https://github.com/NervJS/taro/issues/7226 ref: https://github.com/NervJS/taro/issues/14196 --- packages/taro-ui-docs/markdown/search-bar.md | 1 + packages/taro-ui/src/components/search-bar/index.tsx | 10 +++++++--- packages/taro-ui/types/search-bar.d.ts | 5 +++++ 3 files changed, 13 insertions(+), 3 deletions(-) diff --git a/packages/taro-ui-docs/markdown/search-bar.md b/packages/taro-ui-docs/markdown/search-bar.md index dd85a10e8..f7e893193 100644 --- a/packages/taro-ui-docs/markdown/search-bar.md +++ b/packages/taro-ui-docs/markdown/search-bar.md @@ -192,6 +192,7 @@ export default class Index extends Taro.Component { | showActionButton | √ | √ | 是否一直显示右侧按钮 | Boolean | - | false | | actionName | √ | √ | 右侧按钮文案 | String | - | '搜索' | | inputType | √ | √ | 输入框输入类型 | String | 'text', 'number', 'idcard', 'digit' | 'text' | +| enableNative | | | 是否使用原生键盘,仅支持支付宝小程序 | Boolean | true | ## 事件 diff --git a/packages/taro-ui/src/components/search-bar/index.tsx b/packages/taro-ui/src/components/search-bar/index.tsx index e09641abc..81e0316a0 100644 --- a/packages/taro-ui/src/components/search-bar/index.tsx +++ b/packages/taro-ui/src/components/search-bar/index.tsx @@ -76,7 +76,8 @@ export default class AtSearchBar extends React.Component< actionName = '搜索', inputType, // 处理issue#464 className, - customStyle + customStyle, + enableNative } = this.props const { isFocus } = this.state const fontSize = 14 @@ -135,6 +136,7 @@ export default class AtSearchBar extends React.Component< focus={isFocus} disabled={disabled} maxlength={maxLength} + enableNative={enableNative} onInput={this.handleChange} onFocus={this.handleFocus} onBlur={this.handleBlur} @@ -171,7 +173,8 @@ AtSearchBar.defaultProps = { actionName: '搜索', inputType: 'text', // eslint-disable-next-line @typescript-eslint/no-empty-function - onChange: (): void => {} + onChange: (): void => {}, + enableNative: true } AtSearchBar.propTypes = { @@ -189,5 +192,6 @@ AtSearchBar.propTypes = { onBlur: PropTypes.func, onConfirm: PropTypes.func, onActionClick: PropTypes.func, - onClear: PropTypes.func + onClear: PropTypes.func, + enableNative: PropTypes.bool } diff --git a/packages/taro-ui/types/search-bar.d.ts b/packages/taro-ui/types/search-bar.d.ts index bcc7784d1..4f8303975 100644 --- a/packages/taro-ui/types/search-bar.d.ts +++ b/packages/taro-ui/types/search-bar.d.ts @@ -58,6 +58,11 @@ export interface AtSearchBarProps extends AtComponent { * @default 'text' */ inputType?: 'text' | 'number' | 'idcard' | 'digit' + /** 使用原生键盘 + * @default true + * @supported alipay + */ + enableNative?: boolean /** * 输入框值改变时触发的事件 * @description 必填,开发者需要通过 onChange 事件来更新 value 值变化