Skip to content

Commit

Permalink
feat(weapp/components): 微信小程序添加always-embed属性&支付宝小程序增加controlled属性和ra…
Browse files Browse the repository at this point in the history
…ndom-number属性
  • Loading branch information
SyMind authored and ZakaryCode committed Sep 27, 2020
1 parent e8b4d48 commit 1128d37
Show file tree
Hide file tree
Showing 3 changed files with 93 additions and 13 deletions.
54 changes: 46 additions & 8 deletions packages/shared/src/components.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,33 @@
import { Shortcuts } from './shortcuts'

type SelectEnvOptions = {
default?: Record<string, string>,
alipay?: Record<string, string>,
jd?: Record<string, string>,
qq?: Record<string, string>,
swan?: Record<string, string>,
tt?: Record<string, string>,
weapp?: Record<string, string>
}

function selectEnv (options: SelectEnvOptions): Record<string, any> {
let option
if (process.env.TARO_ENV === 'alipay') {
option = options.alipay
} else if (process.env.TARO_ENV === 'jd') {
option = options.jd
} else if (process.env.TARO_ENV === 'qq') {
option = options.qq
} else if (process.env.TARO_ENV === 'swan') {
option = options.swan
} else if (process.env.TARO_ENV === 'tt') {
option = options.tt
} else if (process.env.TARO_ENV === 'weapp') {
option = options.weapp
}
return option || options.default || Object.create(null)
}

export const styles = {
style: `i.${Shortcuts.Style}`,
class: `i.${Shortcuts.Class}`
Expand Down Expand Up @@ -134,13 +162,14 @@ const Button = {
bindOpenSetting: '',
bindLaunchApp: '',
scope: '',
name: ''
}

if (process.env.TARO_ENV === 'qq') {
Button['app-packagename'] = ''
Button['app-bundleid'] = ''
Button['app-connect-id'] = ''
name: '',
...selectEnv({
qq: {
'app-packagename': '',
'app-bundleid': '',
'app-connect-id': ''
}
})
}

const Checkbox = {
Expand Down Expand Up @@ -203,7 +232,16 @@ const Input = {
bindBlur: '',
bindConfirm: '',
bindKeyboardHeightChange: '',
name: ''
name: '',
...selectEnv({
alipay: {
'random-number': 'false',
controlled: 'false'
},
weapp: {
'always-embed': 'false'
}
})
}

const Label = {
Expand Down
31 changes: 26 additions & 5 deletions packages/taro-components/types/Button.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ interface ButtonProps extends StandardProps {
appParameter?: string

/** 支付宝小程序 scope
*
*
* 生效时机:`open-type="getAuthorize"`
* @supported weapp
*/
Expand All @@ -132,6 +132,27 @@ interface ButtonProps extends StandardProps {
*/
showMessageCard?: boolean

/**
* 应用的包名 (安卓)
* 生效时机:`open-type="launchApp"`
* @supported qq
*/
appPackagename: string,

/**
* 应用的bundleid (iOS)
* 生效时机:`open-type="launchApp"`
* @supported qq
*/
appBundleid: string,

/**
* QQ互联中的AppID
* 生效时机:`open-type="launchApp"`
* @supported qq
*/
appConnectId: string,

/** 用户点击该按钮时,会返回获取到的用户信息,回调的detail数据与 Taro.getUserInfo 返回的一致
*
* 生效时机: `open-type="getUserInfo"`
Expand All @@ -140,7 +161,7 @@ interface ButtonProps extends StandardProps {
onGetUserInfo?: CommonEventFunction<ButtonProps.onGetUserInfoEventDetail>

/** 支付宝获取会员基础信息授权回调
*
*
* 生效时机:`open-type="getAuthorize"`
* @supported alipay
*/
Expand Down Expand Up @@ -182,7 +203,7 @@ interface ButtonProps extends StandardProps {
onOpenSetting?: CommonEventFunction<ButtonProps.onOpenSettingEventDetail>

/** 打开 APP 成功的回调
*
*
* 生效时机:`open-type="launchApp"`
* @supported weapp
*/
Expand Down Expand Up @@ -343,7 +364,7 @@ declare namespace ButtonProps {
/** 小程序消息指定的查询参数 */
query: Record<string, any>
}

interface onGetPhoneNumberEventDetail {
/* 获取用户手机号的调用状态 */
errMsg: string
Expand All @@ -352,7 +373,7 @@ declare namespace ButtonProps {
/** 加密算法的初始向量 */
iv: string
}

interface onOpenSettingEventDetail {
/* 打开授权设置页的调用状态 */
errMsg: string
Expand Down
21 changes: 21 additions & 0 deletions packages/taro-components/types/Input.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,27 @@ interface InputProps extends StandardProps, FormItemProps {
*/
holdKeyboard?: boolean

/**
* 强制 input 处于同层状态,默认 focus 时 input 会切到非同层状态 (仅在 iOS 下生效)
* @default false
* @supported weapp
*/
alwaysEmbed?: boolean

/**
* 当 type 为 number, digit, idcard 数字键盘是否随机排列
* @default false
* @supported alipay
*/
randomNumber?: boolean

/**
* 是否为受控组件
* @default false
* @supported alipay
*/
controlled?: boolean

/** 当键盘输入时,触发input事件,event.detail = {value, cursor, keyCode},处理函数可以直接 return 一个字符串,将替换输入框的内容。
* @supported weapp, h5, rn
*/
Expand Down

0 comments on commit 1128d37

Please sign in to comment.