Skip to content

Commit

Permalink
Merge branches 'develop' and 'develop' of github.com:Tencent/tdesign-…
Browse files Browse the repository at this point in the history
…vue into develop
  • Loading branch information
xiaosansiji committed Jan 23, 2022
2 parents a49517a + b9c4d0c commit 489dfa1
Show file tree
Hide file tree
Showing 15 changed files with 156 additions and 50 deletions.
14 changes: 14 additions & 0 deletions examples/input-number/demos/align.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
<template>
<div class="tdesign-demo-block-column">
<div style="width: 20%">
<t-input-number :default-value="100" align="left" style="width: 120px" />
<t-input-number :default-value="200" align="center" style="width: 120px" />
<t-input-number :default-value="300" align="right" style="width: 120px" />
</div>
<div style="width: 20%">
<t-input-number :default-value="100" align="left" theme="normal" style="width: 120px" />
<t-input-number :default-value="200" align="center" theme="normal" style="width: 120px" />
<t-input-number :default-value="300" align="right" theme="normal" style="width: 120px" />
</div>
</div>
</template>
1 change: 1 addition & 0 deletions examples/input-number/input-number.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@

名称 | 类型 | 默认值 | 说明 | 必传
-- | -- | -- | -- | --
align | String | - | 文本内容位置,居左/居中/居右。可选项:left/center/right | N
decimalPlaces | Number | undefined | [小数位数](https://en.wiktionary.org/wiki/decimal_place) | N
disabled | Boolean | false | 禁用组件 | N
format | Function | - | 指定输入框展示值的格式。TS 类型:`(value: number) => number | string` | N
Expand Down
7 changes: 7 additions & 0 deletions examples/input/demos/align.vue
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
<template>
<div class="tdesign-demo-block-column" style="max-width: 300px">
<t-input default-value="左对齐" align="left" />
<t-input default-value="居中对齐" align="center" />
<t-input default-value="右对齐" align="right" />
</div>
</template>
1 change: 1 addition & 0 deletions examples/input/input.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@

名称 | 类型 | 默认值 | 说明 | 必传
-- | -- | -- | -- | --
align | String | left | 文本内容位置,居左/居中/居右。可选项:left/center/right | N
autocomplete | Boolean | false | 是否开启自动填充功能 | N
autofocus | Boolean | false | 自动聚焦 | N
clearable | Boolean | false | 是否可清空 | N
Expand Down
1 change: 1 addition & 0 deletions src/input-number/input-number.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,7 @@ export default Vue.extend({
`${prefix}-input`,
{
[`${prefix}-is-error`]: this.isError,
[`${prefix}-align-${this.align}`]: this.align,
},
],
};
Expand Down
21 changes: 19 additions & 2 deletions src/input-number/props.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,19 @@

/**
* 该文件为脚本自动生成文件,请勿随意修改。如需修改请联系 PMC
* updated at 2021-11-19 10:44:26
* */

import { TdInputNumberProps } from './type';
import { PropType } from 'vue';

export default {
/** 文本内容位置,居左/居中/居右 */
align: {
type: String as PropType<TdInputNumberProps['align']>,
validator(val: TdInputNumberProps['align']): boolean {
return ['left', 'center', 'right'].includes(val);
},
},
/** [小数位数](https://en.wiktionary.org/wiki/decimal_place) */
decimalPlaces: {
type: Number,
Expand All @@ -33,7 +39,7 @@ export default {
/** 占位符 */
placeholder: {
type: String,
default: '',
default: undefined,
},
/** 组件尺寸 */
size: {
Expand All @@ -43,6 +49,13 @@ export default {
return ['small', 'medium', 'large'].includes(val);
},
},
/** 文本框状态 */
status: {
type: String as PropType<TdInputNumberProps['status']>,
validator(val: TdInputNumberProps['status']): boolean {
return ['success', 'warning', 'error'].includes(val);
},
},
/** 数值改变步数,可以是小数 */
step: {
type: Number,
Expand All @@ -56,6 +69,10 @@ export default {
return ['column', 'row', 'normal'].includes(val);
},
},
/** 输入框下方提示文本,会根据不同的 `status` 呈现不同的样式 */
tips: {
type: [String, Function] as PropType<TdInputNumberProps['tips']>,
},
/** 值 */
value: {
type: Number,
Expand Down
23 changes: 19 additions & 4 deletions src/input-number/type.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,15 @@

/**
* 该文件为脚本自动生成文件,请勿随意修改。如需修改请联系 PMC
* updated at 2021-11-19 10:44:26
* */

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

export interface TdInputNumberProps {
/**
* 文本内容位置,居左/居中/居右
*/
align?: 'left' | 'center' | 'right';
/**
* [小数位数](https://en.wiktionary.org/wiki/decimal_place)
*/
Expand All @@ -31,14 +36,17 @@ export interface TdInputNumberProps {
min?: number;
/**
* 占位符
* @default ''
*/
placeholder?: string;
/**
* 组件尺寸
* @default medium
*/
size?: 'small' | 'medium' | 'large';
/**
* 文本框状态
*/
status?: 'success' | 'warning' | 'error';
/**
* 数值改变步数,可以是小数
* @default 1
Expand All @@ -49,6 +57,10 @@ export interface TdInputNumberProps {
* @default row
*/
theme?: 'column' | 'row' | 'normal';
/**
* 输入框下方提示文本,会根据不同的 `status` 呈现不同的样式
*/
tips?: string | TNode;
/**
* 值
*/
Expand Down Expand Up @@ -85,8 +97,11 @@ export interface TdInputNumberProps {
* 释放键盘时触发
*/
onKeyup?: (value: number, context: { e: KeyboardEvent }) => void;
};
}

export interface ChangeContext { type: ChangeSource; e: InputEvent | MouseEvent | FocusEvent };
export interface ChangeContext {
type: ChangeSource;
e: InputEvent | MouseEvent | FocusEvent;
}

export type ChangeSource = 'add' | 'reduce' | 'input' | '';
1 change: 1 addition & 0 deletions src/input/input.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ export default mixins(getConfigReceiverMixins<InputInstance, InputConfig>('input
[CLASSNAMES.STATUS.disabled]: this.disabled,
[CLASSNAMES.STATUS.focused]: this.focused,
[`${prefix}-is-${this.status}`]: this.status,
[`${prefix}-align-${this.align}`]: this.align !== 'left',
[`${prefix}-is-disabled`]: this.disabled,
[`${prefix}-is-readonly`]: this.readonly,
[`${name}--focused`]: this.focused,
Expand Down
8 changes: 8 additions & 0 deletions src/input/props.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,14 @@ import { TdInputProps } from './type';
import { PropType } from 'vue';

export default {
/** 文本内容位置,居左/居中/居右 */
align: {
type: String as PropType<TdInputProps['align']>,
default: 'left' as TdInputProps['align'],
validator(val: TdInputProps['align']): boolean {
return ['left', 'center', 'right'].includes(val);
},
},
/** 是否开启自动填充功能 */
autocomplete: Boolean,
/** 自动聚焦 */
Expand Down
5 changes: 5 additions & 0 deletions src/input/type.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,11 @@
import { TNode, SizeEnum } from '../common';

export interface TdInputProps {
/**
* 文本内容位置,居左/居中/居右
* @default left
*/
align?: 'left' | 'center' | 'right';
/**
* 是否开启自动填充功能
* @default false
Expand Down
Loading

0 comments on commit 489dfa1

Please sign in to comment.