feat(input): add input-props prop (#204)

* fix: add some lost form props

* chore: remove ts expect error

* feat: add `input-props`

* chore: update docs

* revert: clearable demo

* chore: typo

* chore: remove blank line

* fix: docs & props

* docs: update

* chore: changelog
This commit is contained in:
2021-06-25 22:39:07 +08:00 committed by GitHub
parent 7ce6b92e88
commit fa0a51ee14
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 13 additions and 1 deletions

View File

@ -2,6 +2,8 @@
## Pending
- `n-input` add standard property `input-props`
### Feats
- `n-carousel` supports touch operation, closes [#271](https://github.com/TuSimple/naive-ui/issues/271).

View File

@ -2,6 +2,8 @@
## Pending
- `n-input` 添加原生属性 `input-props`
### Feats
- `n-carousel` 支持触控操作,关闭 [#271](https://github.com/TuSimple/naive-ui/issues/271)

View File

@ -30,6 +30,7 @@ count
| clearable | `boolean` | `false` | |
| default-value | `string \| [string, string] \| null` | `null` | |
| disabled | `boolean` | `false` | |
| input-props | `object` | `undefined` | The props of the input element inside the component. It doesn't work with `pair` input. |
| show-password-toggle | `boolean` | `false` | Controls the display and hiding of passwords |
| maxlength | `number` | `undefined` | |
| minlength | `number` | `undefined` | |

View File

@ -30,6 +30,7 @@ count
| clearable | `boolean` | `false` | |
| default-value | `string \| [string, string] \| null` | `null` | |
| disabled | `boolean` | `false` | |
| input-props | `object` | `undefined` | 组件中 input 元素的属性,对 `pair` 类型不生效 |
| show-password-toggle | `boolean` | `false` | 控制密码的显示隐藏 |
| maxlength | `number` | `undefined` | |
| minlength | `number` | `undefined` | |

View File

@ -13,7 +13,9 @@ import {
watch,
watchEffect,
WatchStopHandle,
provide
provide,
InputHTMLAttributes,
TextareaHTMLAttributes
} from 'vue'
import { useMergedState } from 'vooks'
import { getPadding } from 'seemly'
@ -82,6 +84,8 @@ const inputProps = {
default: true
},
autofocus: Boolean,
inputProps: Object as PropType<TextareaHTMLAttributes | InputHTMLAttributes>,
resizable: {
type: Boolean,
default: true
@ -829,6 +833,7 @@ export default defineComponent({
{this.type === 'textarea' ? (
<div class={`${mergedClsPrefix}-input__textarea`}>
<textarea
{...this.inputProps}
ref="textareaElRef"
class={`${mergedClsPrefix}-input__textarea-el`}
autofocus={this.autofocus}
@ -873,6 +878,7 @@ export default defineComponent({
) : (
<div class={`${mergedClsPrefix}-input__input`}>
<input
{...this.inputProps}
ref="inputElRef"
type={
this.type === 'password' &&