From 9a518cd5fd88efc8fdaecada907366c835dd02fe Mon Sep 17 00:00:00 2001 From: anlyyao Date: Wed, 9 Mar 2022 15:59:13 +0800 Subject: [PATCH] fix(button): use correct default value --- src/button/README.md | 70 ++++++++++++++++++++++++-------------------- src/button/props.ts | 22 +++++++------- src/button/type.ts | 36 ++++++++++++++--------- 3 files changed, 70 insertions(+), 58 deletions(-) diff --git a/src/button/README.md b/src/button/README.md index 6ce987183..a6731d71a 100644 --- a/src/button/README.md +++ b/src/button/README.md @@ -72,37 +72,43 @@ isComponent: true ``` ## API - ### Button Props -| 名称 | 类型 | 默认值 | 说明 | 必传 | -| -- | -- | -- | -- | -- | -| block | Boolean | false | 是否为块级元素| N | -| content | String/Slot | '' | 按钮内容 | N | -| disabled | Boolean | false | 是否禁用按钮| N | -| external-classes | Array | - | 组件类名。`['t-class', 't-class-icon']`| N | -| ghost | Boolean | false | 是否为幽灵按钮(镂空按钮)| N | -| icon | String | - | 图标名称| N | -| loading | Boolean | false | 是否显示为加载状态| N | -| shape | String | rectangle | 按钮形状,有4种:长方形/正方形/圆角长方形/圆形。可选项:rectangle/square/round/circle| N | -| size | String | medium | 组件尺寸。可选项:small/medium/large。TS 类型:`SizeEnum`| N | -| theme | String | undefined | 组件风格,依次为品牌色、危险色。可选项:default/primary/danger| N | -| type | String | - | 同小程序的 formType。可选项:submit/reset| N | -| variant | String | base | 按钮形式,基础、线框、文字。可选项:base/outline/text| N | -| open-type | String | - | 微信开放能力 [查看小程序文档](https://developers.weixin.qq.com/miniprogram/dev/component/button.html)。可选项:contact/share/getPhoneNumber/getUserInfo/launchApp/openSetting/feedback | N | -| hover-stop-propagation | Boolean | false | 指定是否阻止本节点的祖先节点出现点击态| N | -| hover-start-time | Number | 20 | 按住后多久出现点击态,单位毫秒| N | -| hover-stay-time | Number | 70 | 手指松开后点击态保留时间,单位毫秒| N | -| lang | String | en | 指定返回用户信息的语言,zh_CN 简体中文,zh_TW 繁体中文,en 英文。 [查看小程序文档](https://developers.weixin.qq.com/miniprogram/dev/component/button.html)。可选项:en/zh_CN/zh_TW | N | -| session-from | String | - | 会话来源,open-type=contact 时有效 | N | -| send-message-title | String | 当前标题 | 会话内消息卡片标题,open-type=contact 时有效 | N | -| send-message-path | String | 当前分享路径 | 会话内消息卡片点击跳转小程序路径,open-type=contact 时有效 | N | -| send-message-img | String | 截图 | 会话内消息卡片图片,open-type=contact 时有效 | N | -| app-parameter | String | - | 打开 APP 时,向 APP 传递的参数,open-type=launchApp 时有效 | N | -| show-message-card | Boolean | false | 是否显示会话内消息卡片,设置此参数为 true,用户进入客服会话会在右下角显示可能要发送的小程序提示,用户点击后可以快速发送小程序消息,open-type=contact 时有效 | N | -| bindgetuserinfo | Eventhandle | - | 用户点击该按钮时,会返回获取到的用户信息,回调的 detail 数据与wx.getUserInfo返回的一致,open-type=getUserInfo 时有效 | N | -| bindcontact | Eventhandle | - | 客服消息回调,open-type=contact | N | -| bindgetphonenumber | Eventhandle | - | 获取用户手机号回调,open-type=getPhoneNumber 时有效 | N | -| binderror | Eventhandle | - | 当使用开放能力时,发生错误的回调,open-type=launchApp 时有效 | N | -| bindopensetting | Eventhandle | - | 在打开授权设置页后回调,open-type=openSetting 时有效 | N | -| bindlaunchapp | Eventhandle | - | 打开 APP 成功的回调,open-type=launchApp 时有效 | N | +名称 | 类型 | 默认值 | 说明 | 必传 +-- | -- | -- | -- | -- +block | Boolean | false | 是否为块级元素 | N +content | String / Slot | - | 按钮内容 | N +disabled | Boolean | false | 是否禁用按钮 | N +external-classes | Array | - | 组件类名。`['t-class', 't-class-icon']` | N +ghost | Boolean | false | 是否为幽灵按钮(镂空按钮) | N +icon | String | - | 图标名称 | N +loading | Boolean | false | 是否显示为加载状态 | N +shape | String | rectangle | 按钮形状,有 4 种:长方形、正方形、圆角长方形、圆形。可选项:rectangle/square/round/circle | N +size | String | medium | 组件尺寸。可选项:small/medium/large。TS 类型:`SizeEnum` | N +theme | String | default | 组件风格,依次为品牌色、危险色。可选项:default/primary/danger | N +type | String | - | 同小程序的 formType。可选项:submit/reset | N +variant | String | base | 按钮形式,基础、线框、文字。可选项:base/outline/text | N +open-type | String | - | 微信开放能力。
具体释义:
`contact` 打开客服会话,如果用户在会话中点击消息卡片后返回小程序,可以从 bindcontact 回调中获得具体信息,具体说明 (*小程序插件中不能使用*);
`share` 触发用户转发,使用前建议先阅读使用指引
`getPhoneNumber` 获取用户手机号,可以从bindgetphonenumber回调中获取到用户信息,具体说明 (*小程序插件中不能使用*);
`getUserInfo` 获取用户信息,可以从bindgetuserinfo回调中获取到用户信息 (*小程序插件中不能使用*);
`launchApp` 打开APP,可以通过app-parameter属性设定向APP传的参数具体说明
`openSetting` 打开授权设置页;
`feedback` 打开“意见反馈”页面,用户可提交反馈内容并上传日志,开发者可以登录小程序管理后台后进入左侧菜单“客服反馈”页面获取到反馈内容;
`chooseAvatar` 获取用户头像,可以从bindchooseavatar回调中获取到头像信息。
[小程序官方文档](https://developers.weixin.qq.com/miniprogram/dev/component/button.html)。可选项:contact/share/getPhoneNumber/getUserInfo/launchApp/openSetting/feedback/chooseAvatar | N +hover-stop-propagation | Boolean | false | 指定是否阻止本节点的祖先节点出现点击态 | N +hover-start-time | Number | 20 | 按住后多久出现点击态,单位毫秒 | N +hover-stay-time | Number | 70 | 手指松开后点击态保留时间,单位毫秒 | N +lang | String | en | 指定返回用户信息的语言,zh_CN 简体中文,zh_TW 繁体中文,en 英文。。
具体释义:
`en` 英文;
`zh_CN` 简体中文;
`zh_TW` 繁体中文。
[小程序官方文档](https://developers.weixin.qq.com/miniprogram/dev/component/button.html)。可选项:en/zh_CN/zh_TW | N +session-from | String | - | 会话来源,open-type="contact"时有效 | N +send-message-title | String | 当前标题 | 会话内消息卡片标题,open-type="contact"时有效 | N +send-message-path | String | 当前分享路径 | 会话内消息卡片点击跳转小程序路径,open-type="contact"时有效 | N +send-message-img | String | 截图 | 会话内消息卡片图片,open-type="contact"时有效 | N +app-parameter | String | - | 打开 APP 时,向 APP 传递的参数,open-type=launchApp时有效 | N +show-message-card | Boolean | false | 是否显示会话内消息卡片,设置此参数为 true,用户进入客服会话会在右下角显示"可能要发送的小程序"提示,用户点击后可以快速发送小程序消息,open-type="contact"时有效 | N +bindgetuserinfo | Eventhandle | - | 用户点击该按钮时,会返回获取到的用户信息,回调的detail数据与wx.getUserInfo返回的一致,open-type="getUserInfo"时有效 | N +bindcontact | Eventhandle | - | 客服消息回调,open-type="contact"时有效 | N +bindgetphonenumber | Eventhandle | - | 获取用户手机号回调,open-type=getPhoneNumber时有效 | N +binderror | Eventhandle | - | 当使用开放能力时,发生错误的回调,open-type=launchApp时有效 | N +bindopensetting | Eventhandle | - | 在打开授权设置页后回调,open-type=openSetting时有效 | N +bindlaunchapp | Eventhandle | - | 打开 APP 成功的回调,open-type=launchApp时有效 | N +bindchooseavatar | Eventhandle | - | 获取用户头像回调,open-type=chooseAvatar时有效 | N + +### Button Events + +名称 | 参数 | 描述 +-- | -- | -- +click | `(e: MouseEvent)` | 点击时触发 diff --git a/src/button/props.ts b/src/button/props.ts index 29a183f13..63ee7c4be 100644 --- a/src/button/props.ts +++ b/src/button/props.ts @@ -2,7 +2,6 @@ /** * 该文件为脚本自动生成文件,请勿随意修改。如需修改请联系 PMC - * updated at 2021-11-24 10:58:05 * */ import { TdButtonProps } from './type'; @@ -15,7 +14,6 @@ const props: TdButtonProps = { /** 按钮内容 */ content: { type: String, - value: '', }, /** 是否禁用按钮 */ disabled: { @@ -41,10 +39,10 @@ const props: TdButtonProps = { type: Boolean, value: false, }, - /** 按钮形状,有二种:方形、圆角方形 */ + /** 按钮形状,有 4 种:长方形、正方形、圆角长方形、圆形 */ shape: { type: String, - value: 'square', + value: 'rectangle', }, /** 组件尺寸 */ size: { @@ -54,7 +52,7 @@ const props: TdButtonProps = { /** 组件风格,依次为品牌色、危险色 */ theme: { type: String, - value: undefined, + value: 'default', }, /** 同小程序的 formType */ type: { @@ -65,7 +63,7 @@ const props: TdButtonProps = { type: String, value: 'base', }, - /** 微信开放能力 [查看小程序文档](https://developers.weixin.qq.com/miniprogram/dev/component/button.html) */ + /** 微信开放能力。
具体释义:
`contact` 打开客服会话,如果用户在会话中点击消息卡片后返回小程序,可以从 bindcontact 回调中获得具体信息,具体说明 (*小程序插件中不能使用*);
`share` 触发用户转发,使用前建议先阅读使用指引
`getPhoneNumber` 获取用户手机号,可以从bindgetphonenumber回调中获取到用户信息,具体说明 (*小程序插件中不能使用*);
`getUserInfo` 获取用户信息,可以从bindgetuserinfo回调中获取到用户信息 (*小程序插件中不能使用*);
`launchApp` 打开APP,可以通过app-parameter属性设定向APP传的参数具体说明
`openSetting` 打开授权设置页;
`feedback` 打开“意见反馈”页面,用户可提交反馈内容并上传日志,开发者可以登录小程序管理后台后进入左侧菜单“客服反馈”页面获取到反馈内容;
`chooseAvatar` 获取用户头像,可以从bindchooseavatar回调中获取到头像信息。
[小程序官方文档](https://developers.weixin.qq.com/miniprogram/dev/component/button.html) */ openType: { type: String, }, @@ -84,27 +82,27 @@ const props: TdButtonProps = { type: Number, value: 70, }, - /** 指定返回用户信息的语言,zh_CN 简体中文,zh_TW 繁体中文,en 英文。 [查看小程序文档](https://developers.weixin.qq.com/miniprogram/dev/component/button.html) */ + /** 指定返回用户信息的语言,zh_CN 简体中文,zh_TW 繁体中文,en 英文。。
具体释义:
`en` 英文;
`zh_CN` 简体中文;
`zh_TW` 繁体中文。
[小程序官方文档](https://developers.weixin.qq.com/miniprogram/dev/component/button.html) */ lang: { type: String, value: 'en', }, - /** 会话来源,open-type=contact时有效 */ + /** 会话来源,open-type="contact"时有效 */ sessionFrom: { type: String, value: '', }, - /** 会话内消息卡片标题,open-type=contact时有效 */ + /** 会话内消息卡片标题,open-type="contact"时有效 */ sendMessageTitle: { type: String, value: '', }, - /** 会话内消息卡片点击跳转小程序路径,open-type=contact时有效 */ + /** 会话内消息卡片点击跳转小程序路径,open-type="contact"时有效 */ sendMessagePath: { type: String, value: '', }, - /** 会话内消息卡片图片,open-type=contact时有效 */ + /** 会话内消息卡片图片,open-type="contact"时有效 */ sendMessageImg: { type: String, value: '', @@ -114,7 +112,7 @@ const props: TdButtonProps = { type: String, value: '', }, - /** 是否显示会话内消息卡片,设置此参数为 true,用户进入客服会话会在右下角显示可能要发送的小程序提示,用户点击后可以快速发送小程序消息,open-type=contact时有效 */ + /** 是否显示会话内消息卡片,设置此参数为 true,用户进入客服会话会在右下角显示"可能要发送的小程序"提示,用户点击后可以快速发送小程序消息,open-type="contact"时有效 */ showMessageCard: { type: Boolean, value: false, diff --git a/src/button/type.ts b/src/button/type.ts index 9a6621153..b6efebd91 100644 --- a/src/button/type.ts +++ b/src/button/type.ts @@ -2,7 +2,6 @@ /** * 该文件为脚本自动生成文件,请勿随意修改。如需修改请联系 PMC - * updated at 2021-11-24 10:58:05 * */ import { SizeEnum } from '../common/common'; @@ -39,7 +38,7 @@ export interface TdButtonProps { */ externalClasses?: { type: ArrayConstructor; - value?: ['t-class']; + value?: ['t-class', 't-class-icon']; required?: boolean; }; /** @@ -70,12 +69,12 @@ export interface TdButtonProps { required?: boolean; }; /** - * 按钮形状,有二种:方形、圆角方形 - * @default square + * 按钮形状,有 4 种:长方形、正方形、圆角长方形、圆形 + * @default rectangle */ shape?: { type: StringConstructor; - value?: 'square' | 'round'; + value?: 'rectangle' | 'square' | 'round' | 'circle'; required?: boolean; }; /** @@ -89,6 +88,7 @@ export interface TdButtonProps { }; /** * 组件风格,依次为品牌色、危险色 + * @default default */ theme?: { type: StringConstructor; @@ -113,11 +113,19 @@ export interface TdButtonProps { required?: boolean; }; /** - * 微信开放能力 [查看小程序文档](https://developers.weixin.qq.com/miniprogram/dev/component/button.html) + * 微信开放能力。
具体释义:
`contact` 打开客服会话,如果用户在会话中点击消息卡片后返回小程序,可以从 bindcontact 回调中获得具体信息,具体说明 (*小程序插件中不能使用*);
`share` 触发用户转发,使用前建议先阅读使用指引
`getPhoneNumber` 获取用户手机号,可以从bindgetphonenumber回调中获取到用户信息,具体说明 (*小程序插件中不能使用*);
`getUserInfo` 获取用户信息,可以从bindgetuserinfo回调中获取到用户信息 (*小程序插件中不能使用*);
`launchApp` 打开APP,可以通过app-parameter属性设定向APP传的参数具体说明
`openSetting` 打开授权设置页;
`feedback` 打开“意见反馈”页面,用户可提交反馈内容并上传日志,开发者可以登录小程序管理后台后进入左侧菜单“客服反馈”页面获取到反馈内容;
`chooseAvatar` 获取用户头像,可以从bindchooseavatar回调中获取到头像信息。
[小程序官方文档](https://developers.weixin.qq.com/miniprogram/dev/component/button.html) */ openType?: { type: StringConstructor; - value?: 'contact' | 'share' | 'getPhoneNumber' | 'getUserInfo' | 'launchApp' | 'openSetting' | 'feedback'; + value?: + | 'contact' + | 'share' + | 'getPhoneNumber' + | 'getUserInfo' + | 'launchApp' + | 'openSetting' + | 'feedback' + | 'chooseAvatar'; required?: boolean; }; /** @@ -148,7 +156,7 @@ export interface TdButtonProps { required?: boolean; }; /** - * 指定返回用户信息的语言,zh_CN 简体中文,zh_TW 繁体中文,en 英文。 [查看小程序文档](https://developers.weixin.qq.com/miniprogram/dev/component/button.html) + * 指定返回用户信息的语言,zh_CN 简体中文,zh_TW 繁体中文,en 英文。。
具体释义:
`en` 英文;
`zh_CN` 简体中文;
`zh_TW` 繁体中文。
[小程序官方文档](https://developers.weixin.qq.com/miniprogram/dev/component/button.html) * @default en */ lang?: { @@ -157,7 +165,7 @@ export interface TdButtonProps { required?: boolean; }; /** - * 会话来源,open-type=contact时有效 + * 会话来源,open-type="contact"时有效 * @default '' */ sessionFrom?: { @@ -166,7 +174,7 @@ export interface TdButtonProps { required?: boolean; }; /** - * 会话内消息卡片标题,open-type=contact时有效 + * 会话内消息卡片标题,open-type="contact"时有效 * @default 当前标题 */ sendMessageTitle?: { @@ -175,7 +183,7 @@ export interface TdButtonProps { required?: boolean; }; /** - * 会话内消息卡片点击跳转小程序路径,open-type=contact时有效 + * 会话内消息卡片点击跳转小程序路径,open-type="contact"时有效 * @default 当前分享路径 */ sendMessagePath?: { @@ -184,7 +192,7 @@ export interface TdButtonProps { required?: boolean; }; /** - * 会话内消息卡片图片,open-type=contact时有效 + * 会话内消息卡片图片,open-type="contact"时有效 * @default 截图 */ sendMessageImg?: { @@ -202,7 +210,7 @@ export interface TdButtonProps { required?: boolean; }; /** - * 是否显示会话内消息卡片,设置此参数为 true,用户进入客服会话会在右下角显示可能要发送的小程序提示,用户点击后可以快速发送小程序消息,open-type=contact时有效 + * 是否显示会话内消息卡片,设置此参数为 true,用户进入客服会话会在右下角显示"可能要发送的小程序"提示,用户点击后可以快速发送小程序消息,open-type="contact"时有效 * @default false */ showMessageCard?: { @@ -210,4 +218,4 @@ export interface TdButtonProps { value?: boolean; required?: boolean; }; -}; +}