mirror of
https://github.com/tusen-ai/naive-ui.git
synced 2024-11-21 01:13:16 +08:00
refactor(input): exposed clear method
This commit is contained in:
parent
17be8c4881
commit
b473b89c20
@ -5,7 +5,7 @@
|
||||
### Features
|
||||
|
||||
- `n-space` adds `reverse` prop.
|
||||
- `n-input` expose `clear` method, closes [#5423](https://github.com/tusen-ai/naive-ui/issues/5423).
|
||||
- `n-input` adds `clear` method, closes [#5423](https://github.com/tusen-ai/naive-ui/issues/5423).
|
||||
|
||||
## 2.36.0
|
||||
|
||||
|
@ -3,7 +3,7 @@
|
||||
## NEXT_VERSION
|
||||
|
||||
- `n-space` 新增 `reverse` 属性
|
||||
- `n-input` 暴露 `clear` 方法,关闭[#5423](https://github.com/tusen-ai/naive-ui/issues/5423)
|
||||
- `n-input` 新增 `clear` 方法,关闭[#5423](https://github.com/tusen-ai/naive-ui/issues/5423)
|
||||
|
||||
## 2.36.0
|
||||
|
||||
|
@ -133,7 +133,7 @@ export const inputProps = {
|
||||
onBlur: [Function, Array] as PropType<MaybeArray<(e: FocusEvent) => void>>,
|
||||
onClick: [Function, Array] as PropType<MaybeArray<(e: MouseEvent) => void>>,
|
||||
onChange: [Function, Array] as PropType<OnUpdateValue>,
|
||||
onClear: [Function, Array] as PropType<MaybeArray<(e?: MouseEvent) => void>>,
|
||||
onClear: [Function, Array] as PropType<MaybeArray<(e: MouseEvent) => void>>,
|
||||
countGraphemes: Function as PropType<(value: string) => number>,
|
||||
status: String as PropType<FormValidationStatus>,
|
||||
'onUpdate:value': [Function, Array] as PropType<MaybeArray<OnUpdateValue>>,
|
||||
@ -405,7 +405,7 @@ export default defineComponent({
|
||||
if (onFocus) call(onFocus, e)
|
||||
nTriggerFormFocus()
|
||||
}
|
||||
function doClear (e?: MouseEvent): void {
|
||||
function doClear (e: MouseEvent): void {
|
||||
const { onClear } = props
|
||||
if (onClear) call(onClear, e)
|
||||
}
|
||||
@ -585,8 +585,11 @@ export default defineComponent({
|
||||
function handleClick (e: MouseEvent): void {
|
||||
doClick(e)
|
||||
}
|
||||
function handleClear (e?: MouseEvent): void {
|
||||
function handleClear (e: MouseEvent): void {
|
||||
doClear(e)
|
||||
clearValue()
|
||||
}
|
||||
function clearValue (): void {
|
||||
if (props.pair) {
|
||||
doUpdateValue(['', ''])
|
||||
doChange(['', ''])
|
||||
@ -812,7 +815,7 @@ export default defineComponent({
|
||||
inputElRef,
|
||||
textareaElRef,
|
||||
isCompositing: isComposingRef,
|
||||
clear: handleClear,
|
||||
clear: clearValue,
|
||||
focus,
|
||||
blur,
|
||||
select,
|
||||
|
Loading…
Reference in New Issue
Block a user