Skip to content

Commit

Permalink
Merge pull request #900 from jchalex/feat/input-number/inputProps
Browse files Browse the repository at this point in the history
feat(input-number): 透传 Input 组件全部特性,即 inputProps
  • Loading branch information
chaishi authored May 29, 2022
2 parents 11ab68c + 05d10b0 commit 7638af0
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 1 deletion.
1 change: 1 addition & 0 deletions examples/input-number/input-number.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ autoWidth | Boolean | false | 宽度随内容自适应 | N
decimalPlaces | Number | undefined | [小数位数](https://en.wiktionary.org/wiki/decimal_place) | N
disabled | Boolean | false | 禁用组件 | N
format | Function | - | 指定输入框展示值的格式。TS 类型:`(value: number) => number | string` | N
inputProps | Object | - | 透传 Input 输入框组件全部属性。TS 类型:`InputProps`[Input API Documents](./input?tab=api)[详细类型定义](https://github.com/Tencent/tdesign-vue-next/tree/develop/src/input-number/type.ts) | N
max | Number | Infinity | 最大值 | N
min | Number | -Infinity | 最小值 | N
placeholder | String | undefined | 占位符 | N
Expand Down
3 changes: 2 additions & 1 deletion src/input-number/input-number.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { computed, defineComponent } from 'vue';
import { AddIcon, RemoveIcon, ChevronDownIcon, ChevronUpIcon } from 'tdesign-icons-vue-next';
import TButton from '../button';
import TInput from '../input';
import TInput, { InputProps } from '../input';
import props from './props';

// hooks
Expand Down Expand Up @@ -58,6 +58,7 @@ export default defineComponent({
<t-input
{...inputAttrs.value}
{...inputEvents.value}
{...(props.inputProps as InputProps)}
value={displayValue.value}
onChange={(val: string, { e }: { e: InputEvent }) => handleInput(val, e)}
/>
Expand Down
4 changes: 4 additions & 0 deletions src/input-number/props.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,10 @@ export default {
format: {
type: Function as PropType<TdInputNumberProps['format']>,
},
/** 透传 Input 输入框组件全部属性 */
inputProps: {
type: Object as PropType<TdInputNumberProps['inputProps']>,
},
/** 最大值 */
max: {
type: Number,
Expand Down
5 changes: 5 additions & 0 deletions src/input-number/type.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
* 该文件为脚本自动生成文件,请勿随意修改。如需修改请联系 PMC
* */

import { InputProps } from '../input';
import { TNode } from '../common';

export interface TdInputNumberProps {
Expand All @@ -29,6 +30,10 @@ export interface TdInputNumberProps {
* 指定输入框展示值的格式
*/
format?: (value: number) => number | string;
/**
* 透传 Input 输入框组件全部属性
*/
inputProps?: InputProps;
/**
* 最大值
* @default Infinity
Expand Down

0 comments on commit 7638af0

Please sign in to comment.