Skip to content
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
4 changes: 4 additions & 0 deletions packages/components/form-item/form-item.less
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,10 @@
justify-content: flex-start;
}

&--center {
justify-content: center;
}

&--right {
justify-content: flex-end;
}
Expand Down
4 changes: 2 additions & 2 deletions packages/components/form-item/props.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,14 @@
* 该文件为脚本自动生成文件,请勿随意修改。如需修改请联系 PMC
* */

import { TdFormItemProps } from './type';
import type { TdFormItemProps } from './type';
const props: TdFormItemProps = {
/** 是否显示右侧箭头 */
arrow: {
type: Boolean,
value: false,
},
/** 表单内容对齐方式:左对齐、右对齐,优先级高于 Form.contentAlign */
/** 表单内容对齐方式:左对齐、居中对齐及右对齐,优先级高于 Form.contentAlign */
contentAlign: {
type: String,
},
Expand Down
6 changes: 3 additions & 3 deletions packages/components/form-item/type.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
* 该文件为脚本自动生成文件,请勿随意修改。如需修改请联系 PMC
* */

import { FormRule } from '../form/index';
import type { FormRule } from '../form/index';

export interface TdFormItemProps {
/**
Expand All @@ -16,11 +16,11 @@ export interface TdFormItemProps {
value?: boolean;
};
/**
* 表单内容对齐方式:左对齐、右对齐,优先级高于 Form.contentAlign
* 表单内容对齐方式:左对齐、居中对齐及右对齐,优先级高于 Form.contentAlign
*/
contentAlign?: {
type: StringConstructor;
value?: 'left' | 'right';
value?: 'left' | 'center' | 'right';
};
/**
* 表单项说明内容
Expand Down
28 changes: 14 additions & 14 deletions packages/components/form/README.en-US.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,15 @@ 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
colon | Boolean | false | \- | N
content-align | String | left | options: left/right | N
content-align | String | left | options: left/center/right | N
data | Object | {} | Typescript: `FormData` | N
error-message | Object | - | Typescript: `FormErrorMessage` | N
label-align | String | right | options: left/right/top | N
label-width | String / Number | '81px' | \- | N
required-mark | Boolean | true | \- | N
required-mark-position | String | left | Display position of required symbols。options: left/right | N
required-mark-position | String | left | Display position of required symbols. options: left/right | N
reset-type | String | empty | options: empty/initial | N
rules | Object | - | Typescript: `FormRules<FormData>` `type FormRules<T extends Data = any> = { [field in keyof T]?: Array<FormRule> }`。[see more ts definition](https://github.com/Tencent/tdesign-miniprogram/blob/develop/packages/components/form/type.ts) | N
rules | Object | - | Typescript: `FormRules<FormData>` `type FormRules<T extends Data = any> = { [field in keyof T]?: Array<FormRule> }`. [see more ts definition](https://github.com/Tencent/tdesign-miniprogram/blob/develop/packages/components/form/type.ts) | N
scroll-to-first-error | String | - | options: ''/smooth/auto | N
show-error-message | Boolean | true | \- | N
submit-with-warning-message | Boolean | false | \- | N
Expand All @@ -27,18 +27,18 @@ submit-with-warning-message | Boolean | false | \- | N
name | params | description
-- | -- | --
reset | `(detail: { e?: FormResetEvent })` | [see more ts definition](https://github.com/Tencent/tdesign-miniprogram/blob/develop/packages/components/common/common.ts)
submit | `(detail: SubmitContext<FormData>)` | [see more ts definition](https://github.com/Tencent/tdesign-miniprogram/blob/develop/packages/components/form/type.ts)。<br/>`interface SubmitContext<T extends Data = Data> { e?: FormSubmitEvent; validateResult: FormValidateResult<T>; firstError?: string; fields?: any }`<br/><br/>`type FormValidateResult<T> = boolean \| ValidateResultObj<T>`<br/><br/>`type ValidateResultObj<T> = { [key in keyof T]: boolean \| ValidateResultList }`<br/><br/>`type ValidateResultList = Array<AllValidateResult>`<br/><br/>`type AllValidateResult = CustomValidateObj \| ValidateResultType`<br/><br/>`interface ValidateResultType extends FormRule { result: boolean }`<br/><br/>`type ValidateResult<T> = { [key in keyof T]: boolean \| ErrorList }`<br/><br/>`type ErrorList = Array<FormRule>`<br/>
validate | `(result: ValidateResultContext<FormData>)` | [see more ts definition](https://github.com/Tencent/tdesign-miniprogram/blob/develop/packages/components/form/type.ts)。<br/>`type ValidateResultContext<T extends Data> = Omit<SubmitContext<T>, 'e'>`<br/>
submit | `(detail: SubmitContext<FormData>)` | [see more ts definition](https://github.com/Tencent/tdesign-miniprogram/blob/develop/packages/components/form/type.ts). <br/>`interface SubmitContext<T extends Data = Data> { e?: FormSubmitEvent; validateResult: FormValidateResult<T>; firstError?: string; fields?: any }`<br/><br/>`type FormValidateResult<T> = boolean \| ValidateResultObj<T>`<br/><br/>`type ValidateResultObj<T> = { [key in keyof T]: boolean \| ValidateResultList }`<br/><br/>`type ValidateResultList = Array<AllValidateResult>`<br/><br/>`type AllValidateResult = CustomValidateObj \| ValidateResultType`<br/><br/>`interface ValidateResultType extends FormRule { result: boolean }`<br/><br/>`type ValidateResult<T> = { [key in keyof T]: boolean \| ErrorList }`<br/><br/>`type ErrorList = Array<FormRule>`<br/>
validate | `(result: ValidateResultContext<FormData>)` | [see more ts definition](https://github.com/Tencent/tdesign-miniprogram/blob/develop/packages/components/form/type.ts). <br/>`type ValidateResultContext<T extends Data> = Omit<SubmitContext<T>, 'e'>`<br/>

### FormInstanceFunctions 组件实例方法

name | params | return | description
-- | -- | -- | --
clear-validate | `(fields?: Array<keyof FormData>)` | \- | required
reset | `(params?: FormResetParams<FormData>)` | \- | required。[see more ts definition](https://github.com/Tencent/tdesign-miniprogram/blob/develop/packages/components/form/type.ts)。<br/>`interface FormResetParams<FormData> { type?: 'initial' \| 'empty'; fields?: Array<keyof FormData> }`<br/>
set-validate-message | `(message: FormValidateMessage<FormData>)` | \- | required。[see more ts definition](https://github.com/Tencent/tdesign-miniprogram/blob/develop/packages/components/form/type.ts)。<br/>`type FormValidateMessage<FormData> = { [field in keyof FormData]: FormItemValidateMessage[] }`<br/><br/>`interface FormItemValidateMessage { type: 'warning' \| 'error'; message: string }`<br/>
reset | `(params?: FormResetParams<FormData>)` | \- | required. [see more ts definition](https://github.com/Tencent/tdesign-miniprogram/blob/develop/packages/components/form/type.ts). <br/>`interface FormResetParams<FormData> { type?: 'initial' \| 'empty'; fields?: Array<keyof FormData> }`<br/>
set-validate-message | `(message: FormValidateMessage<FormData>)` | \- | required. [see more ts definition](https://github.com/Tencent/tdesign-miniprogram/blob/develop/packages/components/form/type.ts). <br/>`type FormValidateMessage<FormData> = { [field in keyof FormData]: FormItemValidateMessage[] }`<br/><br/>`interface FormItemValidateMessage { type: 'warning' \| 'error'; message: string }`<br/>
submit | `(params?: { showErrorMessage?: boolean })` | \- | required
validate | `(params?: FormValidateParams)` | `Promise<FormValidateResult<FormData>> ` | required。[see more ts definition](https://github.com/Tencent/tdesign-miniprogram/blob/develop/packages/components/form/type.ts)。<br/>`interface FormValidateParams { fields?: Array<string>; showErrorMessage?: boolean; trigger?: ValidateTriggerType }`<br/><br/>`type ValidateTriggerType = 'blur' \| 'change' \| 'submit' \| 'all'`<br/><br/>`type FormValidateResult<T> = boolean \| ValidateResultObj<T>`<br/><br/>`type ValidateResultObj<T> = { [key in keyof T]: boolean \| ValidateResultList }`<br/><br/>`type ValidateResultList = Array<AllValidateResult>`<br/><br/>`type AllValidateResult = CustomValidateObj \| ValidateResultType`<br/><br/>`interface ValidateResultType extends FormRule { result: boolean }`<br/>
validate | `(params?: FormValidateParams)` | `Promise<FormValidateResult<FormData>> ` | required. [see more ts definition](https://github.com/Tencent/tdesign-miniprogram/blob/develop/packages/components/form/type.ts). <br/>`interface FormValidateParams { fields?: Array<string>; showErrorMessage?: boolean; trigger?: ValidateTriggerType }`<br/><br/>`type ValidateTriggerType = 'blur' \| 'change' \| 'submit' \| 'all'`<br/><br/>`type FormValidateResult<T> = boolean \| ValidateResultObj<T>`<br/><br/>`type ValidateResultObj<T> = { [key in keyof T]: boolean \| ValidateResultList }`<br/><br/>`type ValidateResultList = Array<AllValidateResult>`<br/><br/>`type AllValidateResult = CustomValidateObj \| ValidateResultType`<br/><br/>`interface ValidateResultType extends FormRule { result: boolean }`<br/>


### FormItem Props
Expand All @@ -48,14 +48,14 @@ 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
arrow | Boolean | false | \- | N
content-align | String | - | options: left/right | N
content-align | String | - | options: left/center/right | N
help | String | - | \- | N
label | String | '' | \- | N
label-align | String | - | options: left/right/top | N
label-width | String / Number | - | \- | N
name | String | - | \- | N
required-mark | Boolean | undefined | \- | N
rules | Array | - | Typescript: `Array<FormRule> `,[Form API Documents](./form?tab=api)。[see more ts definition](https://github.com/Tencent/tdesign-miniprogram/blob/develop/packages/components/form-item/type.ts) | N
rules | Array | - | Typescript: `Array<FormRule> `,[Form API Documents](./form?tab=api). [see more ts definition](https://github.com/Tencent/tdesign-miniprogram/blob/develop/packages/components/form-item/type.ts) | N
show-error-message | Boolean | undefined | \- | N

### FormItem Slots
Expand All @@ -70,8 +70,8 @@ label | \-
name | type | default | description | required
-- | -- | -- | -- | --
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/blob/develop/packages/components/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/blob/develop/packages/components/form/type.ts) | 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/blob/develop/packages/components/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/blob/develop/packages/components/form/type.ts) | N
enum | Array | - | Typescript: `Array<string>` | N
idcard | Boolean | - | \- | N
len | Number / Boolean | - | \- | N
Expand All @@ -84,8 +84,8 @@ required | Boolean | - | \- | N
telnumber | Boolean | - | \- | N
trigger | String | change | Typescript: `ValidateTriggerType` | N
type | String | error | options: error/warning | N
url | Boolean / Object | - | Typescript: `boolean \| IsURLOptions` `import { IsURLOptions } from 'validator/es/lib/isURL'`。[see more ts definition](https://github.com/Tencent/tdesign-miniprogram/blob/develop/packages/components/form/type.ts) | N
validator | Function | - | Typescript: `CustomValidator` `type CustomValidator = (val: ValueType, context?: { formData: Data , name: string }) => CustomValidateResolveType \| Promise<CustomValidateResolveType>` `type CustomValidateResolveType = boolean \| CustomValidateObj` `interface CustomValidateObj { result: boolean; message: string; type?: 'error' \| 'warning' \| 'success' }` `type ValueType = any`。[see more ts definition](https://github.com/Tencent/tdesign-miniprogram/blob/develop/packages/components/form/type.ts) | N
url | Boolean / Object | - | Typescript: `boolean \| IsURLOptions` `import { IsURLOptions } from 'validator/es/lib/isURL'`. [see more ts definition](https://github.com/Tencent/tdesign-miniprogram/blob/develop/packages/components/form/type.ts) | N
validator | Function | - | Typescript: `CustomValidator` `type CustomValidator = (val: ValueType, context?: { formData: Data , name: string }) => CustomValidateResolveType \| Promise<CustomValidateResolveType>` `type CustomValidateResolveType = boolean \| CustomValidateObj` `interface CustomValidateObj { result: boolean; message: string; type?: 'error' \| 'warning' \| 'success' }` `type ValueType = any`. [see more ts definition](https://github.com/Tencent/tdesign-miniprogram/blob/develop/packages/components/form/type.ts) | N
whitespace | Boolean | - | \- | N

### FormErrorMessage
Expand Down
40 changes: 36 additions & 4 deletions packages/components/form/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,41 @@ toc: false

#### 基础表单

{{ horizontal }}
{{ base }}

{{ vertical }}

### 02 组件状态

#### 提示

{{ help }}

#### 校验规则

{{ rules }}


### 03 组件样式

#### 标签对齐样式

{{ label-align }}

#### 标签带冒号

{{ colon }}

#### 标签必填位置

{{ required-mark }}

#### 标签宽度

{{ label-width }}

#### 标签内容对齐样式

{{ content-align }}


## API
Expand All @@ -49,7 +81,7 @@ toc: false
style | Object | - | 样式 | N
custom-style | Object | - | 样式,一般用于开启虚拟化组件节点场景 | N
colon | Boolean | false | 是否在表单标签字段右侧显示冒号 | N
content-align | String | left | 表单内容对齐方式:左对齐、右对齐。可选项:left/right | N
content-align | String | left | 表单内容对齐方式:左对齐、居中对齐及右对齐。可选项:left/center/right | N
data | Object | {} | 表单数据。TS 类型:`FormData` | N
error-message | Object | - | 表单错误信息配置,示例:`{ idcard: '请输入正确的身份证号码', max: '字符长度不能超过 ${max}' }`。TS 类型:`FormErrorMessage` | N
label-align | String | right | 表单字段标签对齐方式:左对齐、右对齐、顶部对齐。可选项:left/right/top | N
Expand Down Expand Up @@ -88,7 +120,7 @@ validate | `(params?: FormValidateParams)` | `Promise<FormValidateResult<FormDat
style | Object | - | 样式 | N
custom-style | Object | - | 样式,一般用于开启虚拟化组件节点场景 | N
arrow | Boolean | false | 是否显示右侧箭头 | N
content-align | String | - | 表单内容对齐方式:左对齐、右对齐,优先级高于 Form.contentAlign。可选项:left/right | N
content-align | String | - | 表单内容对齐方式:左对齐、居中对齐及右对齐,优先级高于 Form.contentAlign。可选项:left/center/right | N
help | String | - | 表单项说明内容 | N
label | String | '' | 字段标签名称 | N
label-align | String | - | 表单字段标签对齐方式:左对齐、右对齐、顶部对齐。默认使用 Form 的对齐方式,优先级高于 Form.labelAlign。可选项:left/right/top | N
Expand Down
Loading
Loading