Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(FormErrorMessage): add whitespace #397

Merged
merged 1 commit into from
Aug 28, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file modified db/TDesign.db
Binary file not shown.
13 changes: 2 additions & 11 deletions packages/products/tdesign-miniprogram/src/form/README.en-US.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,8 @@ custom-style | Object | - | CSS(Cascading Style Sheets),used to set style on v
colon | Boolean | false | \- | N
disabled | Boolean | undefined | \- | N
error-message | Object | - | Typescript:`FormErrorMessage` | N
form-controlled-components | Array | - | Typescript:`Array<string>` | N
label-align | String | right | options: left/right/top | N
label-width | String / Number | '100px' | \- | N
layout | String | vertical | options: vertical/inline | N
label-width | String / Number | '81px' | \- | N
prevent-submit-default | Boolean | true | \- | N
required-mark | Boolean | undefined | \- | N
reset-type | String | empty | options: empty/initial | N
Expand Down Expand Up @@ -53,17 +51,11 @@ name | String | - | \- | N
required-mark | Boolean | undefined | \- | N
rules | Array | - | Typescript:`Array<FormRule>` | N
show-error-message | Boolean | undefined | \- | N
status | String | - | Typescript:`'error' \| 'warning' \| 'success' \| 'validating'` | N
status-icon | Boolean / Slot | undefined | [see more ts definition](https://github.com/Tencent/tdesign-miniprogram/blob/develop/src/common/common.ts) | N
success-border | Boolean | false | \- | N
tips | String / Slot | - | [see more ts definition](https://github.com/Tencent/tdesign-miniprogram/blob/develop/src/common/common.ts) | N

### FormRule

name | type | default | description | required
-- | -- | -- | -- | --
style | Object | - | CSS(Cascading Style Sheets) | N
custom-style | Object | - | CSS(Cascading Style Sheets),used to set style on virtual component | N
boolean | Boolean | - | \- | N
date | Boolean / Object | - | Typescript:`boolean \| IsDateOptions` `interface IsDateOptions { format: string; strictMode: boolean; delimiters: string[] }`。[see more ts definition](https://github.com/Tencent/tdesign-miniprogram/tree/develop/src/form/type.ts) | N
email | Boolean / Object | - | Typescript:`boolean \| IsEmailOptions` `import { IsEmailOptions } from 'validator/es/lib/isEmail'`。[see more ts definition](https://github.com/Tencent/tdesign-miniprogram/tree/develop/src/form/type.ts) | N
Expand All @@ -87,8 +79,6 @@ whitespace | Boolean | - | \- | N

name | type | default | description | required
-- | -- | -- | -- | --
style | Object | - | CSS(Cascading Style Sheets) | N
custom-style | Object | - | CSS(Cascading Style Sheets),used to set style on virtual component | N
boolean | String | - | \- | N
date | String | - | \- | N
enum | String | - | \- | N
Expand All @@ -102,3 +92,4 @@ required | String | - | \- | N
telnumber | String | - | \- | N
url | String | - | \- | N
validator | String | - | \- | N
whitespace | String | - | \- | N
13 changes: 2 additions & 11 deletions packages/products/tdesign-miniprogram/src/form/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,8 @@ custom-style | Object | - | 样式,一般用于开启虚拟化组件节点场
colon | Boolean | false | 是否在表单标签字段右侧显示冒号 | N
disabled | Boolean | undefined | 是否禁用整个表单 | N
error-message | Object | - | 表单错误信息配置,示例:`{ idcard: '请输入正确的身份证号码', max: '字符长度不能超过 ${max}' }`。TS 类型:`FormErrorMessage` | N
form-controlled-components | Array | - | 允许表单统一控制禁用状态的自定义组件名称列表。默认会有组件库的全部输入类组件:TInput、TInputNumber、TCascader、TSelect、TOption、TSwitch、TCheckbox、TCheckboxGroup、TRadio、TRadioGroup、TTreeSelect、TDatePicker、TTimePicker、TUpload、TTransfer、TSlider。对于自定义组件,组件内部需要包含可以控制表单禁用状态的变量 `formDisabled`。示例:`['CustomUpload', 'CustomInput']`。TS 类型:`Array<string>` | N
label-align | String | right | 表单字段标签对齐方式:左对齐、右对齐、顶部对齐。可选项:left/right/top | N
label-width | String / Number | '100px' | 可以整体设置label标签宽度,默认为100px | N
layout | String | vertical | 表单布局,有两种方式:纵向布局 和 行内布局。可选项:vertical/inline | N
label-width | String / Number | '81px' | 可以整体设置label标签宽度,默认为81px | N
prevent-submit-default | Boolean | true | 是否阻止表单提交默认事件(表单提交默认事件会刷新页面),设置为 `true` 可以避免刷新 | N
required-mark | Boolean | undefined | 是否显示必填符号(*),默认显示 | N
reset-type | String | empty | 重置表单的方式,值为 empty 表示重置表单为空,值为 initial 表示重置表单数据为初始值。可选项:empty/initial | N
Expand Down Expand Up @@ -53,17 +51,11 @@ name | String | - | 表单字段名称 | N
required-mark | Boolean | undefined | 是否显示必填符号(*),优先级高于 Form.requiredMark | N
rules | Array | - | 表单字段校验规则。TS 类型:`Array<FormRule>` | N
show-error-message | Boolean | undefined | 校验不通过时,是否显示错误提示信息,优先级高于 `Form.showErrorMessage` | N
status | String | - | 校验状态,可在需要完全自主控制校验状态时使用。TS 类型:`'error' \| 'warning' \| 'success' \| 'validating'` | N
status-icon | Boolean / Slot | undefined | 校验状态图标,值为 `true` 显示默认图标,默认图标有 成功、失败、警告 等,不同的状态图标不同。`statusIcon` 值为 `false`,不显示图标。`statusIcon` 值类型为渲染函数,则可以自定义右侧状态图标。优先级高级 Form 的 statusIcon。[通用类型定义](https://github.com/Tencent/tdesign-miniprogram/blob/develop/src/common/common.ts) | N
success-border | Boolean | false | 是否显示校验成功的边框,默认不显示 | N
tips | String / Slot | - | 自定义提示内容,样式跟随 `status` 变动,可在需要完全自主控制校验规则时使用。[通用类型定义](https://github.com/Tencent/tdesign-miniprogram/blob/develop/src/common/common.ts) | N

### FormRule

名称 | 类型 | 默认值 | 描述 | 必传
-- | -- | -- | -- | --
style | Object | - | 样式 | N
custom-style | Object | - | 样式,一般用于开启虚拟化组件节点场景 | N
boolean | Boolean | - | 内置校验方法,校验值类型是否为布尔类型,示例:`{ boolean: true, message: '数据类型必须是布尔类型' }` | N
date | Boolean / Object | - | 内置校验方法,校验值是否为日期格式,[参数文档](https://github.com/validatorjs/validator.js),示例:`{ date: { delimiters: '-' }, message: '日期分隔线必须是短横线(-)' }`。TS 类型:`boolean \| IsDateOptions` `interface IsDateOptions { format: string; strictMode: boolean; delimiters: string[] }`。[详细类型定义](https://github.com/Tencent/tdesign-miniprogram/tree/develop/src/form/type.ts) | N
email | Boolean / Object | - | 内置校验方法,校验值是否为邮件格式,[参数文档](https://github.com/validatorjs/validator.js),示例:`{ email: { ignore_max_length: true }, message: '请输入正确的邮箱地址' }`。TS 类型:`boolean \| IsEmailOptions` `import { IsEmailOptions } from 'validator/es/lib/isEmail'`。[详细类型定义](https://github.com/Tencent/tdesign-miniprogram/tree/develop/src/form/type.ts) | N
Expand All @@ -87,8 +79,6 @@ whitespace | Boolean | - | 内置校验方法,校验值是否为空格。示

名称 | 类型 | 默认值 | 描述 | 必传
-- | -- | -- | -- | --
style | Object | - | 样式 | N
custom-style | Object | - | 样式,一般用于开启虚拟化组件节点场景 | N
boolean | String | - | 布尔类型校验不通过时的表单项显示文案,全局配置默认是:`'${name}数据类型必须是布尔类型'` | N
date | String | - | 日期校验规则不通过时的表单项显示文案,全局配置默认是:`'请输入正确的${name}'` | N
enum | String | - | 枚举值校验规则不通过时的表单项显示文案,全局配置默认是:`${name}只能是${validate}等` | N
Expand All @@ -102,3 +92,4 @@ required | String | - | 没有填写必填项时的表单项显示文案,全
telnumber | String | - | 手机号号码校验不通过时的表单项显示文案,全局配置默认是:`'请输入正确的${name}'` | N
url | String | - | 链接校验规则不通过时的表单项显示文案,全局配置默认是:`'请输入正确的${name}'` | N
validator | String | - | 自定义校验规则校验不通过时的表单项显示文案,全局配置默认是:'${name}不符合要求' | N
whitespace | String | - | 值为空格校验不通过时表单项显示文案,全局配置默认是:`'${name}不能为空` | N
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
/* eslint-disable */

/**
* 该文件为脚本自动生成文件,请勿随意修改。如需修改请联系 PMC
* */

import { TdFormItemProps } from './type';
const props: TdFormItemProps = {
/** label 原生属性 */
for: {
type: String,
value: '',
},
/** 表单项说明内容 */
help: {
type: String,
},
/** 表单字段标签对齐方式:左对齐、右对齐、顶部对齐。默认使用 Form 的对齐方式,优先级高于 Form.labelAlign */
labelAlign: {
type: String,
},
/** 可以整体设置标签宽度,优先级高于 Form.labelWidth */
labelWidth: {
type: null,
},
/** 表单字段名称 */
name: {
type: String,
value: '',
},
/** 是否显示必填符号(*),优先级高于 Form.requiredMark */
requiredMark: {
type: null,
value: undefined,
},
/** 表单字段校验规则 */
rules: {
type: Array,
},
/** 校验不通过时,是否显示错误提示信息,优先级高于 `Form.showErrorMessage` */
showErrorMessage: {
type: null,
value: undefined,
},
};

export default props;
73 changes: 73 additions & 0 deletions packages/products/tdesign-miniprogram/src/form/props.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
/* eslint-disable */

/**
* 该文件为脚本自动生成文件,请勿随意修改。如需修改请联系 PMC
* */

import { TdFormProps } from './type';
const props: TdFormProps = {
/** 是否在表单标签字段右侧显示冒号 */
colon: {
type: Boolean,
value: false,
},
/** 是否禁用整个表单 */
disabled: {
type: null,
value: undefined,
},
/** 表单错误信息配置,示例:`{ idcard: '请输入正确的身份证号码', max: '字符长度不能超过 ${max}' }` */
errorMessage: {
type: Object,
},
/** 表单字段标签对齐方式:左对齐、右对齐、顶部对齐 */
labelAlign: {
type: String,
value: 'right',
},
/** 可以整体设置label标签宽度,默认为81px */
labelWidth: {
type: null,
value: '81px',
},
/** 是否阻止表单提交默认事件(表单提交默认事件会刷新页面),设置为 `true` 可以避免刷新 */
preventSubmitDefault: {
type: Boolean,
value: true,
},
/** 是否显示必填符号(*),默认显示 */
requiredMark: {
type: null,
value: undefined,
},
/** 重置表单的方式,值为 empty 表示重置表单为空,值为 initial 表示重置表单数据为初始值 */
resetType: {
type: String,
value: 'empty',
},
/** 表单字段校验规则 */
rules: {
type: Object,
},
/** 表单校验不通过时,是否自动滚动到第一个校验不通过的字段,平滑滚动或是瞬间直达。值为空则表示不滚动 */
scrollToFirstError: {
type: String,
},
/** 校验不通过时,是否显示错误提示信息,统一控制全部表单项。如果希望控制单个表单项,请给 FormItem 设置该属性 */
showErrorMessage: {
type: Boolean,
value: true,
},
/** 校验状态图标,值为 `true` 显示默认图标,默认图标有 成功、失败、警告 等,不同的状态图标不同。`statusIcon` 值为 `false`,不显示图标。`statusIcon` 值类型为渲染函数,则可以自定义右侧状态图标 */
statusIcon: {
type: null,
value: undefined,
},
/** 【讨论中】当校验结果只有告警信息时,是否触发 `submit` 提交事件 */
submitWithWarningMessage: {
type: Boolean,
value: false,
},
};

export default props;
Loading
Loading