Skip to content

Commit 90b13b4

Browse files
novlan1tdesign-bot
andauthored
fix(button): fix button icon size (#4506)
* fix(button): fix button icon size * feat(action-sheet): support preventScrollThrough * feat(image-viewer): support maxzoom * feat(chat-marddown): support scroll horizontally * feat(form): add contentAlign * chore: stash changelog [ci skip] --------- Co-authored-by: tdesign-bot <tdesign@tencent.com>
1 parent 1dcb896 commit 90b13b4

152 files changed

Lines changed: 390 additions & 169 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

packages/components/form-item/form-item.ts

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,20 @@ export default class FormItem extends SuperComponent {
4848
form: {},
4949
colon: false,
5050
innerShowErrorMessage: true,
51+
innerContentAlign: '',
52+
contentStyle: '',
53+
};
54+
55+
observers = {
56+
contentAlign(val: string) {
57+
// 自身传了 contentAlign 时,优先使用自身值
58+
if (val) {
59+
this.setData({
60+
innerContentAlign: val,
61+
contentStyle: `text-align: ${val}`,
62+
});
63+
}
64+
},
5165
};
5266

5367
relations: RelationsOptions = {
@@ -61,11 +75,16 @@ export default class FormItem extends SuperComponent {
6175
const formRules = target.data.rules?.[this.properties.name];
6276
const isRequired = formRules?.some((rule) => rule.required);
6377

78+
const { contentAlign } = this.properties;
79+
const innerContentAlign = contentAlign || target.data.contentAlign || '';
80+
6481
this.setData({
6582
formRules: formRules || [],
6683
colon: target.data.colon,
6784
innerLabelAlign: labelAlign || target.data.labelAlign,
6885
innerLabelWidth: normalizeLabelWidth(labelWidth || target.data.labelWidth),
86+
innerContentAlign,
87+
contentStyle: innerContentAlign ? `text-align: ${innerContentAlign}` : '',
6988
innerRequiredMark: requiredMark || target.data.requiredMark || globalConfig.requiredMark || isRequired,
7089
innerShowErrorMessage:
7190
typeof showErrorMessage === 'boolean' ? showErrorMessage : target.properties.showErrorMessage,

packages/components/form-item/form-item.wxml

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,21 +17,24 @@
1717

1818
<!-- 内容区域 -->
1919
<view class="{{formClass}}__controls {{errorClasses}} {{prefix}}-class-controls">
20-
<view class="{{formClass}}__controls-content {{formClass}}__controls--{{contentAlign}}" style="{{contentStyle}}">
20+
<view
21+
class="{{formClass}}__controls-content {{formClass}}__controls--{{innerContentAlign}}"
22+
style="{{contentStyle}}"
23+
>
2124
<slot />
2225
</view>
2326
<!-- 帮助信息 -->
2427
<view
2528
wx:if="{{help}}"
26-
class="{{formItemClass}}-help {{formClass}}__controls--{{contentAlign}} {{prefix}}-class-help"
29+
class="{{formItemClass}}-help {{formClass}}__controls--{{innerContentAlign}} {{prefix}}-class-help"
2730
>
2831
{{ help }}
2932
</view>
3033

3134
<!-- 校验提示信息 -->
3235
<view
3336
wx:if="{{(errorList.length > 0 && innerShowErrorMessage) || successList.length > 0}}"
34-
class="{{formItemClass}}-extra {{formClass}}__controls--{{contentAlign}} {{prefix}}-class-extra"
37+
class="{{formItemClass}}-extra {{formClass}}__controls--{{innerContentAlign}} {{prefix}}-class-extra"
3538
>
3639
{{errorList.length > 0 && innerShowErrorMessage ? errorList[0].message : successList[0].message}}
3740
</view>

packages/components/form-item/props.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,10 @@ const props: TdFormItemProps = {
1111
type: Boolean,
1212
value: false,
1313
},
14+
/** 表单内容对齐方式:左对齐、右对齐,优先级高于 Form.contentAlign */
15+
contentAlign: {
16+
type: String,
17+
},
1418
/** 表单项说明内容 */
1519
help: {
1620
type: String,

packages/components/form-item/type.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,13 @@ export interface TdFormItemProps {
1515
type: BooleanConstructor;
1616
value?: boolean;
1717
};
18+
/**
19+
* 表单内容对齐方式:左对齐、右对齐,优先级高于 Form.contentAlign
20+
*/
21+
contentAlign?: {
22+
type: StringConstructor;
23+
value?: 'left' | 'right';
24+
};
1825
/**
1926
* 表单项说明内容
2027
*/

packages/components/form/README.en-US.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ name | type | default | description | required
99
style | Object | - | CSS(Cascading Style Sheets) | N
1010
custom-style | Object | - | CSS(Cascading Style Sheets),used to set style on virtual component | N
1111
colon | Boolean | false | \- | N
12+
content-align | String | left | options: left/right | N
1213
data | Object | {} | Typescript: `FormData` | N
1314
error-message | Object | - | Typescript: `FormErrorMessage` | N
1415
label-align | String | right | options: left/right/top | N
@@ -26,7 +27,7 @@ submit-with-warning-message | Boolean | false | \- | N
2627
name | params | description
2728
-- | -- | --
2829
reset | `(detail: { e?: FormResetEvent })` | [see more ts definition](https://github.com/Tencent/tdesign-miniprogram/blob/develop/packages/components/common/common.ts)
29-
submit | `(context: 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/>
30+
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/>
3031
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/>
3132

3233
### FormInstanceFunctions 组件实例方法
@@ -47,6 +48,7 @@ name | type | default | description | required
4748
style | Object | - | CSS(Cascading Style Sheets) | N
4849
custom-style | Object | - | CSS(Cascading Style Sheets),used to set style on virtual component | N
4950
arrow | Boolean | false | \- | N
51+
content-align | String | - | options: left/right | N
5052
help | String | - | \- | N
5153
label | String | '' | \- | N
5254
label-align | String | - | options: left/right/top | N

packages/components/form/README.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@ toc: false
5252
style | Object | - | 样式 | N
5353
custom-style | Object | - | 样式,一般用于开启虚拟化组件节点场景 | N
5454
colon | Boolean | false | 是否在表单标签字段右侧显示冒号 | N
55+
content-align | String | left | 表单内容对齐方式:左对齐、右对齐。可选项:left/right | N
5556
data | Object | {} | 表单数据。TS 类型:`FormData` | N
5657
error-message | Object | - | 表单错误信息配置,示例:`{ idcard: '请输入正确的身份证号码', max: '字符长度不能超过 ${max}' }`。TS 类型:`FormErrorMessage` | N
5758
label-align | String | right | 表单字段标签对齐方式:左对齐、右对齐、顶部对齐。可选项:left/right/top | N
@@ -69,7 +70,7 @@ submit-with-warning-message | Boolean | false | 【讨论中】当校验结果
6970
名称 | 参数 | 描述
7071
-- | -- | --
7172
reset | `(detail: { e?: FormResetEvent })` | 表单重置时触发。[通用类型定义](https://github.com/Tencent/tdesign-miniprogram/blob/develop/packages/components/common/common.ts)
72-
submit | `(context: SubmitContext<FormData>)` | 表单提交时触发。其中 `context.validateResult` 表示校验结果,`context.firstError` 表示校验不通过的第一个规则提醒。`context.validateResult` 值为 `true` 表示校验通过;如果校验不通过,`context.validateResult` 值为校验结果列表。<br />【注意】⚠️ 默认情况,输入框按下 Enter 键会自动触发提交事件,如果希望禁用这个默认行为,可以给输入框添加 enter 事件,并在事件中设置 `e.preventDefault()`。[详细类型定义](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/>
73+
submit | `(detail: SubmitContext<FormData>)` | 表单提交时触发。其中 `context.validateResult` 表示校验结果,`context.firstError` 表示校验不通过的第一个规则提醒。`context.validateResult` 值为 `true` 表示校验通过;如果校验不通过,`context.validateResult` 值为校验结果列表。<br />【注意】⚠️ 默认情况,输入框按下 Enter 键会自动触发提交事件,如果希望禁用这个默认行为,可以给输入框添加 enter 事件,并在事件中设置 `e.preventDefault()`。[详细类型定义](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/>
7374
validate | `(result: ValidateResultContext<FormData>)` | 校验结束后触发,result 值为 true 表示校验通过;如果校验不通过,result 值为校验结果列表。[详细类型定义](https://github.com/Tencent/tdesign-miniprogram/blob/develop/packages/components/form/type.ts)。<br/>`type ValidateResultContext<T extends Data> = Omit<SubmitContext<T>, 'e'>`<br/>
7475

7576
### FormInstanceFunctions 组件实例方法
@@ -90,6 +91,7 @@ validate | `(params?: FormValidateParams)` | `Promise<FormValidateResult<FormDat
9091
style | Object | - | 样式 | N
9192
custom-style | Object | - | 样式,一般用于开启虚拟化组件节点场景 | N
9293
arrow | Boolean | false | 是否显示右侧箭头 | N
94+
content-align | String | - | 表单内容对齐方式:左对齐、右对齐,优先级高于 Form.contentAlign。可选项:left/right | N
9395
help | String | - | 表单项说明内容 | N
9496
label | String | '' | 字段标签名称 | N
9597
label-align | String | - | 表单字段标签对齐方式:左对齐、右对齐、顶部对齐。默认使用 Form 的对齐方式,优先级高于 Form.labelAlign。可选项:left/right/top | N

packages/components/form/props.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,11 @@ const props: TdFormProps = {
1111
type: Boolean,
1212
value: false,
1313
},
14+
/** 表单内容对齐方式:左对齐、右对齐 */
15+
contentAlign: {
16+
type: String,
17+
value: 'left',
18+
},
1419
/** 表单数据 */
1520
data: {
1621
type: Object,

packages/components/form/type.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,14 @@ export interface TdFormProps<FormData extends Data = Data> {
1616
type: BooleanConstructor;
1717
value?: boolean;
1818
};
19+
/**
20+
* 表单内容对齐方式:左对齐、右对齐
21+
* @default left
22+
*/
23+
contentAlign?: {
24+
type: StringConstructor;
25+
value?: 'left' | 'right';
26+
};
1927
/**
2028
* 表单数据
2129
* @default {}

packages/components/upload/README.en-US.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,8 @@ Name | Default Value | Description
5858
--td-upload-add-disabled-bg-color | @bg-color-component-disabled | -
5959
--td-upload-add-icon-disabled-color | @text-color-disabled | -
6060
--td-upload-add-icon-size | 56rpx | -
61-
--td-upload-disabled-mask | rgba(0, 0, 0, 0.6) | -
61+
--td-upload-background | @upload-add-bg-color | -
62+
--td-upload-disabled-mask | @mask-disabled | -
6263
--td-upload-drag-transition-duration | --td-upload-drag-transition-duration | -
6364
--td-upload-drag-transition-timing-function | --td-upload-drag-transition-timing-function | -
6465
--td-upload-drag-z-index | 999 | -

packages/components/upload/README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,8 @@ add-content | 自定义 `add-content` 显示内容
121121
--td-upload-add-disabled-bg-color | @bg-color-component-disabled | -
122122
--td-upload-add-icon-disabled-color | @text-color-disabled | -
123123
--td-upload-add-icon-size | 56rpx | -
124-
--td-upload-disabled-mask | rgba(0, 0, 0, 0.6) | -
124+
--td-upload-background | @upload-add-bg-color | -
125+
--td-upload-disabled-mask | @mask-disabled | -
125126
--td-upload-drag-transition-duration | --td-upload-drag-transition-duration | -
126127
--td-upload-drag-transition-timing-function | --td-upload-drag-transition-timing-function | -
127128
--td-upload-drag-z-index | 999 | -

0 commit comments

Comments
 (0)