From b406a7f238d4c6ab67fd8385f601bdd8fe332f58 Mon Sep 17 00:00:00 2001
From: chenjiajian <770230504@qq.com>
Date: Mon, 10 Apr 2023 15:24:17 +0800
Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96input=E7=BB=84=E4=BB=B6?=
=?UTF-8?q?=E4=BB=A3=E7=A0=81?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
src/form/input.js | 41 +++++++++++++++++++----------------------
1 file changed, 19 insertions(+), 22 deletions(-)
diff --git a/src/form/input.js b/src/form/input.js
index 3ddb88a..af0498b 100644
--- a/src/form/input.js
+++ b/src/form/input.js
@@ -360,12 +360,8 @@ class Input extends Component {
}
`
]
- renderClose() {
- return html``
+ renderClear() {
+ return html``
}
render() {
@@ -379,12 +375,12 @@ class Input extends Component {
- ${this.clearable && this.value ? this.renderClose() : ''}
+ ${this.clearable && this.value ? this.renderClear() : ''}
${this.icon
? html``
: html``}
-
+
${this.#list.map(
(li, idx) =>
html`-
`
}
- onCompositionstart() {
+ handleCompositionstart() {
this.#isComposing = true
}
- onCompositionend() {
+ handleCompositionend() {
this.#isComposing = false
this.filterSuggestList()
}
@@ -439,7 +435,7 @@ class Input extends Component {
}
this.$requestUpdate()
}
- onInput(e) {
+ handleInput(e) {
let { lazy } = this
this.value = e.currentTarget.value
if (lazy && Date.now() - this.#stamp < lazy) {
@@ -457,24 +453,25 @@ class Input extends Component {
})
}
}
- onClick(e) {
+ handleClickItem(e) {
let index = e.target.getAttribute('index')
this.value = this.#list[index].value
this.#list = [this.#list[index]]
this.$refs.suggestion.$animate(true)
this.#listShowing = false
+ this.$emit('select')
}
- onClickClose() {
+ clear() {
this.$refs.input.value = ''
this.value = ''
if (this.#originList.length) {
this.filterSuggestList()
}
}
- onChange() {
+ handleChange() {
this.$emit('change')
}
- onKeyDown(e) {
+ handleKeyDown(e) {
let { lazy, minlength, value } = this
if (e.keyCode === 13) {
e.preventDefault()
@@ -512,7 +509,7 @@ class Input extends Component {
this.$requestUpdate()
}
}
- onFocus() {
+ handleFocus() {
if (!this.#listShowing) {
this.#listShowing = true
this.$refs.suggestion.$animate()