Skip to content

Commit

Permalink
fix(Textarea):the maxlength props only supports number type
Browse files Browse the repository at this point in the history
  • Loading branch information
anlyyao committed Sep 20, 2024
1 parent aca8726 commit 9eaaf25
Show file tree
Hide file tree
Showing 12 changed files with 179 additions and 8 deletions.
Binary file modified db/TDesign.db
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ enter | `(value: TextareaValue)` | \-
focus | `(value: TextareaValue)` | \-
keyboardheightchange | `(height: number, duration: number)` | \-
line-change | `(value: TextareaValue)` | \-

### Textarea External Classes

className | Description
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ enter | `(value: TextareaValue)` | 点击完成时触发
focus | `(value: TextareaValue)` | 获得焦点时触发
keyboardheightchange | `(height: number, duration: number)` | 键盘高度发生变化的时候触发此事件
line-change | `(value: TextareaValue)` | 行高发生变化时触发

### Textarea External Classes

类名 | 描述
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
/**
* 该文件为脚本自动生成文件,请勿随意修改。如需修改请联系 PMC
* */

import { TdTextareaProps } from './type';

export const textareaDefaultProps: TdTextareaProps = {
allowInputOverMax: false,
autofocus: false,
autosize: false,
bordered: false,
disabled: undefined,
indicator: false,
layout: 'horizontal',
placeholder: undefined,
readonly: false,
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
:: BASE_DOC ::

## API


### Textarea Props

name | type | default | description | required
-- | -- | -- | -- | --
className | String | - | className of component | N
style | Object | - | CSS(Cascading Style Sheets),Typescript:`React.CSSProperties` | N
allowInputOverMax | Boolean | false | \- | N
autofocus | Boolean | false | \- | N
autosize | Boolean / Object | false | Typescript:`boolean \| { minRows?: number; maxRows?: number }` | N
bordered | Boolean | false | \- | N
disabled | Boolean | undefined | \- | N
indicator | Boolean | false | \- | N
label | TNode | - | Typescript:`string \| TNode`[see more ts definition](https://github.com/Tencent/tdesign-mobile-react/blob/develop/src/common.ts) | N
layout | String | horizontal | options: vertical/horizontal | N
maxcharacter | Number | - | \- | N
maxlength | Number | - | \- | N
name | String | - | \- | N
placeholder | String | undefined | \- | N
readonly | Boolean | false | \- | N
value | String / Number | - | Typescript:`TextareaValue` `type TextareaValue = string \| number`[see more ts definition](https://github.com/Tencent/tdesign-mobile-react/tree/develop/src/textarea/type.ts) | N
defaultValue | String / Number | - | uncontrolled property。Typescript:`TextareaValue` `type TextareaValue = string \| number`[see more ts definition](https://github.com/Tencent/tdesign-mobile-react/tree/develop/src/textarea/type.ts) | N
onBlur | Function | | Typescript:`(value: TextareaValue, context: { e: FocusEvent }) => void`<br/> | N
onChange | Function | | Typescript:`(value: TextareaValue, context?: { e?: InputEvent }) => void`<br/> | N
onFocus | Function | | Typescript:`(value: TextareaValue, context : { e: FocusEvent }) => void`<br/> | N
29 changes: 29 additions & 0 deletions packages/products/tdesign-mobile-react/src/textarea/textarea.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
:: BASE_DOC ::

## API


### Textarea Props

名称 | 类型 | 默认值 | 描述 | 必传
-- | -- | -- | -- | --
className | String | - | 类名 | N
style | Object | - | 样式,TS 类型:`React.CSSProperties` | N
allowInputOverMax | Boolean | false | 超出maxlength或maxcharacter之后是否还允许输入 | N
autofocus | Boolean | false | 自动聚焦,拉起键盘 | N
autosize | Boolean / Object | false | 高度自动撑开。 autosize = true 表示组件高度自动撑开,同时,依旧允许手动拖高度。如果设置了 autosize.maxRows 或者 autosize.minRows 则不允许手动调整高度。TS 类型:`boolean \| { minRows?: number; maxRows?: number }` | N
bordered | Boolean | false | 是否显示外边框 | N
disabled | Boolean | undefined | 是否禁用文本框 | N
indicator | Boolean | false | 显示文本计数器,如 0/140。当 `maxlength < 0 && maxcharacter < 0` 成立时, indicator无效 | N
label | TNode | - | 左侧文本。TS 类型:`string \| TNode`[通用类型定义](https://github.com/Tencent/tdesign-mobile-react/blob/develop/src/common.ts) | N
layout | String | horizontal | 标题输入框布局方式。可选项:vertical/horizontal | N
maxcharacter | Number | - | 用户最多可以输入的字符个数,一个中文汉字表示两个字符长度 | N
maxlength | Number | - | 用户最多可以输入的字符个数 | N
name | String | - | 名称,HTML 元素原生属性 | N
placeholder | String | undefined | 占位符 | N
readonly | Boolean | false | 只读状态 | N
value | String / Number | - | 文本框值。TS 类型:`TextareaValue` `type TextareaValue = string \| number`[详细类型定义](https://github.com/Tencent/tdesign-mobile-react/tree/develop/src/textarea/type.ts) | N
defaultValue | String / Number | - | 文本框值。非受控属性。TS 类型:`TextareaValue` `type TextareaValue = string \| number`[详细类型定义](https://github.com/Tencent/tdesign-mobile-react/tree/develop/src/textarea/type.ts) | N
onBlur | Function | | TS 类型:`(value: TextareaValue, context: { e: FocusEvent }) => void`<br/>失去焦点时触发 | N
onChange | Function | | TS 类型:`(value: TextareaValue, context?: { e?: InputEvent }) => void`<br/>输入内容变化时触发 | N
onFocus | Function | | TS 类型:`(value: TextareaValue, context : { e: FocusEvent }) => void`<br/>获得焦点时触发 | N
93 changes: 93 additions & 0 deletions packages/products/tdesign-mobile-react/src/textarea/type.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
/* eslint-disable */

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

import { TNode } from '../common';
import { FocusEvent, FormEvent } from 'react';

export interface TdTextareaProps {
/**
* 超出maxlength或maxcharacter之后是否还允许输入
* @default false
*/
allowInputOverMax?: boolean;
/**
* 自动聚焦,拉起键盘
* @default false
*/
autofocus?: boolean;
/**
* 高度自动撑开。 autosize = true 表示组件高度自动撑开,同时,依旧允许手动拖高度。如果设置了 autosize.maxRows 或者 autosize.minRows 则不允许手动调整高度
* @default false
*/
autosize?: boolean | { minRows?: number; maxRows?: number };
/**
* 是否显示外边框
* @default false
*/
bordered?: boolean;
/**
* 是否禁用文本框
*/
disabled?: boolean;
/**
* 显示文本计数器,如 0/140。当 `maxlength < 0 && maxcharacter < 0` 成立时, indicator无效
* @default false
*/
indicator?: boolean;
/**
* 左侧文本
*/
label?: TNode;
/**
* 标题输入框布局方式
* @default horizontal
*/
layout?: 'vertical' | 'horizontal';
/**
* 用户最多可以输入的字符个数,一个中文汉字表示两个字符长度
*/
maxcharacter?: number;
/**
* 用户最多可以输入的字符个数
*/
maxlength?: number;
/**
* 名称,HTML 元素原生属性
* @default ''
*/
name?: string;
/**
* 占位符
*/
placeholder?: string;
/**
* 只读状态
* @default false
*/
readonly?: boolean;
/**
* 文本框值
*/
value?: TextareaValue;
/**
* 文本框值,非受控属性
*/
defaultValue?: TextareaValue;
/**
* 失去焦点时触发
*/
onBlur?: (value: TextareaValue, context: { e: FocusEvent<HTMLTextAreaElement> }) => void;
/**
* 输入内容变化时触发
*/
onChange?: (value: TextareaValue, context?: { e?: FormEvent<HTMLTextAreaElement> }) => void;
/**
* 获得焦点时触发
*/
onFocus?: (value: TextareaValue, context: { e: FocusEvent<HTMLTextAreaElement> }) => void;
}

export type TextareaValue = string | number;
7 changes: 5 additions & 2 deletions packages/products/tdesign-mobile-vue/src/textarea/props.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,11 @@ export default {
allowInputOverMax: Boolean,
/** 自动聚焦,拉起键盘 */
autofocus: Boolean,
/** 是否自动增高,值为 autosize 时,style.height 不生效 */
autosize: Boolean,
/** 高度自动撑开。 autosize = true 表示组件高度自动撑开,同时,依旧允许手动拖高度。如果设置了 autosize.maxRows 或者 autosize.minRows 则不允许手动调整高度 */
autosize: {
type: [Boolean, Object] as PropType<TdTextareaProps['autosize']>,
default: false,
},
/** 是否显示外边框 */
bordered: Boolean,
/** 是否禁用文本框 */
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ name | type | default | description | required
-- | -- | -- | -- | --
allowInputOverMax | Boolean | false | \- | N
autofocus | Boolean | false | \- | N
autosize | Boolean | false | \- | N
autosize | Boolean / Object | false | Typescript:`boolean \| { minRows?: number; maxRows?: number }` | N
bordered | Boolean | false | \- | N
disabled | Boolean | undefined | \- | N
indicator | Boolean | false | \- | N
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
-- | -- | -- | -- | --
allowInputOverMax | Boolean | false | 超出maxlength或maxcharacter之后是否还允许输入 | N
autofocus | Boolean | false | 自动聚焦,拉起键盘 | N
autosize | Boolean | false | 是否自动增高,值为 autosize 时,style.height 不生效 | N
autosize | Boolean / Object | false | 高度自动撑开。 autosize = true 表示组件高度自动撑开,同时,依旧允许手动拖高度。如果设置了 autosize.maxRows 或者 autosize.minRows 则不允许手动调整高度。TS 类型:`boolean \| { minRows?: number; maxRows?: number }` | N
bordered | Boolean | false | 是否显示外边框 | N
disabled | Boolean | undefined | 是否禁用文本框 | N
indicator | Boolean | false | 显示文本计数器,如 0/140。当 `maxlength < 0 && maxcharacter < 0` 成立时, indicator无效 | N
Expand Down
4 changes: 2 additions & 2 deletions packages/products/tdesign-mobile-vue/src/textarea/type.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,10 @@ export interface TdTextareaProps {
*/
autofocus?: boolean;
/**
* 是否自动增高,值为 autosize 时,style.height 不生效
* 高度自动撑开。 autosize = true 表示组件高度自动撑开,同时,依旧允许手动拖高度。如果设置了 autosize.maxRows 或者 autosize.minRows 则不允许手动调整高度
* @default false
*/
autosize?: boolean;
autosize?: boolean | { minRows?: number; maxRows?: number };
/**
* 是否显示外边框
* @default false
Expand Down
2 changes: 0 additions & 2 deletions packages/scripts/api.json
Original file line number Diff line number Diff line change
Expand Up @@ -120032,7 +120032,6 @@
"field_category": 1,
"field_name": "maxlength",
"field_type": [
"1",
"2"
],
"field_default_value": "",
Expand Down Expand Up @@ -120063,7 +120062,6 @@
"Angular(Mobile)"
],
"field_type_text": [
"String",
"Number"
]
},
Expand Down

0 comments on commit 9eaaf25

Please sign in to comment.