Skip to content

Commit

Permalink
feat(Input): support cursorColor props
Browse files Browse the repository at this point in the history
  • Loading branch information
anlyyao committed Oct 22, 2024
1 parent 2c7e8e4 commit 616c1de
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 15 deletions.
3 changes: 2 additions & 1 deletion src/input/README.en-US.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,11 @@ clearable | Boolean / Object | false | show clear icon, clicked to clear input v
confirm-hold | Boolean | false | \- | N
confirm-type | String | done | options: send/search/next/go/done | N
cursor | Number | - | required | Y
cursor-color | String | - | \- | N
cursor-spacing | Number | 0 | \- | N
disabled | Boolean | false | make input to be disabled | N
error-message | String | - | `deprecated` | N
focus | Boolean | false | \- | N
format | Function | - | input value formatter, `type=number` does not work. if you need to format number, `InputNumber` Component might be better。Typescript:`InputFormatType` `type InputFormatType = (value: InputValue) => string`[see more ts definition](https://github.com/Tencent/tdesign-miniprogram/tree/develop/src/input/type.ts) | N
hold-keyboard | Boolean | false | \- | N
label | String / Slot | - | text on the left of input。[see more ts definition](https://github.com/Tencent/tdesign-miniprogram/blob/develop/src/common/common.ts) | N
layout | String | horizontal | options: vertical/horizontal | N
Expand Down Expand Up @@ -64,6 +64,7 @@ focus | `(value: InputValue)` | \-
keyboardheightchange | `(height: number, duration: number)` | \-
nicknamereview | `(pass: boolean, timeout: boolean)` | \-
validate | `(detail: { error?: 'exceed-maximum' \| 'below-minimum' })` | trigger on text length being over max length or max character

### Input External Classes

className | Description
Expand Down
3 changes: 2 additions & 1 deletion src/input/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -97,11 +97,11 @@ clearable | Boolean / Object | false | 是否可清空,默认不启动。值
confirm-hold | Boolean | false | 点击键盘右下角按钮时是否保持键盘不收起 | N
confirm-type | String | done | 设置键盘右下角按钮的文字,仅在type='text'时生效。<br />具体释义:<br />`send` 右下角按钮为“发送”;<br />`search` 右下角按钮为“搜索”;<br />`next` 右下角按钮为“下一个”;<br />`go` 右下角按钮为“前往”;<br />`done` 右下角按钮为“完成”。<br />[小程序官方文档](https://developers.weixin.qq.com/miniprogram/dev/component/input.html)。可选项:send/search/next/go/done | N
cursor | Number | - | 必需。指定 focus 时的光标位置 | Y
cursor-color | String | - | 光标颜色。iOS 下的格式为十六进制颜色值 #000000,安卓下的只支持 default 和 green,Skyline 下无限制 | N
cursor-spacing | Number | 0 | 指定光标与键盘的距离,取 input 距离底部的距离和 cursor-spacing 指定的距离的最小值作为光标与键盘的距离 | N
disabled | Boolean | false | 是否禁用输入框 | N
error-message | String | - | 已废弃。错误提示文本,值为空不显示(废弃属性,如果需要,请更为使用 status 和 tips) | N
focus | Boolean | false | 获取焦点 | N
format | Function | - | 【开发中】指定输入框展示值的格式。TS 类型:`InputFormatType` `type InputFormatType = (value: InputValue) => string`[详细类型定义](https://github.com/Tencent/tdesign-miniprogram/tree/develop/src/input/type.ts) | N
hold-keyboard | Boolean | false | focus时,点击页面的时候不收起键盘 | N
label | String / Slot | - | 左侧文本。[通用类型定义](https://github.com/Tencent/tdesign-miniprogram/blob/develop/src/common/common.ts) | N
layout | String | horizontal | 标题输入框布局方式。可选项:vertical/horizontal | N
Expand Down Expand Up @@ -143,6 +143,7 @@ focus | `(value: InputValue)` | 获得焦点时触发
keyboardheightchange | `(height: number, duration: number)` | 键盘高度发生变化的时候触发此事件
nicknamereview | `(pass: boolean, timeout: boolean)` | 用户昵称审核完毕后触发,仅在 type 为 "nickname" 时有效
validate | `(detail: { error?: 'exceed-maximum' \| 'below-minimum' })` | 字数超出限制时触发

### Input External Classes

类名 | 描述
Expand Down
1 change: 1 addition & 0 deletions src/input/input.wxml
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@
confirm-type="{{confirmType}}"
confirm-hold="{{confirmHold}}"
cursor="{{cursor}}"
cursor-color="{{cursorColor}}"
cursor-spacing="{{cursorSpacing}}"
adjust-position="{{adjustPosition}}"
auto-focus="{{autoFocus}}"
Expand Down
9 changes: 5 additions & 4 deletions src/input/props.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,11 @@ const props: TdInputProps = {
type: Number,
required: true,
},
/** 光标颜色。iOS 下的格式为十六进制颜色值 #000000,安卓下的只支持 default 和 green,Skyline 下无限制 */
cursorColor: {
type: String,
value: '',
},
/** 指定光标与键盘的距离,取 input 距离底部的距离和 cursor-spacing 指定的距离的最小值作为光标与键盘的距离 */
cursorSpacing: {
type: Number,
Expand All @@ -71,10 +76,6 @@ const props: TdInputProps = {
type: Boolean,
value: false,
},
/** 【开发中】指定输入框展示值的格式 */
format: {
type: null,
},
/** focus时,点击页面的时候不收起键盘 */
holdKeyboard: {
type: Boolean,
Expand Down
17 changes: 8 additions & 9 deletions src/input/type.ts
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,14 @@ export interface TdInputProps {
value?: number;
required?: boolean;
};
/**
* 光标颜色。iOS 下的格式为十六进制颜色值 #000000,安卓下的只支持 default 和 green,Skyline 下无限制
* @default ''
*/
cursorColor?: {
type: StringConstructor;
value?: string;
};
/**
* 指定光标与键盘的距离,取 input 距离底部的距离和 cursor-spacing 指定的距离的最小值作为光标与键盘的距离
* @default 0
Expand All @@ -109,13 +117,6 @@ export interface TdInputProps {
type: BooleanConstructor;
value?: boolean;
};
/**
* 【开发中】指定输入框展示值的格式
*/
format?: {
type: undefined;
value?: InputFormatType;
};
/**
* focus时,点击页面的时候不收起键盘
* @default false
Expand Down Expand Up @@ -301,6 +302,4 @@ export interface TdInputProps {
};
}

export type InputFormatType = (value: InputValue) => string;

export type InputValue = string | number;

0 comments on commit 616c1de

Please sign in to comment.